【发布时间】:2016-08-30 17:51:35
【问题描述】:
我正在使用 authorize.net 网站上的 php 示例,但无法使其正常工作。我已经下载了所有供应商软件并更新了作曲家。
在phplog中我不断收到同样的错误:
<code>E00045</code>
<text>The root node does not reference a valid XML namespace.</text>
</message></messages></ErrorResponse>
更新作曲家后不再记录错误。
我的 php:
要求(“anetsdkphp/autoload.php”); $logName = "MYAUTHKEY"; $transKey = "MYTRANSKEY"; 使用 net\authorize\api\contract\v1 作为 AnetAPI; 使用 net\authorize\api\controller 作为 AnetController; 定义(“AUTHORIZENET_LOG_FILE”,“phplog”); 函数chargeCreditCard($amount){ // API 凭证的通用设置 $merchantAuthentication = new AnetAPI\MerchantAuthenticationType(); $merchantAuthentication->setName($logName); $merchantAuthentication->setTransactionKey($transKey); $refId = 'ref' 。时间(); // 创建信用卡的支付数据 $creditCard = new AnetAPI\CreditCardType(); $creditCard->setCardNumber(4111111111111111); $creditCard->setExpirationDate(1238); $paymentOne = 新 AnetAPI\PaymentType(); $paymentOne->setCreditCard($creditCard); //创建一个事务 $transactionRequestType = new AnetAPI\TransactionRequestType(); $transactionRequestType->setTransactionType("authCaptureTransaction"); $transactionRequestType->setAmount($amount); $transactionRequestType->setPayment($paymentOne); $request = new AnetAPI\CreateTransactionRequest(); $request->setMerchantAuthentication($merchantAuthentication); $request->setRefId($refId); $request->setTransactionRequest($transactionRequestType); $controller = new AnetController\CreateTransactionController($request); $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX); #$result = str_replace('xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"', '', $结果); if ($response != null) { $tresponse = $response->getTransactionResponse(); if (($tresponse != null) && ($tresponse->getResponseCode()=="1") ) { echo "充值信用卡授权码:"。 $tresponse->getAuthCode() 。 "\n"; echo "充值信用卡 TRANS ID:"。 $tresponse->getTransId() 。 "\n"; 回声 $tresponse->getResponseCode(); } 别的 { echo "信用卡充值错误:无效响应\n"; var_dump("$tresponse"); } } 别的 { echo "充值信用卡返回空响应"; } } ChargeCreditCard(55.00);回复:
Charge Credit Card ERROR : Invalid response(0)更新作曲家后的响应:
Charge Credit Card ERROR : Invalid response
提前非常感谢!
【问题讨论】:
标签: php xml credit-card authorize.net