Search code examples
phpbraintreegoogle-pay

How to validate a customer token in Braintree-Google Pay integration?


Our implementation is as follows:

  1. Authorize a credit card associated with Google Pay. Get the nonce.

  2. Using the nonce received, create a Customer account. Save the token for future reference.

  3. Complete transaction using saved token.

The question is how to validate the token before starting a new transaction. Token verification is important because, transaction happens after a few days from customer creation.

Tried Braintree\CreditCard::find($token). This worked for customer accounts created with a credit card. Since we are using a nonce from Google Pay instead of Credit card, it will return a message of:

credit card with token $token not found

How to validate a token in above case?


Solution

  • PaymentMethod::find() will resolve the problem

    Reference https://developers.braintreepayments.com/reference/request/payment-method/find/php