Payload Python Library
Project description
Payload Python Library
A Python library for integrating Payload.
Installation
Install using pip
pip install payload-api
Get Started
Once you've installed the Payload Python library to your environment,
import the payload
module to get started. Note: We recommend
using the shorthand name of pl
when importing.
import payload as pl
API Authentication
To authenticate with the Payload API, you'll need a live or test API key. API keys are accessible from within the Payload dashboard.
import payload as pl
pl.api_key = 'secret_key_3bW9JMZtPVDOfFNzwRdfE'
Creating an Object
Interfacing with the Payload API is done primarily through Payload Objects. Below is an example of
creating a customer using the pl.Customer
object.
# Create a Customer
customer = pl.Customer.create(
email='matt.perez@example.com',
name='Matt Perez'
)
# Create a Payment
payment = pl.Payment.create(
amount=100.0,
payment_method=pl.Card(
card_number='4242 4242 4242 4242'
)
)
Accessing Object Attributes
Object attributes are accessible through dot notation.
customer.name
Updating an Object
Updating an object is a simple call to the update
object method.
# Updating a customer's email
customer.update( email='matt.perez@newwork.com' )
Selecting Objects
Objects can be selected using any of their attributes.
# Select a customer by email
customers = pl.Customer.filter_by(
email='matt.perez@example.com'
)
Use the pl.attr
attribute helper
interface to write powerful queries with a little extra syntax sugar.
payments = pl.Payment.filter_by(
pl.attr.amount > 100,
pl.attr.amount < 200,
pl.attr.description.contains("Test"),
pl.attr.created_at > datetime(2019,2,1)
).all()
Testing the Payload Python Library
Tests are contained within the tests/ directory. To run a test file, once within the pipenv shell, enter the command in terminal
pytest tests/{__FILENAME__}.py
Documentation
To get further information on Payload's Python library and API capabilities, visit the unabridged Payload Documentation.
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
File details
Details for the file payload-api-0.3.1.tar.gz
.
File metadata
- Download URL: payload-api-0.3.1.tar.gz
- Upload date:
- Size: 11.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.48.2 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5cd1ca68211959aaf72b8532f5f073783833fc8f53ad409937f63be1e3724356 |
|
MD5 | 0cf73643ec35cf4b0eab418b22e0d9a0 |
|
BLAKE2b-256 | 19222812e70f4a905fa416a2d644ae29918210b95ee0907cd5c0dae1eda6724b |
File details
Details for the file payload_api-0.3.1-py3-none-any.whl
.
File metadata
- Download URL: payload_api-0.3.1-py3-none-any.whl
- Upload date:
- Size: 15.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.48.2 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9234c1002a600ca605d118f65e1c45fe3107f0169cc562c6f2a766ea89ed97b2 |
|
MD5 | 93bffbdc0c121761424f0b1f8a2c5dac |
|
BLAKE2b-256 | f7ae4e99496327129471820a873532916eeca4be7d649203904afeb6b3377a82 |