0

I would like to make a call to a payment provider's verification API to check the status of the transaction.

The problem. The payment provider sends a webhook with the status of the transaction but sometimes this process fails. I typically update the status of the transaction in the firestore document upon receipt of the webhook but sometimes this fails leaving me with incoherent statuses in both the payment gateway's console and the firestore document.

Proposed solution. Upon the creation of a document in firestore, trigger pubsub with a schedule that will run in 5mins.

When the scheduled time arrives, trigger cloud function to run the verification code and update the firestore document.

My request. Any suggestions and code samples on how to accomplish this will be appreciated.

Thank you.

I tried a cloud function that runs periodically on ALL the documents to confirm the ones that have not been updated yet. this is rather an expensive approach seeing that the amount of documents to read and verify is massive. Also, the payment gateway's verification API only accepts a limited amount of request per second.

1 Answers1

0

For this type of runAfter type functionality, have a look at enqueueing functions in Cloud Tasks in the documentation.

Also see:

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807