Skip to main content

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

Project description


title: "README" excerpt: "A description the Ping Payments Python SDK"

Ping Payments Python SDK

Tests PyPI version License: MIT

The Ping Payments Python SDK manages the Ping Payments API.

Table of contents

Requirements

The Ping Payments Python SDK supports the following versions of Python:

  • Python 3, versions 3.7 and later

Installation

Install the latest Ping Payments Python SDK using pip:

pip install ping-sdk

The Ping Payments API

The Ping Payments API is implemented as the PaymentsApi class. The PaymentsApi contains a number of endpoints.

Ping Payments API Endpoints

Available endpoints in the PaymentApi class:

You work with the Ping Payments API by calling methods in the PaymentsApi endpoints.

The Ping Payments Python SDK documentation contains lists of available methods for each endpoint, on the page for each endpoint.

Usage

Here’s how to get started with the Ping Payments API:

Get a tenant ID

Ping Payments provides you with a tenant ID. The Ping Payment API uses tenant IDs for resource permissions.

Important: Make sure you store and access the tenant ID securely.

Using the Ping Payments API:

  • Import the PaymentsAPI class.
  • Instantiate a PaymentsAPI object.
  • Initialize the PaymentsAPI object with the appropriate tenant ID and environment.

Detailed instructions:

  1. Import the PaymentsApi class from the Ping Python SDK module:
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.

Initialize the PaymentsApi in production mode:

payments_api = PaymentsApi(
		tenant_id = '55555555-5555-5555-5555-555555555555'
)

Initialize the PaymentsApi in sandbox mode, for testing:

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

You can ping the API to see if it's accessible. A working response contains the text "pong".

payments_api.ping.ping_the_api()

Get an Instance of an PaymentsApi Object and Call the Methods of the PaymentsApi class

Work with the API by calling the methods on the API object. For example, you call list() for a list of all merchants connected to a tenant:

result = payments_api.merchant.list()

Handle the response

Calls to the Ping Payments API endpoint methods return an ApiResponse object. Properties of the ApiResponse object describe the request (headers and request) and the response (status_code, reason_phrase, text, errors, body, and cursor).

Using the response:

Check whether the response succeeded or failed. Two helper methods in the ApiResponse object 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-4.0.0.tar.gz (12.3 kB view hashes)

Uploaded Source

Built Distribution

ping_sdk-4.0.0-py3-none-any.whl (14.5 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