我需要从表单中获取支付信息并将其放在 XML 中,然后将其发布到支付网关服务器。我充其量只是一个新手,我不确定最简单的方法。
我已经能够通过手动将信息输入到静态 php 文件的 XML 中成功地发布到支付网关,所以我知道 XML 是正确的,对我来说唯一真正的问题是找到获取表单数据的最简单方法和放入 XML 中。
下面是 php 文件和 XML 的示例。
<?php
$TransactionId = intval( date(Yms). rand(1,9) . rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9). rand(0,9) );
$MerchantId="111111";
$TerminalId="111111";
$ApiPassword="111111";
$private_key="asdfasghgfdhggdfgs";
$ApiPassword_encrypt=hash('sha256',$ApiPassword);
$xmlReq='<?xml version="1.0" encoding="UTF-8" ?>
<TransactionRequest xmlns="https://test.processing.com/securePayments/direct/v1/processor.php">
<Language>ENG</Language>
<Credentials>
<MerchantId>'.$MerchantId.'</MerchantId>
<TerminalId>'.$TerminalId.'</TerminalId>
<TerminalPassword>'.$ApiPassword_encrypt.'</TerminalPassword>
</Credentials>
<TransactionType>LP001</TransactionType>
<TransactionId>'.$TransactionId.'</TransactionId>
<ReturnUrl page="http://www.website.net/response.php">
<Param>
<Key>inv</Key>
<Value>'.$TransactionId.'</Value>
</Param>
</ReturnUrl>
<CurrencyCode>USD</CurrencyCode>
<TotalAmount>44450</TotalAmount>
<CardDetails>
<CardHolderName>John Smith</CardHolderName>
<CardNumber>4653111111111111</CardNumber>
<CardExpireMonth>01</CardExpireMonth>
<CardExpireYear>15</CardExpireYear>
<CardType>VI</CardType>
<CardSecurityCode>030</CardSecurityCode>
<CardIssuingBank>UNKNOWN</CardIssuingBank>
<CardIssueNumber></CardIssueNumber>
</CardDetails>
</TransactionRequest>';
$signature_key=trim($private_key.$ApiPassword.$TransactionId);
$signature=base64_encode(hash_hmac("sha256", trim($xmlReq), $signature_key, True));
$encodedMessage=base64_encode($xmlReq);