realex显示缺少强制字段:[/ request / sha1hash]。错误信息

时间:2017-10-25 05:36:16

标签: php realex-payments-api

这是我在DCC中使用的完整源代码,我将商品和帐户替换为实际值

  

$ merchantid =" merchantid&#34 ;; $ secret =" secret&#34 ;; $ account =' 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();

它返回我&#34; 320发生内部错误。&#34;信息 我不确定我做错了什么我想添加DCC设施。

1 个答案:

答案 0 :(得分: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付款