Python Library for BlockBee payment gateway
Project description
BlockBee's Python Library
Python implementation of BlockBee's payment gateway
Requirements:
Python >= 3.0
Requests >= 2.20
Install
pip install python-blockbee
Usage
Importing in your project file
from blockbee import BlockBeeHelper
Generating a new Address
from blockbee import BlockBeeHelper
bb = BlockBeeHelper(coin, own_address, callback_url, params, bb_params, api_key)
address = bb.getAddress()['address_in']
Where:
coin
is the coin you wish to use, from BlockBee's supported currencies (e.g 'btc', 'eth', 'erc20_usdt', ...).own_address
is your own crypto address, where your funds will be sent to.callback_url
is the URL that will be called upon payment.params
is any parameter you wish to send to identify the payment, such as{orderId: 1234}
.bb_params
parameters that will be passed to BlockBee _(check which extra parameters are available here: https://docs.blockbee.io/#operation/create).api_key
is the API Key provided by BlockBee's dashboard.address
is the newly generated address, that you will show your users in order to receive payments.
Getting notified when the user pays
Once your customer makes a payment, BlockBee will send a callback to your
callbackUrl
. This callback information is by default inGET
but you can se it toPOST
by settingpost: 1
inblockbeeParams
. The parameters sent by BlockBee in this callback can be consulted here: https://docs.blockbee.io/#operation/confirmedcallbackget
Checking the logs of a request
from blockbee import BlockBeeHelper
bb = BlockBeeHelper(coin, own_address, callback_url, params, bb_params, api_key)
data = bb.get_logs()
Same parameters as before, the
data
returned can b e checked here: https://docs.blockbee.io/#operation/logs
Generating a QR code
from blockbee import BlockBeeHelper
bb = BlockBeeHelper(coin, own_address, callback_url, params, bb_params, api_key)
###
qr_code = bb.get_qrcode(value, size)
For object creation, same parameters as before. You must first call ``getAddress` as this method requires the payment address to have been created.
For QR Code generation:
value
is the value requested to the user in the coin to which the request was done. Optional, can be empty if you don't wish to add the value to the QR Code.size
Size of the QR Code image in pixels. Optional, leave empty to use the default size of 512.
Response is an object with
qr_code
(base64 encoded image data) andpayment_uri
(the value encoded in the QR), see https://docs.blockbee.io/#operation/qrcode for more information.
Estimating transaction fees
from blockbee import BlockBeeHelper
fees = BlockBeeHelper.get_estimate(coin, addresses, priority, api_key)
Where:
coin
is the coin you wish to check, from BlockBee's supported currencies (e.g 'btc', 'eth', 'erc20_usdt', ...)addresses
The number of addresses to forward the funds to. Optional, defaults to 1.priority
Confirmation priority, (check this article to learn more about it). Optional, defaults todefault
.api_key
is the API Key provided by BlockBee's dashboard.
Response is an object with
estimated_cost
andestimated_cost_usd
, see https://docs.blockbee.io/#operation/estimate for more information.
Converting between coins and fiat
from blockbee import BlockBeeHelper
conversion = BlockBeeHelper.get_conversion(value, from_coin, api_key)
Where:
coin
the target currency to convert to, from BlockBee's supported currencies (e.g 'btc', 'eth', 'erc20_usdt', ...)value
value to convert infrom
.from_coin
currency to convert from, FIAT or crypto.api_key
is the API Key provided by BlockBee's dashboard.
Response is an object with
value_coin
andexchange_rate
, see https://docs.blockbee.io/#operation/convert for more information.
Getting supported coins
from blockbee import BlockBeeHelper
supportedCoins = BlockBeeHelper.get_supported_coins(api_key)
Where:
api_key
is the API Key provided by BlockBee's dashboard.
Response is an array with all supported coins.
Request Payout
from blockbee import BlockBeeHelper
payout = BlockBeeHelper.create_payout(coin, address, value, apiKey)
This function can be used by you to request payouts (withdrawals in your platform).
Where:
coin
The cryptocurrency you want to request the Payout in (e.gbtc
,eth
,erc20_usdt
, ...).address
Address where the Payout must be sent to.value
Amount to send to theaddress
.api_key
is the API Key provided by BlockBee's dashboard.
The response will be only a
success
to confirm the Payout Request was successfully created. To fulfill it you will need to go to BlockBee Dashboard.
Help
Need help?
Contact us @ https://blockbee.io/contacts/
Changelog
1.0.0
- Initial Release
1.0.1
- Minor fixes
1.0.2
- Minor fixes
1.0.3
- Fix import
- Minor fixes
1.1.0
- Added Payouts
- Minor bugfixes
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file python-blockbee-1.1.0.tar.gz
.
File metadata
- Download URL: python-blockbee-1.1.0.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29c50fca098455ea5a8ab3374ddee5ba6817a302318af616cee0f8c42e2a2c6b |
|
MD5 | 5cfd406e5b0a5c36fd148ca377f63222 |
|
BLAKE2b-256 | ad6227b9918b567b554f18d6c451aec5ec29c02cbe0ad24873bfb140841189d6 |