php - Braintree金库问题中双重客户输入

标签 php braintree

交易完成后,金库下有两个客户条目。

我遵循的步骤:

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/

相关文章:

ios - 为什么在Braintree手动集成上出现找不到“Braintree/BTUICTAControl.h”文件的错误?

php - 需要设置Braintree\Configuration::merchantId(或者需要将accessToken传给Braintree\Gateway)

php - 使用 CodeIgniter 查询生成器在连接查询上应用不同

php - 如何记录具有大量结果的查询

php - 需要有关使用 Valums ajax 上传脚本上传文件的帮助

php - 使用 DropIn UI 中的 Nonce 更新 Braintree 订阅付款方式 - 404 未找到错误

php - Braintree PHP SDK cURL 异常

paypal - 在 Braintree 付款中搜索客户的有效订阅

php - Composer 卡在安装依赖项上

php - 如何使用PHP检查用户是否已经存在于MySQL中