Skip to main content
Nova.Pay supports coupon codes that reduce the order total for your customers. The recommended flow is to validate the coupon code first so you can display the discounted price before checkout, then pass the code when fetching payment plans and again when submitting the payment. This ensures the discount is applied consistently at every stage of the purchase.

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
Response:
code
string
required
The coupon code as stored in Nova.Pay (normalized, uppercased).
value
number
required
The discount magnitude. Interpretation depends on type:
  • When type is "percentage", this is the percentage to deduct (e.g. 20.0 = 20% off).
  • When type is "price", this is the fixed amount to deduct in the currency’s major unit (e.g. 15.0 = R$ 15.00 off).
type
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 the coupon 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
The response structure is identical to a normal /payment_plans call, but amount and instalment_amount values are already discounted.

Step 3: Apply the Coupon at Payment Time

Include the coupon 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 complete POST /payments request body that combines a coupon with a credit card payment:
And the same flow with Pix — no card fields needed:
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.