> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gameball.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Redeem Through Gameball Discount Engine

> Use Gameball's built-in discount engine for coupon validation and burning.

# **Gameball Couponing Engine Integration**

Enable your customers to convert loyalty points into discount coupons and apply them at checkout with secure, API-driven flows. Gameball’s built-in coupon engine makes issuing, validating, and redeeming coupons easy, across both **web** and **mobile**.

## **Why Use Gameball’s Couponing Engine?**

Gameball’s native engine provides:

* Unique coupon code generation (SAVE10, FREESHIP, etc.)
* Real-time coupon validation and locking to prevent misuse
* Direct coupon application at checkout via API
* Refund-safe logic (burn or release on success/failure)
* Omnichannel support, coupons work online **and** in-store

## **Implementation Overview**

Gameball supports two implementation paths:

| **Implementation**  | **Description**                                                                                                                                |
| :------------------ | :--------------------------------------------------------------------------------------------------------------------------------------------- |
| **Gameball Widget** | Coupon creation, visibility, and redemption are handled automatically via the widget. You only need to validate and apply coupons at checkout. |
| **Custom UI**       | You are responsible for displaying reward options, generating coupons, and surfacing them at checkout using Gameball’s APIs.                   |

## **Step-by-Step Integration (with Both Flows)**

### **Step 1: Show Available Redemption Options**

