我们正在尝试使用 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/