Android promo-code works every time player starts the game.

Hello!
I’m getting very strange behaviour on IAP plugin 2.1.0 and 2019.4.6f1 with stock purchasing code.
I have a product “product250Gold” which normally ads 250 gold after purchasing. I also have promo-codes created for this product. The product itself is initialized as Consumable:

builder.AddProduct(product250Gold, ProductType.Consumable, new IDs() { { product250GoldApple, AppleAppStore.Name }, { product250GoldGoogle, GooglePlay.Name } });

Here is the strange thing: If player redeems a promo code with this product he/she gets 250 gold every time the game is launched! Even after game is deleted and re-installed.
Could you please help me to fix this issue?

Are you receiving a ProcessPurchase call IAP initialization for this product? Please show your code for ProcessPurchase. I personally have not tested promo codes.

Thanks for the quick response!
Yes, I do receive ProcessPurchase call, it is the only way to add Gold, and gold amount is increasing every launch.
Here is my code:

        public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs e)
        {
            bool validPurchase = true; // Presume valid for platforms with no R.V.
#if !UNITY_EDITOR
#if UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX
            var validator = new CrossPlatformValidator(GooglePlayTangle.Data(), AppleTangle.Data(), Application.identifier);

            try
            {
                var result = validator.Validate(e.purchasedProduct.receipt);

                foreach (IPurchaseReceipt productReceipt in result)
                {
                    GooglePlayReceipt google = productReceipt as GooglePlayReceipt;
                    if (null != google)
                    {
                        //Debug.Log(google.purchaseState);
                        //Debug.Log(google.purchaseToken);
                    }

                    AppleInAppPurchaseReceipt apple = productReceipt as AppleInAppPurchaseReceipt;
                    if (null != apple)
                    {
                        //Debug.Log(apple.originalTransactionIdentifier);
                    }
                }
            }
            catch (IAPSecurityException ex)
            {
                validPurchase = false;
                return PurchaseProcessingResult.Complete;
            }
#endif
#endif

            if (validPurchase)
            {
                // Unlock the appropriate content here.
                if (String.Equals(e.purchasedProduct.definition.id, product250Gold, StringComparison.Ordinal))
                {
                    //Some code to add 250 gold
                }
            }

            return PurchaseProcessingResult.Complete;
        }

I have the same problem. You can selectively apply in-app products and redeem promotional codes. When the product is purchased at the store, “This product is already owned” appears, and when the app is initialized and restarted, the item entered as the promotion code in the public PurchaseProcessingResult ProcessPurchase (PurchaseEventArgs e) function continues to appear at the same time as the IAP initialization. What should I do?

@JeffDUnity3D
I think, that it is almost the same problem: [bug] Unity IAP 2.2.5 cannot ConfirmPendingPurchase
Consumable products doesn’t consume after app relaunch.
I have the same problem with promo codes too.

That is a separate topic, please don’t mix issues.

I am able to purchase consumable products multiple times. Please compare to the behavior without promo codes.

I received an in-app product reward with a promotional code, and when I checked the receipt, there is no orderID. In case it is not consumed because of this, it continues PurchaseProcessingResult ProcessPurchase (PurchaseEventArgs e)
Is the function being called? Is it not related?

Interesting. Do non-promo products work as expected? Are you returning Complete from ProcessPurchase?

For in-app products that are not promotional products, there is no problem if you return Complete from ProcessPurchase.
However, in the case of an in-app product registered as a promotional product, there is no OrderID in the receipt, and even if ProcessPurchase returns Complete, the problem is that the ProcessPurchase function is called and the corresponding promotional product continues to enter when the application is rerun.

Please understand that I am not good at English.
In summary

  1. Register one of the in-app products registered in the app as a promotional reward product.
  2. Enter the promotion code to receive the reward product from the app through the ProcessPurchase function and return Complete.
  3. There is no OrderID when checking receipt in ProcessPurchase function.
  4. Whenever the app is closed and run again, IAP is initialized and the promotional reward product is continuously displayed through the ProcessPurchase function.
  5. There is no problem when purchasing other products sold in the app that are not promotional reward products.

Got it, so the answer is yes. We are checking.

“No OrderID” is expected behaviour for promo codes:
https://developer.android.com/google/play/billing/integrate
“For one-time products, every purchase creates a new purchase token. Most purchases also generate a new Order ID. The exception to this is when the user is not charged any money, as described in Promo codes.”
https://developer.android.com/google/play/billing/security
“Note: Do not use orderId to check for duplicate purchases or as a primary key in your database, as not all purchases are guaranteed to generate an orderId. In particular, purchases made with promo codes do not generate an orderId.”

Correct, we are continuing to test this feature.

Hello I am using the 2019.4.16f1 LTS version and I am experiencing the same phenomenon. Need a quick fix.

Sorry a quick fix is not available. We are working on a tested solution however and should be available soon.

Thank you

Hello!
Could you please confirm if this bug is fixed in versions 3.1.0 and 2.2.8?

On April 1st, the item received as a promotional code was updated to IAP version 2.2.8 and ran again, and the item is still coming in.

We have not addressed the issue yet, you’ll see the mention in the release notes. It’s still several weeks out.

1 Like