Skip to main content
Inspiring
March 17, 2023
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

Inspiring
March 17, 2023

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

Inspiring
March 17, 2023

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

Inspiring
March 17, 2023

No, i didnt

 

Inspiring
March 17, 2023

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.

Inspiring
May 10, 2023

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

Inspiring
May 12, 2023