大佬教程收集整理的这篇文章主要介绍了node.js – 如何使用条带webhooks更新用户的订阅日期?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
Stripe的doc声明我必须在数据库中存储active_until字段.它说当使用webhook进行更改时,我知道webhook就像是一个事件.
真正的问题是
1)如何使用active_until每个月重复一次账单?
2)我如何使用webhook,我真的不明白.
这是迄今为止的代码.
var User = new mongoose.scheR_47_11845@a({
电子邮件:String,
条纹:{
customerId:String,
计划:字符串
}
}); //payment route router.post('/billing/:plan_name',function(req,res,next) { var plan = req.params.plan_name; var StripeToken = req.body.StripeToken; console.log(StripeToken); if (!StripeToken) { req.flash('errors',{ msg: 'Please provide a valid card.' }); return res.redirect('/awesome'); } User.findById({ _id: req.user._iD},function(err,user) { if (err) return next(err); Stripe.customers.create({ source: StripeToken,// obtained with Stripe.js plan: plan,email: user.email }).then(function(customer) { user.Stripe.plan = customer.plan; user.Stripe.customerId = customer.id; console.log(customer); user.save(function(err) { console.log("success"); if (err) return next(err); return next(null); }); }).catch(function(err) { // Deal with an error }); return res.redirect('/'); }); });
我@R_696_10850@active_until时间戳和webhook事件?
每次条带向客户收费时,它都会生成一个webhook,即服务器上对某个指定URL的请求. Stripe可以出于不同的原因生成不同的webhook.
例如,当客户通过订阅收费时,Stripe会向您发送有关付款的信息.
router.post('/billing/catch_paid_invoice',res) { // Here you parse JSON data from Stripe }):
我现在无法访问Stripe设置,但请记住手动设置webhooks的URl.
选择您的帐户名称>帐户设置>网络挂接
active_until只是提醒客户,您的系统仍处于活动状态且已付费服务.在获取webhook时需要更新它.
条纹文档非常好,所以再次浏览它们.
https://stripe.com/docs/guides/subscriptions
以上是大佬教程为你收集整理的node.js – 如何使用条带webhooks更新用户的订阅日期?全部内容,希望文章能够帮你解决node.js – 如何使用条带webhooks更新用户的订阅日期?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。