【发布时间】:2022-01-04 01:38:07
【问题描述】:
Stripe events 有很多不同的类型。此外,他们指出他们可以随时添加更多内容。我正在使用 dj-stripe。使用我的事件处理程序,我对应该监控哪些类型的 webhook 以实现非常简单的 Stripe 订阅设置有了一个很好的了解。在 dj-stripe 框架中是否有一种简单的方法来捕获我在生产中遇到的未处理的 webhook?在这些问题上,我想通过电子邮件向自己发送未处理的 Stripe webhook 事件。
例如,我有以下 webhook 处理程序:
@csrf_exempt
@webhooks.handler("checkout")
def my_handler(event, **kwargs):
print("handling checkout event...")
print(event.type)
@csrf_exempt
@webhooks.handler("customer")
def my_customer_handler(event, **kwargs):
print("handling customer event... in my_customer_handler")
print(event.type)
@csrf_exempt
@webhooks.handler("charge")
def my_charge_handler(event, **kwargs):
print("handling charge event... in my_charge_handler")
print(event.type)
@csrf_exempt
@webhooks.handler("payment_intent")
def my_payment_intent_handler(event, **kwargs):
print("handling payment_intent event... in my_payment_intent_handler")
print(event.type)
@csrf_exempt
@webhooks.handler("price", "product")
def my_price_and_product_handler(event, **kwargs):
print("handling price/product event... in my_price_and_product_handler")
print(event.type)
现在假设某种类型的发票 webhook 进来了。我知道 djstripe 会将此事件保存到 djstripe_invoice 表(通过 path('stripe/', include("djstripe.urls", namespace="djstripe")),)。但是,如果我想知道它不是当前在内置 dj-stripe URL 之外处理的 webhook 类型怎么办?我可以添加任何 webhook 签名来通知我发生了一个 webhook 事件,而我除了更新数据库之外没有做任何事情?
【问题讨论】:
标签: django stripe-payments webhooks