PayU Transaction Status API in PHP

860 Views Asked by At

I am trying to get TXN details from payu api https://www.mylloyd.com/media/commercials/news_paper/integration_document_version_2_51.pdf page no 27

I tried to integrate the same in php

$key = "lm4WnvkL"; 
$salt = "QPQ969eJUB";
$command = "verify_payment";
$var1 = "OID12297670"; //merchant generated 
$txnid = "9084024418"; // payu generated id if needed
$authheader = "PWoH07ktmpG1f4c569tD/ndb7O2YesoYs3r64OTWZ2g=";//if needed

//hash formaula
$hash_str = $key  . '|' . $command . '|' . $var1 . '|' . $salt ;
$hash = strtolower(hash('sha512', $hash_str));
$r = array('key' => $key , 'hash' =>$hash , 'var1' => $var1, 'command' => $command);
$qs= http_build_query($r);
$wsUrl = "https://test.payu.in/merchant/postservice.php?form=2";
//$wsUrl = "https://info.payu.in/merchant/postservice?form=2";

$c = curl_init();
curl_setopt($c, CURLOPT_URL, $wsUrl);
curl_setopt($c, CURLOPT_POST, 1);
curl_setopt($c, CURLOPT_POSTFIELDS, $qs);
curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0);
$o = curl_exec($c);
if (curl_errno($c)) {
  $sad = curl_error($c);
  throw new Exception($sad);
}
curl_close($c);

$valueSerialized = @unserialize($o);
if($o === 'b:0;' || $valueSerialized !== false) {
  print_r($valueSerialized);
}
print_r($o);

This code i picked it up form Transaction Status API in PHP for Payment Gateway

But instread of getting output as json I am getting https://i.ibb.co/2v9s7sJ/image.png

The key and salt are valid since payment is working so you may run the code to test it I will edit that to invalid later

Array ( [isConsentPayment] => 0 [mihpayid] => 9084024418 [mode] => CC [status] => success [unmappedstatus] => captured [key] => lm4WnvkL [txnid] => OID12297670 [amount] => 65.00 [addedon] => 2020-10-01 21:46:59 [productinfo] => This is test [firstname] => Rohit Mahajan [lastname] => [address1] => [address2] => [city] => [state] => [country] => [zipcode] => [email] => [email protected] [phone] => 9420241080 [udf1] => [udf2] => [udf3] => [udf4] => [udf5] => [udf6] => [udf7] => [udf8] => [udf9] => [udf10] => [hash] => ef0ae2368b4703dde6410aed45f13b3f5ef74c2853879305aa6388a600b47ed291fdc85c095dfa49e4741da9683d5cbca6bec14e5ae5e51434a8e52b557eb704 [field1] => 797028716857 [field2] => 674900 [field3] => 922807983480774 [field4] => QnVVWlM1S0ZFOUR2enJ5ZkRoVVc= [field5] => 05 [field6] => [field7] => AUTHPOSITIVE [field8] => [field9] => [giftCardIssued] => true [PG_TYPE] => HDFCPG [encryptedPaymentId] => C63A737828F0D5FE1AFD9CF461992A27 [bank_ref_num] => 922807983480774 [bankcode] => VISA [error] => E000 [error_Message] => No Error [name_on_card] => Test [cardnum] => 401200XXXXXX1112 [cardhash] => This field is no longer supported in postback params. [amount_split] => { [payuMoneyId] => 250546370 [discount] => 0.00 [net_amount_debit] => 65 )

This is the response i got when i finished the transaction so if any field is needed its in this array for the above code

0

There are 0 best solutions below