[Solved] Unity 5.3.5 IAP Test Purchase Fail

Hi,

A month or so ago my test purchases on Google Play were working as expected, until now. No code was changed, yet the receipts now fail to validate on my test device even though the user gets charged.

I/Unity  ( 8294): Receipt1: {"Store":"GooglePlay","TransactionID":"GPA.1375-0918-4825-78179","Payload":"{\"json\":\"{\\\"orderId\\\":\\\"GPA.1375-0918-4825-78179\\\",\\\"packageName\\\":\\\"com.KidKiwi.Assassin\\\",\\\"productId\\\":\\\"c_10\\\",\\\"purchaseTime\\\":1465851902579,\\\"purchaseState\\\":0,\\\"purchaseToken\\\":\\\"mbjfobejmgpopnbioijjfgan.AO-J1OwSeacZ-55nGh2PCiFw_d1woFx7Z3QWACfMpbFskToEjUCxFI-2ZuRWx1pRpIwiW5YVPSplub5xdmLBOFq-B7WKPdZVW7lRg1Eb879FMGpEPu-QQ\\\"}\",\"signature\":\"OjiV8hT+5WkOTHkzBx+YICc8iJRVzuTOxWj1TrvoNBeEoWOdRU0jEV9QsZHocMOtOP6lgAK3ye2bLFddDTeCqxfFWy3ev3MyG8TkJ7jLaSzUFiZADgPm0veedcZGG\\/zaiXsLQKHqJeIkPbZtnCthJ7nv6dozKTbOt0Lq0Q0Z9fS+PX8ROHJ5otjdIJmkeFX4FryRdxWiBHWOZP44rdfzEmwQU7JavwCiNP2nc0gS7PgQ9sMLcxnyLxSeUzp2rdaZXK7JoAniK7SdaAw\\/z20\\/2FGxJhMQ0A0XQjI2kPiw0B3\\/pZI+yD1aQFh9v\\/VQoDXhqeMXPEuX8AaA\\/DavQ==\"}"}

I/Unity  ( 8294):

I/Unity  ( 8294): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 37)

I/Unity  ( 8294):

I/Unity  ( 8294): Invalid receipt, not unlocking content
  Debug.Log("Receipt1:"+args.purchasedProduct.receipt);

if(Application.platform==RuntimePlatform.Android ||
Application.platform==RuntimePlatform.IPhonePlayer ||
Application.platform==RuntimePlatform.OSXPlayer)
{
try
{
varresult=validator.Validate(args.purchasedProduct.receipt);
Debug.Log("Receiptisvalid.Contents:");
foreach(IPurchaseReceipt productReceipt inresult)
{
id=productReceipt.productID;
Debug.Log(productReceipt.productID);
Debug.Log(productReceipt.purchaseDate);
Debug.Log(productReceipt.transactionID);

GooglePlayReceiptgoogle=productReceiptasGooglePlayReceipt;
if(null !=google)
{
Debug.Log(google.purchaseState);
Debug.Log(google.purchaseToken);
}

AppleInAppPurchaseReceiptapple=productReceiptasAppleInAppPurchaseReceipt;
if(null !=apple)
{
Debug.Log(apple.originalTransactionIdentifier);
Debug.Log(apple.cancellationDate);
Debug.Log(apple.quantity);
}
}
}
catch(IAPSecurityException)
{
Debug.Log("Invalidreceipt,notunlockingcontent");
returnPurchaseProcessingResult.Complete;
}
}

Is there a particular reason or fix for this?

Thanks

Hi Cypras,

Since you say no code changed, is there anything else that might have changed between these times? Any changes to the package name or product ids or anything else? Did you update to a new version of IAP in that time?

The package name matches the Google Play store version, all the IAP product ids match, I may have updated the IAP api, but I don’t know, that shouldn’t have broken it anyway?

It certainly shouldn’t have! :slight_smile: But trying to narrow down possible changes…Talking to one of our IAP devs, the issue sounds like the Google API key/signature may not be validating…can you try recopying your API key from Google into the IAP Obfuscator window in the editor?

