3

我已经在我的 magento 安装中实现了 MIGS 支付服务,它使用的是 vpc_php_serverhost_do.php。这些是我传递给该文件的值

<input type="hidden" name="virtualPaymentClientURL" size="63" value="https://migs.mastercard.com.au/vpcpay" maxlength="250">
<input type="hidden" name="vpc_Version" value="1" size="20" maxlength="8">
<input type="hidden" name="vpc_Command" value="pay" size="20" maxlength="16">
<input type="hidden" name="vpc_MerchTxnRef" value="<?php echo $orderId; ?>" size="20" maxlength="40">
<input type="hidden" name="vpc_AccessCode" value="<?php echo $access_code; ?>" size="20" maxlength="8">
<input type="hidden" name="vpc_Merchant" value="<?php echo $merchant; ?>" size="20" maxlength="16">
<input type="hidden" name="vpc_OrderInfo" value="<?php echo $orderId; ?>" size="20" maxlength="34">  
<input type="hidden" name="vpc_Amount" value="<?php echo $amountInFils; ?>" size="20" maxlength="10">  
<input type="hidden" name="vpc_Locale" value="en" size="20" maxlength="5">
<input type="hidden" name="vpc_ReturnURL" size="63" value="<?php echo $url;?>" maxlength="350">
<input type="hidden" name="vpc_user_SessionId" size="63" value="<?php echo $sessionId;?>" maxlength="350">

我已经提供了客户端提供的安全机密,其余代码如下所示

$vpcURL = $_POST["virtualPaymentClientURL"] . "?";

unset($_POST["virtualPaymentClientURL"]); 
unset($_POST["SubButL"]);

$md5HashData = $SECURE_SECRET;
ksort ($_POST);

$appendAmp = 0;

foreach($_POST as $key => $value) {
    if (strlen($value) > 0) {
        if ($appendAmp == 0) {
            $vpcURL .= urlencode($key) . '=' . urlencode($value);
            $appendAmp = 1;
        } else {
            $vpcURL .= '&' . urlencode($key) . "=" . urlencode($value);
        }
        $md5HashData .= $value;
    }
}

if (strlen($SECURE_SECRET) > 0) {
    $vpcURL .= "&vpc_SecureHash=" . strtoupper(md5($md5HashData));
}

header("Location: ".$vpcURL);

它正在重定向到应有的支付网关。问题是我在付款后得到的响应没有编码。响应链接是这样的(出于安全原因,我用 x 更改了数字)

https://xxxxxx/site_test/vpc_php_serverhost_dr.php?vpc_Amount=xx&vpc_BatchNo=x&vpc_Command=pay&vpc_Locale=en&vpc_MerchTxnRef=xxxxx&vpc_Merchant=xxxxx&vpc_Message=Cancelled&vpc_OrderInfo=xxxxx&vpc_SecureHash=xxxxxxxx&vpc_TransactionNo=x&vpc_TxnResponseCode=C&vpc_Version=xx

我应该怎么做才能使响应网址编码?

4

1 回答 1

0

您是否尝试过使用:

<?php
$query_string = 'foo=' . urlencode($foo) . '&bar=' . urlencode($bar);
echo '<a href="mycgi?' . htmlentities($query_string) . '">';
?>

http://php.net/manual/en/function.urlencode.php

于 2014-09-23T20:50:02.887 回答