javascript - 识别使用 Braintree dropin ui 进行购买的客户

标签 javascript php braintree gateway

我们正在尝试使用 Braintree 的 dropin ui 来向客户收取付款。

我们能够接收客户的付款(并到达“成功”页面),现在需要识别哪个客户进行了付款并将其反射(reflect)在我们的数据库中。

自定义字段似乎不适用于 dropin ui 来传递我们的客户端 ID 等。

dropin ui 的“成功”页面上是否有任何变量可以识别在结帐页面中进行购买的用户?

最佳答案

全面披露:我在 Braintree 工作。如果您还有任何疑问,请随时联系support .

访问与交易关联的客户

Braintree_Transaction $result 内返回的记录对象确实有 customerDetails属性(property)。因此,可以识别进行交易的客户:

$result->transaction->customerDetails

将新客户与交易关联

您可以create a customer, store their payment method, and create a transaction at once仅使用 Braintree_Transaction::sale() 。只需传入您从客户端收到的付款方式随机数并将 storeInVaultOnSuccess 设置为 true 即可。 (可选)您可以指定客户 ID 和其他 customer parameters 。 (如果您没有指定客户 ID,网关将为您创建一个。)

$result = Braintree_Transaction::sale([
  'amount' => '10.00',
  'paymentMethodNonce' => nonceFromTheClient,
  'customer' => [
    'id' => 'a_customer_id'
  ],
  'options' => [
    'storeInVaultOnSuccess' => true,
  ]
]);

将现有客户与交易关联

使用 Drop-in UI 时,您可以在生成 client token 时包含该客户的 ID,以指定哪个回头客进行了交易。 :

The Drop-in UI supports presenting returning customers with their saved payment methods. To generate a token for a customer in your vault provide the customer's ID.1

$clientToken = Braintree_ClientToken::generate([
    "customerId" => $aCustomerId
]);

您只能为保管库中已存在的客户指定 ID。

关于javascript - 识别使用 Braintree dropin ui 进行购买的客户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39586081/

相关文章:

javascript - 使用单选按钮进行 jquery 计算

javascript - 如何在asp.net中的 Bootstrap 中单击选项卡进行服务器调用

javascript - 如何让 Google 抓取 AngularJS 应用程序正常?

PHP:通过合并换行符和正确删除空格来清理 HTML

javascript - CSS Hover 被停用

Php 和 MySQL 搜索具有多个空格的字符串会给出空数组

php - QT5 : best efficiant way to "unserialise" array of keys/values from json result

javascript - 如何通过循环动态设置实例变量?

ios - Braintree v.zero sdk v3.5.0 for iOS - 如何保存卡片

Paypal 开发人员 : Under "MyAccount" I want to enable payout . .. 但 'they' 需要更多信息?