[英]has anyone used braintree for token based transactions?
我試圖了解如何使用Braintree,但是在收到所有錯誤之后,他們的文檔變得越來越難以理解。
我想做的是提交客戶帳單信息+信用卡信息,然后接收令牌,以便我可以將其存儲在數據庫中。
這是我寫的,並且出現錯誤。
<?php
include_once("lib/Braintree.php"); //braintree library
include_once("config.php"); //the Braintree_Configurations
$result = Braintree_Customer::create(array(
'firstName' => 'Mike',
'lastName' => 'Jones',
'company' => 'Jones Co.',
'email' => 'mike.jones@example.com',
'phone' => '419.555.1234',
'fax' => '419.555.1235',
'website' => 'http://example.com',
'creditCard' => array(
'number' => '5105105105105100',
'expirationDate' => '05/12',
'cvv' => '123',
'cardholderName' => 'Mike Jones',
'billingAddress' => array(
'firstName' => 'Drew',
'lastName' => 'Smith',
'company' => 'Smith Co.',
'streetAddress' => '1 E Main St',
'extendedAddress' => 'Suite 101',
'locality' => 'Chicago',
'region' => 'IL',
'postalCode' => '60622',
'countryCodeAlpha2' => 'US'
)
)
));
if ($result->success) {
print_r("success!: " . $result->transaction->id);
} else if ($result->transaction) {
print_r("Error processing transaction:");
print_r("\n message: " . $result->message);
print_r("\n code: " . $result->transaction->processorResponseCode);
print_r("\n text: " . $result->transaction->processorResponseText);
} else {
print_r("Message: " . $result->message);
print_r("\nValidation errors: \n");
print_r($result->errors->deepAll());
}
?>
只需刪除'countryCodeAlpha2'=>'US'行,您的代碼即可使用。 還有一點是結果沒有您正在使用的事務對象,例如'$ result-> transaction-> id'。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.