braintree how to vault a payment method ready for subscription

佐手、 提交于 2019-12-24 17:16:40

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!