> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chip-in.asia/llms.txt
> Use this file to discover all available pages before exploring further.

# Subscriptions

## Example Use Cases

|                                            |
| ------------------------------------------ |
| Recurring Memberships                      |
| SaaS (Software-as-a-Service) Products      |
| Educational Content & Courses Subscription |

## API Required

1. [Create Purchase API](/chip-collect/api-reference/purchases/create)
2. [Charge Token API](/chip-collect/api-reference/purchases/charge)

## Example Cases

1. [Subscription With Free Trial](/chip-collect/overview/online-purchases/subscription#1-subscription-with-free-trial)
2. [Subscription With Registration Fee](/chip-collect/overview/online-purchases/subscription#2-subscription-with-registration-fee)

## 1) Subscription With Free Trial

Alan subscribes to a gym membership with a free trial and a monthly subscription of RM 5.00.

1. Create a registration fee using the [Purchases API](/chip-collect/api-reference/purchases/create)
   <br /> - get `checkout_url` from the response body to be used as a payment link
   <br /> - get `id` from the response body to be used as a token
   <br /> *Note: Alan's card must be validated in order for the token to be usable.*

```js theme={null}
{
  "client": {
    "email": "customer@example.com",
    "full_name": "Alan"
  },
  "purchase": {
    "products": [
      {
        "name": "Free Trial",
        "price": 0
      }
    ]
  },
  "skip_capture" : true,
  "brand_id": "<<Brand_id>>"
}
```

2. Create a monthly subscription using the [Purchases API](/chip-collect/api-reference/purchases/create)
   <br /> - get `id` from the response body to be used as a payment link

```js theme={null}
{
  "client": {
    "email": "customer@example.com",
    "full_name": "Alan"
  },
  "purchase": {
    "products": [
      {
        "name": "Subscription fee",
        "price": 500
      }
    ]
  },
  "brand_id": "<<Brand_id>>"
}
```

3. Charge subscription fee id with registration fee id using [Charge token API](/chip-collect/api-reference/purchases/charge)
   <br />Example API : .../purchases/`monthly_subscription_fee_id`/charge/

```js theme={null}
{
  "recurring_token" : "<<free_trial_id>>"
}
```

## 2) Subscription With Registration Fee

Alan subscribes to a gym membership with a registration fee of RM 20.00 and a monthly subscription of RM 5.00.

1. Create a registration fee using the [Purchases API](/chip-collect/api-reference/purchases/create)
   <br /> - get `checkout_url` from the response body to be used as a payment link
   <br /> - get `id` from the response body to be used as a token
   <br /> *Note: Alan's registration fee must be paid in order for the token to be usable.*

```js theme={null}
{
  "client": {
    "email": "customer@example.com",
    "full_name": "Alan"
  },
  "purchase": {
    "products": [
      {
        "name": "Registration Fee",
        "price": 2000
      }
    ]
  },
  "payment_method_whitelist" : ["visa", "mastercard", "maestro"],
  "force_recurring" : true,
  "brand_id": "<<Brand_id>>"
}
```

2. Create a monthly subscription using the [Purchases API](/chip-collect/api-reference/purchases/create)
   <br /> - get `id` from the response body to be used as a payment link

```js theme={null}
{
  "client": {
    "email": "customer@example.com",
    "full_name": "Alan"
  },
  "purchase": {
    "products": [
      {
        "name": "Subscription fee",
        "price": 500
      }
    ]
  },
  "brand_id": "<<Brand_id>>"
}
```

3. Charge subscription fee id with registration fee id using [Charge token API](/chip-collect/api-reference/purchases/charge)
   <br />Example API : .../purchases/`monthly_subscription_fee_id`/charge/

```js theme={null}
{
  "recurring_token" : "<<registration_fee_id>>"
}
```

## Testing Integration

It’s possible to test-drive all checkouts using a test Purchase.

To test a successful payment, you can use the following card numbers:

* 4444 3333 2222 1111 - non-3D Secure card
* 5555 5555 5555 4444 - 3D Secure card

For both cards, please use:

* any cardholder name
* any expiry no earlier than the current month/year
* CVC = 123

To test a failed payment, please change the CVC or expiration date.

When using a 3D Secure enrolled card in S2S checkout, an incorrect CVC will trigger an authorization failure on the S2S callback step (after the customer returns from test ACS). Using a wrong expiry date emulates data validation failure and results in immediate error before that step.

## FAQ

Frequently asked questions regarding subscriptions.

1. Does CHIP handle the automatic renewal of subscriptions? <br />
   No, CHIP does not handle automatic renewal. What CHIP offers is the ability to save and charge a customer's saved card. The automatic renewal logic must be implemented on the merchant's side, for example using a cron job or other scheduling mechanism.

2. What happens if I accidentally charge the customer's card twice? <br />
   Once the payment link is paid, any subsequent payment attempt will be blocked. As a result, the likelihood of a double charge issue is extremely low.

3. What is the token tied to? <br />
   The token is tied to `brand_id`.

4. How is the token referenced? <br />
   The token uses `customer_email` as a reference.

5. Where can I see my customer's tokens? <br />
   You can list the tokens for a customer using the [List Token API](/chip-collect/api-reference/clients/list-recurring-tokens).

6. How do I delete the token? <br />
   You can delete a token using the [Delete Token API](/chip-collect/api-reference/purchases/delete-recurring-token).
