Example using e-commerce platform(WooCommerce)
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.
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 here.
Fill in the configurations 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.
Based on this structure, you will add the configurations we mentioned previously
Name | Value |
---|---|
Method | POST |
Request Headers |
|
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 :
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 :
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.
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
andfixed_product
. So, we will check fixed rate, percentage and free product coupons in dashboard and insert the corresponding value for each coupon type in WooCommerce, i.e: percentage coupon value will bepercent.
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 !
Last updated