Custom Solutions

  • You can handle all the rendering and create your own custom pricing/plan page and use a multi-step process with our REST endpoints to create checkout sessions. This is best for established companies with an existing workflow.

Before you continue, have a look at our page on Checkout Sessions and make sure your configuration is set up.

Custom

If you have an existing workflow or a design theme you really want to follow for your pricing page, this process is for you!

This process is fairly straightforward :

  1. Render a list of all the currently available products.

    Create a GET request with your Public Key to https://api.archetype.dev/public/v1/api/{YOUR_PUBLIC_KEY}/tiers

    This returns a JSON list of products that are currently publicly available. The response will be a JSON list of Products formatted like below.

Field

Description

name

String: The public name of the product. This will be displayed everywhere that is user facing.

description

String: The description of the product. This is an opportunity to explain your features and the specific details of how your users' lives will be improved using your product.

has_full_access

Bool: Flag for if the product has access to all your endpoints. This exists because certain products may not have access to premium endpoints.

has_quota

Bool: Flag for if the product has a quota. If False, users subscribed to this product essentially have unlimited API calls to your backend barring rate limits.

has_trial

Bool: Flag for if the product has a quota. If False, users subscribed to this product essentially have unlimited API calls to your backend barring rate limits.

is_free

Bool: Flag for if the product is free.

period

Enum for the billing cycle or how often subscribers get charged.
Options are month or year. Check out Products for more details.

price

Double: The price in USD of the product for each period. Currently all products are subscription based.

quota

int: The amount of API calls subscribers get per month. If has_quota is false this field is ignored.

tier_id

String: The id of the product. This is important for you to create checkout sessions and in the next step of pricing integration.

trial_length

int: The number of trial_time_frame the trial lasts. If has_trial is false this field is ignored.

trial_time_frame

Enum:

The number of trial_time_frame the trial lasts. If has_trial is false this field is ignored.

Options are day, week and month.

Example

[
    {  
        "name": "Basic", 
        "description": "Basic Description", 
        "has_full_access": true, 
        "has_quota": true, 
        "has_trial": false, 
        "is_free": false,
        "period": "month", 
        "price": 40.0, 
        "quota": 1000, 
        "tier_id": "prod_KqVFQR9chN5jB0", 
        "trial_length": 1, 
        "trial_time_frame": "month" 
    }
    ...
]

📘

Looking for more details on Products?

For more details on what you can do with the products, head over to Products.

With this you'll be able to get all the relevant details like the price, quota, trial length and features.

When a user is ready to subscribe to a tier, you'll need the tier_id for the specific product to create a checkout session for the next step.

  1. Create a custom checkout session when a user clicks "subscribe" or tries to sign up for a plan.

You need to create a POST request to:

https://api.archetype.dev/public/v1/api/create-checkout-session

and add these to the body:

Request Body

Key

Details

uid

Your custom UID that you've generated for the user. Make sure this correlates to the UID you've mapped to Archetype.

tier_id

The tier_id field inside the product that the user clicks on or wants to subscribe to.

This request will return the below checkout session url.

Redirect your user to the newly generated checkout session url. This will take them through the flow and once the user completes or cancels the flow, it'll take them to the return url or redirect url you set in your API settings.

Response

{
    "url": "CHECKOUT_SESSION_URL"
}

Once they've completed the checkout session, they'll be redirected to the url you set for the redirect_url in your settings page.

Notes

  • The uid will be whatever unique identifier you've set for each user. This needs to be static and unchanging.

  • If the user has not been previously registered before, we'll automatically create a new user with the default parameters.

Check out our Users page for more details.

  • Checkout sessions are ephemeral so you'll always have to create a new checkout session. Do not try to cache a checkout session for each user.

  • These are for currently signed in users, default behavior for non-signed in users should be to take them to your signup flow and keep their planned tier in your session to direct them.


Did this page help you?