Stripe checkout.js with coupons

Manuel picture Manuel · Aug 1, 2013 · Viewed 16.8k times · Source

I'm using Stripe's checkout.js because it's so easy to setup and use. Is there a way to add coupons?

<script src="https://checkout.stripe.com/v2/checkout.js"
    class="stripe-button"
    data-key="pk_test_czwzkTp2tactuLOEOqbMTRzG"
    data-amount="2000"
    data-name="Demo Site"
    data-description="2 widgets ($20.00)"
    data-image="/128x128.png">
</script>

Answer

Liyan Chang picture Liyan Chang · Nov 21, 2014

Stripe Checkout does not currently support coupons. It's not listed in the documentation, for either the button or the custom integration.

One might wonder if there is some secret feature. However, using undocumented features, especially when it comes to your payment processor is a bad idea. Full stop.


This being Stack Overflow - let's keep digging!

Fire up jsfiddle. Paste your code into the html section. Open up developer tools so you can see network requests.

There is a en.json, which is a internationalized strings file. If there is an input for coupons, there ought to be a label saying "Enter Coupon Code" or something similar. There is none. (Sure, there is the possibility that Stripe decided to hard code this particular string, but that seems unlikely).

https://checkout.stripe.com/v3/data/languages/en.json

You can also see that inner.js is used to power the popup. Copy the source into a js beautifier and you find that there is no mention. In fact, you can see the code that parses the options and none of them have to do with coupons.

"lib/optionParser": function(exports, require, module) {
    (function() {
        var BOOLEAN_OPTIONS, DEFAULTS, STRING_OPTIONS, URL_OPTIONS, extractValue, helpers, toBoolean, _;
        _ = require("vendor/lodash");
        helpers = require("lib/helpers");
        DEFAULTS = {
            currency: "usd",
            allowRememberMe: true
        };
        BOOLEAN_OPTIONS = ["billingAddress", "shippingAddress", "notrack", "nostyle", "allowRememberMe", "allowPhoneVerification", "zipCode", "trace", "alipayReusable", "bitcoin"];
        STRING_OPTIONS = ["key", "amount", "name", "description", "panelLabel", "currency", "email", "locale", "alipay"];
        URL_OPTIONS = ["url", "referrer", "image"];

You can see how each of the options here align one to one with the options that available for custom integration, which map to the options for the button (you just need to use hyphens instead of camelcase)

At this point, you can keep digging if you want to convince yourself further, but I'd be reaching out to Stripe Support and making a feature request. Happy digging!