Flex Checkout guide
1
Create an API Key in the partner dashboard
In the partner dashboard, navigate to the Developers section. Here you’ll find
an API Keys tab where you can create a key to interact with Flex.Select the
New API Key button and give your key a name. With this key, you can now
make authenticated requests to the Flex API.2
Define a product to sell
Always keep sensitive information—like price and availability—on your server to
prevent customer-side manipulation. Define product data when creating the Checkout
Session using predefined price IDs or on the fly with
price_data.For this example, we’ve created a product eligible via a Letter of Medical Necessity.
To learn more, see the Product docs or
the Product API.3
Define the price for our product
Using the returned
product_id, create a one-time price for $50.99:4
Choose the mode
Checkout supports two modes:
payment (one-time purchases) or subscription.
Learn more about subscription and setup modes in the docs.5
Supply success and cancel URLs
Specify publicly accessible URLs so Flex can redirect after checkout:
success_url:https://withflex.com/thank-you?success=truecancel_url:https://withflex.com/thank-you?canceled=true
6
Build your checkout
On your site’s order preview page, add a button that calls your server to generate
a checkout session.
7
Generate a checkout session
On your server, create a session with your line items and redirect URLs:
8
Redirect users to checkout
The response includes a
redirect_url—send the user there to complete payment:9
Try it out
Navigate to the returned
redirect_url and test with these cards:- Success:
4242 4242 4242 4242 - Decline:
4000 0000 0000 9995
10
Congratulations!
You now have a basic checkout integration working 🎉