Skip to main content

Welcome to our Dev Docs!

Coupons

To grant a discount you can offer Coupon Codes to your customers. A single Coupon Code can be passed with each subscription or up-/downgrade order. A Coupon Code is passed in the Cart object:

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

The Cart object can be passed several SubscriptionJS methods. If the Coupon Code is invalid an error with the code InvalidCouponCode will be returned.

The Preview() method is an exception. It'll return an Order object in either case. It contains the sub object Coupon with detailed information.

Valid Code passed to Preview():

{
    "Order" : {
        "Coupon":{
            "CouponCode":"ABCDEF",
            "CouponId":"55d31a7d68a44f270478425d",
            "DiscountId":"55d31a4e68a44f2704784259"
        },
        ...
    }
}

Invalid Code passed to Preview():

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

Notice

Coupon Codes are normalized to uppercase alphanumeric values before beeing validated. This means that a customer might enter 'ABc*12-3' which will be normalized to 'ABC123'.

The same is done with the codes specified in the billwerk Admin UI. This means a specified code 'AB-C1-23' will match the customer's code 'ABc*12-3'.