Skip to main content

Library to access PayPal’s REST API

Project description

Introduction

paypal_rest is a library to wrap PayPal’s REST interface. In late 2020, most Python libraries for the PayPal API are focused on charging customers. This library is focused on getting information about past charges and customers.

paypal-query tool

This library includes a command line tool, paypal-query, to quickly get information from the API; provide an illustration of using the library; and help with debugging. To use it, first write a configuration file ~/.config/paypal_rest/config.ini with your REST API app credentials from PayPal:

[query]
client_id = ...
client_secret = ...
; site can 'live', 'sandbox', or an API endpoint URL
site = live

To see an overview of transactions over a time period:

paypal-query [--begin DATETIME] [--end DATETIME]

Specify all datetimes in ISO8601 format: YYYY-MM-DDTHH:MM:SS. You can stop at any divider and omit the rest. You can also add a timezone offset, like -04:00 or +01:00, or Z for UTC.

To see details of a specific transaction or subscription:

paypal-query [--end DATETIME] PAYPALID1234ABCD0 [...]

The PayPal API does not let you look up an individual transaction by ID; you have to search through 30-day time windows. The tool will automatically search backwards through time to find your result, but specifying the latest date to search from with the --end option can speed up the search significantly.

Library quickstart

Create a paypal_rest.PayPalAPIClient using one of the classmethod constructors, then call its methods and handle the results:

config = configparser.ConfigParser()
config.read(os.path.expanduser('~/.config/paypal_rest/config.ini'))
paypal = paypal_rest.PayPalAPIClient.from_config(config['query'])
for txn in paypal.iter_transactions(start_date, end_date):
  ...  # txn is a paypal_rest.transaction.Transaction object you can query.

For more details, refer to the pydoc for paypal_rest.PayPalAPIClient and paypal_rest.transaction.Transaction.

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

paypal_rest-1.0.4.tar.gz (30.1 kB view details)

Uploaded Source

Built Distribution

paypal_rest-1.0.4-py2.py3-none-any.whl (30.8 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file paypal_rest-1.0.4.tar.gz.

File metadata

  • Download URL: paypal_rest-1.0.4.tar.gz
  • Upload date:
  • Size: 30.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.3

File hashes

Hashes for paypal_rest-1.0.4.tar.gz
Algorithm Hash digest
SHA256 9ec4838096e9c1aba87ad23667961a386d181546db83ec7a4da24d4f7ccd7b62
MD5 c9ce936bbf34d8c94f8db4d35bb6e9c0
BLAKE2b-256 c9b7071f8329b20233f708feb516433a27aaf8e5a7cb80a9c4b1815b78354c0e

See more details on using hashes here.

File details

Details for the file paypal_rest-1.0.4-py2.py3-none-any.whl.

File metadata

  • Download URL: paypal_rest-1.0.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 30.8 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.3

File hashes

Hashes for paypal_rest-1.0.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 6fdaa83e613200f87154f8da5435e33d4830ae73dc76253669a3b721a27241aa
MD5 6ce478ebc44c3824d8e0ea7fffd9c934
BLAKE2b-256 2c2efd6f2a2e4f2b21413ed8e22de04bea1b9ffccad50b801cfdfbb81b077a53

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