Add discounts for one-time payments
Reduce the amount charged to a customer by discounting their subtotal with coupons and promotion codes.
You can use discounts in Checkout to reduce the amount charged to a customer for one-time payments. Coupons and promotion codes allow for great flexibility in how you define and use them. They can:
- 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
Coupons
Coupons specify a fixed value discount. You can create customer-facing promotion codes that map to a single underlying coupon.
This means that the codes FALLPROMO
and SPRINGPROMO
can both point to one 25% off coupon.
Create a coupon
Coupons are created in the Dashboard or with the API:
curl https://api.payske.com/v1/coupons \
-u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
-d percent_off=20 \
-d duration=once
payske coupons create \
--percent-off=20 \
--duration=once
# Set your secret key. Remember to switch to your live secret key in production.
# See your keys here: https://account.payske.com/api/key
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
Payske::Coupon.create({percent_off: 20, duration: 'once'})
# Set your secret key. Remember to switch to your live secret key in production.
# See your keys here: https://account.payske.com/api/key
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"
payske.Coupon.create(percent_off=20, duration="once")
// Set your secret key. Remember to switch to your live secret key in production.
// See your keys here: https://account.payske.com/api/key
$payske = new \Payske\PayskeClient('sk_test_4eC39HqLyjWDarjtT1zdp7dc');
$payske->coupons->create(['percent_off' => 20, 'duration' => 'once']);
// Set your secret key. Remember to switch to your live secret key in production.
// See your keys here: https://account.payske.com/api/key
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";
CouponCreateParams params =
CouponCreateParams
.builder()
.setPercentOff(new BigDecimal(20))
.setDuration(CouponCreateParams.Duration.ONCE)
.build();
Coupon coupon = Coupon.create(params);
// Set your secret key. Remember to switch to your live secret key in production.
// See your keys here: https://account.payske.com/api/key
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');
const coupon = await payske.coupons.create({percent_off: 20, duration: 'once'});
// Set your secret key. Remember to switch to your live secret key in production.
// See your keys here: https://account.payske.com/api/key
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"
params := &payske.CouponParams{
PercentOff: payske.Float64(20),
Duration: payske.String(string(payske.CouponDurationOnce)),
};
result, _ := coupon.New(params);
// Set your secret key. Remember to switch to your live secret key in production.
// See your keys here: https://account.payske.com/api/key
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";
var options = new CouponCreateOptions { PercentOff = 20m, Duration = "once" };
var service = new CouponService();
service.Create(options);
If you want to create a session with an applied discount, pass the coupon ID in the coupon
parameter of the discounts array. Checkout currently supports up to one coupon or promotion code.
curl https://api.payske.com/v1/checkout/sessions \
-u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
-d "line_items[][price]"="{{PRICE_ID}}" \
-d "line_items[][quantity]"=1 \
-d mode=payment \
-d "discounts[][coupon]"="{{COUPON_ID}}" \
-d success_url="https://example.com/success" \
-d cancel_url="https://example.com/cancel"
# Set your secret key. Remember to switch to your live secret key in production.
# See your keys here: https://account.payske.com/api/key
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
session = Payske::Checkout::Session.create({
line_items: [{
price: '{{PRICE_ID}}',
quantity: 1,
}],
mode: 'payment',
discounts: [{
coupon: '{{COUPON_ID}}',
}],
success_url: 'https://example.com/success',
cancel_url: 'https://example.com/cancel',
})
# Set your secret key. Remember to switch to your live secret key in production.
# See your keys here: https://account.payske.com/api/key
payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
session = payske.checkout.Session.create(
line_items=[{
'price': '{{PRICE_ID}}',
'quantity': 1,
}],
mode='payment',
discounts=[{
'coupon': '{{COUPON_ID}}',
}],
success_url='https://example.com/success',
cancel_url='https://example.com/cancel',
)
// Set your secret key. Remember to switch to your live secret key in production.
// See your keys here: https://account.payske.com/api/key
\Payske\Payske::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc');
$session = \Payske\Checkout\Session::create([
'line_items' => [[
'price' => '{{PRICE_ID}}',
'quantity' => 1,
]],
'mode' => 'payment',
'discounts' => [[
'coupon' => '{{COUPON_ID}}',
]],
'success_url' => 'https://example.com/success',
'cancel_url' => 'https://example.com/cancel',
]);
// Set your secret key. Remember to switch to your live secret key in production.
// See your keys here: https://account.payske.com/api/key
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";
SessionCreateParams params =
SessionCreateParams.builder()
.addLineItem(
SessionCreateParams.LineItem.builder()
.setPrice("{{PRICE_ID}}")
.setQuantity(1L)
.build())
.setMode(SessionCreateParams.Mode.PAYMENT)
.addDiscount(
SessionCreateParams.Discount.builder()
.setCoupon("{{COUPON_ID}}")
.build())
.setSuccessUrl("https://example.com/success")
.setCancelUrl("https://example.com/cancel")
.build();
Session session = Session.create(params);
// Set your secret key. Remember to switch to your live secret key in production.
// See your keys here: https://account.payske.com/api/key
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');
const session = await payske.checkout.sessions.create({
line_items: [{
price: '{{PRICE_ID}}',
quantity: 1,
}],
mode: 'payment',
discounts: [{
coupon: '{{COUPON_ID}}',
}],
success_url: 'https://example.com/success',
cancel_url: 'https://example.com/cancel',
});
// Set your secret key. Remember to switch to your live secret key in production.
// See your keys here: https://account.payske.com/api/key
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"
params := &payske.CheckoutSessionParams{
LineItems: []*payske.CheckoutSessionLineItemParams{
&payske.CheckoutSessionLineItemParams{
Price: payske.String("{{PRICE_ID}}"),
Quantity: payske.Int64(1),
},
},
Mode: payske.String("payment"),
Discounts: []*payske.CheckoutSessionDiscountParams{
&payske.CheckoutSessionDiscountParams{
Coupon: payske.String("{{COUPON_ID}}"),
},
},
SuccessURL: payske.String("https://example.com/success"),
CancelURL: payske.String("https://example.com/cancel"),
}
session, _ := session.New(params)
// Set your secret key. Remember to switch to your live secret key in production.
// See your keys here: https://account.payske.com/api/key
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";
var options = new SessionCreateOptions
{
LineItems = new List<SessionLineItemOptions>
{
new SessionLineItemOptions
{
Price = "{{PRICE_ID}}",
Quantity = 1,
},
},
Mode = "payment",
Discounts = new List<SessionDiscountOptions>
{
new SessionDiscountOptions
{
Coupon = "{{COUPON_ID}}",
},
},
SuccessUrl = "https://example.com/success",
CancelUrl = "https://example.com/cancel",
};
var service = new SessionService();
var session = service.Create(options);
Configure a coupon
Coupons have the following parameters that you can use for one-time payments:
id
, a unique identifier for the couponcurrency
percent_off
oramount_off
max_redemptions
redeem_by
, the latest date at which this coupon can be appliedapplies_to
, limits the products that the coupon applies to
Limit redemption usage
The max_redemptions
and redeem_by
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_to
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.