Skip to main content

Use this Python library to manage Ping Payments API regarding merchants, payment orders, payments and payouts

Project description

Ping Payments Python SDK

Tests PyPI version License: MIT

Use this Python library to manage Ping Payments API regarding merchants, payment orders, payments and payouts.

Table of contents

Requirements

The SDK supports the following versions of Python:

  • Python 3 versions 3.6 and later

Installation

Install the latest SDK using pip:

pip install ping-sdk

Payments API

Payments API

Usage

First time using Payments API? Here’s how to get started:

Get a tenant ID

To use the Payments API to manage the resources you need to get a tenant ID. A tenant ID is provided to you by Ping Payments.

When you call the Payments API, you call it using a tenant ID. A tenant ID has specific permissions to resources. Important: Make sure you store and access the tenant ID securely.

To use the Payments API, you import the PaymentsAPI class, instantiate a PaymentsAPI object, and initialize it with the appropriate tenant ID and environment. Here’s how:

  1. Import the PaymentsApi class from the Ping Python SDK module so you can call the Payments API:
from ping.payments_api import PaymentsApi
  1. Instantiate a PaymentsApi object and initialize it with the tenant ID and the environment that you want to use.

To access sandbox resources, initialize the PaymentsApi with environment set to sandbox:

payments_api = PaymentsApi(
		tenant_id = '55555555-5555-5555-5555-555555555555',
		environment = 'sandbox'
)

To access production resources, initialize the PaymentsApi with environment set to production:

payments_api = PaymentsApi(
		tenant_id = '55555555-5555-5555-5555-555555555555',
		environment = 'production'
)

Get an Instance of an API object and call its methods

The API is implemented as a class. With the PaymentsApi object you work with an API by calling it's methods.

Work with the API by calling the methods on the API object. For example, you would call get_merchants to get a list of all merchant for the tenant:

result = payments_api.merchant.get_merchants()

See the SDK documentation for the list of methods for the API class.

Handle the response

API calls return an ApiResponse object that contains properties that describe both the request (headers and request) and the response (status_code, reason_phrase, text, errors, body, and cursor). Here’s how to handle the response:

Check whether the response succeeded or failed. ApiResponse has two helper methods that enable you to easily determine the success or failure of a call:

if result.is_success():
# Display the response as text
print({result.text})
# Call the error method to see if the call failed
elif result.is_error():
print(f"Errors: {result.errors}")

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

ping-sdk-2.1.0.tar.gz (11.7 kB view hashes)

Uploaded Source

Built Distribution

ping_sdk-2.1.0-py3-none-any.whl (14.4 kB view hashes)

Uploaded Python 3

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