0
votes

I'm currently using Cloud Firestore as my backend for a mobile app. I've got basic payments working with Stripe with cloud functions programmed with node.js, however, when setting up for Stripe Connect, the process requires a redirect uri (which I input in the settings of my Stripe account).

I have very little experience with redirects and callbacks. What is the address that I can use as a redirect uri? How does this address get established?

It would also be great to hear your thoughts on how I would go about capturing the information from the redirect through a firestore trigger (node.js).

Any help would be much appreciated!

Thank you.

1

1 Answers

1
votes

One solution is to use an HTTPS Cloud Function.

As explained in the doc, "after you deploy an HTTPS function, you can invoke it through its own unique URL.". The URL will look like: https://us-central1-.cloudfunctions.net/stripeWebhook and you just have to declare it in your Stripe settings.

In the Cloud Function, you will be able to get the values passed to the body of the HTTP request, as follows:

exports.stripeWebhook = functions.https.onRequest((req, res) => {
    const orderId = req.body.data.object.metadata.orderId;
    const sourceId = req.body.data.object.id;
    const sourceType = req.body.data.object.type;
    ....
});

and also to write to Firestore, in order to update the record corresponding to the paiement. You may watch the following official video for an example:https://www.youtube.com/watch?v=7IkUgCLr5oA&t=1s&list=PLl-K7zZEsYLkPZHe41m4jfAxUi0JjLgSM&index=3