I am building a create-react-app using Firebase and react-router. I would like to integrate Stripe as payment service provider.
As part of the Stripe verification process, I need to provide the IP address of the user agreeing to the Terms and Conditions, as per the Stipe docs:
stripe.accounts.update(
{CONNECTED_STRIPE_ACCOUNT_ID},
{
tos_acceptance: {
date: Math.floor(Date.now() / 1000),
ip: request.connection.remoteAddress // Assumes you're not using a proxy
}
}
});
Because I am using a combination of Firebase and react-router, I does not seem like I can use an Express like (req, res) to get the IP in the backend: I dont think I could link the IP address obtained to the user uid. Also when trying to use the ipify of this world on the client with react, I always end up with the same IP in production (no matter the device or location):
import http from 'http';
componentDidMount () {
http.get({'host': 'api.ipify.org', 'port': 80, 'path': '/'}, function(resp) {
resp.on('data', ip => {
alert("My public IP address is: " + ip);
});
});
}
Any idea how I could retrieve the user's IP address either through Firebase Cloud Functions or directly from the client?
Thanks