我正在尝试使用Intuit的QBMS在网站上建立信用卡界面,并且我已根据Intuit文档中的规范设置了XML请求。我还设置了AppID,连接票和应用程序登录。但是当我进行测试时,我收到以下错误:
SAX解析器返回的未知错误。来自其他包的异常:java.lang.StringIndexOutOfBoundsException:字符串索引超出范围:-1
这是XML请求:
$productionUrl = 'https://merchantaccount.quickbooks.com/j/AppGateway';
$connectionTicket = 'SDK-xxx-xxx-xxxxxxxxxxxxxxxxxxxxxxxx';
$applicationLogin = 'qbms.site.com';
$appID = "111111111";
$xml = rawurlencode('<?xml version="1.0"?>
<?qbmsxml version="4.1"?>
<QBMSXML>
<SignonMsgsRq>
<SignonDesktopRq>
<ClientDateTime>' . date('Y-m-d\TH:i:s') . '</ClientDateTime>
<ApplicationLogin>' . $applicationLogin . '</ApplicationLogin>
<ConnectionTicket>' . $connectionTicket . '</ConnectionTicket>
<Language>English</Language>
<AppID>' . $appID . '</AppID>
<AppVer>1.0</AppVer>
</SignonDesktopRq>
</SignonMsgsRq>
<QBMSXMLMsgsRq>
<CustomerCreditCardChargeRq>
<TransRequestID>' . $_transId . '</TransRequestID>
<CreditCardNumber>' . $_cc_number . '</CreditCardNumber>
<ExpirationMonth>' . $_cc_exp_month . '</ExpirationMonth>
<ExpirationYear>' . $_cc_exp_year . '</ExpirationYear>
<IsCardPresent>false</IsCardPresent>
<Amount>' . $_amount . '</Amount>
<NameOnCard>' . $_cc_name . '</NameOnCard>
<CreditCardAddress>' . $_cc_address . '</CreditCardAddress>
<CreditCardPostalCode>' . $_cc_zip . '</CreditCardPostalCode>
<SalesTaxAmount>' . $_tax . '</SalesTaxAmount>
</CustomerCreditCardChargeRq>
</QBMSXMLMsgsRq>
</QBMSXML>');
$header[] = "Content-type: application/x-qbmsxml";
$header[] = "Content-length: " . strlen($xml);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_URL, $productionUrl);
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
$response = curl_exec($ch);
curl_close($ch);
print_r($response);
答案 0 :(得分:0)
由于文档仍然不可用,特别是https://developer.intuit.com/qbsdk-current/Common/newOSR/index.html
这是基于我测试的推测。检查<TransRequestID>
包含一个数字,仅包含前导或后续的字母字符(如果有)。
响应包含此xml:<TxnAuthorizationStamp>
这是你的TransRequestID加1。我想如果它无法弄清楚如何增加它将会失败。
请更新您的所有进度。
答案 1 :(得分:0)
我知道这是一个老问题,但我遇到了类似的问题,并且能够让它运转起来。
当我从请求xml包中删除此短语时:
<?xml version="1.0"?>
SAX解析器错误消失了,它可以正常工作。