【问题标题】:Identify customer who made purchase using braintree dropin ui识别使用 Braintree dropin ui 进行购买的客户
【发布时间】:2016-09-20 05:07:28
【问题描述】:

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

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

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

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

【问题讨论】:

    标签: javascript php braintree gateway


    【解决方案1】:

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

    访问与交易关联的客户

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

    $result->transaction->customerDetails
    

    将新客户与交易相关联

    您可以只使用Braintree_Transaction::sale() create a customer, store their payment method, and create a transaction at once。只需传入您从客户那里收到的付款方式随机数并将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 来指定哪个返回客户进行了交易:

    Drop-in UI 支持向回头客展示他们保存的付款方式。要在您的保管库中为客户生成令牌,请提供客户的 ID。1

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

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

    【讨论】:

      猜你喜欢
      • 2020-06-05
      • 1970-01-01
      • 2023-03-14
      • 1970-01-01
      • 1970-01-01
      • 2022-09-28
      • 2021-10-19
      • 2021-12-16
      • 2018-08-01
      相关资源
      最近更新 更多