![](/img/trans.png)
[英]How to implement recurring billing in PHP application using Braintree payment gateway?
[英]PHP Braintree - create flow with Recurring Billing without using Subscriptions
我不想創建訂閱,但仍然能夠在我的 SaaS 軟件中使用定期計費方法:
所有這些都沒有訂閱功能。 布倫特里允許嗎?
目前我遇到以下問題:
該錯誤是有道理的,但我如何將當前用戶注冊與 braintree 中創建的客戶匹配,以便以后使用付款方式令牌重新使用交易銷售?
https://developer.paypal.com/braintree/docs/guides/customers#create-with-payment-method
// After the Transaction Sale is executed with success I try this:
$result = $gateway->customer()->create(
[
'firstName' => $customer['name'],
'company' => $customer['company'],
'email' => $customer['email'],
'paymentMethodNonce' => $customer['payment_method_nonce']
]);
這將返回付款方式令牌,我將能夠像這樣保存在數據庫中:
$db->braintree_customer_id = $braintreeCustomer->customer->id;
$db->braintree_payment_token = $braintreeCustomer->customer->paymentMethods[0]->token;
$db->save();
在下個月,我的軟件將能夠使用以下方式執行付款:
$result = $gateway->transaction()->sale(
[
'amount' => $price,
'paymentMethodToken' => $token, // <--- saved in DB
'options' =>
[
'submitForSettlement' => true
]
]);
解決了。
這個問題的答案“所有這些都沒有訂閱功能。Braintree 允許嗎?” 是是的。
關於錯誤“不能多次使用 payment_method_nonce”,我必須首先使用 nonce 創建客戶,然后使用令牌執行銷售。
$result = $gateway->customer()->create(
[
'firstName' => $customer['name'],
'company' => $customer['company'],
'email' => $customer['email'],
'paymentMethodNonce' => $customer['payment_method_nonce']
]);
// We now execute the payment with the token returned
$braintree->executePayment($result->customer->paymentMethods[0]->token, $total);
由於我將令牌保存在數據庫中,因此我可以在下個月隨時再次執行付款,而無需用戶干預。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.