Also I noticed the spacing is kind of weird in your code sample, is this your actual code and it just got messed up on the copy or is this an edited version?

This was the problem, I didn’t even know about the IAP Obfuscator window, so that’s weird.

And yes, it was just messed up on the copy.

Thank you!

1 Like

Hi Cypras,

Great! I’m glad that got it working! Here’s a link to the Purchase Validation manual pages, in case you haven’t already come across it: Unity - Manual: Receipt validation

Thanks.

Now in another project I’m getting a build error after importing Unity Purchasing. I know it’s related because when I remove Unity Purchasing it builds correctly.

See:

Error

CommandInvokationFailure: Unable to convert classes into dex format. See the Console for details.
C:/Program Files/Java/jdk1.8.0_31\bin\java.exe -Xmx2048M -Dcom.android.sdkmanager.toolsdir=“C:/Users/Josh/Documents/Android Build/Manager/sdk\tools” -Dfile.encoding=UTF8 -jar “C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar” -

stderr[
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/amazon/device/iap/package-info;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/amazon/device/iap/PurchasingListener;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/amazon/device/iap/PurchasingService;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/amazon/device/iap/ResponseReceiver;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/amazon/device/iap/internal/a;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/amazon/device/iap/internal/a/a;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/amazon/device/iap/internal/a/b;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/amazon/device/iap/internal/a/c;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/amazon/device/iap/internal/a/c$1;

UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: Translation has been interrupted
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:608)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:311)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at SDKMain.main(SDKMain.java:129)
Caused by: java.lang.InterruptedException: Too many errors
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:600)
… 9 more
]
stdout[
processing archive C:\Users\Josh\Desktop\XtinctProjects\Xtinct - Copy\Xtinct\towerdefence\Temp\StagingArea\android-libraries\AmazonAppStore\libs.\classes.jar…
ignored resource META-INF/
ignored resource META-INF/MANIFEST.MF
ignored resource com/
ignored resource com/unity/
ignored resource com/unity/purchasing/
ignored resource com/unity/purchasing/amazon/
processing com/unity/purchasing/amazon/AmazonPurchasing.class…
processing com/unity/purchasing/amazon/AmazonPurchasing$1.class…
processing com/unity/purchasing/amazon/AmazonPurchasing$2.class…
processing com/unity/purchasing/amazon/AmazonPurchasing$3.class…
processing com/unity/purchasing/amazon/AmazonPurchasing$4.class…
processing com/unity/purchasing/amazon/AmazonPurchasing$LocaleNotFoundException.class…
processing com/unity/purchasing/amazon/AmazonPurchasingService.class…
processing com/unity/purchasing/amazon/BuildConfig.class…
processing com/unity/purchasing/amazon/CurrencyMapper.class…
processing com/unity/purchasing/amazon/IPurchasingService.class…
processing archive C:\Users\Josh\Desktop\XtinctProjects\Xtinct - Copy\Xtinct\towerdefence\Temp\StagingArea\android-libraries\AmazonAppStore\libs.\in-app-purchasing-2.0.61.jar…
ignored resource META-INF/MANIFEST.MF
processing com/amazon/device/iap/package-info.class…
processing com/amazon/device/iap/PurchasingListener.class…
processing com/amazon/device/iap/PurchasingService.class…
processing com/amazon/device/iap/ResponseReceiver.class…
processing com/amazon/device/iap/internal/a.class…
processing com/amazon/device/iap/internal/a/a.class…
processing com/amazon/device/iap/internal/a/b.class…
processing com/amazon/device/iap/internal/a/c.class…
processing com/amazon/device/iap/internal/a/c$1.class…
processing com/amazon/device/iap/internal/a/d.class…
processing com/amazon/device/iap/internal/b.class…
processing com/amazon/device/iap/internal/b/a.class…
processing com/amazon/device/iap/internal/b/a/a.class…
processing com/amazon/device/iap/internal/b/a/b.class…
processing com/amazon/device/iap/internal/b/a/c.class…
processing com/amazon/device/iap/internal/b/a/d.class…
processing com/amazon/device/iap/internal/b/b.class…
processing com/amazon/device/iap/internal/b/b/a.class…
processing com/amazon/device/iap/internal/b/b/a$1.class…
processing com/amazon/device/iap/internal/b/b/b.class…
processing com/amazon/device/iap/internal/b/b/c.class…
processing com/amazon/device/iap/internal/b/b/d.class…
processing com/amazon/device/iap/internal/b/c.class…
processing com/amazon/device/iap/internal/b/c/a.class…
processing com/amazon/device/iap/internal/b/c/b.class…
processing com/amazon/device/iap/internal/b/c/c.class…
processing com/amazon/device/iap/internal/b/c/d.class…
processing com/amazon/device/iap/internal/b/d.class…
processing com/amazon/device/iap/internal/b/d/a.class…
processing com/amazon/device/iap/internal/b/d/b.class…
processing com/amazon/device/iap/internal/b/d/c.class…
processing com/amazon/device/iap/internal/b/d/d.class…
processing com/amazon/device/iap/internal/b/e.class…
processing com/amazon/device/iap/internal/b/e/a.class…
processing com/amazon/device/iap/internal/b/e/b.class…
processing com/amazon/device/iap/internal/b/e/c.class…
processing com/amazon/device/iap/internal/b/e/d.class…
processing com/amazon/device/iap/internal/b/e$1.class…
processing com/amazon/device/iap/internal/b/f.class…
processing com/amazon/device/iap/internal/b/f/a.class…
processing com/amazon/device/iap/internal/b/f/b.class…
processing com/amazon/device/iap/internal/b/f/c.class…
processing com/amazon/device/iap/internal/b/g.class…
processing com/amazon/device/iap/internal/b/g/a.class…
processing com/amazon/device/iap/internal/b/g/b.class…
processing com/amazon/device/iap/internal/b/h.class…
processing com/amazon/device/iap/internal/b/h/a.class…
processing com/amazon/device/iap/internal/b/i.class…
processing com/amazon/device/iap/internal/c.class…
processing com/amazon/device/iap/internal/c/a.class…
processing com/amazon/device/iap/internal/c/a$1.class…
processing com/amazon/device/iap/internal/c/b.class…
processing com/amazon/device/iap/internal/c/c.class…
processing com/amazon/device/iap/internal/c/d.class…
processing com/amazon/device/iap/internal/c/e.class…
processing com/amazon/device/iap/internal/d.class…
processing com/amazon/device/iap/internal/e.class…
processing com/amazon/device/iap/internal/model/ProductBuilder.class…
processing com/amazon/device/iap/internal/model/ProductDataResponseBuilder.class…
processing com/amazon/device/iap/internal/model/PurchaseResponseBuilder.class…
processing com/amazon/device/iap/internal/model/PurchaseUpdatesResponseBuilder.class…
processing com/amazon/device/iap/internal/model/ReceiptBuilder.class…
processing com/amazon/device/iap/internal/model/UserDataBuilder.class…
processing com/amazon/device/iap/internal/model/UserDataResponseBuilder.class…
processing com/amazon/device/iap/internal/model/a.class…
processing com/amazon/device/iap/internal/util/MetricsHelper.class…
processing com/amazon/device/iap/internal/util/a.class…
processing com/amazon/device/iap/internal/util/a$1.class…
processing com/amazon/device/iap/internal/util/b.class…
processing com/amazon/device/iap/internal/util/c.class…
processing com/amazon/device/iap/internal/util/d.class…
processing com/amazon/device/iap/internal/util/e.class…
processing com/amazon/device/iap/model/package-info.class…
processing com/amazon/device/iap/model/FulfillmentResult.class…
processing com/amazon/device/iap/model/Product.class…
processing com/amazon/device/iap/model/Product$1.class…
processing com/amazon/device/iap/model/ProductDataResponse.class…
processing com/amazon/device/iap/model/ProductDataResponse$RequestStatus.class…
processing com/amazon/device/iap/model/ProductType.class…
processing com/amazon/device/iap/model/PurchaseResponse.class…
processing com/amazon/device/iap/model/PurchaseResponse$RequestStatus.class…
processing com/amazon/device/iap/model/PurchaseUpdatesResponse.class…
processing com/amazon/device/iap/model/PurchaseUpdatesResponse$RequestStatus.class…
processing com/amazon/device/iap/model/Receipt.class…
processing com/amazon/device/iap/model/RequestId.class…
processing com/amazon/device/iap/model/RequestId$1.class…
processing com/amazon/device/iap/model/UserData.class…
processing com/amazon/device/iap/model/UserData$1.class…
processing com/amazon/device/iap/model/UserDataResponse.class…
processing com/amazon/device/iap/model/UserDataResponse$RequestStatus.class…
processing archive C:\Users\Josh\Desktop\XtinctProjects\Xtinct - Copy\Xtinct\towerdefence\Temp\StagingArea\android-libraries\ChartboostSDK\libs.\chartboost.jar…
ignored resource META-INF/MANIFEST.MF
processing com/chartboost/sdk/CBImpressionActivity.class…
processing com/chartboost/sdk/CBImpressionActivity$1.class…
processing com/chartboost/sdk/CBImpressionActivity$2.class…
processing com/chartboost/sdk/CBLocation.class…
processing com/chartboost/sdk/Chartboost.class…
processing com/chartboost/sdk/Chartboost$1.class…
processing com/chartboost/sdk/Chartboost$10.class…
processing com/chartboost/sdk/Chartboost$11.class…
processing com/chartboost/sdk/Chartboost$12.class…
processing com/chartboost/sdk/Chartboost$13.class…
processing com/chartboost/sdk/Chartboost$14.class…
processing com/chartboost/sdk/Chartboost$15.class…
processing com/chartboost/sdk/Chartboost$16.class…
processing com/chartboost/sdk/Chartboost$17.class…
processing com/chartboost/sdk/Chartboost$18.class…
processing com/chartboost/sdk/Chartboost$19.class…
processing com/chartboost/sdk/Chartboost$2.class…
processing com/chartboost/sdk/Chartboost$20.class…
processing com/chartboost/sdk/Chartboost$21.class…
processing com/chartboost/sdk/Chartboost$22.class…
processing com/chartboost/sdk/Chartboost$23.class…
processing com/chartboost/sdk/Chartboost$24.class…
processing com/chartboost/sdk/Chartboost$25.class…
processing com/chartboost/sdk/Chartboost$26.class…
processing com/chartboost/sdk/Chartboost$27.class…
processing com/chartboost/sdk/Chartboost$28.class…
processing com/chartboost/sdk/Chartboost$29.class…
processing com/chartboost/sdk/Chartboost$3.class…
processing com/chartboost/sdk/Chartboost$30.class…
processing com/chartboost/sdk/Chartboost$31.class…
processing com/chartboost/sdk/Chartboost$32.class…
processing com/chartboost/sdk/Chartboost$33.class…
processing com/chartboost/sdk/Chartboost$34.class…
processing com/chartboost/sdk/Chartboost$35.class…
processing com/chartboost/sdk/Chartboost$4.class…
processing com/chartboost/sdk/Chartboost$5.class…
processing com/chartboost/sdk/Chartboost$6.class…
processing com/chartboost/sdk/Chartboost$7.class…
processing com/chartboost/sdk/Chartboost$8.class…
processing com/chartboost/sdk/Chartboost$9.class…
processing com/chartboost/sdk/Chartboost$CBFramework.class…
processing com/chartboost/sdk/Chartboost$CBMediation.class…
processing com/chartboost/sdk/Chartboost$a.class…
processing com/chartboost/sdk/ChartboostActivity.class…
processing com/chartboost/sdk/ChartboostDelegate.class…
processing com/chartboost/sdk/InPlay/CBInPlay.class…
processing com/chartboost/sdk/InPlay/a.class…
processing com/chartboost/sdk/InPlay/a$1.class…
processing com/chartboost/sdk/InPlay/a$2.class…
processing com/chartboost/sdk/InPlay/a$a.class…
processing com/chartboost/sdk/InPlay/a$b.class…
processing com/chartboost/sdk/Libraries/CBLogging.class…
processing com/chartboost/sdk/Libraries/CBLogging$Level.class…
processing com/chartboost/sdk/Libraries/CBUtility.class…
processing com/chartboost/sdk/Libraries/a.class…
processing com/chartboost/sdk/Libraries/a$1.class…
processing com/chartboost/sdk/Libraries/b.class…
processing com/chartboost/sdk/Libraries/c.class…
processing com/chartboost/sdk/Libraries/c$1.class…
processing com/chartboost/sdk/Libraries/c$a.class…
processing com/chartboost/sdk/Libraries/d.class…
processing com/chartboost/sdk/Libraries/e.class…
processing com/chartboost/sdk/Libraries/e$1.class…
processing com/chartboost/sdk/Libraries/e$a.class…
processing com/chartboost/sdk/Libraries/e$b.class…
processing com/chartboost/sdk/Libraries/f.class…
processing com/chartboost/sdk/Libraries/g.class…
processing com/chartboost/sdk/Libraries/g$1.class…
processing com/chartboost/sdk/Libraries/g$a.class…
processing com/chartboost/sdk/Libraries/g$b.class…
processing com/chartboost/sdk/Libraries/g$c.class…
processing com/chartboost/sdk/Libraries/g$d.class…
processing com/chartboost/sdk/Libraries/g$e.class…
processing com/chartboost/sdk/Libraries/g$f.class…
processing com/chartboost/sdk/Libraries/g$g.class…
processing com/chartboost/sdk/Libraries/g$h.class…
processing com/chartboost/sdk/Libraries/g$i.class…
processing com/chartboost/sdk/Libraries/g$j.class…
processing com/chartboost/sdk/Libraries/g$k.class…
processing com/chartboost/sdk/Libraries/g$l.class…
processing com/chartboost/sdk/Libraries/g$m.class…
processing com/chartboost/sdk/Libraries/g$n.class…
processing com/chartboost/sdk/Libraries/g$o.class…
processing com/chartboost/sdk/Libraries/g$p.class…
processing com/chartboost/sdk/Libraries/g$q.class…
processing com/chartboost/sdk/Libraries/h.class…
processing com/chartboost/sdk/Libraries/h$a.class…
processing com/chartboost/sdk/Libraries/i.class…
processing com/chartboost/sdk/Libraries/j.class…
processing com/chartboost/sdk/Libraries/j$1.class…
processing com/chartboost/sdk/Libraries/j$2.class…
processing com/chartboost/sdk/Libraries/j$a.class…
processing com/chartboost/sdk/Libraries/k.class…
processing com/chartboost/sdk/Model/CBError.class…
processing com/chartboost/sdk/Model/CBError$1.class…
processing com/chartboost/sdk/Model/CBError$CBClickError.class…
processing com/chartboost/sdk/Model/CBError$CBImpressionError.class…
processing com/chartboost/sdk/Model/CBError$a.class…
processing com/chartboost/sdk/Model/a.class…
processing com/chartboost/sdk/Model/a$1.class…
processing com/chartboost/sdk/Model/a$a.class…
processing com/chartboost/sdk/Model/a$b.class…
processing com/chartboost/sdk/Model/a$c.class…
processing com/chartboost/sdk/Model/a$d.class…
processing com/chartboost/sdk/Model/a$e.class…
processing com/chartboost/sdk/Model/b.class…
processing com/chartboost/sdk/Tracking/CBAnalytics.class…
processing com/chartboost/sdk/Tracking/CBAnalytics$1.class…
processing com/chartboost/sdk/Tracking/CBAnalytics$CBIAPPurchaseInfo.class…
processing com/chartboost/sdk/Tracking/CBAnalytics$CBIAPType.class…
processing com/chartboost/sdk/Tracking/CBAnalytics$CBLevelType.class…
processing com/chartboost/sdk/Tracking/a.class…
processing com/chartboost/sdk/a.class…
processing com/chartboost/sdk/b.class…
processing com/chartboost/sdk/b$1.class…
processing com/chartboost/sdk/b$2.class…
processing com/chartboost/sdk/b$3.class…
processing com/chartboost/sdk/b$4.class…
processing com/chartboost/sdk/b$5.class…
processing com/chartboost/sdk/b$a.class…
processing com/chartboost/sdk/b$b.class…
processing com/chartboost/sdk/b$c.class…
processing com/chartboost/sdk/b$d.class…
processing com/chartboost/sdk/b$e.class…
processing com/chartboost/sdk/c.class…
processing com/chartboost/sdk/c$1.class…
processing com/chartboost/sdk/c$a.class…
processing com/chartboost/sdk/d.class…
processing com/chartboost/sdk/d$1.class…
processing com/chartboost/sdk/d$1$1.class…
processing com/chartboost/sdk/d$2.class…
processing com/chartboost/sdk/d$3.class…
processing com/chartboost/sdk/d$4.class…
processing com/chartboost/sdk/d$a.class…
processing com/chartboost/sdk/d$b.class…
processing com/chartboost/sdk/e.class…
processing com/chartboost/sdk/e$1.class…
processing com/char

Hi Cypras,

Check out these responses to the same issue and let me know if any work for you! (They’re all from the same forum thread, and it might be easier to just read the whole thing, but I’m calling out three key responses) :slight_smile:

Okay, for some reason my receipts are no longer giving me an ‘orderid’ field, and my transactionID field is blank. This is given when testing a published app on the Play Store.

I/Unity   (18323): Receipt1: {"Store":"GooglePlay","TransactionID":"","Payload":"{\"json\":\"{\\\"packageName\\\":\\\"com.KidKiwi.Xtinct\\\",\\\"productId\\\":\\\"2_rg30\\\",\\\"purchaseTime\\\":1466747582262,\\\"purchaseState\\\":0,\\\"purchaseToken\\\":\\\"nkmlgfcmlbkachhlfaieklfh.AO-J1OxZjzuoDh_tifqXj9b-yTRS1Pp9nVNnMC2wbei_FdL6DlkUnlAFBv1elbA1jEAVLQwvsKdB4gsGjmHnRCUSECm-ga99nsbyKI0Dr8PKbV5SbJfrC14\\\"}\",\"signature\":\"hVrgVIQoJMN+e7qNLDxGnd9G89UAaZE1NFdE18D7fcfqfyS2JrxQpniwWydsVVziIdufehsXChxJOgqf7W+j3NXlZW6WnELGH0ftwwMDsUBcR0cl3mvzleBebEqauf\\/08zsMiZzQSgKyqKUq8TDPxXkINHttPFAs\\/EHqyTJnjpH2Fqr1BdLJqdg6ZPNsuIwSlV\\/e\\/tTP1ZPjhMGw7\\/KViQgnKMKTHb\\/26A52lRBg8FXaEqFKdhx8npso5Gbwsv9trnYPz2a\\/zkLv24KfRb7\\/O3V18GoDw70y2M\\/VNdRoxEcQ0J6AhlbbxTTVT0fLxuiOyWZEziItyNiFGlJT3cJwQQ==\"}"}

Why does it do this?

Hi @Cypras et al,

The orderid no longer showing in test purchases is coming from a change from Google, we are currently looking into its possible effects on Unity IAP. Please see this forum post for updates: [Closed] Bizarre IAP behaviour on Android - Unity Services - Unity Discussions

1 Like