The Elements Pay Python SDK
Project description
Elements Python SDK
Python bindings for the Elements API.
Installation
You can install this package from source:
python setup.py install
Configuration
This library requires you to configure the API key:
import elements
elements.api_key = "my_api_key"
You may connect to the sandbox by configuring the base url:
import elements
elements.api_base = elements.API_SANDBOX
Usage
import elements
# To create an authorized charge
authorized_charge = elements.Charge.create(
amount=300000,
currency="USD",
payment_method_id="PM-XXXX",
)
# Access model attributes like object fields
authorized_charge.amount # 30000
authorized_charge.currency # "USD"
authorized_charge.captured # False
# To capture a charge
captured_charge = elements.Charge.capture(
"CH-pV4rzxf9yRoWaPeJL2C47JoC",
amount=300000
)
# To create a client token
client_token = elements.ClientToken.create(external_customer_id="foo").client_token
# To retrieve a payment method
payment_method = elements.PaymentMethod.retrieve(
"PM-XXXX",
external_customer_id="cus_ext_id"
)
Please refer to our REST API docs for detailed API usage.
Development and Testing
First, set up the virtualenv for development by:
make
Then you may run tests like so:
make test
If you want to test for a specific Python version, supply the version like so (you must have the corresponding version installed first):
TOX_ARGS="-e py38" make test
To run the formatter, do
make fmt
For adhoc testing, you may start a Python REPL and import elements, you may test your changes with a local or a sandbox
environment by setting the api_base
and api_key
:
import elements
elements.api_base = "http://localhost:3000"
elements.api_key = "my_api_key"
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
Built Distribution
Hashes for elements_pay-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d9e57bcb69358938db5a656b8dc14e95898a23c0b652e6f66174af18030326b |
|
MD5 | 946ea13f5dcf78fb2ab2341031623e7c |
|
BLAKE2b-256 | 91c67a54db8a63e619a327208ce70df73b96b79916b7821dd872f1e083f912e9 |