Skip to main content

Python Client for Affirm

Project description

Affirm Python SDK

Affirm Python SDK is a client library to interact with Affirm. For API reference: https://docs.affirm.com/Integrate_Affirm/Direct_API/Affirm_API_Reference

Affirm helps customers to pay over time for things they want to buy. The customers are in control of how long you get to make monthly payments. They do the approval process in minutes. This client will help you integrate with Affirm.

Usage

Client Creation

from affirm import Client
client = Client(auth=(<PUBLIC_API_KEY>, <PRIVATE_API_KEY>))

Performing Authorize

from affirm import Client
client = Client(auth=(<PUBLIC_API_KEY>, <PRIVATE_API_KEY>))
resp = client.charge.create(data={"checkout_token":<CHECKOUT_TOKEN_FROM_AFFIRM>, "order_id": <YOUR_GENERATED_ORDER_ID>)

Performing Capture

from affirm import Client
client = Client(auth=(<PUBLIC_API_KEY>, <PRIVATE_API_KEY>))
resp = client.charge.capture(charge_id = <CHARGE_ID>, order_id=<YOUR_GENERATED_ORDER_ID>)

Performing Refund

from affirm import Client
client = Client(auth=(<PUBLIC_API_KEY>, <PRIVATE_API_KEY>))
resp = client.charge.capture(charge_id = <CHARGE_ID>, order_id= <YOUR_GENERATED_ORDER_ID>)

Perform Update

from affirm import Client
client = Client(auth=(<PUBLIC_API_KEY>, <PRIVATE_API_KEY>))
resp = client.charge.update(charge_id = <CHARGE_ID>, order_id": <YOUR_GENERATED_ORDER_ID>)

Perform Void

from affirm import Client
client = Client(auth=(<PUBLIC_API_KEY>, <PRIVATE_API_KEY>))
resp = client.charge.void(charge_id=<CHARGE_ID>, order_id=<YOUR_GENERATED_ORDER_ID>)

Using the client for Production(or live)

The only change you need to make pass a prod keyward while to client creation step.

from affirm import Client
client = Client(auth=(<PUBLIC_API_KEY>, <PRIVATE_API_KEY>), prod=True)

If you have any questions please shoot a mail to anshul[dot]jmi[at]gmail[dot]com.

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

affirm-pay-0.6.tar.gz (5.0 kB view details)

Uploaded Source

File details

Details for the file affirm-pay-0.6.tar.gz.

File metadata

  • Download URL: affirm-pay-0.6.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.11.1 setuptools/39.1.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.10

File hashes

Hashes for affirm-pay-0.6.tar.gz
Algorithm Hash digest
SHA256 350eed28b4752babf3703aaa47dbeb5bea9e0c563941affe5baf485c3d7d1f9a
MD5 53a22c5a7e1dca0562e39092fc9ee8a3
BLAKE2b-256 5763b95499591588a3171707d1e70ff89deafc0134e7517662be3d80f629f49a

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