systemphil / symposia

Symposia is a philosophy course platform🏺
https://symposia.sphil.xyz
Apache License 2.0
6 stars 1 forks source link

Stripe integration #19

Closed Firgrep closed 5 months ago

Firgrep commented 11 months ago

Integrate Stripe, webhooks, etc. We will also have to figure out how we're relating the courses to the user and to Stripe.

Firgrep commented 11 months ago

Reminder

Added a field on the Course model for the stripe product ID. Currently set as optional in the schema but this should be necessary when we move closer to prod.

Firgrep commented 11 months ago

Started sketching out how the integration could work. My initial idea, which I now realize is rather silly and cumbersome, was to create the product and prices on the Stripe portal and then the admin would have to copy over the necesssary details for course creation.

Instead, it's better to bake in the product and price creation along with the course creation process using Stripe's API. Instead of the admin having to visit two platforms, they just use symposia, which handles all communication with Stripe. Now, this requires a bigger backend on our side but it pays off in user-friendliness and may actually save complexity elsewhere. Therefore, any course CRUD related matters must have the accompanying logic with Stripe, and I expect that we won't need to make use of a webhook here (at least for this) since the Stripe SDK will give us the responses we need as we do CRUD stuff related to courses, and that following these successful responses, the backend flow proceeds to do CRUD stuff for course information and essential stripe information on our db.

Firgrep commented 8 months ago

Began writing the backend code. I realized that a few of our tables were redundant and I moved the stripe product info as optional fields in the Course table. Learned that you cannot easily delete products and prices can never be deleted, only archived, so that requires a bit of rethinking in the backend flow. I am also not sure if we should have one product with multiple prices or multiple products with individual prices. Going to have to just test this out and see how it works as the docs aren't clear enough on this.