Skip to content
Advertisement

PHP Braintree – create flow with Recurring Billing without using Subscriptions

I’d like not to create subscriptions but still be able to have the Recurring Billing approach in my SaaS software:

  1. Signup for a paid plan
  2. Apply Transaction Sale function
  3. Create braintree customer
  4. Save Payment Method Token in DB
  5. In the next month (whenever I want) use the Payment Method Token to create a new Transaction Sale

All of this without subscription feature. Does Braintree allow it?

Currently I’m having the following problem:

  1. The user signups for a paid plan
  2. The Transaction Sale is executed with the Nonce value
  3. I try to create the customer in Braintree using the same Nonce and I get the error “Cannot use a payment_method_nonce more than once”

The error makes sense, but how would I match the current user signup with the created customer in braintree in order to later use the Payment Method Token to re-use the Transaction Sale?

https://developer.paypal.com/braintree/docs/guides/customers#create-with-payment-method

JavaScript

This would return the Payment Method Token and I would be able to save in DB like this:

JavaScript

And in the next month, my software would be able to execute a payment using:

JavaScript

Advertisement

Answer

Solved.

The answer to this question “All of this without subscription feature. Does Braintree allow it?” is Yes.

And about the error “Cannot use a payment_method_nonce more than once”, I had to create firstly the customer using the nonce and then execute the sale using the token.

JavaScript

Since I save the token in the DB, I’m able to execute the payment again in the next month whenever I want without user interference.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement