payu php sdk - payu-india/payu-sdk-php GitHub Wiki

PayU PHP Serverside sdk


Prerequisites:

composer, php v > 7

PHP server side sdk to interact with PayU. This is primarily for generating hashes at the server to interact with PayU for making transaction.


Installation through package manager

$composer require payusdk/payu

Installation Manually

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

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

include "payu/PayUClient.php";
use payu\PayUClient;

Now, simply create an object of PayU Client :

$obj = new PayUClient("<key>","<salt>");

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

$params = array("txnid"=>"8980990","amount"=>"10","productinfo"=>"iPhone","firstname"=>"Ashish","email"=>"[email protected]","udf1"=>"udf1","udf2"=>"udf2","udf3"=>"udf3","udf4"=>"udf4","udf5"=>"udf5");

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:

Hasher.generate_hash(params)

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.

Hasher.validate_hash(params)

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

⚠️ **GitHub.com Fallback** ⚠️