【发布时间】:2018-02-18 06:53:22
【问题描述】:
我在Java Spring MVC Web Application 中配置了Stripe 付款。我可以添加Customer,创建Plan 并为客户设置Subscriptions。由于我有定期付款,我想在生成发票和付款后向客户发送电子邮件通知。从 Stripe 文档中,我需要的事件类型是 invoice.upcoming.、invoice.payment_succeeded 和 customer.subscription.trial_will_end,因为我有几个计划的试用期。
我在我的应用程序中添加了一个 webhook 端点,如下所示:
@ResponseBody
@RequestMapping(consumes="application/json", produces="application/json", method=RequestMethod.POST, value="/webhook-endpoint")
public Response stripeWebhookEndpoint(@RequestBody String stripeJsonEvent)
{
Event event = Event.GSON.fromJson(stripeJsonEvent, Event.class);
String type = event.getType();
StripeObject stripeObject = event.getData().getObject();
return Response.status(Response.Status.OK).build();
}
我正在尝试获取event type 和customer Id,以便能够从我的数据库中获取客户并根据事件发送电子邮件通知。因为我的 localhost 中有我的 webhook url,所以我无法从 Stripe 触发实际数据。我也无法从 Stripe 文档中找到示例数据:https://stripe.com/docs/api#invoice_object。我也试过Retrive stripe data from stripe webhook event,但没有一些样本数据就无法测试。
有什么方法可以让我从活动中获取所需的详细信息,并在我的本地主机上进行测试。
【问题讨论】:
标签: java stripe-payments webhooks