0
我創建了一些計劃並將Stripe subscription.id和客戶ID保存到我的數據庫中。現在我正在創建webhook來接收JSON數據以更新過期日期以及是否其他字段。我現在需要弄清楚如何根據webhook的用戶來過濾用戶,以便相應地更新模型。以下是我對Flask中webhook的看法。如何在Python/Flask中使用條帶webhook識別客戶
@app.route('/webhooks', methods=['GET', 'POST'])
def webhook():
event_json = json.loads(request.data)
event = stripe.Event.retrieve(event_json['id'])
if event.type == 'invoice.payment_succeeded':
# Not sure how to query specific user what event is about
invoice = event.data.object
elif event.type == 'customer.subscription.updated':
#or
elif event.type == 'customer.subscription.active_until':
subscription = event.data.object
我創建6個計劃和所有正在這樣的罰款,我可以從本地服務器中刪除,並會從磁條自動刪除。我創建了一個計劃,並且它也被更新爲條帶。我需要的是使用webhook數據更新更新包的「日期」。請幫忙。