Smartpay 使用時の割引を提示する

Offer you customers discounts when using Smartpay.

You can use discounts in Smartpay checkout to reduce the amount charged to a customer for their order. Coupons and promotion codes allow for great flexibility in how you define and use them.

  • Offer percentage or flat amount discounts
  • Set an expiry date or maximum redemption for your coupons and promotion codes
  • Customize who's eligible for the discount
    • once per customer
    • first time order
    • minimum order amount
    • etc.

Coupons

Coupons specify a percentage or flat amount discount. You can create multiple customer-facing promotion codes that map to a single underlying coupon.

This means that the codes NEWYEARSALE and SAKURASALE can both point to one 25% off coupon.

Create a coupon in the Smartpay dashboard

  1. Login to the Smartpay dashboard
  2. Select 「クーポン」 on the left panel
  1. Click 「クーポンを作成」 in the top right corner
  2. Fill out the form with the required information and click 「クーポンを作成」

クーポンを作成

Make sure you are creating the coupon in the right mode (Test vs Live). In the Smartpay dashboard, you can switch between Test and Live mode on the bottom left corner. If the dashboard is in Test mode all new coupons created will be test coupons. Test coupons can not be used with real customer orders and can only be used for testing.

Create a coupon through the API

You can create a coupon using the create a coupon API endpoint.

Coupons have the following parameters that you can specify (for further details see the create a coupon API endpoint):

  • discountType: The type of the discount offered. Possible values are amount for a fixed value discount and percentage for a percentage discount.
  • discountAmount / discountPercentage: Depending on the discountType one of these fields needs to be filled out to specify the discount value. discountPercentage needs to be a value between 0 and 100.
  • expiresAt optional: An optional expiry date, after which the coupon can no longer be redeemed.
  • maxRedemptionCount optional: Maximum number of times this coupon can be redeemed, in total, across all customers, before it is no longer valid.
curl --request POST \
     --url https://api.smartpay.co/v1/coupons \
     --header 'Authorization: Basic <YOUR_SECRET_KEY>' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
     "discountPercentage": 50,
     "discountType": "percentage",
     "maxRedemptionCount": 100000,
     "name": "New Years sale 50% off"
}
'
from smartpay import Smartpay

SECRET_KEY = os.environ.get("SECRET_KEY", "<YOUR_SECRET_KEY>")
PUBLIC_KEY = os.environ.get("PUBLIC_KEY", "<YOUR_PUBLIC_KEY>")

smartpay = Smartpay(SECRET_KEY, public_key=PUBLIC_KEY)

coupon = smartpay.create_coupon(
    name="New Years sale 50% off",
    discount_type=Smartpay.COUPON_DISCOUNT_TYPE_PERCENTAGE,
    discount_percentage=50,
    max_redemption_count=100000,
)
package main

import (
	"context"
	"fmt"
	. "github.com/smartpay-co/sdk-go"
)

func main() {
	ctx := context.Background()
	client, _ := NewClientWithResponses("<YOUR_SECRET_KEY>", "<YOUR_PUBLIC_KEY>")

	couponPayload := CreateACouponJSONRequestBody{
    Name:               "New Years sale 50% off",
    DiscountType:       DiscountTypePercentage,
    DiscountPercentage: 50,
    MaxRedemptionCount: 100000,
	}

	result, err := client.CreateACouponWithResponse(ctx, couponPayload)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(result.Body))
}
const Smartpay = require("@smartpay/sdk-node").default; // The Nodejs SDK

// Replace the keys with yours
const SECRET_KEY = process.env.SECRET_KEY || "<YOUR_SECRET_KEY>";
const PUBLIC_KEY = process.env.PUBLIC_KEY || "<YOUR_PUBLIC_KEY>";

const smartpay = new Smartpay(SECRET_KEY, {
  publicKey: PUBLIC_KEY,
});

const coupon = await smartpay.createCoupon({
  name: "New Years sale 50% off",
  discountType: "percentage",
  discountPercentage: 50,
  maxRedemptionCount: 100000,
});

Promotion codes

