title: Transaction Status API in PHP for Payment Gateway
body: <p>I am working on PayUMoney payment gateway. I have integrated it successfully. Now before undergoing through audit process by PayUMoney suddenly they told me that I have to integrate transaction status API on my portal. They have provided me API for it. I have integrated that also. Following is the code they have provided me.</p>
  
  <pre><code>$key = "gtKFFx";
  $salt = "eCwWELxi";
  $command = "verify_payment";
  $var1 = "NPMM87334121";
  
  //hash formaula
  $hash_str = $key  . '|' . $command . '|' . $var1 . '|' . $salt ;
  $hash = strtolower(hash('sha512', $hash_str));
  $r = array('key' =&gt; $key , 'hash' =&gt;$hash , 'var1' =&gt; $var1, 'command' =&gt; $command);
  $qs= http_build_query($r);
  $wsUrl = "https://test.payu.in/merchant/postservice.php?form=1";
  //$wsUrl = "https://info.payu.in/merchant/postservice?form=1";
  
  $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);
  </code></pre>
  
  <p>Above Code gives me response as follows : </p>
  
  <pre><code>Array
  (
      [status] =&gt; 1
      [msg] =&gt; 1 out of 1 Transactions Fetched Successfully
      [transaction_details] =&gt; Array
          (
              [NPMM87334121] =&gt; Array
                  (
                      [mihpayid] =&gt; 403993715517090502
                      [request_id] =&gt; 
                      [bank_ref_num] =&gt; 
                      [amt] =&gt; 100813.00
                      [transaction_amount] =&gt; 100813.00
                      [txnid] =&gt; TRANS-2011-01-05-11-05-00
                      [additional_charges] =&gt; 0.00
                      [productinfo] =&gt; Test
                      [firstname] =&gt; Test User
                      [bankcode] =&gt; CC
                      [udf1] =&gt; 
                      [udf3] =&gt; 
                      [udf4] =&gt; 
                      [udf5] =&gt; 
                      [field2] =&gt; 
                      [field9] =&gt; FSS0001-Authentication Not Available
                      [error_code] =&gt; E500
                      [payment_source] =&gt; payu
                      [card_type] =&gt; VISA
                      [error_Message] =&gt; Bank failed to authenticate the customer
                      [net_amount_debit] =&gt; 0.00
                      [disc] =&gt; 0.00
                      [mode] =&gt; CC
                      [PG_TYPE] =&gt; HDFCPG
                      [card_no] =&gt; 411111XXXXXX1111
                      [name_on_card] =&gt; Demo
                      [udf2] =&gt; 
                      [addedon] =&gt; 2018-01-05 11:21:36
                      [status] =&gt; failure
                      [unmappedstatus] =&gt; failed
                      [Merchant_UTR] =&gt; 
                      [Settled_At] =&gt; 
                  )
  
          )
  
  )
  </code></pre>
  
  <p>After this I have written following line to access above response.</p>
  
  <pre><code>$checkout_data = $o['transaction_details'][$var1];
  </code></pre>
  
  <p>But after this line it gives me following error.</p>
  
  <pre><code>Message: Illegal string offset 'transaction_details'
  Message: Illegal string offset 'NPMM87334121'
  </code></pre>
  
  <p>I don't understand where I am doing the mistake. The response given by payu is in array so if I am accessing it as array, Still why it gives me error. </p>