PHP:授权.使用XML AIM时出现网络错误


PHP: Authorize.Net error while using XML AIM

我最近几天在Authorize.net处理方面很吃力。

我正在使用测试模式和测试卡详细信息。

我收到错误:E0007-由于身份验证值无效,用户身份验证失败

这是我正在使用的代码。

$content =
        "<?xml version='"1.0'" encoding='"utf-8'"?>" .
        "<createCustomerPaymentProfileRequest xmlns='"AnetApi/xml/v1/schema/AnetApiSchema.xsd'">" .
        "<merchantAuthentication>".
        "<name>" . $this->g_loginname . "</name>".
        "<transactionKey>" . $this->g_transactionkey . "</transactionKey>".
        "</merchantAuthentication>".
        "<customerProfileId>" . $cid . "</customerProfileId>".
        "<paymentProfile>".
        "<customerType>individual</customerType>".
        "<billTo>".
         "<firstName>".$vars['fname']."</firstName>".
         "<lastName>".$vars['lname']."</lastName>".
         "<company>".$vars['company']."</company>".
         "<address>".$vars['baddress']."</address>".
         "<city>".$vars['bcity']."</city>".
   "<state>".$vars['bstate']."</state>".
     "<zip>".$vars['bzip']."</zip>".
     "<country>USA</country>".
         "<phoneNumber>".$vars['phone']."</phoneNumber>".
        "</billTo>".
        "<payment>".
         "<creditCard>".
          "<cardNumber>".$vars['ccno']."</cardNumber>".
          "<expirationDate>20".$exp_date[1].'-'.$exp_date[0]."</expirationDate>". // required format for API is YYYY-MM
          "<cardCode>".$vars['ccv']."</cardCode>".
         "</creditCard>".
        "</payment>".
        "</paymentProfile>".
        "<validationMode>testMode</validationMode>". // or testMode
        "</createCustomerPaymentProfileRequest>";

这是解析XML后的最终发布内容。

<?xml version="1.0" encoding="utf-8"?>
   <createCustomerPaymentProfileRequest           xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
 <merchantAuthentication>
  <name>5EmThCM9ba6w</name>
  <transactionKey>29EFx88Vw9m3c73k</transactionKey>
</merchantAuthentication>
<customerProfileId>1000</customerProfileId>
<paymentProfile>
<customerType>individual</customerType>
<billTo>
  <firstName>sasa</firstName>
  <lastName> dfsdfsd</lastName>
  <company>Software</company>
  <address>sasa</address>
  <city>sa</city>
  <state>AZ</state>
  <zip>23223</zip>
  <country>USA</country>
  <phoneNumber>323-232-2323</phoneNumber>
</billTo>
<payment>
  <creditCard><cardNumber>4012888888881881</cardNumber>
    <expirationDate>2017-12</expirationDate>
    <cardCode>232</cardCode>
  </creditCard>
</payment>
</paymentProfile>
<validationMode>testMode</validationMode>

这就是我得到的XML。我正在测试模式下使用测试卡详细信息。我无法理解我是如何获得错误的用户凭据错误消息的。请检查XML一次。

终于拿到了。我在主机Url方面犯了一个错误。我使用了api.authorized.net。实际上,我们应该使用apitest.authorification.net为测试帐户。