question

Evan Walker avatar image
Evan Walker asked

How would I add coupon input and button.,How would I add coupons input and button to my game?

I tried using the documentation for adding coupons and that method didnt work please help.

3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Ivan Cai avatar image Ivan Cai ♦ commented ·
0 Likes 0 ·
Evan Walker avatar image Evan Walker Ivan Cai ♦ commented ·

I tried but I dont get how to make the gui

0 Likes 0 ·
Evan Walker avatar image Evan Walker Ivan Cai ♦ commented ·

or script it

0 Likes 0 ·
Ivan Cai avatar image
Ivan Cai answered

The example is as follows:

c# script code:

 string couponCode;
    public GameObject RedeemPanel;
    //Get inputfield 
    public void InputCouponCode(string CodeIn) 
    {
        couponCode = CodeIn;
    }
    //Open or Close Panel
    public void OpenCloseRedeemPanel() 
    {
        RedeemPanel.SetActive(!RedeemPanel.activeInHierarchy);
    }
    //Click submitbutton to redeem
    public void RedeemCoupon() 
    {
        var primaryCatalogName = "Main"; // In your game, this should just be a constant matching your primary catalog
        var request = new RedeemCouponRequest
        {
            CatalogVersion = primaryCatalogName,
            CouponCode = couponCode // This comes from player input, in this case, one of the coupon codes generated above
        };
        PlayFabClientAPI.RedeemCoupon(request, OnRedeemSuccess=>{
            Debug.Log("Redeem Coupon successfully!");
        }, DisplayPlayFabError);
    }

Unity component view:


foryan25.png (6.4 KiB)
foryan26.png (9.4 KiB)
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Evan Walker avatar image Evan Walker commented ·

It worked thx so much!

0 Likes 0 ·
Evan Walker avatar image
Evan Walker answered

Thx so much I will tell you if it works out for me!

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.