我的基本设置是创建一个会话,并使用checkout.session.complete为true时发送的Stripe Webhook完成付款。
但是要能够更新数据库中的current_period_end,当invoice.payment_succeeded为true时,我必须使用webhook。
这可以一起工作,但是,我有问题!
问题::当用户第一次订阅时,Stripe发送一个checkout.session.complete和invoice.payment_succeeded的webhook。
我只想在用户首次订阅时只接收checkout.session.complete,因此可以防止第一次发送invoice.payment_succeeded /当发送checkout.session.complete时?
答案 0 :(得分:1)
invoice
对象具有属性billing_reason。如果invoice.payment_succeeded
的webhook事件是通过创建新的订阅触发的,则billing_reason
的值将为“ subscription_create”。
答案 1 :(得分:0)
根据在条带上找到的客户或未通过 api 搜索找到的客户,将“meta_data”设置为 cusotmer 的类型。这将有助于在您收到付款时进行比较。