Skip to main content

Python client for the BitPay payment web API distributed via PyPi with object-orientated interface

Project description

New usage: from bitpay_client import BitPay.API
©2014 BITPAY, INC.

Permission is hereby granted to any person obtaining a copy of this
software and associated documentation for use and/or modification in
association with the bitpay.com service.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Bitcoin Python payment library using the bitpay.com service.

Installation
------------

Varies depending on what python webserver framework you are using
(SimpleHTTPServer, Flask, Bottle, Django, etc.). Most of the calls will
run as-is from a script, but bpVerifyNotification will require updating
depending on your framework. You can integrate these functions into your
custom shopping cart implementation.

Configuration
-------------

Note: Python 2.7 and its built in libraries are required for use of this
code library.

1. Create an API key at bitpay.com by clicking My Account > API Access
Keys > Add New API Key.
2. In the bp\_options.py file, configure the options specific to your
implementation.

Usage
-----

1. In your shopping cart code, call bpCreateInvoice() with the
appropriate orderID, price, posData and options.
2. The library will attempt to POST the new invoice information via curl
to the BitPay network. If successful, you will receive an invoice in
the return response. Any errors in this process will return an array
with a single element: 'error' and the exception msg.
3. You may use the bpLog function manually to log any information you
would like to track or automatically by setting the useLogging option
to true in the bp\_options file. The log file could potentially get
very large, depending on usage, so monitor closely or only use during
debugging.
4. Responses from the BitPay network are JSON. You can use the new
decodeResponse() function to convert these to an associative array,
if needed.

Troubleshooting
---------------

The official BitPay API documentation should always be your first
reference for development: https://bitpay.com/downloads/bitpayApi.pdf

1. Verify that your "notificationURL" for the invoice is "https://"
(not "http://")
2. Ensure a valid SSL certificate is installed on your server. Also
ensure your root CA cert is updated. If your CA cert is not current,
you will see curl SSL verification errors.
3. Verify that your callback handler at the "notificationURL" is
properly receiving POSTs. You can verify this by POSTing your own
messages to the server from a tool like Chrome Postman.
4. Verify that the POST data received is properly parsed and that the
logic that updates the order status on the merchants web server is
correct.
5. Verify that the merchants web server is not blocking POSTs from
servers it may not recognize. Double check this on the firewall as
well, if one is being used.
6. Use the logging functionality to log errors during development. If
you contact BitPay support, they will ask to see the log file to help
diagnose any problems.
7. Check the version of this Python library agains the official
repository to ensure you are using the latest version. Your issue
might have been addressed in a newer version of the library.
8. If all else fails, send an email describing your issue *in detail* to
support@bitpay.com
9. To manually test the library, update the options file with your API
key and do the following:

.. raw:: html

<pre>
$ python
>>> import bp_lib
>>> bp_lib.bpCreateInvoice(123, 1, 'fish')
</pre>

After a brief pause, you should get a JSON response that looks
something like:

.. raw:: html

<pre>
{'status': 'new', 'invoiceTime': 1393950046292, 'currentTime': 1393950046520, 'url': 'https://bitpay.com/invoice?id=aASDF2jh4ashkASDfh234', 'price': 1, 'btcPrice': '1.0000', 'currency': 'BTC', 'posData': '{"posData": "fish", "hash": "ASDfkjha452345ASDFaaskjhasdlfkflkajsdf"}', 'expirationTime': 1393950946292, 'id': 'aASDF2jh4ashkASDfh234'}
</pre>

Change Log
----------

Version 1.1 - Added new HTTP header for version tracking

Version 1 - Initial version

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bitpay-client-0.1.1.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bitpay-client-0.1.1.linux-x86_64.tar.gz (11.0 kB view details)

Uploaded Source

File details

Details for the file bitpay-client-0.1.1.tar.gz.

File metadata

  • Download URL: bitpay-client-0.1.1.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for bitpay-client-0.1.1.tar.gz
Algorithm Hash digest
SHA256 81b704a18f80c3e6656d86ec46e791af031d8de115e08a94e78d14ac75d768eb
MD5 7cacfc6827fd0a1258aefedcb4bef560
BLAKE2b-256 930f52b3f9c5316cd8e19a674532b6405cdbc621db116097a9affe0c75b504fa

See more details on using hashes here.

File details

Details for the file bitpay-client-0.1.1.linux-x86_64.tar.gz.

File metadata

File hashes

Hashes for bitpay-client-0.1.1.linux-x86_64.tar.gz
Algorithm Hash digest
SHA256 9aaaf12e7dd92882fac64cc8ae5740986e2dc2f059e2e85ba05b5bc57d2c9f96
MD5 dd6175751fd4ad4447e790e734d0fa9e
BLAKE2b-256 1c90e801606a2aa8dcc39d3b9bfed9e084b64daca103b6f32e4226c78d87beee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page