【问题标题】:Double customer entry in braintree vault issueBraintree Vault 问题中的双重客户输入
【发布时间】:2016-01-06 14:35:59
【问题描述】:

交易完成后,保险柜下有两个客户入口。

我遵循的步骤:

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,
 ),
));

我的代码有问题吗?为什么要为一笔交易创建两条客户记录?对于第一个记录,记录名字和姓氏。但是第二种情况没有存储这样的细节。 第二步和第三步需要先创建客户。

【问题讨论】:

  • 另一种解决方案是在第一步忽略客户创建并生成客户端令牌而不传递任何客户 ID。在交易销售电话中,将所有客户信息与其他信息一起传递。

标签: php braintree


【解决方案1】:

全面披露:我在 Braintree 工作。

您的代码正在创建两个单独的客户,因为当您调用 Transaction::sale 时,它​​并没有将来自您的 Customer::create 调用的客户与之绑定,并且您可以选择将付款方式存储在保险库中成功。这会在从交易中保存付款方式时创建一个客户,因为付款方式必须与客户相关联。要解决您的问题,请在调用 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,
  ),
));

【讨论】:

    猜你喜欢
    • 2016-12-08
    • 1970-01-01
    • 1970-01-01
    • 2011-08-02
    • 1970-01-01
    • 2019-11-18
    • 1970-01-01
    • 2020-09-09
    • 1970-01-01
    相关资源
    最近更新 更多