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.2.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.2-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pgrwpy-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 4d821ada899d613a14f71cae9ff61c561f62d85cd225f626dd3ee721ca506c68
MD5 1954b0978722129e5a36841d34d7330a
BLAKE2b-256 88db7056378245456bb0ef1c6ec8f8e1f8bd32dcf2048ff6cca414b18517e333

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pgrwpy-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.0 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0f40d3054bc73990ca16d5099d04f22ad8a975e3ea3688bc5d21b851619a51b5
MD5 26eea8ee68ef9ac1da7b9f3bafc759a7
BLAKE2b-256 12be823fa51f4387ea6b7e8d102b86c7110235cf10befb47a8251cec03be6986

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