我正在使用John Conde为Authorize.Net制作的AuthnetXML课程。我正在尝试使用profileID
为用户创建paymentprofileid
和createCustomerProfileRequest
,然后如果已创建,则将新创建的customerprofileid
和customerpaymentprofileid
应用于{ {1}}并尝试通过进行交易。
当它第一次通过时创建了帐户但是页面变成了白色,就像有什么东西坏了一样,然后我点击 f5 来推进它,它会很好。它的构建方式是,如果用户已经拥有ID,我将绕过第一部分。 (创建配置文件)我觉得它不会让我一个接一个地调用api,或者帐户需要一分钟才能在服务器上传播?
有没有人遇到过这样的事情?
答案 0 :(得分:3)
我见过这样的事。我掀起了一个例子,或多或少地做了你正在尝试做的事情,并没有遇到任何问题,所以我在这里发帖给你比较你的代码。希望它对你有所帮助:
<?php
require('../../config.inc.php');
require('../../AuthnetXML.class.php');
$xml = new AuthnetXML(AUTHNET_LOGIN, AUTHNET_TRANSKEY, AuthnetXML::USE_DEVELOPMENT_SERVER);
$xml->createCustomerProfileRequest(array(
'profile' => array(
'merchantCustomerId' => '87658',
'email' => 'user@example.com',
'paymentProfiles' => array(
'billTo' => array(
'firstName' => 'John',
'lastName' => 'Smith',
'address' => '123 Main Street',
'city' => 'Townsville',
'state' => 'NJ',
'zip' => '12345',
'phoneNumber' => '800-555-1234'
),
'payment' => array(
'creditCard' => array(
'cardNumber' => '4111111111111111',
'expirationDate' => '2016-08',
),
),
),
'shipToList' => array(
'firstName' => 'John',
'lastName' => 'Smith',
'address' => '123 Main Street',
'city' => 'Townsville',
'state' => 'NJ',
'zip' => '12345',
'phoneNumber' => '800-555-1234'
),
),
'validationMode' => 'liveMode'
));
$profile_id = $xml->customerProfileId;
$payment_profile_id = $xml->customerPaymentProfileIdList->numericString;
$shipping_profile_id = $xml->customerShippingAddressIdList->numericString;
$xml = new AuthnetXML(AUTHNET_LOGIN, AUTHNET_TRANSKEY, AuthnetXML::USE_DEVELOPMENT_SERVER);
$xml->createCustomerProfileTransactionRequest(array(
'transaction' => array(
'profileTransAuthCapture' => array(
'amount' => '10.95',
'customerProfileId' => $profile_id,
'customerPaymentProfileId' => $payment_profile_id,
'customerShippingAddressId' => $shipping_profile_id,
'order' => array(
'invoiceNumber' => 'INV000001',
'description' => 'description of transaction',
'purchaseOrderNumber' => 'PONUM000001'
),
'taxExempt' => 'false',
'recurringBilling' => 'false',
'cardCode' => '000'
)
),
'extraOptions' => '<![CDATA[x_customer_ip=100.0.0.1]]>'
));
echo $xml;
?>
这里是来回发送的XML:
<强> createCustomerProfileRequest 强>
<?xml version="1.0"?>
<createCustomerProfileRequest>
<merchantAuthentication>
<name>cnpdev4289</name>
<transactionKey>SR2P8g4jdEn7vFLQ</transactionKey>
</merchantAuthentication>
<profile>
<merchantCustomerId>87658</merchantCustomerId>
<email>user@example.com</email>
<paymentProfiles>
<billTo>
<firstName>John</firstName>
<lastName>Smith</lastName>
<address>123 Main Street</address>
<city>Townsville</city>
<state>NJ</state>
<zip>12345</zip>
<phoneNumber>800-555-1234</phoneNumber>
</billTo>
<payment>
<creditCard>
<cardNumber>4111111111111111</cardNumber>
<expirationDate>2016-08</expirationDate>
</creditCard>
</payment>
</paymentProfiles>
<shipToList>
<firstName>John</firstName>
<lastName>Smith</lastName>
<address>123 Main Street</address>
<city>Townsville</city>
<state>NJ</state>
<zip>12345</zip>
<phoneNumber>800-555-1234</phoneNumber>
</shipToList>
</profile>
<validationMode>liveMode</validationMode>
</createCustomerProfileRequest>
<?xml version="1.0" encoding="utf-8"?>
<createCustomerProfileResponse>
<messages>
<resultCode>Ok</resultCode>
<message>
<code>I00001</code>
<text>Successful.</text>
</message>
</messages>
<customerProfileId>11234435</customerProfileId>
<customerPaymentProfileIdList>
<numericString>10232106</numericString>
</customerPaymentProfileIdList>
<customerShippingAddressIdList>
<numericString>10454653</numericString>
</customerShippingAddressIdList>
<validationDirectResponseList>
<string>1,1,1,This transaction has been approved.,0ZSYP6,Y,2180917446,none,Test transaction for ValidateCustomerPaymentProfile.,0.00,CC,auth_only,87658,John,Smith,,123 Main Street,Townsville,NJ,12345,,800-555-1234,,user@example.com,,,,,,,,,0.00,0.00,0.00,FALSE,none,CE4F0E75B0703C40FE109A7B0B2E0575,,2,,,,,,,,,,,XXXX1111,Visa,,,,,,,,,,,,,,,,</string>
</validationDirectResponseList>
</createCustomerProfileResponse>
<强> createCustomerProfileTransactionRequest 强>
<?xml version="1.0"?>
<createCustomerProfileTransactionRequest>
<merchantAuthentication>
<name>cnpdev4289</name>
<transactionKey>SR2P8g4jdEn7vFLQ</transactionKey>
</merchantAuthentication>
<transaction>
<profileTransAuthCapture>
<amount>10.95</amount>
<customerProfileId>11234435</customerProfileId>
<customerPaymentProfileId>10232106</customerPaymentProfileId>
<customerShippingAddressId>10454653</customerShippingAddressId>
<order>
<invoiceNumber>INV000001</invoiceNumber>
<description>description of transaction</description>
<purchaseOrderNumber>PONUM000001</purchaseOrderNumber>
</order>
<taxExempt>false</taxExempt>
<recurringBilling>false</recurringBilling>
<cardCode>000</cardCode>
</profileTransAuthCapture>
</transaction>
<extraOptions><![CDATA[x_customer_ip=100.0.0.1]]></extraOptions>
</createCustomerProfileTransactionRequest>
<?xml version="1.0" encoding="utf-8"?>
<createCustomerProfileTransactionResponse>
<messages>
<resultCode>Ok</resultCode>
<message>
<code>I00001</code>
<text>Successful.</text>
</message>
</messages>
<directResponse>1,1,1,This transaction has been approved.,S6HDI6,Y,2180917449,INV000001,description of transaction,10.95,CC,auth_capture,87658,John,Smith,,123 Main Street,Townsville,NJ,12345,,800-555-1234,,user@example.com,John,Smith,,123 Main Street,Townsville,NJ,12345,,,,,FALSE,PONUM000001,F0FA82F73AA206A4D7D956E98AF97725,P,2,,,,,,,,,,,XXXX1111,Visa,,,,,,,,,,,,,,,,,10454653,100.0.0.1]]></directResponse>
</createCustomerProfileTransactionResponse>