Skip to main content

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 details)

Uploaded Source

Built Distribution

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

paytring-1.0.7-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file paytring-1.0.7.tar.gz.

File metadata

  • Download URL: paytring-1.0.7.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.7

File hashes

Hashes for paytring-1.0.7.tar.gz
Algorithm Hash digest
SHA256 ba65f0e653f50920c2ea30aa2e6ef36bf9392521f92a5dce2616fcc7ed9c5af4
MD5 1b44cfa4c467580b840d038403db8541
BLAKE2b-256 032cd191014b41793c869b560e89e53503f43bb02d84fa8d9186c01c6e9c6111

See more details on using hashes here.

File details

Details for the file paytring-1.0.7-py3-none-any.whl.

File metadata

  • Download URL: paytring-1.0.7-py3-none-any.whl
  • Upload date:
  • Size: 11.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.7

File hashes

Hashes for paytring-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 4f9f0d9e66127f1fd182c576f1d83406f90930303841e338474aa95d517e0342
MD5 27ae076cbc192c33daae67a180eb7016
BLAKE2b-256 843f0a05724cbdeacc115fa27cf237cb6cb1706bb411bd113cecb6a238d6685a

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