6

I am using a Braintree Payment Nonce to create a recurring subscription request. The below code is what I have to create a subscription. I'm using Payment Nonce which is received from Client. But the subscription request fails with a message "Payment method nonce is invalid."

Any help/pointers would be much appreciated.

SubscriptionRequest request = new SubscriptionRequest()
                .paymentMethodNonce(customer.getPaymentNonce())
                .planId(customer.getPlan().getBraintreePlanId());
Result<Subscription> result = getGateway().subscription().create(request);
ronsi
  • 519
  • 1
  • 7
  • 15

1 Answers1

2

I work at Braintree. I'd suggest you reach out to our support team if you have more questions.

Unfortunately the "Payment method nonce is invalid" validation error is currently undocumented; that should be fixed soon.

This error means that the nonce couldn't be found, due it not existing, being locked, being already used, not pointing to a vaulted card, etc. In your example, customer.getPaymentNonce() likely isn't returning a valid payment method nonce. Make sure it was created with a customer ID and vaulted, and that you're not trying to use the same nonce more than once.

agf
  • 171,228
  • 44
  • 289
  • 238
  • Thanks. Yes I had figured that out. But thanks very much. I have another Braintree API question which I have posted at the below address. It would be really appreciated if you could take sometime to answer it. Thanks again. http://stackoverflow.com/questions/25148517/braintree-drop-in-ui-does-not-show-cvv-field – ronsi Aug 05 '14 at 21:21
  • @agf I am still seeing this error message `"Payment method nonce is invalid"`. Any update on this? – java_dude May 15 '15 at 02:45
  • @java_dude You'll have to get in touch with our support team so they can take a look at the specifics of your case. – agf May 15 '15 at 04:51
  • @agf I will. Support has been awesome. Thanks. – java_dude May 15 '15 at 04:53
  • @agf sorry to ask different thing , How can we know that payment done by client is using Paypal or credit card ? – Parag Chauhan Nov 20 '15 at 05:46
  • @ParagChauhan The payment method nonce you get has a `type` attribute, or equivalent method. See https://developers.braintreepayments.com/reference/response/payment-method-nonce/ruby for example. – agf Nov 20 '15 at 05:51
  • In braintree-java-2.63.0 java library, the Customer class does not have a method: "getPaymentNonce" – Ed J Jun 17 '16 at 09:57
  • @EdJ That is a method on some object the person asking the question created, not on a Braintree object. Once you have a customer with a vaulted payment method, you don't need a nonce -- you can charge the [customer](https://developers.braintreepayments.com/reference/request/transaction/sale/java#customer_id) or [payment method](https://developers.braintreepayments.com/reference/request/transaction/sale/java#payment_method_token) directly. – agf Jun 19 '16 at 03:27