Platform listener always receives both direct events and connect account events in webhook
nerder opened this issue · comments
Issue
From my testing it seems like that when an event is triggered from the connected account, and a listener for a platform is present, that listener will be invoked as well.
Expected Behavior
Only the connected webhook listener is to be called, as in the actual live environment.
Steps to reproduce
- Create 2 endpoints, one for connected events and one for platform events
- Setup 2 listener with the same event for both webhook endpoint
- Fire that event from the connected account
Traceback
Share any debug output that was given by the CLI
Environment
macOS
stripe-cli: latest
@nerder could you please list out the CLI commands you used to create those endpoints?
I'm using the docker containers, so in my docker compose I have this:
stripe-cli-connected:
image: stripe/stripe-cli:latest
container_name: stripe-cli-connected
command: >
listen
--device-name ${DEVICE_NAME}-connected
--events=customer.created,customer.deleted,customer.updated,customer.subscription.created,customer.subscription.updated,customer.subscription.deleted,payment_method.attached,payment_method.detached,invoice.paid
--forward-connect-to http://localshost:5001/connected/stripe-connected
environment:
- STRIPE_API_KEY
- DEVICE_NAME
stripe-cli-platform:
image: stripe/stripe-cli:latest
container_name: stripe-cli-platform
command: >
listen
--device-name ${DEVICE_NAME}-platform
--events=customer.created,customer.deleted,customer.updated,payment_method.attached,payment_method.updated,payment_method.detached
--forward-to http://localshost:5001/platform/stripe-platform
environment:
- STRIPE_API_KEY
- DEVICE_NAME
@nerder I recommend setting --forward-connect-to
to a dummy URL in your platform listener. Your platform listener will still receive connect events, but they will be forwarded to your dummy URL.
stripe-cli-connected:
image: stripe/stripe-cli:latest
container_name: stripe-cli-connected
command: >
listen
--device-name ${DEVICE_NAME}-connected
--events=customer.created,customer.deleted,customer.updated,customer.subscription.created,customer.subscription.updated,customer.subscription.deleted,payment_method.attached,payment_method.detached,invoice.paid
--forward-connect-to http://localshost:5001/connected/stripe-connected
environment:
- STRIPE_API_KEY
- DEVICE_NAME
stripe-cli-platform:
image: stripe/stripe-cli:latest
container_name: stripe-cli-platform
command: >
listen
--device-name ${DEVICE_NAME}-platform
--events=customer.created,customer.deleted,customer.updated,payment_method.attached,payment_method.updated,payment_method.detached
--forward-to http://localshost:5001/platform/stripe-platform
--forward-connect-to dummy
environment:
- STRIPE_API_KEY
- DEVICE_NAME
When --forward-to
is provided without --forward-connect-to
, we forward events from the platform and connected accounts to the same URL. To forward them to different URLs, we usually recommend running one listen
session with both --forward-to
and --forward-connect-to
. For example:
command: >
listen
--events=customer.created,customer.deleted,customer.updated,customer.subscription.created,customer.subscription.updated,customer.subscription.deleted,payment_method.attached,payment_method.detached,invoice.paid
--forward-connect-to http://localshost:5001/connected/stripe-connected
--forward-to http://localshost:5001/platform/stripe-platform
However, this doesn't support specifying different event types or device name for each kind of endpoint, which is why I recommend using a dummy endpoint.
Let me know if this helps.