php - 在测试模式下集成 PayUMoney 支付网关时出现“抱歉出现错误”

标签 php integration payment-gateway payu payumoney

我正在尝试将 PayUMoney 支付网关集成到我的客户站点中。我的客户向我提供了 PayUMoney 的登录详细信息。我能够找到Merchant Key,但找不到两者中的任何一个:

  1. 商业盐
  2. 开发者网站,我可以在其中创建测试帐户并在沙盒上进行测试

PayUMoney 为我提供了一个带有一些默认值的表单,但是当我测试时,它给出了消息:抱歉发生了一些错误。

这是表格:

<?php
// Merchant key here as provided by Payu
$MERCHANT_KEY = "JBZaLc";

// Merchant Salt as provided by Payu
$SALT = "GQs7yium";

// End point - change to https://secure.payu.in for LIVE mode
$PAYU_BASE_URL = "https://test.payu.in";

$action = '';

$posted = array();
if(!empty($_POST)) {
//print_r($_POST);
foreach($_POST as $key => $value) {    
$posted[$key] = $value; 

}
}

$formError = 0;

if(empty($posted['txnid'])) {
// Generate random transaction id
$txnid = substr(hash('sha256', mt_rand() . microtime()), 0, 20);
} else {
$txnid = $posted['txnid'];
}
$hash = '';
// Hash Sequence
$hashSequence =     "key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5|udf6|udf7|udf8|udf9|udf10";
if(empty($posted['hash']) && sizeof($posted) > 0) {
if(
      empty($posted['key'])
      || empty($posted['txnid'])
      || empty($posted['amount'])
      || empty($posted['firstname'])
      || empty($posted['email'])
      || empty($posted['phone'])
      || empty($posted['productinfo'])
      || empty($posted['surl'])
      || empty($posted['furl'])
      || empty($posted['service_provider'])
) {
$formError = 1;
} else {
//$posted['productinfo'] = json_encode(json_decode('[{"name":"tutionfee","description":"","value":"500","isRequired":"false"},{"name":"developmentfee","description":"monthly tution     fee","value":"1500","isRequired":"false"}]'));
$hashVarsSeq = explode('|', $hashSequence);
$hash_string = '';  
foreach($hashVarsSeq as $hash_var) {
  $hash_string .= isset($posted[$hash_var]) ? $posted[$hash_var] : '';
  $hash_string .= '|';
}

$hash_string .= $SALT;


$hash = strtolower(hash('sha512', $hash_string));
$action = $PAYU_BASE_URL . '/_payment';
}
} elseif(!empty($posted['hash'])) {
$hash = $posted['hash'];
$action = $PAYU_BASE_URL . '/_payment';
}
?>
<html>
<head>
<script>
var hash = '<?php echo $hash ?>';
function submitPayuForm() {
  if(hash == '') {
    return;
  }
  var payuForm = document.forms.payuForm;
  payuForm.submit();
}
</script>
</head>
<body onLoad="submitPayuForm()">
<h2>PayU Form</h2>
<br/>
<?php if($formError) { ?>
  <span style="color:red">Please fill all mandatory fields.</span>
  <br/>
  <br/>
<?php } ?>
<form action="<?php echo $action; ?>" method="post" name="payuForm">
  <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 ?>" />
  <table>
    <tr>
      <td><b>Mandatory Parameters</b></td>
    </tr>
    <tr>
      <td>Amount: </td>
      <td><input name="amount" value="<?php echo (empty($posted['amount'])) ? '' : $posted['amount'] ?>" /></td>
      <td>First Name: </td>
      <td><input name="firstname" id="firstname" value="<?php echo (empty($posted['firstname'])) ? '' : $posted['firstname']; ?>" /></td>
    </tr>
    <tr>
      <td>Email: </td>
      <td><input name="email" id="email" value="<?php echo (empty($posted['email'])) ? '' : $posted['email']; ?>" /></td>
      <td>Phone: </td>
      <td><input name="phone" value="<?php echo (empty($posted['phone'])) ? '' : $posted['phone']; ?>" /></td>
    </tr>
    <tr>
      <td>Product Info: </td>
      <td colspan="3"><textarea name="productinfo"><?php echo (empty($posted['productinfo'])) ? '' : $posted['productinfo'] ?></textarea></td>
    </tr>
    <tr>
      <td>Success URI: </td>
      <td colspan="3"><input name="surl" value="<?php echo (empty($posted['surl'])) ? '' : $posted['surl'] ?>" size="64" /></td>
    </tr>
    <tr>
      <td>Failure URI: </td>
      <td colspan="3"><input name="furl" value="<?php echo (empty($posted['furl'])) ?     '' : $posted['furl'] ?>" size="64" /></td>
    </tr>

    <tr>
      <td>Service Provider: </td>
      <td colspan="3"><input name="service_provider" value="<?php echo (empty($posted['service_provider'])) ? '' : $posted['service_provider'] ?>" size="64" /></td>
    </tr>

    <tr>
      <td><b>Optional Parameters</b></td>
    </tr>
    <tr>
      <td>Last Name: </td>
      <td><input name="lastname" id="lastname" value="<?php echo (empty($posted['lastname'])) ? '' : $posted['lastname']; ?>" /></td>
      <td>Cancel URI: </td>
      <td><input name="curl" value="" /></td>
    </tr>
    <tr>
      <td>Address1: </td>
      <td><input name="address1" value="<?php echo (empty($posted['address1'])) ? '' : $posted['address1']; ?>" /></td>
      <td>Address2: </td>
      <td><input name="address2" value="<?php echo (empty($posted['address2'])) ? '' : $posted['address2']; ?>" /></td>
    </tr>
    <tr>
      <td>City: </td>
      <td><input name="city" value="<?php echo (empty($posted['city'])) ? '' : $posted['city']; ?>" /></td>
      <td>State: </td>
      <td><input name="state" value="<?php echo (empty($posted['state'])) ? '' : $posted['state']; ?>" /></td>
    </tr>
    <tr>
      <td>Country: </td>
      <td><input name="country" value="<?php echo (empty($posted['country'])) ? '' : $posted['country']; ?>" /></td>
      <td>Zipcode: </td>
      <td><input name="zipcode" value="<?php echo (empty($posted['zipcode'])) ? '' : $posted['zipcode']; ?>" /></td>
    </tr>
    <tr>
      <td>UDF1: </td>
      <td><input name="udf1" value="<?php echo (empty($posted['udf1'])) ? '' : $posted['udf1']; ?>" /></td>
      <td>UDF2: </td>
      <td><input name="udf2" value="<?php echo (empty($posted['udf2'])) ? '' : $posted['udf2']; ?>" /></td>
    </tr>
    <tr>
      <td>UDF3: </td>
      <td><input name="udf3" value="<?php echo (empty($posted['udf3'])) ? '' : $posted['udf3']; ?>" /></td>
      <td>UDF4: </td>
      <td><input name="udf4" value="<?php echo (empty($posted['udf4'])) ? '' : $posted['udf4']; ?>" /></td>
    </tr>
    <tr>
      <td>UDF5: </td>
      <td><input name="udf5" value="<?php echo (empty($posted['udf5'])) ? '' : $posted['udf5']; ?>" /></td>
      <td>PG: </td>
      <td><input name="pg" value="<?php echo (empty($posted['pg'])) ? '' : $posted['pg']; ?>" /></td>
    </tr>
    <tr>
      <?php if(!$hash) { ?>
        <td colspan="4"><input type="submit" value="Submit" /></td>
      <?php } ?>
    </tr>
  </table>
