Skip to main content

PayU Python SDK

Project description

PayU Python Serverside sdk

Installation through package manager

$pip install payu-sdk

If you are on python 3x pls run below:

$pip3 install payu-sdk

Installation Manually

download zip from releases, unzip and just drag & drop payu-sdk folder at your end.

Usage You need to set up your key and salt values, you can find in your dashboard.

import payu_sdk
client = payu_sdk.payUClient("<key>","<salt>")

Next you have to collect payment params needed to make a payment request e.g.

params = {"txnid":"202005110207","amount":"10","productinfo":"iPhone","firstname":"userFirstName","email":""}

You can also append user defined values to the params in udfs. e.g.

params = {"udf1":"street address","udf2":"city","udf3":"zip","udf4":"country","udf5":"some other value"

Generate Payment Hash To get the payment hash you need to call generate_hash function as follows:


To generate API hash you'll need majorly four params (i.e. key,command,var1,salt), you can call inbuilt APIHash as follows:

apiHash = payu_sdk.Hasher.APIHash(hashForAPI)

You can pass command & var1 as params :

params = {"command":"verify_payment","var1":"7fa6c4783a363b3da573"}

Calling PayU APIs for payment flow

1). paymentRequest: you need to call this API to make payment, in response it will give you payment page where you can proceed & make a payment through payment modes.

from payu_sdk.request import createRequest

req = createRequest.paymentRequest(payload) 

Sample payload e.g.


2). Verify payment API call : This API gives you the status of the transaction.We recommend to use this API to reconcile with PayU’s database once you receive the response. It has two types:

from payu_sdk.API import paymentAPI

i). Verify Payment Status by Transaction ID :This API gives you the status of the transaction by passing transactionId as input parameter.

res = paymentAPI.verifyPayment.verifyPaymentStatusByTransactionID(payload_verifyPayment)

sample payload :


ii). Verify Payment Status by PayUID : This API gives you the status of the transaction similar to verify_payment API. The only difference is that the input parameter in this API (i.e. var1) is the PayUID (MihpayID) generated at PayU’s end.

res = paymentAPI.verifyPayment.verifyPaymentStatusByPayUID(payload_verifyPayment)

3). Refund APIs: This API is used to check the status of refund/cancel requests. Whenever the cancel_refund_transaction API is executed successfully, a request ID is returned in the output parameters for that particular request, var1 is Request ID

Res = RefundAPI.refundTransaction(payload_ RefundAPI) 


res = paymentAPI.OffersAPIs.CheckOfferStatusByCategoryAndCardNumber(payload_vOffersAPIs)

Validate Hash After transaction is made, you need to cross-verify the hash to make sure it was not tempered. So, if the hash generated from validate hash matched the reverse_hash(you get after each transaction) that means transaction was not tempered.


Note: Calculation of reverse hash is mandatory and we recommend this to be calculated after each transaction.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release. See tutorial on generating distribution archives.

Built Distribution

payu_sdk-1.2.0-py3-none-any.whl (9.6 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page