4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Stripe CliのWebhookのイベントを細かく管理する

Last updated at Posted at 2025-01-23

決済サービスのStripeは、Stripe Cliを使うことでローカル上でもWebhookのテストが行えて便利です。

通常stipe Cliはコマンドを実行すると一つのエンドポイントでテストが可能です。
しかし、今回複数のエンドポイントでwebhookのイベントごとに分けたいケースがありました。
そのような場合はBash処理にすることで複数のエンドポイントがあってもWebhookのテストを行うことが出来、便利です。

#!/bin/bash

# 各イベントを別々のエンドポイントに転送
stripe listen --events customer.subscription.updated --forward-to http://localhost:8080/stripe/webhook/subscription-updated &
pid1=$!

stripe listen --events checkout.session.completed --forward-to http://localhost:8080/stripe/webhook/checkout-completed &
pid2=$!

wait $pid1 $pid2
4
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?