I'm new to brain tree payment gateway. I can't understand that what is payment_method_nonce (token provided by end user) or how this token is generated ?
Also I dont know how to get the customer card details, how to store it, and how to do transactions with the "payment_method_token"
result = Braintree::PaymentMethodNonce.create("A_PAYMENT_METHOD_TOKEN")
nonce = result.payment_method_nonce.nonce
Can any body explain how to create or get A_PAYMENT_METHOD_TOKEN?
The paymentmethodtoken is a unique identifier for the customer's credit card that we use to make purchases.
If you check the result object you can extract the payment method token from it and can be stored in your side for future transaction for the same user without entering the card details.

This is required to save the payment method nonce as a payment method token. The payment method nonce can only be used once, where the token is a reusable value that will not expire.
You’ll need to first create the customer and payment method in one call, and then use the payment method token from the result object to create the subscription. Keep in mind that you will need to first create a plan in the Control Panel, but you can override most of the plan details when you create the subscription.
After you create a Customer with a stored payment method you can use the returned token to subscribe a user to a plan. This article explains it well: https://developers.braintreepayments.com/guides/recurring-billing/overview
A Real Time Example by Site point Team on How to Integrate Braintree Can be found in the bellow link:
Integrate Braintree Payments into Rails
payment_method_nonce is the params that your braintree form submit to your controller.
You can use nonce_from_the_client = params['payment_method_nonce'] to create braintree Transaction
result = Braintree::Transaction.sale(
:amount => "100.00",
:payment_method_nonce => nonce_from_the_client
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With