0

这是我与 DCC 一起使用的完整源代码,我用实际值替换了 Mercerid 和 account

$merchantid = "商人"; $secret = "秘密"; $account = '帐户';

这就是我创建哈希的方式

$tmp = "$timestamp.$merchantid.$orderid.$amountinCents.$currency.$cardnumber";
$md5hash = md5($tmp);
$tmp = "$md5hash.$secret";
$md5hash = md5($tmp);

下面是xml发送代码

$xml = "<request type='auth' timestamp='$timestamp'>
    <merchantid>$merchantid</merchantid>
    <account>$account</account>
    <orderid>$orderid</orderid>
    <amount currency='$currency'>$amountinCents</amount>
    <DCC_ENABLE>1</DCC_ENABLE>
    <card> 
        <number>$cardnumber</number>
        <expdate>$expdate</expdate>
        <type>$cardtype</type> 
        <chname>$cardname</chname>
        <cvn> 
            <number>$cvvno</number> 
            <presind>1</presind> 
        </cvn>
    </card> 
    <dccinfo>
        <ccp>euroconex</ccp>
        <type>1</type>
        <ratetype>S</ratetype>
        <amount currency='$currency'>$amountinCents</amount>
    </dccinfo>
    <autosettle flag='1'/>
    <md5hash>$md5hash</md5hash>
    <tssinfo>
        <address type=\"billing\">
            <country>ie</country>
        </address>
    </tssinfo>
</request>";

// Send the request array to Realex Payments
$ch = curl_init();    
curl_setopt($ch, CURLOPT_URL, "https://api.sandbox.realexpayments.com/epage-remote.cgi");
curl_setopt($ch, CURLOPT_POST, 1); 
curl_setopt($ch, CURLOPT_USERAGENT, "payandshop.com php version 0.9"); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); //This should always be set to 'TRUE' when in production to ensure the SSL is enabled.
$response = curl_exec ($ch);     
curl_close ($ch);
$parseXML = simplexml_load_string($response);
echo "<pre>";print_r($parseXML);die();

它返回“320 发生内部错误”。消息我不确定我做错了什么我想添加 DCC 设施。

4

1 回答 1

0

谢谢你的问题。首先,我强烈建议您使用 SHA1 算法而不是 MD5 来散列交易详细信息。

其次,您没有发布您的请求 XML,但它必须遵守以下格式:

<?xml version='1.0' encoding='UTF-8'?>
<request type='auth' timestamp='20171025141809'>
<merchantid>Merchant ID</merchantid>
<account>internet</account>
<channel>ECOM</channel>
<orderid>N6qsk4kYRZihmPrTXWYS6g</orderid>
<amount currency='EUR'>1001</amount>
<card>
    <number>4263970000005262</number>
    <expdate>0519</expdate>
    <chname>James Mason</chname>
    <type>VISA</type>
    <cvn>
        <number>123</number>
        <presind>1</presind>
    </cvn>
</card>
<autosettle flag='1'/>
<comments>
    <comment id='1'>Mobile Channel</comment>
    <comment id='2'>Down Payment</comment>
</comments>
<sha1hash>87707637a34ba651b6185718c863abc64b673f20</sha1hash>
</request>

请确保您在请求 XML 中有 sha1hash 元素,并且使用适当的值填充它。

最好的,

肖恩

Realex 支付

于 2017-10-25T13:18:14.157 回答