all repos — caroster @ e2598a4ee8509d750b345ddab93497d0102ac1d8

[Octree] Group carpool to your event https://caroster.io

STRIPE.md (view raw)

 1# Usage with Stripe
 2
 3Caroster can be linked to Stripe in order to manage modules for an event.
 4
 5> If your install your own instance of Caroster, you can ignore
 6> the configuration of Stripe. You will need to enable modules manually for
 7> each event (or add a lifecycle hook in Strapi).
 8
 9## Configuration
10
11Stripe link needs some configuration to declare in `backend/.env`:
12
13- `STRIPE_SECRET_KEY`: Stripe API secret key to communicate with Stripe
14- `STRIPE_ENDPOINT_SECRET`: Webhook secret to validate signatures
15
16Then, we need to configure "Modules" in Strapi admin to provide more precise
17configurations for Stripe.
18
19## Process
20
211. User clicks on "Activate" button on frontend
222. User is redirected to Stripe Payment link page configured for the targeted module
233. User fills form and processes payment
244. Backend (Strapi) receives a webhook from Stripe on successfull payment
255. Backend enables module for the targeted event
26
27## Development tool
28
29To simulate webhook in a local dev environment, you can use [Strip CLI](https://stripe.com/docs/stripe-cli).
30
31**Handle webhooks from your local env:**
32
33```bash
34stripe listen --forward-to localhost:1337/api/webhooks
35```
36
37**Simulate a payment for an event:**
38
39```bash
40# '7172ec65-5be1-4fcd-80cb-200914756d9a' is event's UUID
41stripe trigger checkout.session.completed  --add checkout_session:client_reference_id=7172ec65-5be1-4fcd-80cb-200914756d9a
42```