# Coupon

# Introduction

Now, The WeOmni platform provide both api and ui for mange coupons.

In part UI, you can use followings:

  • Generate coupons
  • Detail of each coupon
  • Void coupon
  • Import for generate coupon
  • Export coupon

In part API ,we provide api followings:

  • Apply coupon
  • Redeem coupon
  • Void coupon

# Step by step to manage coupon

# 1.Create campaign

# 1.1 Create a new campaign that buy 2 discount 5 percent

On campaign section in WeOmniPlatform, you can click 'Create a new Campaign' for redirect to create a campaign. Campaign creation

Campaign creation

# 1.2 Fill a campaign details

Field ‘Ref Code’ is unique key that cannot duplicate each campaign.Campaign creation

# 1.3 Fill rule of campaign that buy 2 discount 5 percent

You can click ‘Add When’ and then will show condition. You can fill following pictures and then save this campaign.

Campaign creation

# 1.4 Result campaign

See campaign that have just created

Campaign creation

# 2.Generate coupon

# 2.1 Generate coupon prefix ‘EGG_POS’ with amount 1000 pieces.

Go to campaign ‘Buy 2 Discount 5%’ and click to expand section ‘Manage Coupon Codes’ and ‘Generate Coupons' then you can fill details for generate coupons. And click 'generate’ button.

Campaign creation

# 2.2 Click Search coupon

You can see all coupon that just have generated.

Campaign creation

# 3.Apply coupon

WeOmni platform provide apply coupon api. It can check coupon that can use before redeem coupon. You can get benefit from this api.

# 3.1 Request for campaign Buy 2 discount 5%

You should create request body with coupon code, amount more than 2 following Request section.

Scope: coupon.code.r
curl --location --request POST 'https://alpha-platform.weomni-test.com/coupon/api/projects/6088ecd806b0ab000182e538/coupons/codes/apply-coupon' \
--header 'Authorization: Bearer {Bearer Token} \
--header 'Content-Type: application/json' \
--data-raw '{
  "couponCode": "EGG_POS_05qHjWO",
  "attribute": {
  },
  "cart": {
    "items": [
      {
        "name": "Ipad Pro 12.9",
        "sku": "eggpos01",
        "amount": 3,
        "price": 39000,
        "tags": [
          "gadget"
        ]
      }
    ]
  }
}'

# 3.2 Response for campaign Buy 2 discount 5%

You can see benefit of this coupon and details of response that have name of campaign Buy 2 discount 5%.

{
    "couponTemplateId": "60af452b30ef39000134a1bf",
    "actions": [
        {
            "rule": {
                "id": "b9182d82-e89f-4f1c-9014-1a20ac910a09",
                "name": "Buy 2 discount 5 percent",
                "thenOperator": "AND"
            },
            "campaign": {
                "id": "60af1f96e7a5b70001d78349",
                "name": "Buy 2 Discount 5% ",
                "startDate": "2021-05-27T04:16:00Z",
                "endDate": "2021-06-27T04:25:00Z",
                "refCode": "EGG-POS-DISCOUNT-5PERCENT",
                "imageUrl": null
            },
            "action": {
                "action": null,
                "internalAction": false,
                "actionRef": "4a1c7127-5691-4098-a989-07e3836c5f30",
                "data": [
                    {
                        "type": "custom",
                        "attribute": "amount",
                        "op": null,
                        "value": "5",
                        "valueType": "STRING",
                        "note": null,
                        "resolveAction": false
                    },
                    {
                        "type": "custom",
                        "attribute": "unit",
                        "op": null,
                        "value": "Percent",
                        "valueType": "STRING",
                        "note": null,
                        "resolveAction": false
                    }
                ]
            }
        }
    ]
}

# See more detail: Document-Apply-Coupon

# Redeem coupon

WeOmni platform provide Redeem coupon api. You can use coupon from this api.

# 4.1 Request for redeem coupon

you can create request with coupon code, channel, orderRef that for tracking with your order and amount more than 2 for match condition with campaign