Promotion codes are customer-facing codes created on top of coupons. You can also specify additional restrictions that control when a customer can apply the promotion. You can share these codes with customers who can enter them into the Smartpay checkout to apply a discount.

The code created (eg. NEWYEARSALE) needs to be unique across all of your promotion codes.

Add a promotion code in the Smartpay dashboard

  1. Login to the Smartpay dashboard
  2. Select 「クーポン」 on the left panel
  3. Select the Coupon you just created
  4. Click 「プロモーションコード追加」
  5. Fill out the form with the required information and click 「プロモーションコード追加」

Coupon details

プロモーションコード追加

Create a promotion code through the API

You can create a coupon using the create a promotion code API endpoint.

Promotion codes have the following parameters that you can specify (for further details see the create a promotion code API endpoint):

  • code: The customer-facing code. This code must be unique across all your promotion codes.
  • coupon: The unique identifier for the Coupon this promotion code belongs to.
  • expiresAt optional: An optional expiry date, after which the code can no longer be redeemed.
  • firstTimeTransaction optional: Limit the code to customers with no prior successful Smartpay orders on your shop. Defaults to false if not set.
  • maxRedemptionCount optional: Maximum number of times this code can be redeemed, in total, across all customers, before it is no longer valid.
  • minimumAmount optional: The minimum amount required to redeem this code (e.g., the amount of the order must be ¥10,000 or more to be applicable).
  • onePerCustomer optional: Limit this code to be usable only once per customer. Defaults to false if not set.
curl --request POST \
     --url https://api.smartpay.co/v1/promotion-codes \
     --header 'Authorization: Basic <YOUR_SECRET_KEY>' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
     "code": "NEWYEARSALE",
     "coupon": "coupon_test_7sbA4DmtHi33TWvf9FPjMh",
     "currency": "JPY",
     "expiresAt": 1672425576000,
     "firstTimeTransaction": true,
     "maxRedemptionCount": 1000,
     "minimumAmount": 1000
}
'
from smartpay import Smartpay

SECRET_KEY = os.environ.get("SECRET_KEY", "<YOUR_SECRET_KEY>")
PUBLIC_KEY = os.environ.get("PUBLIC_KEY", "<YOUR_PUBLIC_KEY>")

smartpay = Smartpay(SECRET_KEY, public_key=PUBLIC_KEY)

coupon = smartpay.create_promotion_code(
    code="NEWYEARSALE",
    coupon="coupon_test_7sbA4DmtHi33TWvf9FPjMh",
    currency="JPY",
    expires_at=1672425576000,
    first_time_transaction=True,
    max_redemption_count=1000,
    minimum_amount=1000,
)
package main

import (
	"context"
	"fmt"
	. "github.com/smartpay-co/sdk-go"
)

func main() {
	ctx := context.Background()
	client, _ := NewClientWithResponses("<YOUR_SECRET_KEY>", "<YOUR_PUBLIC_KEY>")

	couponPayload := CreateAPromotionCodeJSONRequestBody{
    Code:                 "NEWYEARSALE",
    Coupon:               "coupon_test_7sbA4DmtHi33TWvf9FPjMh",
    Currency:             "JPY",
    MinimumAmount:        1000,
    ExpiresAt:            1672425576000,
    FirstTimeTransaction: true,
    MaxRedemptionCount:   1000,
	}

	result, err := client.CreateAPromotionCodeWithResponse(ctx, couponPayload)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(result.Body))
}
const Smartpay = require("@smartpay/sdk-node").default; // The Nodejs SDK

// Replace the keys with yours
const SECRET_KEY = process.env.SECRET_KEY || "<YOUR_SECRET_KEY>";
const PUBLIC_KEY = process.env.PUBLIC_KEY || "<YOUR_PUBLIC_KEY>";

const smartpay = new Smartpay(SECRET_KEY, {
  publicKey: PUBLIC_KEY,
});

const promotionCode = await smartpay.createPromotionCode({
  code: "NEWYEARSALE",
  coupon: "coupon_test_7sbA4DmtHi33TWvf9FPjMh",
  currency: "JPY",
  expiresAt: 1672425576000,
  firstTimeTransaction: true,
  maxRedemptionCount: 1000,
  minimumAmount: 1000,
});