before
BACKND Guidelines > 6. Implementing Coupon Functions > Step 1. Pre-arrangements
Pre-arrangements
The following tasks must be completed in advance to implement coupon functions.
- A chart for using the mail
- Logic of completed login method
- Logic of completed game information management method
- Create a script exclusive to coupons
1. A chart for using the mail
The information from a chart that allows you to use mail functions is required to implement the items provided after claiming the mail.
Go to BACKND Console, and in BACKND Base > Chart Management
, change the Mail Use status to Enabled for the chart that holds the item to be provided as a coupon reward.
If there are no registered charts, first proceed with 4. Implementing Chart Functions Step 2. Registering Charts to the Console.
Click the Edit button on the right of the chart.
![](https://developer.thebackend.io/static/img/newconsole/en/SDKDocs/BACKND Base/BACKND Guidelines/Step6 Coupon/BACKND_PreArrangements_01_EN.png)
Set the Mail Use status to Enabled.
![](https://developer.thebackend.io/static/img/newconsole/en/SDKDocs/BACKND Base/BACKND Guidelines/Step6 Coupon/BACKND_PreArrangements_02_EN.png)
After the change, the mail function is displayed as Enabled.
![](https://developer.thebackend.io/static/img/newconsole/en/SDKDocs/BACKND Base/BACKND Guidelines/Step6 Coupon/BACKND_PreArrangements_03_EN.png)
2. Logic of completed login method
All BACKND functions except login and sign-up require a login process to successfully call their methods.
If the login logic has not been implemented, please fully implement it according to the guidelines in 1. Implementing Login/Sign-up.
3. Logic of completed game information management method
This example shows the process leading up to the logic that saves items returned after using coupons. Therefore, 2. Implementing Game Information Functions, which is used to save data, must first be implemented.
If the game information function logic has not been implemented, please fully implement it according to 2. Implementing Game Information Functions.
4. Create a script exclusive to coupons
Create a new script and change the name to BackendCoupon.
Then, open the BackendCoupon.cs script and change the content according to the following:
BackendCoupon.cs
using System.Collections.Generic;
using System.Text;
using UnityEngine;
// Adds BACKND SDK namespace
using BackEnd;
public class BackendCoupon {
private static BackendCoupon _instance = null;
public static BackendCoupon Instance {
get {
if(_instance == null) {
_instance = new BackendCoupon();
}
return _instance;
}
}
public void CouponUse(string couponNumber) {
// Step 3. Using Coupons and Saving Items
}
}
BackendManager.cs
using UnityEngine;
using System.Threading.Tasks;
// Adds BACKND SDK namespace
using BackEnd;
public class BackendManager : MonoBehaviour {
void Start() {
var bro = Backend.Initialize(true); // Initialize BACKND
// Response value for BACKND initialization
if(bro.IsSuccess()) {
Debug.Log("Initialization successful : " + bro); // If successful, 'statusCode 204 Success'
} else {
Debug.LogError("Initialization failed : " + bro); // If failed, a 4xx statusCode error occurs
}
Test();
}
// A method that allows synchronous methods to be called from asynchronous methods(cannot be accessed by the Unity UI)
async void Test() {
await Task.Run(() => {
BackendLogin.Instance.CustomLogin("user1", "1234");
// Adds logic for using coupons
Debug.Log("Test complete.");
});
}
}