Scope: coupon.code.u
curl --location --request POST 'https://alpha-platform.weomni-test.com/coupon/api/projects/6088ecd806b0ab000182e538/coupons/codes/redeem' \
--header 'Authorization: Bearer {bearer token} \
--header 'Content-Type: application/json' \
--data-raw '{
     "usedAt": {
        "merchatId": "EGG_POS_13ded3ff41",
        "shopId": "TDPK_1f34fgh345g"
    },
    "couponCode": "EGG_POS_05qHjWO",
    "channel": "EGG_POS",
    "orderRef": "EGG_purchase_43243d_34dd",
    "attribute": {
    },
    "cart": {
        "items": [
            {
                "name": "Ipad Pro 12.9",
                "sku": "IPAD-2019",
                "amount": 3,
                "price": 39000,
                "tags": [
                    "gadget"
                ]
            }
        ]
    }
}'

# 4.2 Response for redeem coupon

If you redeem success, you can see all benefit of this coupon.

# You should be keep id that is ‘redemptionId' for track between order and coupon. So when use need to void coupon, you can use 'redemptionId’ to void it.

{
    "id": "60af5426872c5d0001677fe9",
    "couponCode": "EGG_POS_05qHjWO",
    "usedDate": "2021-05-27T08:11:18.424616Z",
    "usedAt": {
        "merchatId": "EGG_POS_13ded3ff41",
        "shopId": "TDPK_1f34fgh345g"
    },
    "actionTxs": [
        {
            "createdBy": "coupon_campaign",
            "createdDate": "2021-05-27T08:11:18.342Z",
            "lastModifiedBy": "coupon_campaign",
            "lastModifiedDate": "2021-05-27T08:11:18.342Z",
            "id": "60af5426b3d8ea00010d2241",
            "externalTxRef": null,
            "status": "COMPLETE",
            "then": {
                "action": null,
                "internalAction": false,
                "actionRef": "4a1c7127-5691-4098-a989-07e3836c5f30",
                "data": [
                    {
                        "type": "custom",
                        "attribute": "amount",
                        "op": null,
                        "value": "5",
                        "valueType": "STRING",
                        "note": null,
                        "resolveAction": false
                    },
                    {
                        "type": "custom",
                        "attribute": "unit",
                        "op": null,
                        "value": "Percent",
                        "valueType": "STRING",
                        "note": null,
                        "resolveAction": false
                    }
                ]
            },
            "projectId": "6088ecd806b0ab000182e538",
            "errors": []
        }
    ]
}

# 4.3 Details of coupon

Search coupon with ‘EGG_POS' then will show all coupon with prefix ‘EGG_POS’. and click 'View’

Campaign creation

Campaign creation

# See more detail: Document-Redeem-Coupon

# Void coupon

# 5.1 Void with WeOmni platform UI

In WeOmni Platform provide for admin can void coupon in coupon detail page. You can click ‘Void’ for void this coupon

Campaign creation

When voided, status will change to ‘Voided’ and coupon used will decrease for redeem again.

Campaign creation

# 5.2 Void with WeOmni platform Api

In request, you create void with ‘redemptionId’ that can get from redeem api and ‘voidBy’ for track coupon.

Scope: coupon.code.u
curl --location --request POST 'https://alpha-platform.weomni-test.com/coupon/api/projects/6088ecd806b0ab000182e538/coupons/codes/void' \
--header 'Authorization: Bearer {bearer token} \
--header 'Content-Type: application/json' \
--data-raw '{
    "redemptionId": "60af5426872c5d0001677fe9",
    "voidBy": "ADMIN_EGG_POS_TRUE_DIGITAL"
}'

When you voided success, you can get details that are voidDate, isVoid and voidBy.

{
    "id": "60af5426872c5d0001677fe9",
    "voidDate": "2021-05-27T09:14:50.996602Z",
    "isVoid": true,
    "voidBy": "ADMIN_EGG_POS_TRUE_DIGITAL"
}

####See more detail: Document-Void-Coupon

Last Updated: 5/31/2021, 11:55:02 AM