Is there anyone that has gotten IAP integrated into their Unity mobile game that can provide some steps on how they went about testing that it was working? I've done the following, but when I try to call LaunchCheckoutFlow I get the following error when my callback is triggered (also, there is NO list anywhere in the documentation that explains what the error codes mean or why they would be thrown):
LaunchCheckoutFlowCallback Error code: 1 http: -1 msg: IAP not purchased
I am able to call the other IAP related functions (get user purchases and get products for sku), but I cannot test an actual purchase.
Steps I have taken so far: I have set up my oculus id as a developer for the app. I built and loaded an apk onto my device (since you can't test checkout from the Unity editor) When the code that should trigger the checkout flow is run, the Gear Store scene loads, but a message saying no purchase was made is displayed.
What steps am I missing here in order to test whether the IAP worked? Do I actually need to upload a build to the dashboard in order to test IAP? (Please tell me this isn't the case, because that would make iterative development a real PITA). Do I need to use Test Users somehow? Can we please get some clear documentation or examples on how to set this all up?
You shouldn't need to download the app through the Gear store to test things out. You should be able to use test users so you don't need to spend real money on testing IAP purchase.
You should have a test user tab on the developer portal where you can create new test accounts. These should automatically have a test credit card attached to them. You'll need to login to the Oculus app on your phone using these credentials and then run through the test purchase.
If your call to get products for SKU works correctly then your items are most likely set up correctly and should be fine. Let me know if switching to a test user account changes anything with your test.
I created a test user and logged in on my phone using the generated email and the password I provided. However, now my GetProductsBySKU function is returning with a 500 Internal Server Error.
Yeah, saw your thread about it too. Interestingly, I do not get 500 errors when calling GetProductsBySKU/GetPurchases when running through the Unity Editor with my developer user token entered - although you can't test LaunchCheckoutFlow from within the Editor.
I also do not have a problem calling GetProductsBySKU/GetPurchases on device when using my real oculus account - however, in that case LaunchCheckoutFlow does not work. Using my real account, I am able to bring up the purchase confirmation dialog in Bait!, the one game it seems to have implemented IAP.
My test user password meets the password requirements for an account. I have also entered in one of the test credit card numbers listed in the platform documentation.
Hopefully we can get an answer on what's going on here soon. Maybe it's some kind of in-development authentication/certificate problem that the platform backend isn't handling?
When running in the Unity Editor (entering in my real accounts user token into the platform settings menu), I have no problem calling GetProductsBySKU/GetPurchases. Of course, you can't test LaunchCheckoutFlow from the editor, so that's as far as you can go in editor.
So next I do a build and run of my app and push it to device. The Development flag is set on the build.
If I use my real account, I can see through LogCat that GetProductsBySKU/GetPurchases works. However LaunchCheckoutFlow fails. I am able to get to the purchase confirmation page in Bait!, the only game that I know of that has successfully integrated IAP.
When I switch to using my test account, I am able to log in to the oculus app. My test user password meets the password requirements. I have entered one of the test credit card numbers listed in the platform documentation. Unfortunately, GetProductsBySKU/GetPurchases suffer from 500 internal server errors.
Given that the server error is not consistent across Unity editor, device with real account, and device with test account, I have a suspicion that there is something possibly wrong on the authentication/certificate side of things.
Hopefully we can get an update on what is going on this today.
I was able to get IAP calls working successfully this morning on a device using Unity. The following is the list of steps I took:
1. Created a new Gear app. Apps are tied to a given platform so you need a Gear appID to run on Gear. 2. Added my Oculus account as a developer on the new app. 3. Installed Unity 5.3.4p3. 4. Installed the OVR plugin for Unity found here (https://developer.oculus.com/downloads/game-engines/1.3.2/OVRPlugin_for_Unity_5/) 5. Generated an OSIG file for my device. 6. Created a new unity project. 7. Added my OSIG to Assets/Plugins/Android/Assets 8. In the Start() method of my main scene I added a call to Core.Initialize("<YourAppIDHere>"); 9. To verify that I properly own the app I then call Entitlements.IsUserEntitledToApplication().OnComplete(getEntitlementCallback);
10. My callback code outputs success or failure and in the case of success attempts to make an IAP purchase:
void getEntitlementCallback(Message msg)
{
if (!msg.IsError)
{
printOutputLine("You are entitled to use this app.");
printOutputLine("You are NOT entitled to use this app.");
}
}
11. I build and run the project with Android as the target platform which copies the APK to my device. 12. I launch the app from the device.
This flow works for me and I'm prompted to confirm the purchase of the IAP item. This is using a normal account with a valid credit card attached to the account. Can you guys see if you can get this working or if you're missing a step?
The only step that I am not making is the Entitlements.IsUserEntitledToApplication() call, because I thought I saw in the documentation somewhere that that call was not necessary on Unity builds. I'll try including that in my initialization flow to see if it makes a difference.
However, I'm trying to get this to work with a test user account. Do I need to add the test user account as a developer of the app in order to "trick" the platform into thinking the test user is entitled?
Another question - does the platform sdk require that the user be entitled to the application in order to make the other IAP product/purchase status requests?
In short, adding the IsUserEntitled check (the one missing step) does not change anything for me. I'm following all the other steps outlined above.
More detail:
When using a test user on device, the entitlement check fails. Also, there is no quick way to add a test user as a developer for an application (to grant them the entitlement). Test users do not show up in the Organization account list. So there is no way to use the generated test users for IAP...
If I switch to my actual oculus account that is registered as a developer for this app, the entitlement check passes, and calls to GetPurchases and GetProducts work.
However, when I try to LaunchCheckout I get an error in Oculus Home that says "Something went wrong with your purchase. Please try again later." The returned error message values: Error code: 1 http: -1 msg: IAP not purchased
Basically, I am right back where we started. If I need to share code with someone at Oculus to figure this out, I'm happy to do so.
Hmm, one thing I noticed that is different is I am now using Unity 5.3.4p5, since that's the new safe version to use as it has built-in OVRPlugin 1.3.2 support.