简体   繁体   English

识别使用Braintree Dropin UI进行购买的客户

[英]Identify customer who made purchase using braintree dropin ui

We are experimenting with Braintree's dropin ui to collect payment from customers. 我们正在尝试使用Braintree的dropin ui从客户处收取款项。

We are able to receive payment from customers (and arrive at the 'success' page) and now need to identify which customer made the payment and reflect it on our database. 我们能够从客户那里收到付款(并到达“成功”页面),现在需要确定哪个客户付款了,并将其反映在我们的数据库中。

Custom fields don't seem to work with dropin ui to pass our client id, etc. 自定义字段似乎不适用于dropin ui来传递我们的客户端ID等。

Is there any variable on the 'success' page of the dropin ui that identifies the user who made the purchase in the checkout page? dropin ui的“成功”页面上是否有任何变量可以标识在结帐页面上进行购买的用户?

Full disclosure: I work at Braintree. 全面披露:我在Braintree工作。 If you have any further questions, feel free to contact support . 如果您还有其他疑问,请随时与支持小组联系。

Accessing the customer associated with a transaction 访问与交易相关的客户

The Braintree_Transaction record returned within a $result object does have a customerDetails property. $result对象内返回的Braintree_Transaction记录确实具有customerDetails属性。 Therefore, the customer who made the transaction can be identified: 因此,可以确定进行交易的客户:

$result->transaction->customerDetails

Associating a new customer with a transaction 将新客户与交易关联

You can create a customer, store their payment method, and create a transaction at once using only Braintree_Transaction::sale() . 您可以仅使用Braintree_Transaction::sale() 创建客户,存储其付款方式并立即创建交易 Simply pass in the payment method nonce that you received from your client and set storeInVaultOnSuccess to true . 只需传入您从客户那里收到的付款方式随机数,然后将storeInVaultOnSuccess设置为true Optionally, you can specify a customer ID and other customer parameters . (可选)您可以指定客户ID和其他客户参数 ( If you do not specify a customer ID, the gateway will create one for you. ) 如果您未指定客户ID,则网关将为您创建一个。

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

Associating an existing customer with a transaction 将现有客户与交易关联

When using the Drop-in UI, you may specify which returning customer made a transaction by including that customer's ID when you generate a client token : 当使用Drop-in UI时,您可以在生成客户令牌时通过包含该客户的ID来指定哪个回头客户进行交易:

The Drop-in UI supports presenting returning customers with their saved payment methods. Drop-in UI支持向回头客显示他们保存的付款方式。 To generate a token for a customer in your vault provide the customer's ID. 要为您的保管库中的客户生成令牌,请提供客户的ID。 1 1个

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

You may only specify IDs for customers that already exist in your vault. 您只能为库中已经存在的客户指定ID。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM