A class to use the BitPay Payment Gateway API in a django project.
Read the BitPay API documentation (PDF).
New Invoices with new Bitcoin addresses are created each time the CreateInvoice
method is called. BitPay links these addresses with your BitPay account and payments are stored in your BitPay balance. You can set up BitPay to pay out to your bank account daily, or split your incoming payments into Bitcoins and your desired currency (more info).
###Note
I only used two optional fields, redirectURL
and itemDesc
in the code. There are lots more available in the BitPay API docs (PDF).
- Add the bitpay.py file to your project (anywhere you want)
- Apply for a new API key from https://bitpay.com/api-keys
- Add
BITPAY_API_KEY = 'yourkey'
to settings.py
from bitpay import BitPay
bp = BitPay()
response = bp.CreateInvoice(total, currency, return_url, description)
You can then use response['url']
to redirect the user to the invoice page, or alternatively show an Embedded Invoice on your page.
- Write a view that handles IPNs from BitPay