validateDiscountsCoupon
Validate a discount coupon code.
Description
This method validates a discount coupon code and checks whether it exists and is currently active. It takes a coupon code as input and returns a Promise that resolves to true if the coupon is valid or false if the coupon does not exist or has expired.
Discounts.validateDiscountsCoupon(
code*);
Parameters schema
Schema
code(required): string
The coupon code to validate
Examples
Minimal example
const response = await Discounts.validateDiscountsCoupon('SUMMER20');
Example response
{
"valid": true,
"coupon": {
"id": 1,
"discountId": 1,
"code": "SUMMER-KBWZ-2428",
"usedAt": null,
"isUsed": false,
"isReusable": false,
"orderId": null
}
}
Response schema
Schema: ICouponValidationResult
valid: boolean
Whether the coupon is valid.
coupon: unknown
Coupon data if the coupon is valid.
error: string
Error message if the coupon is invalid.