so I've spent a fair amount of time (weeks) with this issue however still have not been able to figure out how to resolve it. I believe I've narrowed it down to the issue of trying to get a Stripe Connect webhook to fire once a user has completed the signup form through the Stripe Connect Express process. Here's the example Stripe gives with their RocketRides.io demo. I've submitted an issue to stripe but am waiting to hear back. I was hoping to get there quicker with the help of the SO community.
I've previously created other questions as I chase the proverbial rabbits down their various holes as I go through the trial and error process of trying to narrow down the issue so bear with me. You can find these other links at the bottom of this question post.
The snippet below displays my Stripe CLI Log when I am "listening" with stripe listen
.
This snippet displays the stripe logs tail
The customer.created
is fired when a user signs up for my app, which is supposed to happen using the code below. I am not sure if this is supposed to be used when trying to use a Stripe Connect Account which is my intention. I'm still figuring out Stripe. The bottom line is I need to have payout and subscription capability, and from the research I've done, Stripe Connect is the direction to go.
exports.createStripeCustomerHTTPSCall = functions.firestore.document('Users/{userName}').onCreate((change, context) =>{
console.log("Stripe Customer profile for " + context.params.userName + " created.");
return stripeToken.customers.create(
{
description: 'My First Test Customer (created for API docs)',
email: context.params.userName,
},
(err, customer) => {
// asynchronously called
console.log("Creating Stripe customer failed because: " + err.toString())
}
)
Once a user signs up for the App and is logged in the FirebaseDatabase as a user, they will be directed to the Stripe Connect Express form.
The issue now I'm running into is getting stripe to fire a Connect Webhook which would trigger Step 4, a Cloud Functions version of a cURL request to the redirected URL with the Authentication code
, and potentially a state code
. The account.application.authorized
event only occurs in my listener only after I have sent in a cURL request (I think is called a GET Request? I'm not a formally trained programmer)
I believe the issue lies in setting up a webhook to fire once a user has completed the form and is redirected which I think should be account.updated
?
Here is my Node.js code. I'm not sure if its relevant since I can't even get the webhook to fire but just in case:
exports.stripeCreateOathResponseToken = functions.https.onRequest((req, res) => {
console.log("rawbody: " + rawbody); // <-- usually comes back with req.rawbody
console.log("request.body: " + req.body); // <-- returns undefined
console.log("request.query.code: " + req.query.code); // <-- returns undefined
console.log("request.query.body: " + req.query.body); // <-- returns undefined
console.log("request.query.state: " + req.query.state); // <-- returns undefined
return stripeToken.oauth.token({
grant_type: 'authorization_code',
code: req.query.code,
}).then(function(response) {
// asynchronously called
return res.send(response)
// var connected_account_id = response.stripe_user_id;
})
.catch(error=> {
res.send(error)
})
});
In case its relevant, here is android kotlin code for when user decides to sign up for payouts capabilities. AKA Stripe Connect Express
openURL.data = Uri.parse(
"https://connect.stripe.com/express/oauth/authorize?" +
"redirect_uri=http://XXXXXXXXXXXXXX.com&" +
"client_id=ca_XXXXXXXXXXXXXXXXXXXX" + // how to hide client id? maybe look at how to access from stripe CLI
"state=" + mAuth.currentUser!!.uid +
"&stripe_user[email]=" + userEmail +
"&stripe_user[business_type]=individual" +
"&stripe_user[phone_number]=" + userPhoneNumberStripped +
"#/")
startActivity(openURL)
Previous Questions
Stripe Firebase Cloud Functions - res.send() is not a function
Cloud Firebase Stripe Connect - Retrieve Authorization Code / Access Token, State, etc
Firebase Cloud Functions - Stripe Connect Webhook not firing
Android Stripe Connect WebView - Create Account Form NOT loading