Step 1: Validate a Coupon
Before showing the discounted price to a customer, verify that the coupon code exists, is active, and applies to the product being purchased. Endpoint:GET /coupons/{code}/validate
string
required
The coupon code as stored in Nova.Pay (normalized, uppercased).
number
required
The discount magnitude. Interpretation depends on
type:- When
typeis"percentage", this is the percentage to deduct (e.g.20.0= 20% off). - When
typeis"price", this is the fixed amount to deduct in the currency’s major unit (e.g.15.0= R$ 15.00 off).
string
required
Discount strategy. One of:
If the coupon code is invalid, expired, or does not apply to the specified product, the API returns
422 Unprocessable Entity with a descriptive error message. Always handle this case in your UI so customers can correct the code.Step 2: Fetch Payment Plans with the Coupon
Once you have a valid coupon, pass it as thecoupon query parameter when fetching payment plans. Nova.Pay recalculates plan amounts server-side and returns prices that already reflect the discount — you can display these directly to the customer without any client-side arithmetic.
Endpoint: GET /payment_plans
products is required for checkout-page requests. The response is grouped by payment method, and each option’s value is the per-installment amount with the valid coupon applied. This example assumes a product total of 100, a 20% coupon, no fees, and all three methods configured.
fixed and percentage, both already included in value. Do not apply these fees again. See the Payment Plans reference for the complete field descriptions.
Step 3: Apply the Coupon at Payment Time
Include thecoupon field in your POST /payments request body. Nova.Pay validates the coupon again server-side and applies the discount to the charge.
Endpoint: POST /payments
Full End-to-End Example
Here is a completePOST /payments request body that combines a coupon with a credit card payment:
If the coupon code passed in
POST /payments is invalid or does not apply to the selected products, Nova.Pay returns 422 Unprocessable Entity with an error message identifying the problem. Make sure your checkout UI surfaces this error clearly so customers can enter a different code or proceed without a coupon.