Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Platform listener always receives both direct events and connect account events in webhook #1127

Open
nerder opened this issue Oct 10, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@nerder
Copy link

nerder commented Oct 10, 2023

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

  1. Create 2 endpoints, one for connected events and one for platform events
  2. Setup 2 listener with the same event for both webhook endpoint
  3. Fire that event from the connected account

Traceback

Share any debug output that was given by the CLI

Environment

macOS
stripe-cli: latest

@nerder nerder added the bug Something isn't working label Oct 10, 2023
@etsai-stripe
Copy link
Contributor

@nerder could you please list out the CLI commands you used to create those endpoints?

@nerder
Copy link
Author

nerder commented Nov 30, 2023

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

@vcheung-stripe
Copy link
Collaborator

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants