Use the UI to insert Braintree to select a payment method for recurring billing - or: find a payment method for a payment MethodNonce

I am building a simple payment system using Braintree payments, PHP and JavaScript. I am using the Braintree Drop-In UI and would like to create subscriptions (like recurring billing).

For this I use:

// $_customer is a Braintree_Customer object; a customer stored in the Vault
$subscription_create = Braintree_Subscription::create([
  'id' => $_customer->id,
  'planId' => 'some_package',
  'paymentMethodToken' => $_customer->defaultPaymentMethod()->token
]);

      

This works great and creates a subscription using the customer's default payment method. However, I don't see the customer being able to change the default payment method. There seems to be no way to do this in the input UI.

Does this mean that I cannot use the UI for re-billing? Do I have to write my own user interface so customers can change the default payment method?


There is a way to make the default payment method. I could use this one, however, I only get paymentMethodNonce from the client. How do I find the paymentMethod associated with this nonce?

+3


source to share


1 answer


I work at Braintree. If you have more questions, you can always contact our support team .

You don't need a special method for this, you can pass the nonce directly toBraintree_PaymentMethod::create

:



$result = Braintree_PaymentMethod::create(array(
    'customerId' => '12345',
    'paymentMethodNonce' => 'nonce-from-the-client'
));

      

+3


source







All Articles