Skip to main content

pypay provides a clean API for confirming Paypal payments via PDT or IPN. It takes the boilerplate out of interacting with these services and normalises the Paypal response into something sensible.

Under the hood pypay uses the excellent Requests library for handling http.

Installation

pip install pypay

Usage

To check a payment via PDT

import pypay

response = pypay.pdt_confirm('your_transaction_id', 'your_identity_token')

To check a payment via IPN

import pypay

response = pypay.ipn_confirm('query_params_from_paypal')

You can pass the query params as either a string (e.g. ‘quantity=1&name=joe’) or a dict. This is particularly useful if you’re using Django as you can drop in request.POST and everything will just work.

Response objects

Response objects always have two properties

response.confirmed # bool indicating if payment is verified

response.details # dict containing all the Paypal variables that were returned

Handling exceptions

In the event of a problem making the http call to Paypal, pypay will raise a pypay.exceptions.RequestError.

The values passed to pdt_confirm and ipn_confirm are sanity checked and a pypay.exceptions.InvalidPaypalData will be raised if they are of the wrong type.

Python version support

pypay runs on Python 2.6, 2.7, 3.3, 3.4, 3.5 and 3.6 using the Six compatibility library.

Running tests

Run the test suite with Tox

pip install tox

Tests are written with pytest

Release files for pypay 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pypay 0.2.1
File Size Uploaded
pypay-0.2.1.tar.gz 4.4 kB Details

Release files / pypay-0.2.1.tar.gz

Download URL pypay-0.2.1.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
239134702e16e27b1aa47320c843c01f834dc59f11e49d9dd22a861c4967c4f6
BLAKE2b-256 checksum
How to use checksums
ec20c52583d03c4dabb1e53edf24e4016fbe2027cb96207d5cc8aacad5f69bd7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2.1 This release

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page