Skip to main content

PG Rewards python SDK

Project description

PG Rewards SDK - Python

So you are a developer and will start accepting payments with moncash. The PG Rewards Payments SDK is the easiest way to complete the integration in record time. With the PG Rewards Payment SDK, you can create a payment process through moncash to meet the unique needs of your projects.

Getting an API Key

before we start the integration make sure you have:

  • Registered for a PG Rewards developer Account
  • Navigate to Settings > Developer Setting
  • Click on Generate New Credentials to get new credentials

Install pip package

$ pip install pgrwpy

Getting Started

You need to setup your key and secret using the following:

To work in production mode you need to specify your production userID & secretKey along with a production_mode True boolean flag

import pgrwpy

client = pgrwpy.Client(auth=(userID, secretKey),
                         production_mode=True)

or

To work in sandbox mode you need to specify your sandbox userID & secretKey keys along with a False boolean flag or you could just omit the production_mode flag since it defaults to False if not specified

import pgrwpy

client = pgrwpy.Client(auth=(API_KEY, API_SECRET),
                         production_mode=False)

After setting up the client instance you can get the current pgrwpy SDK version using the following:

print(client.get_version())

Create a paymet with Mon Cash

In order to receive payments using this flow, first of all you will need to create a Moncash payment. Following are the important parameters that you can provide for this method:

Field Required Type Description
amount Yes number Amount in Haitian Currency (gourdes)
referenceId Yes string Your internal reference ID into your own system for tracking purposes
successUrl Yes string Send the user back once the transaction is successfully complete
errorUrl Yes string Send the user back if there is an error with the transaction

For details of all the request and response parameters , check our PG API Documentation guide

data = {
    "amount": 500,
    "referenceId": "12345test",
    "successUrl": "https://example.com",
    "errorUrl": "https://example.com"
}

client.Payment.moncash(data)

Did you get a HTTP 201 response, if yes then you are all set for the next step.


Get Payment Details

Now that you have created a payment, the next step is to implement polling to get Payment Details. We recommend a 4-5 second interval between requests. Following are the important parameters that you can provide for this method:

Field Required Type Description
orderId Yes string Your internal reference ID into your own system for tracking purposes

Fetch a particular Moncash payment details

client.Payment.get_payment_details("<orderId>")

For details of all the request and response parameters , check our PG API Documentation guide On successful payment, the status in the response will change to COMPLETED In case of a pending for Payment, the status in the response will change to PENDING


Task | workflow

  • Moncash
  • Payment details
  • Card

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

pgrwpy-0.1.1.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pgrwpy-0.1.1-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file pgrwpy-0.1.1.tar.gz.

File metadata

  • Download URL: pgrwpy-0.1.1.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for pgrwpy-0.1.1.tar.gz
Algorithm Hash digest
SHA256 53efa3329a00ce51e12b5a3d1ab8d4a8438ad8c57006b67dd8cf91af54196e5f
MD5 5580171c30f00bfaaeaf7e1a635542f0
BLAKE2b-256 ac0d1e102d39ff9558e248cf35ddbfd3e3efffd86c84d1e5a1f9ed3f2d1aa937

See more details on using hashes here.

File details

Details for the file pgrwpy-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pgrwpy-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for pgrwpy-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0f1a4cd897e993f46290a484be26ff228e27474256ec291a810c82a69e0ac65e
MD5 749a9bb59d405e44b0ecafe5e5e7a079
BLAKE2b-256 9689f3029abb5a768da5bc59bbc433f3a94abe15d912a59a3af838f1edcf38d6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page