Before you start
Create the code in Product Catalog → Discounts and check that it:- is active and has not expired;
- has not reached its redemption limit;
- applies to the selected product and plan; and
- uses the same currency as the price when it is a fixed-amount discount.
Let the customer enter a code
When creating a checkout session through the API, setdiscountsEnabled to true. This shows the discount-code field so the customer can enter an eligible code.
discountsEnabled defaults to true. Set it to false only when you want to hide discount-code entry for that session.
Pre-apply a code with the Checkout API
Pass the code asdiscountCode in the JSON request body. Kelviq validates it while creating the checkout session. If the code is inactive, expired, or not valid for the selected plan, the request fails instead of creating a session with the wrong price.
checkoutUrl. Before completing payment, confirm that checkout shows the code, adjusted price, currency, and billing period you expect.
Pre-apply a code in a static checkout link
For a static product checkout link, use the snake-casediscount_code query parameter:
The names are different by design: use
discountCode in an API JSON body and discount_code in a static checkout URL.Test the integration
Test the complete flow in sandbox before using a production code:- Create a sandbox discount and an eligible product price.
- Create the checkout session with the matching sandbox API key.
- Open the returned checkout URL.
- Confirm the original price, discount, tax, and final total.
- Complete payment with a sandbox payment method and check the resulting order.
Troubleshooting
For the complete request and response schema, see Create a checkout session API reference.