</form>
</body>
</html>

最佳答案

这让初学者感到困惑。提供的默认 keysalt 不会立即起作用。

为了使用测试 key 和盐来测试网关,请按照以下步骤操作:

  1. Go on test.payumoney.com
  2. Sign up as a merchant - use any of your valid email ids - kindly do not use a random email id.
  3. Complete the "Business Details" - you may use PAN no. ABCDE1234F and DOB - 01/04/1990
  4. Complete "Bank Account Details" (You may use IFSC- ALLA0212632)
  5. You dont have to worry about Bank verification step or any other step after that.
  6. Go to below mentioned location to get the Test Merchant Id : Seller Dashboard -> Settings -> My account -> Profile Settings

  7. After that send your test merchant id to technical team using contact us form and they will approve.

  8. Once approved you can find your test key and salt at : Seller Dashboard -> Settings -> My account -> Merchant Key - Salt.
  9. Replace default key and salt with newly generated test key and salt. After this you should not see error, Sorry, Some Problem Occurred.

希望对您有所帮助。

关于php - 在测试模式下集成 PayUMoney 支付网关时出现“抱歉出现错误”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23773892/

相关文章:

android - 如何只允许借记卡用于谷歌钱包集成 Android

php - 如果找到某个字符串则返回 true 或 false

php - 使用 php 进行 Mysql 日期时间输入

asp.net - 用于 ASP.Net(也许是 MVC)网站的博客引擎

security - Apple Pay token transactionId 是否全局唯一?

android - 如何在 authorize.net sdk for android 中传递 api 登录 key 和交易 ID?

php文件不输出结果

php - 在上传 PHP 之前调整图像大小

python - 这段在 python 中求解积分方程的代码有什么问题

C++ 库集成到 iPhone 应用程序