I have a problem when implementing the Google Pay api, i cant perform a payment. I implemented the the Google Pay api the same as the documentation say, and i saw i need to provide a gateway provider. I provided the following object:
"gateway": "stripe"
"stripe:version": "2018-10-31"
"stripe:publishableKey": "YOUR_PUBLIC_STRIPE_KEY"
Everything work as expected, i can see the GPay button i can open it and choose my card, but when i click pay, i can see in the console a json token object returned from Google Pay api, i dont know what are the next steps, if somebody have experience with that please help.
I tried with examples from the Google Pay api, also look the Stripe documentation but i didnt find where i need to pass this token object from Google Pay api
The next step once you received the token from Google Pay is to perform the actual authorization by calling the respective Stripe APIs.
Call the /v1/payment_methods
API with the token you received in the response from Google Pay: paymentData.paymentMethodData.tokenizationData.token.id
curl https://api.stripe.com/v1/payment_methods \
-u sk_test_your_secret: \
-d type=card \
-d "card[token]"=tok_abc1234
In the response you will receive an id
. Use it to finally call the /v1/payment_intents
API:
curl https://api.stripe.com/v1/payment_intents \
-u sk_test_your_secret: \
-X "POST" \
-d amount=100 \
-d payment_method=pm_your_pm \
-d currency=usd
Additional API calls may be needed depending on the status of the Payment Intent. For more information on how Payment Intents work please see: https://stripe.com/docs/payments/intents
Update:
There is an even simpler way to charge a user by passing the paymentData.paymentMethodData.tokenizationData.token.id
to the /v1/charges
API directly:
curl https://api.stripe.com/v1/charges \
-u sk_test_your_secret: \
-d amount=100 \
-d currency=usd \
-d source=tok_abc1234