> For the complete documentation index, see [llms.txt](https://apg-software-solutions.gitbook.io/bubblebase/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://apg-software-solutions.gitbook.io/bubblebase/apis/stripe/stripe-checkout-subscription-mode.md).

# Stripe Checkout (subscription mode)

Manages recurring payments through subscription-based billing.

When a user clicks on the "select plan" button in ⛏️Subscription Cards, custom workflows are triggered from the reusable element "🔐 SECURITY REDIRECT ", from which we use the [Retrieve Subscription API Call](broken://pages/pBKIDdEg51uLo1Kqcaa3) to check if the user is subscribed to a plan as follows:

#### &#x20;<mark style="background-color:yellow;">If</mark> <mark style="background-color:yellow;"></mark><mark style="background-color:yellow;">**user's retrieve subscription is 0**</mark> <mark style="background-color:yellow;"></mark><mark style="background-color:yellow;">(meaning not subscribed to any plan), this triggers a custom workflow to</mark> <mark style="background-color:yellow;"></mark><mark style="background-color:yellow;">**Create a subscription.**</mark> <mark style="background-color:yellow;"></mark><mark style="background-color:yellow;">Here are the steps:</mark>&#x20;

1. Calling the [Stripe Checkout (Subscription with price id) API](/bubblebase/apis/stripe/stripe-checkout-subscription-mode/stripe-checkout-subscription-with-price-id.md) by passing the price ID and ensuring the "mode" parameter is set to subscription.
2. Triggering the 📚 Log API Response custom if step 1 returned an error. Here we capture the error details to use it to create a new **dt\_API\_log** record and trigger a toast displaying the error body.
3. Navigating the user to a stripe hosted page by using result of step 1's **body url** as the destination. This stripe page allows the user to checkout using a credit card (it can also be configured from the Stripe's dashboard to accept other means of payment).

#### &#x20;<mark style="background-color:yellow;">If</mark> <mark style="background-color:yellow;"></mark><mark style="background-color:yellow;">**user's retrieve subscription > 0**</mark> <mark style="background-color:yellow;"></mark><mark style="background-color:yellow;">(meaning user is subscribed to a plan), this triggers a custom workflow to</mark> <mark style="background-color:yellow;"></mark><mark style="background-color:yellow;">**Update a subscription**</mark> <mark style="background-color:yellow;"></mark><mark style="background-color:yellow;">using a confirmation popup</mark> <mark style="background-color:yellow;"></mark><mark style="background-color:yellow;">**(**</mark><mark style="background-color:yellow;">🍿PU\_Action) which handles the steps for updating a subscription:</mark>&#x20;

1. Using the **Stripe - Update Subscription** action by passing in the subscription\_id, items\_id, and price\_id parameters from the Retrieve Subscription API Call.
2. Triggering the 📚 Log API Response custom if step 1 returned an error. Here we capture the error details to use it to create a new **dt\_API\_log** record and trigger a toast displaying the error body.
3. Triggering a toast if step 1 was successful.
