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

The Ping Payments Python SDK manages the Ping Payments API and Ping Payment Links 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

Documentation

The Ping Payments Python SDK documentation contains complete information to be able to work with the SDK. Go to Python SDK documentation for the full documentation.

Ping Payments API

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

Ping Payments API Endpoints

Ping Payment Links API

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

Ping Payment Links API Endpoints

Usage

Get a tenant ID

Ping Payments provides you with a tenant ID and are used for resource permissions.

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

Instructions

  1. Import the PaymentsApi class from the Ping 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'
)

Make calls

Work with the API by by choosing a Endpoint and calling it´s methods. For example, you can choose the endpoint merchants and call the method list() to 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 returns an ApiResponse object. Properties of the ApiResponse object contains information regarding 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 is_success()and is_error() in the ApiResponse object determine the success or failure of a call:

if result.is_success():
	# Display the successful response as text
	print(result.text)
elif result.is_error():
	# Display the error response
	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.1.0.tar.gz (14.5 kB view hashes)

Uploaded Source

Built Distribution

ping_sdk-4.1.0-py3-none-any.whl (22.0 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