Braintree: test nonces are resulting in Payment Method Nonce is Invalid

1.1k views Asked by At

I am in the process of using the sandbox to test creating a new recurring billing subscription using a fake nonce but I keep getting an error indicating the payment nonce is invalid, here is the object I am sending to the gateway.subscription.create method:

{
  paymentMethodNonce: 'fake-valid-nonce',
  planId: 'ip19',
  price: 2.5,
  options: { startImmediately: true }
}

This is the error I am receiving when I make me call to gateway.subscription.create:

[
  ValidationError {
    attribute: 'payment_method_nonce',
    code: '91925',
    message: 'Payment method nonce is invalid.'
  }
]

I am using the fake nonces listed in this article, https://developer.paypal.com/braintree/docs/reference/general/testing/node#nonce-fake-valid-nonce

I am passing the sandbox credentials when I make my initial connection but it seems like it is not honoring the fake nonce.

2

There are 2 answers

0
hollabaq On

Payment method nonces can only be used in certain specific conditions. Fake nonces do not support these specific use cases. You need to use a payment method token to create a subscription or use a generated payment method nonce from the specific client workflows mentioned in the API reference.

0
Daniel Cazares On

None of them have ever worked? They should work at least once. Otherwise, if you have a payment method in your vault, do something like braintree.PaymentMethodNonce.create('token').payment_method_nonce.nonce to generate a new nonce for server-side testing.