如何将order_id和其他订单详细信息传递到Payumoney成功页面

时间:2019-04-25 06:26:32

标签: php payumoney payment-integration

我正在将Payumoney付款集成到我的网站中。付款集成成功,但是我需要将订单ID放入我的订单成功页面。 我从表单中发布了order_id,并尝试从订单成功页面获取它,但是它返回校验和错误消息。

Profile.php

<?php  
define('MERCHANT_KEY', 'xxxxxx');
define('SALT', 'yyyyyyy');
define('PAYU_BASE_URL', 'https://sandboxsecure.payu.in');    //Testing url 
Use in development mode
//define('PAYU_BASE_URL', 'https://secure.payu.in');  //actual URL Use in 
production mode
define('SUCCESS_URL', $baseurl.'/order-success.php');  //order sucess url 
replace with your complete url
define('FAIL_URL', $baseurl.'/order-fail.php');    //add complete url 
$txnid = substr(hash('sha256', mt_rand() . microtime()), 0, 20);
$email = $email;
$mobile = $mobile;
$firstName = $name;;
$lastName =  $surname;;
$totalCost = '1';
$order_id = $rowcart['cartid'];
$hash         = '';
$hash_string = MERCHANT_KEY."|".$txnid."|".$totalCost."|"."productinfo|".$firstName."|".$email."|||||||||||".SALT;
$hash = strtolower(hash('sha512', $hash_string));
$action = PAYU_BASE_URL . '/_payment'; 

?>
<form action="<?php echo $action; ?>" method="post" name="payuForm" id="payuForm" style="display: none">
    <input type="hidden" name="key" value="<?php echo MERCHANT_KEY ?>" />
     <input type="hidden" name="hash" value="<?php echo $hash ?>"/>
    <input type="hidden" name="txnid" value="<?php echo $txnid ?>" />
    <input name="amount" type="number" value="<?php echo $totalCost; ?>" />
    <input type="text" name="firstname" id="firstname" value="<?php echo $firstName; ?>" />
    <input type="email" name="email" id="email" value="<?php echo $email; ?>" />
    <input type="text" name="phone" value="<?php echo $mobile; ?>" />
    <textarea name="productinfo"><?php echo "productinfo"; ?></textarea>
    <input type="text" name="surl" value="<?php echo SUCCESS_URL; ?>" />
    <input type="text" name="furl" value="<?php echo  FAIL_URL?>"/>
    <input type="text" name="service_provider" value="payu_paisa"/>
    <input type="text" name="lastname" id="lastname" value="<?php echo $lastName ?>" />
     <input type="text" name="orderid" id="orderid" value="<?php echo $order_id ?>" />


 </form>
<script type="text/javascript">
    function submitForm(){
        var payuForm = document.forms.payuForm;
     payuForm.submit();
   }

</script>

Payment-success.php

   <?php

   $status = $_POST["status"];
$firstname = $_POST["firstname"];
  $amount = $_POST["amount"];
  $txnid = $_POST["txnid"];
 $posted_hash = $_POST["hash"];
  $key = $_POST["key"];
  $productinfo = $_POST["productinfo"];
 $email = $_POST["email"];
 $salt = "IYdC2b1qIb";
  $order_id = $_POST["orderid"];

  If (isset($_POST["additionalCharges"])) {
   $additionalCharges = $_POST["additionalCharges"];
   $retHashSeq = $additionalCharges . '|' . $salt . '|' . $status . '|||||||||||' . $email . '|' . $firstname . '|' . $productinfo . '|' . $amount . '|' . $txnid . '|' . $key;
} else {

    $retHashSeq = $salt . '|' . $status . '|||||||||||' . $email . '|' . $firstname . '|' . $productinfo . '|' . $amount . '|' . $txnid . '|' . $key;
  }
  $hash = hash("sha512", $retHashSeq);

  if ($hash != $posted_hash) {
     echo "Invalid Transaction. Please try again";
  } 

我需要在payment-success.php获取订单ID。有什么办法吗? 预先感谢

1 个答案:

答案 0 :(得分:0)

我已经阅读了Payu money api文档,并发现了这一点。您可以将order_id传递给udf1或udf2字段,因为它是用户定义的字段,因此您可以在其中设置order_id并在Response上获取它。

Payumoney APi Doc