Checkout Sessions are a way to set up a subscription for your customers. You can create a Checkout Session for a specific amount and currency, and share the Checkout Session URL with your customers. Your customers can then subscribe using their preferred payment method.

Create a customer

Before creating a Checkout Session, you need to create a customer. You can create a customer using the Customers API

.

Create a customer
curl https://api.yorlet.com/v1/customers \
  -H "Authorization: Bearer {{API_KEY}}" \
  -H "Content-Type: application/json" \
  -d '{
        "email": "[email protected]"
      }'

If the request completed successfully, the response contains the customer object.

Customer object
{
  "id": "cus_lrhplff1u4ZhIPSU",
  "object": "customer",
  "email": "[email protected]"
  // ... other fields on the Customer object
}

Create a Checkout Session

To create a Checkout Session

, you need to specify the currency, customer, description, and subscription_data.

Create a Checkout Session
curl https://api.yorlet.com/v1/checkout_sessions \
  -H "Authorization: Bearer {{API_KEY}}" \
  -H "Content-Type: application/json" \
  -d '{
        "currency": "gbp",
        "customer": "{{CUSTOMER_ID}}",
        "payment_method_types": ["card"],
        "subscription_data": {
          "collection_method": "charge_automatically",
          "interval": "month",
          "interval_count": 1,
          "items": [
            {
              "description": "Monthly rent",
              "price_data": {
                "amount": 10000,
                "currency": "gbp",
                "tax_percent": 0,
              },
              "type": "rent"
            }
          ],
          "start_date": 1719225600
        }
      }'

If the request completed successfully, the Checkout Session object contains the url parameter.

Checkout Session object
{
  "id": "cks_lvu4xju9NAB38beQ",
  "object": "checkout_session",
  // ... other fields on the Checkout Session object
  "url": "https://pay.yorlet.com/checkout/cks_lvu4xju9NAB38beQ"
}

Share the Checkout Session URL

After creating a Checkout Session, you will receive a Checkout Session URL. Share this link with your customers so they can subscribe using their preferred payment method.

Handle the Checkout Session completion

When your customers complete the checkout process, you will receive a webhook event. You can use the Webhooks API

to handle the event.