是否可以验证 Webhook 事件已注册/触发事件?

huangapple go评论64阅读模式
英文:

Is it possible to validate a Webhook Event is registered / Trigger an event?

问题

  1. 有没有办法验证是否将payment_intent.succeeded重定向到Webhook(当然是在客户被收费之前)?
  2. 或者有没有通过API触发事件的方法?

我知道可以通过CLI触发事件:

stripe trigger payment_intent.succeeded

但在这种情况下对我没有帮助。

英文:

I integrated Stripe into our application. Now I need to make sure, our customers configured it correctly, so I can show a warning instead of the checkout form.

My first thought was, when a payment_intent.created comes to my webhook, I update some state in my database, that the webhook was receiving it, and before checkout, I will validate against this.

However, the customer can select specific events, which will be signaled to the webhook. If he doesn't have payment_intent.succeeded enabled, it will never been fired. And that's what I need to validate most specificaly.

So:

  1. Is there a way, to validate, if the payment_intent.succeeded is redirected to the webhook (of course before a customer gets charged)?
  2. Alternative: Is there a way to trigger an Event via API?

I know, I can trigger an Event via the CLI:

stripe trigger payment_intent.succeeded

But this doesn't help me in this case.

答案1

得分: 1

Stripe CLI的方法将在以下情况下起作用:如果您的CLI实例已登录到客户的Stripe帐户,或者您可以使用他们的API密钥。这将允许您指定实时API密钥。

如果您拥有客户的API密钥,您可以使用Webhooks API。您可以检索客户帐户的Webhooks并检查它们配置了哪些事件。您甚至可以更新Webhook以侦听payment_intent.succeeded事件,如果目前未侦听。

英文:

The Stripe CLI approach would work if your CLI instance was signed in to your customer's Stripe account or you could use their API keys. This would allow you to specify the live API key as well.

If you have the customer's API keys, you can use the Webhooks API. You can retrieve the webhooks for the customer's account and examine what events they are configured for. You can even update the webhook to listen for the payment_intent.succeeded event if it is not currently being listened to.

huangapple
  • 本文由 发表于 2023年6月16日 04:17:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/76485231.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定