# Stripe

> Connect Stripe to your Cademí: the product, price or payment link ID, the optional restricted key and the webhook endpoint with the right events.

Connect Stripe to your Cademí so each confirmed payment gives the student access on its own. You need the identifiers of what you sell on Stripe and a webhook endpoint pointing to Cademí. The restricted API key is optional.

## 1. Create the delivery in Cademí

1. In the Cademí dashboard, open **Sales > Deliveries** and add a delivery.
2. In **Select a Gateway**, pick **Stripe**.
3. In **Delivery Name**, enter a name that helps you recognize it later.
4. In **Sales Mode**, choose **One-time sale** or **Subscription**, matching the billing on Stripe.
5. The **Gateway connection** section shows the **Product ID, Price ID or Payment Link ID** field, the **Restricted API Key (optional)** field and the **Postback URL**.

Keep the delivery open: you come back to it in the next steps.

## 2. Find the identifiers on Stripe

Register the **product ID** and the **payment link ID** the student uses to buy. You need both: the purchase arrives through the payment link, but in some notices, such as a subscription cancellation, Stripe sends only the product ID.

**Product ID:**

1. In the Stripe dashboard, open **Products** and click the product.
2. Copy the product ID in the **Details** box.
3. Paste it into **Product ID, Price ID or Payment Link ID** in the Cademí delivery.

**Payment link ID:**

1. In the Stripe dashboard, open **Payment Links** (under **More**, if it is not in the top menu).
2. Open the link and copy its ID.
3. Paste it into the same delivery field, next to the product ID.

**One product or several:** use the same Stripe product for different billing (monthly and yearly, for example) when the student gets the same access in Cademí. Create another product, with another delivery, when the access changes, such as one course released daily and another released weekly.

## 3. Set up the webhook

1. In the Stripe dashboard, open **Developers > Webhooks** and click **Add endpoint**.
2. In **Endpoint URL**, paste the **Postback URL** of the delivery.
3. In **Events to send**, select: `checkout.session.completed`, `invoice.paid`, `invoice.payment_failed` and `customer.subscription.deleted`.
4. Click **Add endpoint** and, in Cademí, save the delivery.
