Add discounts
Learn how to apply discounts with coupons and promotion codes in your custom integration.
You can use discounts to reduce the amount charged to a customer. Coupons and promotion codes allow you to:
- Apply a discount to an entire purchase subtotal
- Apply a discount to specific products
- Reduce the total charged by a percentage or a flat amount
- Create customer-facing promotion codes on top of coupons to share directly with customers
クーポンを作成する
クーポンは固定額の割引を指定します。1 つのベースとなるクーポンにマッピングされる、顧客向けのプロモーションコードを作成できます。つまり、FALLPROMO
と SPRINGPROMO
の両方のコードを 1 つの 25% 割引のクーポンに関連付けることができます。クーポンは、ダッシュボードまたは API で作成できます。
Use a coupon
To create a session with an applied discount, pass the coupon ID in the coupon
parameter of the discounts array. Checkout Sessions support up to one coupon or promotion code.
Configure a coupon
Coupons have the following parameters that you can use:
currency
percent_
oroff amount_
off max_
redemptions redeem_
: The latest date customers can apply the couponby applies_
: Limits the products that the coupon applies toto
Limit redemption usage
The max_
and redeem_
values apply to the coupon across every application. For example, you can restrict a coupon to the first 50 usages of it, or you can make a coupon expire by a certain date.
Limit eligible products
You can limit the products that are eligible for discounts using a coupon by adding the product IDs to the applies_
hash in the Coupon
object. Any promotion codes that map to this coupon only apply to the list of eligible products.
Delete a coupon
You can delete coupons in the Dashboard or the API. Deleting a coupon prevents it from being applied to future transactions or customers.
プロモーションコードを作成する
プロモーションコードは、クーポンに加えて作成される顧客向けのコードです。また、顧客がプロモーションを適用できる期間を管理する追加の制限を指定することもできます。これらのコードは顧客に伝えることができ、顧客が購入時に入力すると割引の適用を受けることができます。
promotion code (プロモーションコード) を作成するには、既存の coupon
と制限 (たとえば、特定の customer
に制限するなど) を指定します。顧客に提供したい特定のコードがある場合には (FALL25OFF
など)、code
を設定します。このフィールドを空白にすると、ランダムな code
が生成されます。
この code
では大文字小文字が区別され、すべての顧客向けの有効なプロモーションコードの中で一意になります。以下に例を挙げます。
- 同じ
code
を使用して、対象の顧客が制限された複数のプロモーションコードを作成できますが、そのcode
を再利用して、すべての顧客が引き換えできるプロモーションコードを作成することはできません。 - あらゆる顧客が引き換え可能なプロモーションコードを作成する場合、同じ
code
で別の有効なプロモーションコードを作成することはできません。 code: NEWUSER
でプロモーションコードを作成し、active: false
を渡してそれを無効化してから、code: NEWUSER
で新しいプロモーションコードを作成できます。
プロモーションコードは、ダッシュボードのクーポンセクションまたは API で作成できます。
Use a promotion code 
On your server, enable customer-redeemable promotion codes using the allow_promotion_codes parameter in a Checkout Session.
On your client, use applyPromotionCode to apply a promotion code that your customer enters. Use removePromotionCode to remove all previously applied promotion codes.
プロモーションコードを設定する
プロモーションコードごとに、対象の顧客、引き換え回数、その他の制限をカスタマイズできます。
特定の顧客に限定する
プロモーションを特定の顧客に限定するには、プロモーションコードを作成する際に customer (顧客) を指定します。顧客が指定されていない場合、すべての顧客がコードを引き換えることができます。
初回注文に限定する
また、restrictions.first_time_transaction を使用して、プロモーションコードを初めての顧客のみに限定することもできます。customer
が定義されていない場合、または定義された customer
が過去に支払いをしたことがない場合や、無効化されていないインボイスがない場合は、初回の取引とみなされます。
注
セッションで Customer (顧客) が作成されない場合、代わりにゲスト顧客がダッシュボードに作成されます。新規の顧客に限定されたプロモーションコードも、これらのセッションでは受け付けられます。
最低金額を設定する
プロモーションコードでは、minimum_amount と minimum_amount_currency を設定して、割引対象の最低取引額を設定できます。プロモーションコードの制限は引き換え時に確認されるため、最低取引額はサブスクリプションの初回の支払いにのみ適用されます。
有効期限をカスタマイズする
expires_at を使用してプロモーションコードの有効期限を設定できます。ベースとなるクーポンにすでに redeem_
が設定されている場合には、プロモーションコードの期限をクーポンの期日よりも後にすることはできません。promotion_
が指定されていない場合は、クーポンの redeem_
が自動的に expires_
となります。
たとえば、クーポンを 1 年間サポートするプランがあり、引き換え期間を顧客がクーポンを受け取ってから 1 週間以内にするとします。その場合、coupon[redeem_
を現在から 1 年後にし、各 promotion_
を作成日の 1 週間後に設定できます。
引き換え回数を制限する
max_redemptions を使用して引き換え回数を制限できます。これは coupon パラメーターと同様に機能します。ベースとなるクーポンにすでに max_
が設定されている場合、プロモーションコードの max_
をクーポンの上限値より大きくすることはできません。
たとえば、シーズンセールのクーポンの引き換えを先着 50 人の顧客に制限する一方で、冬のプロモーションで引き換えを利用できる対象を 20 人のみにすることができます。このシナリオでは、coupon[max_
および promotion_
を設定できます。
無効なプロモーション
active パラメーターを使用して、プロモーションコードが現在引き換え可能かどうかを設定できます。ただし、プロモーションのベースとなるクーポンが無効になると、そのプロモーションコードはすべて永久に無効になります。同様に、プロモーションコードが max_
や expires_
に達した場合にも、永久に無効になります。これらのプロモーションコードを再度有効にすることはできません。
プロモーションを削除する
ダッシュボードまたは API を使用して、プロモーションを削除できます。プロモーションを削除すると、そのプロモーションは今後の取引や顧客に適用できなくなります。