0
votes

I am using Firebase Cloud Functions to handle Stripe webhooks. I let new app users create a payment method with Stripe. When they click on add card, stripe calls a webhook URL, which is a Firebase Cloud Function. That function searches for the app user from Firestore, gets the name, creates a new Stripe Customer with the user name, and updates the user in firebase with the stripe account ID.

Simple and it works.

But now, how do I update my Expo app State with the new stripe customer ID? Is there a way to update the app from the cloud function somehow?

If you're thinking "why don't you just call your firestore from the app when the success URL is reached?" then it's a problem, because I cannot know for sure that by the time I am on the success redirect URL, my cloud function finished doing what it's supposed to do.

Should I create a dynamic link for this? is there another way? Suggestions?

1

1 Answers

2
votes

Is there a way to update the app from the cloud function somehow?

You could devise a way for the app to know the ID of a Firestore document that will eventually contain the results of the function. The app can set up a listener on that document to know when it's been created or updated by the function, so that no matter what is the sequence of events, the app knows where to get results as fast as possible without polling.