Вы также можете попробовать использовать AuthnetXML , который легче, чем их SDK, и проще в использовании.Он даже включает пример, который показывает, как добавить несколько позиций:
require('../../config.inc.php');
require('../../AuthnetXML.class.php');
$xml = new AuthnetXML(AUTHNET_LOGIN, AUTHNET_TRANSKEY, AuthnetXML::USE_DEVELOPMENT_SERVER);
$xml->createTransactionRequest(array(
'refId' => rand(1000000, 100000000),
'transactionRequest' => array(
'transactionType' => 'authCaptureTransaction',
'amount' => 5,
'payment' => array(
'creditCard' => array(
'cardNumber' => '4111111111111111',
'expirationDate' => '122016',
'cardCode' => '999',
),
),
'order' => array(
'invoiceNumber' => '1324567890',
'description' => 'this is a test transaction',
),
'lineItems' => array(
'lineItem' => array(
0 => array(
'itemId' => '1',
'name' => 'vase',
'description' => 'Cannes logo',
'quantity' => '18',
'unitPrice' => '45.00'
),
1 => array(
'itemId' => '2',
'name' => 'desk',
'description' => 'Big Desk',
'quantity' => '10',
'unitPrice' => '85.00'
)
)
),
'tax' => array(
'amount' => '4.26',
'name' => 'level2 tax name',
'description' => 'level2 tax',
),
'duty' => array(
'amount' => '8.55',
'name' => 'duty name',
'description' => 'duty description',
),
'shipping' => array(
'amount' => '4.26',
'name' => 'level2 tax name',
'description' => 'level2 tax',
),
'poNumber' => '456654',
'customer' => array(
'id' => '18',
'email' => 'someone@blackhole.tv',
),
'billTo' => array(
'firstName' => 'Ellen',
'lastName' => 'Johnson',
'company' => 'Souveniropolis',
'address' => '14 Main Street',
'city' => 'Pecan Springs',
'state' => 'TX',
'zip' => '44628',
'country' => 'USA',
),
'shipTo' => array(
'firstName' => 'China',
'lastName' => 'Bayles',
'company' => 'Thyme for Tea',
'address' => '12 Main Street',
'city' => 'Pecan Springs',
'state' => 'TX',
'zip' => '44628',
'country' => 'USA',
),
'customerIP' => '192.168.1.1',
'transactionSettings' => array(
'setting' => array(
0 => array(
'settingName' =>'allowPartialAuth',
'settingValue' => 'false'
),
1 => array(
'settingName' => 'duplicateWindow',
'settingValue' => '0'
),
2 => array(
'settingName' => 'emailCustomer',
'settingValue' => 'false'
),
3 => array(
'settingName' => 'recurringBilling',
'settingValue' => 'false'
),
4 => array(
'settingName' => 'testRequest',
'settingValue' => 'false'
)
)
),
'userFields' => array(
'userField' => array(
'name' => 'MerchantDefinedFieldName1',
'value' => 'MerchantDefinedFieldValue1',
),
'userField' => array(
'name' => 'favorite_color',
'value' => 'blue',
),
),
),
));
?>
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<title>AIM :: Authorize and Capture</title>
<style type="text/css">
table
{
border: 1px solid #cccccc;
margin: auto;
border-collapse: collapse;
max-width: 90%;
}
table td
{
padding: 3px 5px;
vertical-align: top;
border-top: 1px solid #cccccc;
}
pre
{
overflow-x: auto; /* Use horizontal scroller if needed; for Firefox 2, not needed in Firefox 3 */
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */ /*
width: 99%; */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
table th
{
background: #e5e5e5;
color: #666666;
}
h1, h2
{
text-align: center;
}
</style>
</head>
<body>
<h1>
AIM :: Authorize and Capture
</h1>
<h2>
Results
</h2>
<table>
<tr>
<th>Response</th>
<td><?php echo $xml->messages->resultCode; ?></td>
</tr>
<tr>
<th>code</th>
<td><?php echo $xml->messages->message->code; ?></td>
</tr>
<tr>
<th>Successful?</th>
<td><?php echo ($xml->isSuccessful()) ? 'yes' : 'no'; ?></td>
</tr>
<tr>
<th>Error?</th>
<td><?php echo ($xml->isError()) ? 'yes' : 'no'; ?></td>
</tr>
<tr>
<th>authCode</th>
<td><?php echo $xml->transactionResponse->authCode; ?></td>
</tr>
<tr>
<th>transId</th>
<td><?php echo $xml->transactionResponse->transId; ?></td>
</tr>
</table>
<h2>
Raw Input/Output
</h2>
<?php
echo $xml;
?>
</body>
</html>
Отказ от ответственности: я являюсь автором этого кода.