Skip to main content

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


Download files

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

Source Distribution

elements-pay-1.0.3.tar.gz (134.3 kB view details)

Uploaded Source

Built Distribution

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

elements_pay-1.0.3-py3-none-any.whl (137.0 kB view details)

Uploaded Python 3

File details

Details for the file elements-pay-1.0.3.tar.gz.

File metadata

  • Download URL: elements-pay-1.0.3.tar.gz
  • Upload date:
  • Size: 134.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for elements-pay-1.0.3.tar.gz
Algorithm Hash digest
SHA256 8b863554a3e9ea91745b8c2cf0fbf15d47ae17a0c8c49f17ddf44edaaf58d8f9
MD5 cd5e8e3cbddb74d4681220b1836eb733
BLAKE2b-256 f4842a7f2efed05c75ef8080aca9501896fd0453ffaceba1dd8e27e5b80c0009

See more details on using hashes here.

File details

Details for the file elements_pay-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: elements_pay-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 137.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for elements_pay-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0086cb0782ae1069755e5e66970d210fa3aaa5210fd2d249230dc17c3dd5e852
MD5 b9e95fc2006b894d003fbc6ced92c6b1
BLAKE2b-256 d5428defb82cef889517bfeb04c7f46238c597651a01af0ec797a90375d985a3

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