Coder Social home page Coder Social logo

pypayd's Introduction

pypayd

Pypayd is a minimalistic daemon for accepting bitcoin payments. This is meant to be a good alternative if you do not want setup an account with a third-party payment processor. Pypayd provides an API for creating orders and automatically records order fulfillment (payment received) as well as invalid payments.

Pypayd automatically creates receiving addresses from it's own wallet, a wrapper around the pycoin implementation of BIP32. The wallet (can generate addresses from a public or private master-key (note that there is no need to store the private key on the server). It also supports loading keys from mnemonic, byte-string, or encrypted file.

installation

For now the recomended installation method is to use git clone https://github.com/pik/pypayd.git following that cd into the pypayd directory and execute pip install -r pip-requirements.txt, with this you should be good to go (one thing to note is that in some cases APSW may require manual installation).

configuration

You are able to configure pypayd via creating pypayd.conf file. Consult src/config.py for configuration values.

currency exchange rates

Currently there are three sources of live currency exehange rates available:

example usage

Obtain an encrypted-file with a publickey on an offline server from a mnemonic:

python pypayd.py wallet --from-mnemonic "cigarette add choice joke guess process blood freak rise favorite write pen" --mnemonic-type="electrum" --to-file="payment_wallet.txt" --encrypt-pw="foobar"

This will generate a BIP32 wallet from the mnemonic and save only the master public key to an encrypted file. CP the file to your online server. Then run pypayd:

python pypayd.py --server wallet --from-file="payment_wallet.txt" --encrypt-pw="foobar"

Then from your webserver (i.e. to create an order for a payment of 20 usd):

import requests
import json
url = "http://127.0.0.1:3080"
headers = {'content-type': 'application/json'}
payload = {
    "method": "create_order",
    "params": {"amount": 20.0, "qr_code": True},
    "jsonrpc": "2.0",
    "id": 0,
}
response = requests.post( url, data=json.dumps(payload), headers=headers).json()

This will return an automatically created order_id, a price converted to Bitcoin from the DEFAULT_CURRENCY by the DEFAULT_TICKER, a receiving address, as well as a time left on the transaction (note that the timeleft on the transaction is the time-lapse after which a payment received for the order will not be considered valid; it may be preferable to set a longer TX_LIFE then the one displayed to the customer). The full argument list for create_order as follows:

* amount          order amount in native currency
* currency        takes a string such as 'USD', config.DEFAULT_CURRENCY if none
* item_number     specify an item-number to associate  with the order in the database
* order_id        specify an order-id, if one is not given an order-id will be created by hashing other order attributes
* gen_new         generate a new address for the order if True, otherwise uses config settings
* qr_code         generate a qr_code for the corresponding receiving address if True

dependencies

  • Python3
  • See pip-requirements.txt

to do

See the TODO list.

interfaces

Pypayd supports insight-api (run locally or hosted: https://insight.bitpay.com/) and blockr (https://blockr.io/). I'll probably add support for jmcorgan's fork of bitcoin-core with address indexing in the near future. To configure set BLOCKCHAIN_SERVICE to the interface Pypayd should load ("insight" or "blockr") and BLOCKCHAIN_CONNECT to the complete url in the pypayd.conf file.

pypayd's People

Contributors

pik avatar ser avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.