cancel
Showing results for 
Search instead for 
Did you mean: 

IAPs Not working second time

alkashebat
Protege

I have a consumable item setup in my Meta Dashboard and have it implemented in my game. When you go buy it in-game for the first time, the pop ups to purchase appears and you can purchase it. Then the next time you try to purchase, there's no popup. But the purchase is successful and the currency is being given. 
Support saying "go on forums" but no one ever answers me. 

Can anybody help me? im pretty sure my script IS okay.

Unity 2021.3.19f1

1 ACCEPTED SOLUTION

Accepted Solutions

After you call the checkout flow and successfully make the purchase, you dispense currency in your game. Ideally, what you should do after that is to call Platform.IAP.ConsumePurchase() to notify the API that you have successfully dispensed the currency. Kinda like this:

Platform.IAP.ConsumePurchase([your_SKU_here]).OnComplete([newVariable] => 
{
    if ([newVariable].IsError) {
        // Insert whatever bit of code to execute here if ConsumePurchase fails.
    }
    else {
        // Insert whatever bit of code to execute here if ConsumePurchase is successful.
        // You can use [newVariable].Data to access any other data that was fetched
        // when ConsumePurchase was executed.
    }
});

 

AFAIK, this only works for consumables. It should make the purchase popup prompt show up again.

View solution in original post

14 REPLIES 14

onenightblitz
Protege

Did you call ConsumePurchase() after dispensing your currency? That should clear the product from the user's purchases.

No, i didnt

 

okay i just tried, didnt work even for Durable item. How can we or i invite Oculus (Meta) Employee here? it seems to be their bug, not mine. 


After you call the checkout flow and successfully make the purchase, you dispense currency in your game. Ideally, what you should do after that is to call Platform.IAP.ConsumePurchase() to notify the API that you have successfully dispensed the currency. Kinda like this:

Platform.IAP.ConsumePurchase([your_SKU_here]).OnComplete([newVariable] => 
{
    if ([newVariable].IsError) {
        // Insert whatever bit of code to execute here if ConsumePurchase fails.
    }
    else {
        // Insert whatever bit of code to execute here if ConsumePurchase is successful.
        // You can use [newVariable].Data to access any other data that was fetched
        // when ConsumePurchase was executed.
    }
});

 

AFAIK, this only works for consumables. It should make the purchase popup prompt show up again.

should i put it inside LaunchCheckoutFlowCallback after the purchase is complete? or it should be a void?

IAP.ConsumePurchase(FiveThousandDabloonString).OnComplete(msg =>
{
if (msg.IsError)
{
// Insert whatever bit of code to execute here if ConsumePurchase fails.
}
else
{
// Insert whatever bit of code to execute here if ConsumePurchase is successful.
// You can use [newVariable].Data to access any other data that was fetched
// when ConsumePurchase was executed.
}
});

can the NewVariable be a msg? or no?

```private void Buy5000DabloonsCallback(Message<Oculus.Platform.Models.Purchase> msg)
    {
        if (msg.IsError)
        {
 
            buy5000.PurchasingText.SetActive(false);
            buy5000.PurchaseDidntComplete.SetActive(true);
            return;
 
        }
        else
        {
 
            IAP.ConsumePurchase(FiveThousandDabloonString).OnComplete(msg =>
            {
                if (msg.IsError)
                {
 
                    buy5000.PurchasingText.SetActive(false);
                    buy5000.PurchaseDidntComplete.SetActive(true);
                    return;
 
                }
                else
                {
 
                    TheCloudScript.amountToGive = 5000;
                    TheCloudScript.GiveCurrency();
                    playFabLogin.GetVirtualCurrencies();
                    buy5000.PurchasingText.SetActive(false);
                    buy5000.PurchasedText.SetActive(true);
 
                    //purchasedItems.text = string.Empty;
                    GetPurchases();
                    GetPrices();
 
                }
            });
 
            
 
        }```

Now my script looks like this. If the purchase is success, then it consuming the purchase and if theres no errors it gives the currency.

ITS WORKING! THANKS! ITS BEEN 2 WEEKS!

Do you know anything like that but for Durable items?