Gameball Developers Guide
v3.0
v3.0
  • Introduction
  • What's New in V3.0
  • Installing Gameball
    • Web
      • Show Gameball Customer Widget
      • Track Customer Events
      • Track Orders & Cashback Reward
      • Integrate Redemption
      • Track Referrals
      • Go-Live Checklist
    • iOS
      • Getting Started
      • Initialize Gameball Customer Profile
      • Track Customer Events
      • Track Orders & Cashback Reward
      • Integrate Redemption
      • Track Referrals
      • Push Notifications
      • Go-Live Checklist
    • Android
      • Getting Started
      • Initialize Gameball SDK
      • Initialize Gameball Customer Profile
      • Track Customer Events
      • Track Referrals
      • Push Notifications
      • Go-Live Checklist
    • React Native
      • Getting Started
      • Initialize Gameball Customer Profile
      • Track Customer Events
      • Track Orders & Cashback Reward
      • Integrate Redemption
      • Track Referrals
      • Push Notifications
      • Go-Live Checklist
      • Migration from v1 to v2
    • Flutter
      • Getting Started
      • Initialize Gameball SDK
      • Initialize Gameball Customer Profile
      • Track Customer Events
      • Track Referrals
      • Go-Live Checklist
    • Generic Mobile App
      • Initialize Gameball Customer Profile
      • Track Customer Events
      • Track Orders & Cashback Reward
      • Integrate Redemption
      • Track Referrals
      • Push Notifications
    • Retail & Modern POS
      • Initialize Gameball Customer Profile
      • Track Orders & Cashback Reward
      • Track Refunds
      • Enable Redemption
        • Prepare POS for Redemption
        • Using Virtual ID
          • Using Virtual Card
  • REST API
    • Overview
      • Server-Side SDKs
    • Authentication
    • API Reference
      • Customer
      • Event
      • Transactions
      • Order
      • Coupons
      • Leaderboard 👑
      • Notifications 👑
      • Configurations 👑
      • Batches 👑
        • Batch Operations Data
      • OTP
      • Partner 🤝
        • Client 🤝
        • Redemption Rule 🤝
        • Cashback Rule 🤝
    • Webhooks
      • Notifications Webhook
      • Customer Profile Webhook
    • Errors
    • Object Reference
  • Tutorials
    • Build Custom UI Elements 👑
      • Display Reward Campaign Progress
      • Show VIP Tiers
      • Show Customer Points Balance
      • Build Leaderboards
      • Show Notifications Inbox
      • Adapt UI to Configurations
      • Advanced UI Techniques
        • Increase Sales with Cashback UI Elements
        • Derive Engagement with Rewards Campaigns UI Elements
    • Tracking Customer Events
    • Build your Own Notification System
    • Checkout Integration Example
    • Redemption Integration Options
      • Redeem with coupon system
        • Integrate your coupon system
          • Example using e-commerce platform(WooCommerce)
          • Example using a custom coupon system
        • Build couponing experience
          • Using Gameball widget
          • Build custom experience
            • Showing customers available points
            • Allowing customers to create coupons
            • Apply the discount code to your cart
        • Coupon integration reference
      • Redeem with direct debt
        • Get customers points balance
        • Redeem customer points
  • Third Party Integrations
    • Segment Integration
Powered by GitBook
On this page
  1. Tutorials
  2. Redemption Integration Options
  3. Redeem with coupon system
  4. Integrate your coupon system

Example using e-commerce platform(WooCommerce)

PreviousIntegrate your coupon systemNextExample using a custom coupon system

Last updated 1 year ago

Please note that the same steps can be applied to different platforms with a slight changes based on your platform, we are only using WooCommerce for the sake of this example.

In this guide, we will show you how to integrate a platform's existing coupon system with Gameball backend, we will give example of integrating Gameball with WooCommerce coupon system.

Integrating With WooCommerce coupon API

We are only interested in the create coupon endpoint, so we can safely ignore others endpoints related to coupon.

  1. Search on google or in your platform documentation for the API responsible for creating coupons or coupon system API or similar keywords, you will find it .

  2. Fill in the based on the coupon HTTP request structure in your create coupon endpoint, for example WooCommerce will expect Gameball Backend to send an HTTP request with the following JSON body when creating a new coupon.

POST /wp-json/wc/v3/coupons HTTP/1.1
Content-Type: application/json
Authorization: Basic API_KEY:API_SECRET

{
  "code": "MYCOUPON",
  "amount": 10,
  "discount_type": "percent",
  "usage_limit": 100,
  "expiry_date": "2023-12-31"
  "product_ids" :"[]",
  "product_categories" : "[]",
}
Name
Value

Method

POST

Request Headers

{ Authorization : OAuth oauth_consumer_key="ck_c9943d372c50",oauth_signature_method="HMAC-SHA1",oauth_timestamp="",oauth_nonce="ESXiR5boeRS",oauth_version="1.0",oauth_signature="ws%2F6UwgNor56Huc4ULYTVp51bIQ%3D"

}

Payload

In the payload json object, the key is always fixed, only values between {{}} are changed based on coupon property names in the request body, for example if WooCommerce changed name of discount_type attribute in the coupon properties table to coupon_type the json body should looks like this :

{
 "playerUniqueId": "{{email_restrictions}}",
 "entitledProductIds":"{{product_ids}}",
 "entitledCollectionIds":"{{product_categories}}",
 "oncePerCustomer": "{{usage_limit_per_user}}",
 "code": "{{code}}",
 "usageLimit": "{{usage_limit}}",
 "value": "{{amount}}",
 "couponType": "{{coupon_type}}"
}

You need to pass the required attributes only, in WooCommerce coupon API, the coupon code attribute is the only required attribute, so the following payload is also valid :

{
"code":"{{code}}"
}

You can pass other attributes based on your preferences, for example, couponType attribute is not required in case you want to create the default type.

The coupon creation endpoint must return 200 code in order for coupon to be created successfully.

  1. Click on test connection to check if your configurations is correct or not.

Now you are all set to start creating coupons for your customers !

Based on this structure, you will add the configurations we mentioned

Define coupon type values. You may have noticed there are four checkboxes at the end of the configurations page in dashboard, each checkbox represents one of the coupon types supported by Gameball, you need to check if WooCommerce support it or not and if it support it you need to provide value for it based on its corresponding type in WooCommerce coupon API, for example, there are three discount types in WooCommerce percent, fixed_cart and fixed_product. So, we will check fixed rate, percentage and free product coupons in and insert the corresponding value for each coupon type in WooCommerce, i.e: percentage coupon value will be percent.

{
 "playerUniqueId": "{{email_restrictions}}",
 "entitledProductIds":"{{product_ids}}",
 "entitledCollectionIds":"{{product_categories}}",
 "oncePerCustomer": "{{usage_limit_per_user}}",
 "code": "{{code}}",
 "usageLimit": "{{usage_limit}}",
 "value": "{{amount}}",
 "couponType": "{{discount_type}}"
}
here
configurations
previously
dashboard
coupon creation endpoint
https://example.com/wp-json/wc/v3/coupons