我已经创建了几个计划,并将条纹subscription.id和客户id保存到我的数据库中。现在,我正在创建webhook来接收JSON数据,以更新过期、if和其他一些字段。我现在所需要的就是弄清楚如何根据webhook是关于谁来过滤用户,以便我可以相应地更新模型。下面是我对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数据更新包。请帮帮忙。
发布于 2017-04-16 21:29:29
https://stripe.com/docs/api#subscriptions
https://stripe.com/docs/api#event_object
您可以从webhook事件中收到的数据中找到customer_id和subscription_id。您可以打印数据print(event_json['data'])
https://stackoverflow.com/questions/43221153
复制相似问题