Search code examples
phpstripe-paymentsgoogle-pay

Test stripe api payment using google pay token


I have set up a Google Pay button on the front end of my website and have tested communicating with the Google Pay API and have successfully received a response.

I have a Laravel project (PHP) so the front end sends this data to the server to be processed.

Once I have this response however I am not sure how to pass the required information to stripe api. From my understanding I need to pass the token received in the response to stripe's api but not sure how to formulate the request to stripe using this token.

Any assistance would be greatly appreciated


Solution

  • On your PHP side, you need to create a Charge on Stripe: https://stripe.com/docs/api/charges/create , using stripe-php library.

    The Stripe Token you got from Google Pay, you would pass that under the source: tok_123 parameter.

    (recommended) If you are using PaymentIntent/PaymentMethod objects, you would create a PaymentIntent (https://stripe.com/docs/api/payment_intents/create) using the API and pass payment_method: pm_123.