Promotion codes
A promotion code is a discount a customer types at checkout. To give one person a discount that applies without typing anything, use a customer discount. A code applies on every Checkout session in the mode it was created in: the API, a payment link, the hosted page and the embed. It is not limited to one product. An invoice does not take a code. Setallow_promotion_codes to false on a session to hide the field. See Checkout.
API and Console. The
/v1/promotion_codes routes create, list, read and switch off codes with a secret key that has the checkout scope. Console does the same under Checkout, Promotion codes, and follows the Test / Live switch. A code is made in one mode: a test key makes test codes, and a live key does not see them. Payment links use the live codes from Banking, Collections, Links.Routes
There is no
DELETE. Switch a code off with active: false, and it stops giving the discount.
Create a code
Every field is on Create a promotion code and Retrieve a promotion code. Those pages are the contract.code is 3 to 40 letters, numbers, - or _, saved in uppercase, so save20 is SAVE20. Send percent_off or amount_off, not both. amount_off is whole cents and needs currency. duration is once (the first payment, the default), forever, or repeating with duration_in_months from 1 to 36. The response is 201. amount_off is in cents. active is true only while the code is on and not archived. times_redeemed counts the payments that used it.
Codes are unique per mode among the ones not archived. A second SAVE20 in the same mode is 409 invalid_request with error.fields naming code. The same code in the other mode is fine.
Switch a code on or off
POST /v1/promotion_codes/:id takes active only. false turns the code off, and it stops working at once: a checkout started after that cannot use it. true turns it back on.
A code is immutable. Its discount, currency, duration, months, limit and end date are fixed, so changing any of them is 409 invalid_request, with error.fields naming the field. Make a new code instead. An archived code cannot change either.
Turning a code off is applied at the payment provider too, where the code was already used for a checkout. If the provider refuses the change, nothing changes and the call answers 503 api_error. Retry it.
GET /v1/promotion_codes lists this mode’s codes, newest first, with active=true or active=false as a filter. GET /v1/promotion_codes/:id reads one.
Where a code shows
On the hosted page, the overlay and the inline form, a customer sees Add promotion code whenever this mode has a code they can use. A valid code shows the amount off with a remove button. An invalid code reads “That code isn’t valid.” An amount off works on checkouts in that currency. A percent off works on every currency.Console
In Console, Checkout, Promotion codes. The page follows the Test / Live switch, so a test code is not in the live list. A code’s Code is 3 to 40 characters, uppercase. Discount is Percent off (1 to 100) or Amount off (with a currency). Applies to is First payment, A number of months (1 to 36) or Every payment. Times it can be used and Expires are optional. Each code in the list shows how many times it was used, and the limit if set. A switch turns the code on or off, and the Archive icon removes it from use. Archiving is Console only: a code archived in Console answers asactive: false and archived: true on the API.
Banking, Collections, Links, Promotion codes is the same live catalog, for payment links. It does not follow the Test / Live switch.
Webhooks
Creating or switching off a promotion code does not send a merchant webhook event.Errors
See Errors.
Customer discounts
A customer discount belongs to one person. You grant it to an email address. When that person checks out with that email, the discount applies and they see it. Nobody else can use it. Use a customer discount when the price is for someone in particular: a discount for a team, a veteran, a member of a community, or an agreed rate for one account. For a code anyone can type, use a promotion code.API and Console.
/v1/discounts grants, lists and switches off customer discounts with a secret key that has the checkout scope. Console does the same on a customer’s page, under Discounts. A discount is made in one mode: a test key makes test discounts.How it applies
- A checkout session created with a
customer_emailthat has an active discount applies it. The payer sees “Your discount is applied” and the amount off, with no code to type. - Send
customer_emailwhen you create the session. A discount can only apply to a session that knows the customer’s email. In a signed-in product you already have it, so pass it every time. A payment link, or a session created without an email, takes no customer discount: the payer pays the listed price, and can still use a public promotion code. - It applies to one-time payments and to subscriptions. A subscription with a
repeatingorforeverdiscount keeps the discount on each renewal, for as long as the duration lasts. - A discount is applied by Easner as a coupon on the payment provider’s side. A payer cannot type it, and it never appears as a code.
- A session that applies a customer discount does not show the Add promotion code field. Public promotion codes do not stack on a customer discount. This is set by the payment provider, which does not allow both on one session.
- A discount is matched on the email, without regard to capitals.
Ada@Example.comandada@example.comare the same person.
Routes
There is no
DELETE. To stop a discount, send active: false. It stops applying at once, to new checkouts and to renewals that have not yet been charged.
Grant a discount
POST /v1/discounts takes:
201:
Idempotency-Key. A retry with the same key and body answers 200 with the same discount.
One active discount per email. A second active discount for the same email in the same mode is 409. Switch the first one off, then grant the new one. This keeps the price for each person easy to explain.
Easner emails the customer when a discount is granted, from your business name: that the discount is on, what it changes, and for how long. The email never contains a code.
The amount and the duration are fixed. To change them, switch the discount off and grant a new one.
List and read
customer_email and active. Lists take limit and starting_after. See v1 reference.
Switch a discount off
active: false stops the discount at once. A subscription that already has it loses it at its next renewal. Charges already made are not changed. active: true switches it back on, if no other discount is active for the same email.
Processing fee
A discount cannot be combined with a processing fee that your customers pay. If you pass the fee to customers (Settings, Payments tab, Processing fees),POST /v1/discounts answers 409 with the message “Discounts can’t be combined with a processing fee paid by customers.” Change who pays the fee first.
Webhooks
Granting, listing and switching off a discount does not send a merchant webhook event. A subscription’s renewal still sendssubscription.updated, with the amount that was charged.
Console
In Console, open Checkout, Customers, then the customer. The Discounts section lists each discount with its value, its duration and whether it is active. Grant discount asks for the discount, then shows the new monthly amount before it is saved. Revoke asks first and says what the next invoice becomes. Past invoices do not change.Errors
See Errors.
