我正在尝试从 mysql 表中提取信息并将其插入 createTransactionRequest 数组以显示电子邮件中的行项。当我这样做并在页面上回显时,它看起来应该是这样,但它一直给我一个错误。如果我删除数组( $lineitem ),我创建它会很好。我觉得我插入了这个错误,或者它只是不可能按照我试图这样做的方式来做到这一点。希望有这方面经验的人可以帮助我解决这个问题。
我像这样创建数组。
while($r = mysql_fetch_array($cartitems)) {
$lineitem[] = array('itemId' => ''.$r['itemid'].'','name' => ''.$r['productname'].'','description' => ''.$r['productdescription'].'','quantity' => '1','unitPrice' => ''.$price.'');
}
然后我像这样将它插入数组中..
$xml->createTransactionRequest(array(
'refId' => rand(1000000, 100000000),
'transactionRequest' => array(
'transactionType' => 'authCaptureTransaction',
'amount' => 45.00,
'payment' => array(
'creditCard' => array(
'cardNumber' => '4111111111111111',
'expirationDate' => '122015',
'cardCode' => '123',
),
),
'order' => array(
'invoiceNumber' => '123123',
'description' => 'Purchase from website',
),
'lineItems' => array(
'lineItem' => $lineitem
),
'poNumber' => '123123321',
'customer' => array(
'id' => 123,
'email' => email@website.com,
),
'billTo' => array(
'firstName' => $firstname,
'lastName' => $lastname,
'address' => $address,
'city' => $city,
'state' => $state,
'zip' => $zipcode,
'country' => 'USA',
),
'customerIP' => 12-12-12-1234,
'transactionSettings' => array(
'setting' => array(
0 => array(
'settingName' =>'allowPartialAuth',
'settingValue' => 'false'
),
1 => array(
'settingName' => 'duplicateWindow',
'settingValue' => '0'
),
2 => array(
'settingName' => 'emailCustomer',
'settingValue' => 'true'
),
3 => array(
'settingName' => 'recurringBilling',
'settingValue' => 'false'
),
4 => array(
'settingName' => 'testRequest',
'settingValue' => 'false'
)
)
),
),
));
---------------编辑下面,显示打印输出----------------
Array
(
[refId] => 90801855
[transactionRequest] => Array
(
[transactionType] => authCaptureTransaction
[amount] => 31.41
[payment] => Array
(
[creditCard] => Array
(
[cardNumber] => 4111111111111111
[expirationDate] => 042012
[cardCode] => 123
)
)
[order] => Array
(
[invoiceNumber] => 1360116011
[description] => Purchase from website
)
[lineItems] => Array
(
[lineItem] => Array
(
[0] => Array
(
[itemId] => 1
[name] => item one title
[description] => item one description
[quantity] => 1
[unitPrice] => 19.90
)
[1] => Array
(
[itemId] => 4
[name] => item 4 title
[description] => item 4 description
--
[quantity] => 1
[unitPrice] => 15.00
)
)
)
[poNumber] => 22
[customer] => Array
(
[id] => 2
[email] => email@website.com
)
[billTo] => Array
(
[firstName] => john
[lastName] => smith
[address] => 132 addy here lane
[city] => foxboro
[state] => MA
[zip] => 01955
[country] => USA
)
[customerIP] => 12.123.123.123
[transactionSettings] => Array
(
[setting] => Array
(
[0] => Array
(
[settingName] => allowPartialAuth
[settingValue] => false
)
[1] => Array
(
[settingName] => duplicateWindow
[settingValue] => 0
)
[2] => Array
(
[settingName] => emailCustomer
[settingValue] => true
)
[3] => Array
(
[settingName] => recurringBilling
[settingValue] => false
)
[4] => Array
(
[settingName] => testRequest
[settingValue] => false
)
)
)
)
)