Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot create subscription using Braintree Payment Nonce

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);
like image 615
ronsi Avatar asked Jul 27 '14 02:07

ronsi


1 Answers

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.

like image 161
agf Avatar answered Oct 02 '22 22:10

agf