Stripe Connect Express Webhook - 如何在用户完成 Stripe Connect Express 表单并重定向后触发 Stripe webhook
Stripe Connect Express Webhook - How to get Stripe webhook to fire once user has completed Stripe Connect Express form and is redirected
所以我花了相当多的时间(几周)来解决这个问题,但仍然无法弄清楚如何解决它。我相信我已经将其缩小到试图在用户通过 Stripe Connect Express 流程完成注册表单后触发 Stripe Connect webhook 的问题。这是 Stripe 给出的示例 RocketRides.io demo。我已经向条纹提交了一个问题,但正在等待回音。我希望在 SO 社区的帮助下更快到达那里。
我之前提出了其他问题,因为我在尝试缩小问题范围的反复试验过程中将众所周知的兔子追逐到各种洞中,所以请耐心等待。您可以在这个问题的底部找到这些其他链接 post。
当我 "listening" 和 stripe listen
时,下面的代码片段显示了我的 Stripe CLI 日志。
此代码段显示 stripe logs tail
当用户注册我的应用程序时会触发 customer.created
,这应该使用下面的代码发生。我不确定在尝试使用我打算使用的 Stripe Connect 帐户时是否应该使用它。我还在研究 Stripe。最重要的是,我需要具备支付和订阅功能,根据我所做的研究,Stripe Connect 是前进的方向。
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())
}
)
用户注册应用程序并以用户身份登录 FirebaseDatabase 后,他们将被定向到 Stripe Connect Express form。
我现在 运行 遇到的问题是让 stripe 触发 Connect Webhook 这将触发第 4 步,cURL 请求的 Cloud Functions 版本重定向到 URL 与 Authentication code
,并可能是 state code
。 account.application.authorized
事件仅在我发送 cURL 请求后才会在我的侦听器中发生(我认为这称为 GET 请求?我不是受过正式培训的程序员)
我认为问题在于设置一个 webhook,以便在用户完成表单并被重定向后触发,我认为应该是 account.updated
?
这是我的 webhook 设置:
这是我的 Node.js 代码。我不确定它是否相关,因为我什至无法触发 webhook 但以防万一:
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)
})
});
如果相关,这里是 android kotlin 代码,用于用户决定注册支付功能时的代码。又名 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)
以前的问题
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
在这种情况下,webhook 将不起作用;您反而希望将用户 - 在他们完成 OAuth 流程后 - 重定向到运行您在那里提供的 Node.js 代码的 Cloud Functions URL(然后将他们重定向到您的下一步来自那里)。
您还需要确保您要重定向到的 URL 在仪表板的平台设置中被列为重定向 URL,参见此处:https://stripe.com/docs/connect/express-accounts#integrating-oauth
就 GCF 中的重定向而言,这可能会有所帮助:
所以我花了相当多的时间(几周)来解决这个问题,但仍然无法弄清楚如何解决它。我相信我已经将其缩小到试图在用户通过 Stripe Connect Express 流程完成注册表单后触发 Stripe Connect webhook 的问题。这是 Stripe 给出的示例 RocketRides.io demo。我已经向条纹提交了一个问题,但正在等待回音。我希望在 SO 社区的帮助下更快到达那里。
我之前提出了其他问题,因为我在尝试缩小问题范围的反复试验过程中将众所周知的兔子追逐到各种洞中,所以请耐心等待。您可以在这个问题的底部找到这些其他链接 post。
当我 "listening" 和 stripe listen
时,下面的代码片段显示了我的 Stripe CLI 日志。
此代码段显示 stripe logs tail
当用户注册我的应用程序时会触发 customer.created
,这应该使用下面的代码发生。我不确定在尝试使用我打算使用的 Stripe Connect 帐户时是否应该使用它。我还在研究 Stripe。最重要的是,我需要具备支付和订阅功能,根据我所做的研究,Stripe Connect 是前进的方向。
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())
}
)
用户注册应用程序并以用户身份登录 FirebaseDatabase 后,他们将被定向到 Stripe Connect Express form。
我现在 运行 遇到的问题是让 stripe 触发 Connect Webhook 这将触发第 4 步,cURL 请求的 Cloud Functions 版本重定向到 URL 与 Authentication code
,并可能是 state code
。 account.application.authorized
事件仅在我发送 cURL 请求后才会在我的侦听器中发生(我认为这称为 GET 请求?我不是受过正式培训的程序员)
我认为问题在于设置一个 webhook,以便在用户完成表单并被重定向后触发,我认为应该是 account.updated
?
这是我的 webhook 设置:
这是我的 Node.js 代码。我不确定它是否相关,因为我什至无法触发 webhook 但以防万一:
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)
})
});
如果相关,这里是 android kotlin 代码,用于用户决定注册支付功能时的代码。又名 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)
以前的问题
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
在这种情况下,webhook 将不起作用;您反而希望将用户 - 在他们完成 OAuth 流程后 - 重定向到运行您在那里提供的 Node.js 代码的 Cloud Functions URL(然后将他们重定向到您的下一步来自那里)。
您还需要确保您要重定向到的 URL 在仪表板的平台设置中被列为重定向 URL,参见此处:https://stripe.com/docs/connect/express-accounts#integrating-oauth
就 GCF 中的重定向而言,这可能会有所帮助: