Library to access PayPal's REST API
Find a file
Brett Smith c4561a0026 setup: Move test dependencies into tox configuration.
pytest-runner, and generally doing this through setuptools, is deprecated.
A little sad, but understandable. Handle tests in tox as recommended.
2021-03-31 16:15:36 -04:00
paypal_rest cliquery: Dump individual objects as an array. 2020-11-24 09:22:59 -05:00
tests client: iter_transactions() supports date ranges longer than a month. 2020-11-19 15:38:13 -05:00
.gitignore setup: Packaging improvements for 1.0 release. 2020-11-19 12:02:48 -05:00
CODE.rst setup: Move test dependencies into tox configuration. 2021-03-31 16:15:36 -04:00
LICENSE.txt Initial commit. 2020-11-18 15:57:38 -05:00
MANIFEST.in setup: Packaging improvements for 1.0 release. 2020-11-19 12:02:48 -05:00
pyproject.toml setup: Convert to building with pyproject.toml. 2021-03-31 12:10:47 -04:00
README.rst README: Small improvements throughout. 2020-11-24 09:22:24 -05:00
setup.cfg setup: Move test dependencies into tox configuration. 2021-03-31 16:15:36 -04:00
setup.py setup: Convert to building with pyproject.toml. 2021-03-31 12:10:47 -04:00

paypal_rest
===========

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``.