Sy Moen
Sy Moen

Reputation: 124

Braintree API: How can I tell which payment_method is associated with my nonce?

Background:

  1. I create a braintree customer with firstName, lastName and email
  2. I use the dropin ui in checkout form and it creates a payment_method and token and sends me a nonce. Good so far.
  3. I need to add a billing address to the payment_method before I charge the nonce...

Question: How can I discover which payment_method is associated with my nonce?

Edit to add: There is a paradoxical reference at the bottom of the javascript+PHP page to an otherwise undocumented [paymentMethodNonce] parameter which uses an also undocumented [options][verifyCard] parameter. I suppose I could run [paymentMethodNonce] sans [options] against each payment_method token associated the user and inspect the errors... lol.

Upvotes: 4

Views: 4895

Answers (1)

agf
agf

Reputation: 176950

I work at Braintree. If you have more questions, I suggest you reach out to our support team.

When you use the Drop-In UI, it doesn't automatically create a payment method, just a nonce. You pass the nonce back to your server and create a payment method with it:

$result = Braintree_PaymentMethod::create(array(
    'customerId' => '12345',
    'paymentMethodNonce' => 'nonce-from-the-client'
));

If the nonce points to an already-vaulted payment method for that customer, you'll get back the existing payment method rather than a duplicate.

You can then update that payment method to add a billing address before using it to create a transaction.

Upvotes: 6

Related Questions