Coupons

Billwerk+ Premium & Enterprise allows you to provide discounts to customers through Coupon Codes, which can be applied to subscription orders and upgrade or downgrade orders.

Applying a Coupon Code

To apply a Coupon Code, include it in the Cart object when creating an order. Here is an example of how to add a Coupon Code to a cart object:

var cart = {
    "planVariantId": "527caacdeb596a247c6e0500",
    "couponCode": "ACB-123"
};

Coupon Code Validation

When you pass the Cart object to SubscriptionJS methods, the system validates the Coupon Code. An error with the code InvalidCouponCode will be returned if the Coupon Code is not valid.

The Preview() method operates differently. It returns an Order object regardless of Coupon Code validity. For a valid Coupon Code, the response includes a Coupon object with details:

{
    "Order": {
        "Coupon": {
            "CouponCode": "ABCDEF",
            "CouponId": "55d31a7d68a44f270478425d",
            "DiscountId": "55d31a4e68a44f2704784259"
        },
        // Additional order details...
    }
}

For an invalid Coupon Code, the response will contain an error message within the Coupon object:

{
    "Order" : {
        "Coupon":{
            "CouponCode":"ABCDEF",
            "ErrorMessage":"CouponCode is invalid",
            "ErrorCode":"InvalidCouponCode"
        },
        ...
    }
}

Normalization of Coupon Codes

Coupon Codes are converted to uppercase alphanumeric values before validation. This means input like 'ABc12-3' normalizes to 'ABC123'. The normalization process is consistent with the code entries in the Billwerk+ Premium & Enterprise Admin UI, ensuring that 'AB-C1-23' specified by an admin will match a customer-entered 'ABc12-3'.