问题
I'd like to create a customer with a payment method then store the payment method in the vault
and then to create a subscription for the user
so far I have this:
$rs = \Braintree_Customer::create([
'id' =>$m_id,
'firstName' =>$username,
'paymentMethodNonce' =>$nonce
]);
but this doesn't appear to be storing payment methods in the vault, is the above code correct for storing payment methods in the vault?
回答1:
You need to send the customer_id
and paymentmethodnonce
to BT. Follow the ways
$result = Braintree_PaymentMethod::create([
'customerId' => '12345',
'paymentMethodNonce' => nonceFromTheClient
]);
From the result you can get the braintree token (token = result.payment_method.token)
store in the database. You can use this token for the subscription.
来源:https://stackoverflow.com/questions/31317177/braintree-how-to-vault-a-payment-method-ready-for-subscription