Search code examples
google-apistripe-paymentsdialogflow-esactions-on-googlegoogle-pay

How manage payment in Google Action using Transactions API


I have developed a Google Actions Application to buy physical goods. I followed this guide: https://developers.google.com/assistant/transactions/physical/dev-guide-physical-gpay

I get the correct request / response flow:

"paymentInfo": {
   "displayName": "Mastercard *ommited for security*",
   "googleProvidedPaymentInstrument": {
      "instrumentToken": "*ommited for security*"
   },
   "paymentType": "PAYMENT_CARD"
}

and finally Google returns me an instrumentToken in base64, which I think I can decode and use the ID inside it to call the Stripe API: https://stripe.com/docs/api/charges/create#create_charge-source. I tested it and it works, but seems extrange to me... Do I have to do this for every order that is successful?

My question is: Do I have to call the Stripe API myself? Is there no way Google will do it for me? In case I have to send it, should I do it when I receive the request with this field "userDecision": "ORDER_ACCEPTED" and then update the order if the payment is successful?

I have read all the official Google documentation for Actions and I cannot understand the entire flow of interaction.


Solution

  • As @taintedzodiac mentioned in the comment, if you use Stripe as your payment processor then you will have to use Stripe explicitly each time. This is not something that the platform will do automatically.