Skip to main content

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',
	full_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 both 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
var 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.Payments.filter_by(
    pl.attr.amount > 100,
    pl.attr.amount < 200,
    pl.attr.description.contains("Test"),
    pl.attr.created_at > datetime(2019,2,1))
).all()

Documentation

To get further information on Payload's Python library and API capabilities, visit the unabridged Payload Documentation.

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

payload-api-0.1.3.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

payload_api-0.1.3-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file payload-api-0.1.3.tar.gz.

File metadata

  • Download URL: payload-api-0.1.3.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.7

File hashes

Hashes for payload-api-0.1.3.tar.gz
Algorithm Hash digest
SHA256 e0bded20ce639b199b70a7dfcd05657e9fa28ed20b754aa30a22c346d3a0110a
MD5 0d1a238a5de7a3235b80599d92dfd2a0
BLAKE2b-256 04ea601b5c70a7f0a21a5b85ab6fe09ee6dd2f42f8271850979e3d8183eeb248

See more details on using hashes here.

File details

Details for the file payload_api-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: payload_api-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.7

File hashes

Hashes for payload_api-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f662f9098de2b8501d3e96ce96f329408dcd7c1785be563a7c56a49e6c6b0474
MD5 1915dfd3f77035fc8b2db6459c568e19
BLAKE2b-256 ec6cee45a6d82d265fe1fd2f4d358e25bd816d71853e2475968bfd7a7191b7cf

See more details on using hashes here.

Supported by

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