我已将djstripe Webhook订阅删除Webhook配置为保存具有取消状态的订阅。
from djstripe import webhooks
import djstripe.model
@webhooks.handler("customer.subscription.deleted")
def subscription_deletion_handler(event, **kwargs):
data = event.data.get("object", {})
djstripe_subs_status = data.get('status')
djstripe_subs_id = data.get('id')
djstripe_subscription = djstripe.models.Subscription.objects.get(id=djstripe_subs_id)
djstripe_subscription.status = djstripe_subs_status
djstripe_subscription.save()
但是在获取订阅对象时,它会抛出
djstripe.models.billing.subscription.DoesNotExist
异常,并自动从数据库中删除了对象。请更正我,让我知道以上代码中是否有任何问题。