Shawn Ang
Shawn Ang

Reputation: 538

BrainTreePayments create new payment method

I am going through the BrainTreePayments documentation page and I came across the Payment Methods. The documentation says "To create a new payment method for an existing customer, the only required attributes are the customer ID and payment method nonce."

gateway.paymentMethod.create({
  customerId: "12345",
  paymentMethodNonce: nonceFromTheClient
}, function (err, result) { });

The question is

1) How do we create a new payment method for a new customer without payment method nonce? 2) How do we verify the validity of an existing payment method?

Upvotes: 0

Views: 659

Answers (1)

hollabaq
hollabaq

Reputation: 617

Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support.

1) A payment method is like a container to store payment information in your Vault, whereas the payment method nonce is a way to deliver payment information to Braintree. You use a payment method nonce to deliver payment information to create payment methods, transactions, etc. A payment method can be referenced to generate a payment method nonce from stored payment information, but the payment method must store something. You can't create an empty payment method.

2) To verify an existing payment method, use 'PaymentMethod.update()' and include 'verify_card' in your options. If you have enabled fraud tools in your control panel, newly created payment methods for credit cards will be verified before they are stored in the Vault. Cards that are not valid will not be stored and you will receive an error response.

Upvotes: 1

Related Questions