onepf / OpenIAB

Open In-App Billing for Google Play, SlideMe, Amazon Store, Nokia Store, Samsung Apps, Yandex.Store, Appland, Aptoide, AppMall and Fortumo.
http://onepf.org/openiab/
Apache License 2.0
473 stars 172 forks source link

How Does The Code Look Like In IAP Unity - How to set it up correctly #540

Closed DennisLiu88 closed 6 years ago

DennisLiu88 commented 6 years ago

Hi,

Need help please.

I have try integrated the open iab in my game with unity engine. But i don't find any tutorial that explain more clearly. I find the tutorial at youtube here : open iab tutorial But it is not in english. I don't understand what he say.

Could someone take a look with my code if i have set it correclty ? Below is my link sample code :

My Sample Code

Link above expired in 14 days. I will update if still not answer.

My Question

Here below is correct or not ? `

   const string SKU1 = "com.Idea2Infinity.moonshardislandlife";

const string SKU2 = "com.Idea2Infinity.moonshardislandlife";

const string SKU3 = "com.Idea2Infinity.moonshardislandlife";

const string SKU4 = "com.Idea2Infinity.moonshardislandlife";

const string SKU5 = "com.Idea2Infinity.moonshardislandlife";

const string SKU6 = "com.Idea2Infinity.moonshardislandlife";

`

Here below is correct or not ? `

           OpenIAB.mapSku(SKU1, OpenIAB_Android.STORE_GOOGLE, "pack1gt");

    OpenIAB.mapSku(SKU2, OpenIAB_Android.STORE_GOOGLE, "pack2gt");

    OpenIAB.mapSku(SKU3, OpenIAB_Android.STORE_GOOGLE, "pack3gt");

    OpenIAB.mapSku(SKU4, OpenIAB_Android.STORE_GOOGLE, "estateagenbundle");

    OpenIAB.mapSku(SKU5, OpenIAB_Android.STORE_GOOGLE, "landlordbundle");

    OpenIAB.mapSku(SKU6, OpenIAB_Android.STORE_GOOGLE, "miraclebundle");

`

Here below is correct or not ? `

    public void pack1gt() {
    OpenIAB.purchaseProduct(SKU1);
}

public void pack2gt() {
    OpenIAB.purchaseProduct(SKU2);
}

`

Here how to recognize each product when success ? `

    private void purchaseSucceededEvent(Purchase purchase)
{
    Debug.Log("purchaseSucceededEvent: " + purchase);
    Debug.Log ("purchasesuccess: " + purchase.AppstoreName);
    Debug.Log ("purchasesuccess: " + purchase.Sku);
    _label = _label + "\n" + "PURCHASED:" + purchase.ToString();
    OpenIAB.consumeProduct(purchase);
    Debug.Log (_label);
    if (purchase.Sku == "pack1gt") {
        sp.pack1gt ();
    } else if (purchase.Sku == "pack2gt") {
        sp.pack2gt ();
    } else if (purchase.Sku == "pack3gt") {
        sp.pack3gt ();
    } else if (purchase.Sku == "estateagenbundle") {
        sp.EstateAgentBundle ();
    } else if (purchase.Sku == "landlordbundle") {
        sp.LandLordBundle ();
    } else if (purchase.Sku == "miraclebundle") {
        sp.MiracleBundle ();
    }

}

`

Thank Very Much Dennis

DennisLiu88 commented 6 years ago

I found the solution my self. I posted it at stackoverflow. Here : The Solution Here