openpay python sdk
Python Openpay SDK
This module is created to achieve payment via. Openpay from any web based platform created by Python. Every merchant can use this SDK for its clients to handle order creation to complete payment.
pip install python-openpay
Creation of Merchant
Every merchant object is created by using compulsory attribute jam_auth_token, country_code and along with other two non-mandatory attributes such as - auth_token and openpay_url_mode as follows:-.
from openpay import Merchant merchant= Merchant(jam_auth_token='your jam auth token',country_code="au or uk" auth_token=None, openpay_url_mode="Live")
Here, openpay_url_mode is used to specify the mode of URL, such as "Live" or "Training". This is required for testing this SDK in demo or production purpose.
Now a merchant can set up success, cancel and failure urls for redirecting a client during or after payment through openpay as follows:-
merchant.set_callback_url(callback_url=val1, cancel_url=val2, failure_url=val3)
if any fraud is taking place corresponding to a plan id then merchant can call this following function
Note: This is not mandatory. It will only be called if fraud occurs
Creation of Client
A particular merchant has a set of clients for his site. So, when we create a client object then we have to associate a merchant object with it. Possible ways to associate a client with merchant are as follows:-
from openpay import Client client = Client(merchant=merchant) # association with merchant
Later, we can update a client object using demographic information as follows(res for residential and del for delivery address):-
client(first_name='openpay', family_name='test', firstname.lastname@example.org', res_address_1='15/520 Collins Street', res_suburb='Melbourne', res_state='Victoria', res_postcode=3000, dob='06 Jan 1985')
Add just add del_ suffix like
del_address_1 instead of
address, suburb and state.
Another way to create client with two above steps in together as follows :
client = Client(first_name='Test', family_name='User', email@example.com', address_1='15/520 Collins Street', suburb='Melbourne', state='Victoria', postcode=3000, dob='06 Jan 1985', merchant=merchant)
%b Month as locale’s abbreviated name. Jan, Feb, …, Dec. So, any valid date format should be
like '06 Jan 1985'. In addition, postal code should be of length 4.
Check if price is valid for payment(comes in min max range)
Before initiating order, need to check if price is valid with
If the status is True or error is blank in response then we can proceed further with the next call
Online order creation
Here, client is going to order one or more item(s) from merchant site and param purchase_price is the sum of item(s) prices chosen by client.
client.new_online_order(purchase_price=<total price>, plan_creation_type="Pending")
After successful execution, a plan ID is created for the client.
Check Min and Max purchase price
This method is used to check whether the purchase_price is in the minimum and maximum price range of a merchant or not.
Create online plan
plan_link = client.create_online_plan(order_id= <orderID created from merchant site>)
Openpay provides all possible plans to pay purchase_price for this client. Once a plan is chosen by client then Openpay redirects him for payment.
Check payment and order status
To check payment and order status for a client, we should call below functions with plan_id as argument respectively.
If merchant wants to create any partial refund for a plan then he has to set arguments plan_id and new_purchase_price as follows:-
client.refund_status(plan_id=plan_id, new_purchase_price= <revised purchase price>)
Note: Argument new_purchase_price is calculated as follows:-
previous purchase price - amount of price to refund
In case of full refund, set arguments plan_id and full_refund as follows:-
If merchant wants to initiate a dispatch of an order then he will following method with corresponding plan_id of that order as follows:-
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size python_openpay-0.6.3-py3-none-any.whl (8.8 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
|Filename, size python-openpay-0.6.3.tar.gz (6.9 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for python_openpay-0.6.3-py3-none-any.whl