Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
alkashebat's avatar
alkashebat
Protege
2 years ago
Solved

IAPs Not working second time

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

  • 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.

15 Replies

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

      • onenightblitz's avatar
        onenightblitz
        Protege

        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.

    • alkashebat's avatar
      alkashebat
      Protege

      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. 


  • normally i'd use msg.Data to get the purchase list but if msg.GetPurchaseList() does the same thing with minimal performance impact then you should be ok