<Tabs>
  <Tab title="Gameball Widget">
    Handled by the widget, the customer sees eligible redemption options inside the widget.

    <img src="https://mintcdn.com/gameball/tbHJ33JKkFfY2kVp/images/redemption-options.png?fit=max&auto=format&n=tbHJ33JKkFfY2kVp&q=85&s=8ef79beccd779b7383557fe4fd8b04ea" alt="Image(124) Pn" title="Image(124) Pn" className="mx-auto" style={{ width:"26%" }} width="684" height="1266" data-path="images/redemption-options.png" />
  </Tab>

  <Tab title="Custom UI">
    You must fetch and display all eligible redemption options.

    <img src="https://mintcdn.com/gameball/tbHJ33JKkFfY2kVp/images/redeem-ui.png?fit=max&auto=format&n=tbHJ33JKkFfY2kVp&q=85&s=43bd22942a17882aa7562ea5bc722b59" alt="Image(123) Pn" title="Image(123) Pn" className="mx-auto" style={{ width:"84%" }} width="978" height="340" data-path="images/redeem-ui.png" />

    **API:**

    [GET /customers//redemption-configurations](/api-reference/configurations/reward-configurations/redemption-settings)

    ```
    {
      "redemptionConfigurations": [
        {
          "id": 2138,
          "title": "Redeem 100 Points for $10 OFF",
          "pointsRequired": 100,
          "coupon": {
            "couponType": "fixed",
            "discountValue": 10.0,
            "currency": "USD",
            "validityDays": 30
          }
        },
        {
          "id": 2139,
          "title": "Redeem 200 Points for Free Shipping",
          "pointsRequired": 200,
          "coupon": {
            "couponType": "free_shipping",
            "validityDays": 15
          }
        }
      ]
    }
    ```
  </Tab>
</Tabs>

***

### **Step 2: Generate Coupon**

<Tabs>
  <Tab title="Gamball Widget">
    Automatically triggered inside the widget when a redemption is made. No API call is needed.

    <img src="https://mintcdn.com/gameball/tbHJ33JKkFfY2kVp/images/redemptionthroughwidget-ezgif.com-video-to-gif-converter.gif?s=53649a5821191333fb580b33c63a20a6" alt="Redemptionthroughwidget Ezgif Com Video To Gif Converter Gi" title="Redemptionthroughwidget Ezgif Com Video To Gif Converter Gi" className="mx-auto" style={{ width:"27%" }} width="722" height="1304" data-path="images/redemptionthroughwidget-ezgif.com-video-to-gif-converter.gif" />
  </Tab>

  <Tab title="Custom UI">
    You must call the Generate Coupon API when a customer chooses a reward. By pressing the redeem button, the [Generate Coupon API](/api-reference/coupons/generate-coupon) should be triggered, where the output is another UI representing the coupon generated with the coupon code from the API's response for the customer to use

    <img src="https://mintcdn.com/gameball/aE9N_MZB2lsHVWWd/images/image%20(126).png?fit=max&auto=format&n=aE9N_MZB2lsHVWWd&q=85&s=51a5e3b5d4b8f687e87ebce13f221c26" alt="Image(126) Pn" title="Image(126) Pn" className="mx-auto" style={{ width:"51%" }} width="782" height="412" data-path="images/image (126).png" />

    <img src="https://mintcdn.com/gameball/aE9N_MZB2lsHVWWd/images/image%20(125).png?fit=max&auto=format&n=aE9N_MZB2lsHVWWd&q=85&s=125657234c5fd3e2a9681187834aa7cb" alt="Image(125) Pn" title="Image(125) Pn" className="mx-auto" style={{ width:"53%" }} width="722" height="428" data-path="images/image (125).png" />

    ```json theme={null}
    {
      "ruleId": "12345",
      "customerId": "customer123",
      "email": "customer@example.com",
      "mobile": "+1234567890"
    }
    ```

    ```json theme={null}
    {
      "code": "SAVE10",
      "startDate": "2024-11-01T00:00:00Z",
      "expiryDate": "2024-12-01T23:59:59Z",
      "usageLimit": 1,
      "discountValue": 10,
      "minOrderValue": 50,
      "type": "fixed_discount"
    }
    ```
  </Tab>
</Tabs>

***

### **Step 3: Display Coupons at Checkout**

<Tabs>
  <Tab title="Gameball Widget">
    Customers can open “My Coupons” inside the widget to copy and apply a coupon.

    <img src="https://mintcdn.com/gameball/tbHJ33JKkFfY2kVp/images/viewmycouponsonwidget-ezgif.com-video-to-gif-converter.gif?s=2b3c7da0a57d963d6d08d494dcc20629" alt="Viewmycouponsonwidget Ezgif Com Video To Gif Converter Gi" title="Viewmycouponsonwidget Ezgif Com Video To Gif Converter Gi" className="mx-auto" style={{ width:"30%" }} width="700" height="1278" data-path="images/viewmycouponsonwidget-ezgif.com-video-to-gif-converter.gif" />
  </Tab>

  <Tab title="Custom UI">
    You must fetch and show all active customer coupons on your checkout page.

    <img src="https://mintcdn.com/gameball/tbHJ33JKkFfY2kVp/images/couponredemption-ezgif.com-video-to-gif-converter.gif?s=556cff6c61f9d36653fe0677f10ca40a" alt="Couponredemption Ezgif Com Video To Gif Converter Gi" title="Couponredemption Ezgif Com Video To Gif Converter Gi" className="mx-auto" style={{ width:"34%" }} width="800" height="1178" data-path="images/couponredemption-ezgif.com-video-to-gif-converter.gif" />

    **API:**

    [GET /customers//coupons](/api-reference/customers/management/get-customer-coupons)

    ```json theme={null}
    {
      "coupons": [
        {
          "code": "GB2024",
          "type": "percentage_discount",
          "value": 15,
          "expiryDate": "2024-12-31T23:59:59Z",
          "isUsed": false
        },
        {
          "code": "GBFREESHIP",
          "type": "free_shipping",
          "value": 0,
          "expiryDate": "2024-11-30T23:59:59Z",
          "isUsed": false
        }
      ]
    }
    ```

    **Suggested UI Behavior:**

    * Show coupon name, value, and expiry
    * Allow the customer to select one, which fills the input field automatically
  </Tab>
</Tabs>

***

### **Step 4: Validate & Lock the Coupon**

<Tabs>
  <Tab title="Gameball Widget">
    Not handled by widget. You must validate and lock the coupon before applying it at checkout.
  </Tab>

  <Tab title="Custom UI">
    Same as widget, you must validate and lock the coupon before applying it.
  </Tab>
</Tabs>

<img src="https://mintcdn.com/gameball/tbHJ33JKkFfY2kVp/images/couponredemption-ezgif.com-video-to-gif-converter.gif?s=556cff6c61f9d36653fe0677f10ca40a" alt="Couponredemption Ezgif Com Video To Gif Converter Gi" title="Couponredemption Ezgif Com Video To Gif Converter Gi" className="mx-auto" style={{ width:"34%" }} width="800" height="1178" data-path="images/couponredemption-ezgif.com-video-to-gif-converter.gif" />

**API Options:**

* [Validate Single Coupon](/api-reference/coupons/validate-single-coupon)
* [Validate Multiple Coupons](/api-reference/coupons/validate-multiple-coupons)

**Use Case: Mixed Coupons Applied in a Single Order**

Imagine your checkout allows customers to stack or combine different coupon types on the same order. For example:

* One discount coupon: SAVE10 (\$10 off)
* One free shipping coupon: FREESHIP (waives shipping fees)

At checkout, the customer selects both coupons to maximize savings.

**You must:**

1. Verify that each coupon is still valid and not expired.
2. Lock both coupons together so no other session can reuse them while the customer completes payment.

In this case, POST /validate-coupons lets you validate and lock both in one atomic call.

```json theme={null}
{
  "customerId": "cust_12345",
  "coupons": ["SAVE10", "FREESHIP"],
  "lock": true
}
```

```json theme={null}
{
  "lockReference": "abc123lock",
  "valid": true,
  "coupons": [
    {
      "code": "SAVE10",
      "type": "fixed_discount",
      "value": 10
    },
    {
      "code": "FREESHIP",
      "type": "free_shipping",
      "value": 0
    }
  ]
}
```

<Note>
  Save the lockReference. It is required in the next step.
</Note>

<Tip>
  **When This is Helpful:**

  * You allow **multiple coupon stacking** in one order
  * You need to **lock them together** to avoid conflicts
  * You want to handle validation in one API call for efficiency
</Tip>

### **Step 5: Burn (Apply) the Coupon**

<Tabs>
  <Tab title="Gameball Widget">
    Not handled by the widget. You must finalize the coupon usage.
  </Tab>

  <Tab title="Custom UI">
    Same as the widget, you must finalize usage.
  </Tab>
</Tabs>

<img src="https://mintcdn.com/gameball/tbHJ33JKkFfY2kVp/images/couponredemption-ezgif.com-video-to-gif-converter.gif?s=556cff6c61f9d36653fe0677f10ca40a" alt="Couponredemption Ezgif Com Video To Gif Converter Gi" title="Couponredemption Ezgif Com Video To Gif Converter Gi" className="mx-auto" style={{ width:"35%" }} width="800" height="1178" data-path="images/couponredemption-ezgif.com-video-to-gif-converter.gif" />

**Option A: Burn Manually**

[POST /burn-coupon](/api-reference/coupons/burn-coupon)

```json theme={null}
{
  "lockReference": "5e21ff4baf5d4760a8a43c7b2513298e"
}
```

**Option B: Use Order API (Recommended)**

[POST /order](/api-reference/order/order-tracking)

```
{
  "customerId": "customer123",
  "orderId": "ORD123",
  "totalPaid": 90,
  "orderDate": "2024-10-16T12:00:00Z",
  "redemption": {
    "lockReference": "5e21ff4baf5d4760a8a43c7b2513298e"
  }
}
```

<Info>
  The Order API burns the coupon and logs the order in one step.
</Info>

### **Step 6: Release Coupon (If Checkout Fails or Is Abandoned)**

<Tabs>
  <Tab title="Gameball Widget">
    Not handled by widget. You must manually release or rely on timeout.
  </Tab>

  <Tab title="Custom UI">
    Same, handle manual or automatic release based on your flow.
  </Tab>
</Tabs>

<img src="https://mintcdn.com/gameball/tbHJ33JKkFfY2kVp/images/couponrelease-ezgif.com-video-to-gif-converter.gif?s=c437440194d26fdacaa5e04e72c9a7e6" alt="Couponrelease Ezgif Com Video To Gif Converter Gi" title="Couponrelease Ezgif Com Video To Gif Converter Gi" className="mx-auto" style={{ width:"39%" }} width="758" height="1270" data-path="images/couponrelease-ezgif.com-video-to-gif-converter.gif" />

**Manual Release API:**

[POST /release-coupon](/api-reference/coupons/release-coupons)

```json theme={null}
{
  "lockReference": "5e21ff4baf5d4760a8a43c7b2513298e"
}
```

<Tip>
  **Automatic Release:**

  Configure the timeout duration in your Gameball dashboard under *Coupon Settings*.
</Tip>

## **Summary Table**

| **Step**                   | **API**                          | **Widget** | **Custom UI** |
| :------------------------- | :------------------------------- | :--------- | :------------ |
| 1. Show Redemption Options | GET /redemption-configurations   | (Auto)     | (Manual)      |
| 2. Generate Coupon         | POST /generate-coupon            | Auto       | (Manual)      |
| 3. Display Coupons         | GET /customers/id/coupons        | Auto       | (Manual)      |
| 4. Validate & Lock         | POST /validate-coupon(s)         | Auto       | Required      |
| 5. Burn/Apply              | POST /burn-coupon or POST /order | Manual     | ✅             |
| 6. Release                 | POST /release-coupon             | ❌          | ✅             |

***

## Related Resources

<CardGroup cols={2}>
  <Card title="Generate Coupon API" icon="ticket" href="/api-reference/coupons/generate-coupon">
    Issue coupons from Gameball’s built-in engine
  </Card>

  <Card title="Get Customer Coupons API" icon="list" href="/api-reference/customers/management/get-customer-coupons">
    Display coupons generated for a customer
  </Card>

  <Card title="Validate Coupon API" icon="shield-check" href="/api-reference/coupons/validate-single-coupon">
    Confirm coupon eligibility before checkout
  </Card>

  <Card title="Burn Coupon API" icon="fire" href="/api-reference/coupons/burn-coupon">
    Finalize coupon usage after successful payment
  </Card>
</CardGroup>
