4

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.

neophyte
  • 6,540
  • 2
  • 28
  • 43
Sy Moen
  • 124
  • 2
  • 11

1 Answers1

6

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.

agf
  • 171,228
  • 44
  • 289
  • 238
  • from we can able to find customerId? And once we get Result then how to use them to send nonce value to server? As my server wants nonce value from client side and I am able to find that by using Braintree.PaymentMethodNonceListener (). But in response it is showing that "Cannot determine payment method.". Please suggest me the right path. – anddev Jun 02 '15 at 08:42
  • Well, when I use the dropin it *does* create a payment method, however, you are right. If I attempt to create a payment_method with the nonce, it does return the existing payment method created with that nonce. Thanks! – Sy Moen Jun 02 '15 at 14:54
  • @anddev I suggest you [contact the Braintree support team](https://support.braintreepayments.com/). – agf Jun 02 '15 at 16:02
  • I don't see the "find or create" functionality of `create()` [in the docs](https://developers.braintreepayments.com/reference/request/payment-method/create/php) or in practice using sandbox cards. – jchook Apr 15 '18 at 18:52
  • 1
    @jchook It's not find or create. When I say "an already-vaulted payment method" I don't mean the credit card number matches an already vaulted one, I mean that the nonce was created from the ID of a vaulted payment method. – agf Apr 16 '18 at 05:08