A SDK which helps to create, fetch or refund an order on Paytring
Project description
Paytring\Python
Installation
The source code is currently hosted on GitHub at : https://github.com/paytring/python-sdk
Binary installers for the latest released version are available at the Python Package Index (PyPI)
pip install paytring
Set-Up Environment Variables
import os
os.environ['key'] = "your_key"
os.environ['secret'] = "your_secret"
Payment Usage
from paytring.client import Order
Create Instance
order = Order()
Create Order
Input Parameter
- Receipt ID(string)
- Payment_Info (Dictionary)
- Callback Url(string)
- Customer Info ( Dictionary )
Optional Parameters
- Billing Info ( Dictionary )
- Shipping Info ( Dictionary )
- Notes ( Dictionary )
- TPV ( Dictionary )
- PG (String)
- PG Pool ID (String)
Methods
payment_info = {
"amount": "100",
"currency": "INR" # currency INR or USD
}
customer_info = {
"cname": "test",
"email": "abc@gmail.com" -> it will be baseEncode256,
"phone": "9999999999"
}
billing_info = {
"firstname" : "John",
"lastname" : "Doe",
"phone" : "09999999999",
"line1" : "Address Line 1",
"line2" : "Address Line 2",
"city" : "Gurugram",
"state" : "Haryana",
"country" : "India",
"zipcode" : "122001"
}
shipping_info = {
"firstname" : "John",
"lastname" : "Doe",
"phone" : "09999999999",
"line1" : "Address Line 1",
"line2" : "Address Line 2",
"city" : "Gurugram",
"state" : "Haryana",
"country" : "India",
"zipcode" : "122001"
}
notes = {
"udf1" : "udf1",
"udf2" : "udf2",
"udf3" : "udf3",
}
tpv = [
{
"name": "Test",
"account_number": "0000001234567890",
"ifsc": "BankIFSC0001"
}
]
response = order.create(
receipt_id,
callback_url,
payment_info,
customer_info,
billing_info(optioanl),
shipping_info(optioanl),
notes(optioanl),
tpv(optioanl),
pg(optioanl),
pg_pool_id(optional)
)
Response
{
"status": true,
"url": "www.makepayment.com",
"order_id": "365769619161481216"
}
Fetch Order
Input Paramete
- Order ID(string)
Methods
order.fetch(
order_id
)
Response
{
"status": true,
"order": {
"order_id": "489651149222183338",
"receipt_id": "testmode323",
"pg_transaction_id": "489651179018519803",
"amount": 100,
"currency": "INR",
"pg": "RazorPay",
"method": "UPI",
"order_status": "success",
"unmapped_status": "captured",
"customer": {
"name": "John",
"email": "abc@gmail.com",
"phone": "9999999999"
},
"notes": {
"udf1": "",
"udf2": "",
"udf3": "",
"udf4": "",
"udf5": "",
"udf6": "",
"udf8": "",
"udf9": "",
"udf10": ""
},
"billing_address": {
"firstname": "",
"lastname": "",
"phone": "",
"line1": "",
"line2": "",
"city": "",
"state": "",
"country": "",
"zipcode": ""
},
"shipping_address": {
"firstname": "",
"lastname": "",
"phone": "",
"line1": "",
"line2": "",
"city": "",
"state": "",
"country": "",
"zipcode": ""
},
"additional_charges": 0,
"mdr": ""
}
}
Fetch Order By Receipt-ID
Input Paramete
- Receipt ID(string)
Methods
order.fetch_by_receipt_id(
receipt_id
)
Response
{
"status": true,
"order": {
"order_id": "489651149222183338",
"receipt_id": "testmode323",
"pg_transaction_id": "489651179018519803",
"amount": 100,
"currency": "INR",
"pg": "RazorPay",
"method": "UPI",
"order_status": "success",
"unmapped_status": "captured",
"customer": {
"name": "test",
"email": "abc@gmail.com",
"phone": "9999999999"
},
"notes": {
"udf1": "",
"udf2": "",
"udf3": "",
"udf4": "",
"udf5": "",
"udf6": "",
"udf8": "",
"udf9": "",
"udf10": ""
},
"billing_address": {
"firstname": "",
"lastname": "",
"phone": "",
"line1": "",
"line2": "",
"city": "",
"state": "",
"country": "",
"zipcode": ""
},
"shipping_address": {
"firstname": "",
"lastname": "",
"phone": "",
"line1": "",
"line2": "",
"city": "",
"state": "",
"country": "",
"zipcode": ""
},
"additional_charges": 0,
"mdr": ""
}
}
Refund Order
Input Parameters
- Order ID(string)
Methods
order.refund(
order_id
)
Response
Success Response
{
"status": true,
"message": "Refund has been initiated"
}
Error Response
{
"status": false,
"error": {
"message": "error message here",
"code": 204
}
}
Process Order
Input Parameters
- Order ID(string): ORder id got in response when order is created on paytring
- Method
- Code
Optional Parameters
- VPA(String) : Only required if method is upi and code is collect
- Card : Only required if method & code is card
- Device : Mandatory if method is upi and code is intent, eg. android, ios
card = {'number': "1234XXXXXXXXXXX",
'cvv': "123",
"expiry_month": "07",
"expiry_year": "21",
"holder_name": "John Doee"
}
Methods
order.process_order(order_id="paytring order id", method='card', code='card', card=card)
Response
{
'status': True,
'payment_id': '586493765254906097',
'data': {'type': 'otp', 'url': ' ', 'param': [], 'resend_url': ' ', 'resend_param': []
}
}
Validate VPA
Input Parameters
- VPA(String) : VPA number you want to validate
Methods
order.validate_vpa(vpa='vpa')
Response
{
'status': True,
'isVPAValid': True,
'payerAccountName': 'John Doee'
}
Validate Card
Input Parameters
- bin : Card bin you want to be validated.( first 6 digits of card number )
Methods
response = order.validate_card(bin='438976')
Response
{
'status': True,
'isCardValid': True,
'payerAccountName': 'John Doee'
}
Subscription Usage
from paytring.client import Subscription
Create Instance
subscription = Subscription()
Create Plan
Input Parameter
- Plan ID(string)
- Payment_Info (Dictionary)
- Plan Info ( Dictionary )
- Notes ( Dictionary )
Methods
payment_info = {
"amount": "100",
"currency": "INR" # currency INR or USD
}
plan_info = {
"title": "Daily 1 rupee plan",
"description": "test plan",
"frequency": "1",
"cycle": "12",
}
notes = {
"udf1" : "udf1",
"udf2" : "udf2",
"udf3" : "udf3",
}
response = subscription.create_plan(
plan_id,
payment_info,
plan_info,
notes
)
Response
{
'status': True,
'plan_id': '552678261629388919'
}
Fetch Plan
Input Paramete
- Plan ID(string)
Methods
subscription.fetch_plan(
plan_id
)
Response
{
'status': True,
'plan': {
'plan_id': '552678261629388919',
'mer_reference_id': 'PLAN1234768547984',
'amount': 100,
'currency': 'INR',
'plan_status': 'created',
'frequency': '1',
'cycle': '12',
'notes': {
'udf1': 'udf1',
'udf2': 'udf2',
'udf3': 'udf3'
}
}
}
Fetch Plan By Receipt-ID
Input Paramete
- Receipt ID(string)
Methods
subscription.fetch_plan_by_receipt_id(
receipt_id
)
Response
{
'status': True,
'plan': {
'plan_id': '552678261629388919',
'mer_reference_id': 'PLAN1234768547984',
'amount': 100,
'currency': 'INR',
'plan_status': 'created',
'frequency': '1',
'cycle': '12',
'notes': {
'udf1': 'udf1',
'udf2': 'udf2',
'udf3': 'udf3'
}
}
}
Error Response
{
"status": false,
"error": {
"message": "error message here",
"code": 204
}
}
Create Subscription
Input Parameter
- Receipt ID (string)
- Plan ID (string)
- Callback Url(string)
- Customer Info ( Dictionary )
Optional Parameters
- Billing Info ( Dictionary )
- Shipping Info ( Dictionary )
- Notes ( Dictionary )
- PG (String)
- PG Pool ID (String)
Methods
payment_info = {
"amount": "100",
"currency": "INR" # currency INR or USD
}
customer_info = {
"cname": "test",
"email": "abc@gmail.com" -> it will be baseEncode256,
"phone": "9999999999"
}
billing_info = {
"firstname" : "John",
"lastname" : "Doe",
"phone" : "09999999999",
"line1" : "Address Line 1",
"line2" : "Address Line 2",
"city" : "Gurugram",
"state" : "Haryana",
"country" : "India",
"zipcode" : "122001"
}
shipping_info = {
"firstname" : "John",
"lastname" : "Doe",
"phone" : "09999999999",
"line1" : "Address Line 1",
"line2" : "Address Line 2",
"city" : "Gurugram",
"state" : "Haryana",
"country" : "India",
"zipcode" : "122001"
}
notes = {
"udf1" : "udf1",
"udf2" : "udf2",
"udf3" : "udf3",
}
response = subscription.create_subscription(
receipt_id,
plan_id,
callback_url,
customer_info,
billing_info(optioanl),
shipping_info(optioanl),
notes(optioanl),
pg(optioanl),
pg_pool_id(optional)
)
Response
{
"status": true,
"url": "https://api.paytring.com/pay/subscription/87583758943797",
"subscription_id": "87583758943797"
}
Fetch Subscription
Input Parameters
- Subscription ID(string)
Methods
subscription.fetch_subscription(
subscription_id
)
Response
{
'status': True,
'subscription': {
'subscription_id': '552679210171237835',
'mer_reference_id': '6574363653869523845',
'amount': 100,
'currency': 'INR',
'subscription_status': 'active'
}
}
Fetch Subscription By Receipt-ID
Input Parameters
- Receipt ID(string)
Methods
subscription.fetch_subscription_by_receipt_id(
receipt_id
)
Response
{
'status': True,
'subscription': {
'subscription_id': '552679210171237835',
'mer_reference_id': '6574363653869523845',
'amount': 100,
'currency': 'INR',
'subscription_status': 'active'
}
}
Error Response
{
"status": false,
"error": {
"message": "error message here",
"code": 204
}
}
Currency Conversion Usage
from paytring.client import Settlement
Create Instance
currency = CurrencyConversion()
Input Parameters
- currency_from(String)
- currency_to(String)
- Accpted Currencies : INR|USD|AUD|BGN|CAD|EUR|JPY|NZD|QAR|SGD|KRW|CHF|GBP|AED|NZD
Methods
currency.convert_currency(currency_from='USD', currency_to='IND')
Response
{ 'status': True,
'data': {'from': 'USD', 'to': 'INR','rate': '83.02'}
}
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
paytring-1.0.7.tar.gz
(12.2 kB
view hashes)
Built Distribution
paytring-1.0.7-py3-none-any.whl
(11.0 kB
view hashes)