Skip to content

Conversation

@shahzaib-ali-khan
Copy link

Implement Stripe webhook for invoice.paid

The method stripe_webhook() is a generic one and can be used for other events as well. To support other events, separate methods should be created and hooked up in SUPPORTED_EVENTS

  • Webhook endpoint is /webhooks/stripe that handles invoice.paid events from Stripe
  • Signature verification to ensure request is coming from Stripe
  • Checks if tenant_id is in the metadata of Invoice object then scope is Tenant otherwise Host
  • Create BillingRecord object in the database

How to test:

  • Stripe module should be enabled
  • Stripe API_KEYS and WEBHOOK_SECRET should be set

Other than webhook implmentation. This PR also add OS independence while creating temp files

from api.interfaces.api_controllers.prices_endpoint import router as prices_router
from api.interfaces.api_controllers.billing_endpoint import router as billing_router
from api.interfaces.api_controllers.stripe_endpoint import router as stripe_router
from api.interfaces.api_controllers.webhook.stripe import router as stripe_webhook_router
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already a stripe_endpoint.py please use that

/webhooks

@sajanv88
Copy link
Owner

@shahzaib-ali-khan Can you please resolve the conflict?

@shahzaib-ali-khan
Copy link
Author

@shahzaib-ali-khan Can you please resolve the conflict?

Done

Copy link
Owner

@sajanv88 sajanv88 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tenant and scope check is missing.. and move the webhook inside stripe endpoint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants