Skip to content

added webhook handling & publishable key#15

Merged
ncoop57 merged 1 commit into
mainfrom
webhook
May 16, 2026
Merged

added webhook handling & publishable key#15
ncoop57 merged 1 commit into
mainfrom
webhook

Conversation

@kafkasl
Copy link
Copy Markdown
Contributor

@kafkasl kafkasl commented May 15, 2026

There's 3 main changes:

  1. added publishable_key to StripeApi
  2. added webhook handling
  3. commented out all the high-level / helpers methods

However, the main goal for opening the PR is merge 1, the publishable key, because it's used by the solve-lp billing code. Number 2 & 3 are nice-to-haves but could be merged later, they might change shape a bit.

1. publishable_key

We added the publishable_key to the StripeApi class. This public key is used by stripe.js so we can collect the CC cards of the users through the `setupIntent (docs here. This is used by the upcoming solve-lp PR to set up payment intents.

2. Webhook handling

We added all the machinery necessary to process stripe webhooks. In order to make it nicer we created return classes for all the StripeApi objects using the component schemas from the OpenAPI. Those are the changes in spec.py and the new class StripeObj and stripe_obj in core.py.

The reason to add our own signature verification and webhook parsing is to avoid having to import both faststripe for API calls and then also the stripe official library for webhook handling (as it currently happens in plash & solve-lp). Having them in a single library will make it easier to test and make sure they remain in sync because we had an issue where stripe version was auto-updated and it broke our webhook handling.

We also added a service_name to the StripeApi. The service_name is an attempt to standardize how each app filters its own webhooks. Currently all apps receive all webhooks and handle them differently. Including metadata with the service name a then calling filter_events should make it easier.

However, this is not yet used, and including metadata in all webhooks is tricky because each API call includes it differently. Products, subscriptions and charges all have the metadata in a different place. If we end up migrating plash into solveit, this will not be a concern anymore, so we might not use it. I suggest leaving it for now, we are currently working on a how-to app (not commited here) and we might include it.

3 high-level methods

As agreed on discord all the high-level methods have been commented. They deal with creating Price, Products, Subscription, and one-time payments. None of those are required now that we'll use setupIntent + charges so it is likely we will get rid of them, or they might change shape.

Finally I added a .env.example because I feel it's very useful to quickly land and get a repo running.

@kafkasl kafkasl self-assigned this May 15, 2026
@kafkasl kafkasl added the enhancement New feature or request label May 15, 2026
@kafkasl kafkasl requested a review from jph00 May 15, 2026 18:20
Copy link
Copy Markdown
Contributor

@ncoop57 ncoop57 left a comment

Choose a reason for hiding this comment

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

this is great, thanks @kafkasl !

@ncoop57 ncoop57 merged commit b002222 into main May 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants