交易完成后,金库下有两个客户条目。
我遵循的步骤:
1. Created customer.
//first customer vault entry is created at this point
$customerParams = Braintree_Customer::create(array(
'firstName' => $firstName,
'lastName' => $lastName,
));
2.然后生成clientToken
Braintree_ClientToken::generate(array(
"customerId" => $customerParams->customer->id
));
3.然后在api的帮助下成功在js中生成nonce:
var client = new braintree.api.Client({clientToken: ctoken});
client.tokenizeCard({
...
...
});
4.此时再次创建新客户
Braintree_Transaction::sale(array(
'amount' => $mapCidInvoiceID['amount'],
'orderId' => $redirectParams['invoiceID'],
'paymentMethodNonce' => $nonce,
'options' => array(
'storeInVaultOnSuccess' => true,
),
));
我的代码有问题吗?为什么一笔交易会创建两条客户记录?对于第一个记录,记录名字和姓氏。但第二种情况没有存储这样的细节。 第二步和第三步需要首先创建客户。
最佳答案
全面披露:我在 Braintree 工作。
您的代码正在创建两个单独的客户,因为当您调用 Transaction::sale 时,它没有绑定(bind)来自 Customer::create 调用的客户,并且您可以选择设置将付款方式存储在保险库中成功。这会在保存交易中的付款方式时创建一个客户,因为付款方式必须与客户绑定(bind)。要解决您的问题,请在调用 Transaction::sale 时将从 Customer::create 返回的客户 ID 作为 customerId 参数传递。
Braintree_Transaction::sale(array(
'amount' => $mapCidInvoiceID['amount'],
'orderId' => $redirectParams['invoiceID'],
'customerId' => $customerParams->customer->id
'paymentMethodNonce' => $nonce,
'options' => array(
'storeInVaultOnSuccess' => true,
),
));
关于php - Braintree金库问题中双重客户输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34635668/