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 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', 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)
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:-
client(first_name='openpay', family_name='test', firstname.lastname@example.org', address_1='15/520 Collins Street', suburb='Melbourne', state='Victoria', postcode=3000, dob='06 Jan 1985')
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.
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.4.1.tar.gz (5.7 kB)||File type Source||Python version None||Upload date||Hashes View hashes|