I’m having trouble getting IAP to work on iOS. It was working a long time ago, i’m not sure when it broke. I haven’t been able to get any version of In-App Purchasing to work now. The current version I’m trying is 4.0.0 but I also tried 3.2.3 and 2.1.1. I’m using Unity version 2020.1.14f1
Even with 3.x+ versions of IAP when I click the Update button in the IAP services window it installs a bunch of stuff in Assets/Plugins/UnityPurchasing. It doesn’t create IAPProductCatalog.json, BillingMode.json, AppleTangle.cs, or GooglePlayTangle.cs though. So to resolve the errors after clicking Update I delete everything out of Assets/Plugins/UnityPurchasing. Errors go away and purchasing works in the editor. Then when I build to device and run on an iPhone I have the sandbox purchase go through (I get the "You’re all set. your purchase was successful. [Environment: Sandbox] message) but then nothing happens instead of giving the purchased item.
In my Apple portal all of my billing, banking, and tax info is up to date.
Am I installing IAP wrong? Any insight would be greatly appreciated. log attached
Can you edit your post please and add the logs as an attachment? It will be much easier to read, thanks. Also, you only install IAP from Package Manager, do not use the Services window nor click on any Import buttons. When the upgrade is complete, you should make sure to delete /Assets/Plugins/UnityPurchasing. Ensure to make a full project backup before doing any major upgrades.
Thanks Jeff, my post has been updated with the log as an attachment.
I made a new build with Assets/Plugins/UnityPurchasing folder deleted and I’m still having the same issue. I will stay away from the service window update button.
Another thing that might be worth noting is that the sandbox account only lets me attempt purchasing each IAP once. After I get the message that the purchase worked in the sandbox environment the next time I click that same IAP button nothing happens. This happens even on consumable purchases that should be repeatable.
The logs say that you have a Null Reference Exception in ProcessPurchase, you’ll want to debug there. Also compare your code to the Sample IAP Project.
@JeffDUnity3D I know this is a bit off topie but Could you please update Sample IAP Project with the new version 4.0 ? I have a problem with the change from “IGooglePlayStoreExtensions” to “IGooglePlayConfiguration” regarding the “?.SetDeferredPurchaseListener(OnPurchaseDeferred);”
in my IAPManager but the Changelog in 4.0.0 says
Changed: - IGooglePlayStoreExtensions.SetDeferredPurchaseListener to IGooglePlayConfiguration.SetDeferredPurchaseListener
and naturally now I get an error at that line of code because of the change
In Package Manager for In App Purchasing 4.0.0, I would encourage you to Import the deferred purchase sample, it will demonstrate the updated code:
var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
builder.Configure<IGooglePlayConfiguration>().SetDeferredPurchaseListener(OnDeferredPurchase);
this working fine for android , but when i am trying to pass the ios apple review team , it always getting rejected with this error : “When validating receipts on your server, your server needs to be able to handle a production-signed app getting its receipts from Apple’s test environment. The recommended approach is for your production server to always validate receipts against the production App Store first. If validation fails with the error code “Sandbox receipt used in production,” you should validate against the test environment instead.”
so i googled the validating receipt , but couldnt find what and where to add the right things .
i already looked on this : Unity - Manual: Receipt validation
but this wasnt clear enough to help me where i want to add those codes.
can someone give the steps where to start?
This is a separate issue, typically you would want to start a new thread. However, this is a known limitation with Codeless IAP, it does not support receipt validation which is required by Apple. You will want to use Scripted IAP instead, perhaps start with the Sample IAP Project v2 here, or the shipping Samples with IAP 4.x https://discussions.unity.com/t/700293/3
This thread is discussing IAP on iOS. You are showing the Google (Android) code, just comment out that line. I believe you are missing the closing > character
The API hasn’t changed much, so I’m unsure what you are referring to. I have written the code for you, in the Sample IAP Project. We also have many great Samples that ship with the product, you can view them in Package Manager.
And this thread is discussing iOS, you are posting a Google issue. I have purposely left the code as-is in the Sample IAP Project to motivate the user to understand the updated code. I will go ahead and lock this thread now. Ensure to be using IAP 4.1.3 (or higher)