Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by diegomh7 · May 19, 2016 at 02:16 PM · google playapiiap

IAP failing on google play, is this because the app is in beta?

This may be something as simple as because the App is unpublished on google plays side and I've only uploaded a Beta version and therefore fails. BUT, if I publish it and it's not that, my plan to take over the world and make bazillions fails and no one will be able to buy anything and I'll end up as poor as now :)

Just to make things easier here's my entire purchaser script, the only thing I'm doing it clicking a button on the scene which calls a corresponding BuykProductIDConsumable99p() function on a button :

The returned Error is :

BuyProductID: FAIL. Not purchasing product, either is not found or is not available for purchase

The code is :

using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.Purchasing;

//DerivingthePurchaserclassfromIStoreListenerenablesittoreceivemessagesfromUnityPurchasing. public class Purchaser : MonoBehaviour, IStoreListener { private static IStoreController m_StoreController; //ReferencetothePurchasingsystem. private static IExtensionProvider m_StoreExtensionProvider; //Referencetostore-specificPurchasingsubsystems.

//Productidentifiersforallproductscapableofbeingpurchased:"convenience"generalidentifiersforusewithPurchasing,andtheirstore-specificidentifiercounterparts //forusewithandoutsideofUnityPurchasing.Definestore-specificidentifiersalsooneachplatform'spublisherdashboard(iTunesConnect,GooglePlayDeveloperConsole,etc.)

private static string kProductIDConsumable = "consumable"; //Generalhandlefortheconsumableproduct. private static string kProductIDNonConsumable = "nonconsumable"; //Generalhandleforthenon-consumableproduct. private static string kProductIDSubscription = "subscription"; //Generalhandleforthesubscriptionproduct.

private static string kProductNameAppleConsumable = "com.unity3d.test.services.purchasing.consumable"; //AppleAppStoreidentifierfortheconsumableproduct. private static string kProductNameAppleNonConsumable = "com.unity3d.test.services.purchasing.nonconsumable"; //AppleAppStoreidentifierforthenon-consumableproduct. private static string kProductNameAppleSubscription = "com.unity3d.test.services.purchasing.subscription"; //AppleAppStoreidentifierforthesubscriptionproduct.

private static string kProductNameGooglePlayConsumable = "com.unity3d.test.services.purchasing.consumable"; //GooglePlayStoreidentifierfortheconsumableproduct. private static string kProductNameGooglePlayNonConsumable = "com.unity3d.test.services.purchasing.nonconsumable"; //GooglePlayStoreidentifierforthenon-consumableproduct. private static string kProductNameGooglePlaySubscription = "com.unity3d.test.services.purchasing.subscription"; //GooglePlayStoreidentifierforthesubscriptionproduct.

private static string kProductIDConsumable99p = "ninetynine"; private static string kProductIDConsumable199 = "oneninetynine"; private static string kProductIDConsumable499 = "fourninetynine"; private static string kProductIDConsumable899 = "eightninetynine"; private static string kProductIDConsumable1499 = "fourteenninetynine";

private static string kProductNameGooglePlay99 = "com.myappname.twothousandbundle"; private static string kProductNameGooglePlay199 = "com.myappname.oneninetynine"; //Changed for forum post private static string kProductNameGooglePlay499 = "com.myappname.fourninetynine"; private static string kProductNameGooglePlay899 = "com.myappname.eightninetynine"; private static string kProductNameGooglePlay1499 = "com.myappname.onehundredk";

void Start() { //Ifwehaven'tsetuptheUnityPurchasing reference if (m_StoreController == null) { //Begintoconfigureourconnectionto Purchasing InitializePurchasing(); } }

public void InitializePurchasing() { //IfwehavealreadyconnectedtoPurchasing... if (IsInitialized()) { //...wearedonehere. return; }

//Createabuilder,firstpassinginasuiteofUnityprovidedstores. var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

regionProducts Added

builder.AddProduct( kProductIDConsumable99p, ProductType.Consumable, new IDs() { //{kProductNameGooglePlay99,AppleAppStore.Name}, {kProductNameGooglePlay99, GooglePlay.Name}, } );//Buy99p bundle

builder.AddProduct( kProductNameGooglePlay199, ProductType.Consumable, new IDs() { //{kProductNameGooglePlay199,AppleAppStore.Name}, {kProductNameGooglePlay199, GooglePlay.Name}, } );//Buy1.99 bundle

builder.AddProduct( kProductIDConsumable499, ProductType.Consumable, new IDs() { //{kProductNameGooglePlay499,AppleAppStore.Name}, {kProductNameGooglePlay499, GooglePlay.Name}, } );//Buy4.99 bundle

builder.AddProduct( kProductIDConsumable899, ProductType.Consumable, new IDs() { //{kProductNameGooglePlay899,AppleAppStore.Name}, {kProductNameGooglePlay899, GooglePlay.Name}, } );//buy8.99

builder.AddProduct( kProductIDConsumable1499, ProductType.Consumable, new IDs() { //{kProductNameGooglePlay1499,AppleAppStore.Name}, {kProductNameGooglePlay1499, GooglePlay.Name}, } );//Buy14.99

endregion

//Addaproducttosell/restorebywayofitsidentifier,associatingthegeneralidentifierwithitsstore-specificidentifiers. builder.AddProduct(kProductIDConsumable, ProductType.Consumable, new IDs(){{ kProductNameAppleConsumable, AppleAppStore.Name },{ kProductNameGooglePlayConsumable, GooglePlay.Name },});//Continueaddingthenon-consumableproduct. builder.AddProduct(kProductIDNonConsumable, ProductType.NonConsumable, new IDs(){{ kProductNameAppleNonConsumable, AppleAppStore.Name },{ kProductNameGooglePlayNonConsumable, GooglePlay.Name },});//Andfinishaddingthesubscriptionproduct. builder.AddProduct(kProductIDSubscription, ProductType.Subscription, new IDs(){{ kProductNameAppleSubscription, AppleAppStore.Name },{ kProductNameGooglePlaySubscription, GooglePlay.Name },});//Kickofftheremainderoftheset-upwithanasynchrounouscall,passingtheconfigurationandthisclass'instance.ExpectaresponseeitherinOnInitializedorOnInitializeFailed. UnityPurchasing.Initialize(this, builder); }

private bool IsInitialized() { //OnlysayweareinitializedifboththePurchasingreferencesareset. return m_StoreController != null && m_StoreExtensionProvider != null; }

public void BuyConsumable() { //Buytheconsumableproductusingitsgeneralidentifier.ExpectaresponseeitherthroughProcessPurchaseorOnPurchaseFailedasynchronously. BuyProductID(kProductIDConsumable); }

public void BuykProductIDConsumable99p() { //Buytheconsumableproductusingitsgeneralidentifier.ExpectaresponseeitherthroughProcessPurchaseorOnPurchaseFailedasynchronously. BuyProductID(kProductNameGooglePlay99); //BuyProductID(kProductNameGooglePlay99); } public void BuykProductIDConsumable199() { //Buytheconsumableproductusingitsgeneralidentifier.ExpectaresponseeitherthroughProcessPurchaseorOnPurchaseFailedasynchronously. BuyProductID(kProductNameGooglePlay199); //BuyProductID(kProductNameGooglePlay199); }

public void BuykProductIDConsumable499() { //Buytheconsumableproductusingitsgeneralidentifier.ExpectaresponseeitherthroughProcessPurchaseorOnPurchaseFailedasynchronously. BuyProductID(kProductNameGooglePlay499); //BuyProductID(kProductNameGooglePlay499); }

public void BuykProductIDConsumable899() { //Buytheconsumableproductusingitsgeneralidentifier.ExpectaresponseeitherthroughProcessPurchaseorOnPurchaseFailedasynchronously. BuyProductID(kProductNameGooglePlay899); //BuyProductID(kProductNameGooglePlay899); }

public void BuykProductIDConsumable1499() { //Buytheconsumableproductusingitsgeneralidentifier.ExpectaresponseeitherthroughProcessPurchaseorOnPurchaseFailedasynchronously. BuyProductID(kProductNameGooglePlay1499); //BuyProductID(kProductNameGooglePlay1499); }

public void BuyNonConsumable() { //Buythenon-consumableproductusingitsgeneralidentifier.ExpectaresponseeitherthroughProcessPurchaseorOnPurchaseFailedasynchronously. BuyProductID(kProductIDNonConsumable); }

public void BuySubscription() { //Buythesubscriptionproductusingitsthegeneralidentifier.ExpectaresponseeitherthroughProcessPurchaseorOnPurchaseFailedasynchronously. BuyProductID(kProductIDSubscription); }

void BuyProductID(string productId) { //Ifthestoresthrowanunexpectedexception,usetry..catchtoprotectmylogichere. try { //IfPurchasinghasbeeninitialized... if (IsInitialized()) { //...lookuptheProductreferencewiththegeneralproductidentifierandthePurchasingsystem'sproductscollection. Product product = m_StoreController.products.WithID(productId);

//Ifthelookupfoundaproductforthisdevice'sstoreandthatproductisreadytobesold... if (product != null && product.availableToPurchase) { Debug.Log (string.Format("Purchasingproductasychronously:'{0}'", product.definition.id));//...buytheproduct.ExpectaresponseeitherthroughProcessPurchaseorOnPurchaseFailedasynchronously. m_StoreController.InitiatePurchase(product); } //Otherwise... else { //...reporttheproductlook-upfailuresituation Debug.Log ("BuyProductID:FAIL.Notpurchasingproduct,eitherisnotfoundorisnotavailableforpurchase"); } } //Otherwise... else { //...reportthefactPurchasinghasnotsucceededinitializingyet.Considerwaitinglongerorretryinginitiailization. Debug.Log("BuyProductIDFAIL.Notinitialized."); } } //Completetheunexpectedexceptionhandling... catch (Exception e) { //...byreportinganyunexpectedexceptionforlaterdiagnosis. Debug.Log ("BuyProductID:FAIL.Exceptionduringpurchase." + e); } }

//Restorepurchasespreviouslymadebythiscustomer.Someplatformsautomaticallyrestorepurchases.ApplecurrentlyrequiresexplicitpurchaserestorationforIAP. public void RestorePurchases() { //IfPurchasinghasnotyetbeensetup... if (!IsInitialized()) { //...reportthesituationandstoprestoring.Considereitherwaitinglonger,orretryinginitialization. Debug.Log("RestorePurchasesFAIL.Notinitialized."); return; }

//IfwearerunningonanAppledevice... if (Application.platform == RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.OSXPlayer) { //...beginrestoring purchases Debug.Log("RestorePurchasesstarted...");

//FetchtheApplestore-specificsubsystem. var apple = m_StoreExtensionProvider.GetExtension(); //Begintheasynchronousprocessofrestoringpurchases.ExpectaconfirmationresponseintheActionbelow,andProcessPurchaseiftherearepreviouslypurchasedproductstorestore. apple.RestoreTransactions((result) => { //Thefirstphaseofrestoration.IfnomoreresponsesarereceivedonProcessPurchasethennopurchasesareavailabletoberestored. Debug.Log("RestorePurchasescontinuing:" + result + ".Ifnofurthermessages,nopurchasesavailabletorestore."); }); } //Otherwise... else { //WearenotrunningonanAppledevice.Noworkisnecessarytorestorepurchases. Debug.Log("RestorePurchasesFAIL.Notsupportedonthisplatform.Current=" + Application.platform); } }

// //--- IStoreListener //

public void OnInitialized(IStoreController controller, IExtensionProvider extensions) { //Purchasinghassucceededinitializing.CollectourPurchasingreferences. Debug.Log("OnInitialized:pASS");

//OverallPurchasingsystem,configuredwithproductsforthisapplication. m_StoreController = controller; //Storespecificsubsystem,foraccessingdevice-specificstorefeatures. m_StoreExtensionProvider = extensions; }

public void OnInitializeFailed(InitializationFailureReason error) { //Purchasingset-uphasnotsucceeded.Checkerrorforreason.Considersharingthisreasonwiththeuser. Debug.Log("OnInitializeFailedInitializationFailureReason:" + error); }

public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args) { //Aconsumableproducthasbeenpurchasedbythisuser. if (String.Equals(args.purchasedProduct.definition.id, kProductIDConsumable, StringComparison.Ordinal)) { Debug.Log(string.Format("ProcessPurchase:pASS.Product:'{0}'", args.purchasedProduct.definition.id));//Iftheconsumableitemhasbeensuccessfullypurchased,add100coinstotheplayer'sin-gamescore. //ScoreManager.score+=100; }

//Or...anon-consumableproducthasbeenpurchasedbythisuser. else if (String.Equals(args.purchasedProduct.definition.id, kProductIDNonConsumable, StringComparison.Ordinal)) { Debug.Log(string.Format("ProcessPurchase:pASS.Product:'{0}'", args.purchasedProduct.definition.id));}//Or...asubscriptionproducthasbeenpurchasedbythisuser. else if (String.Equals(args.purchasedProduct.definition.id, kProductIDSubscription, StringComparison.Ordinal)) { Debug.Log(string.Format("ProcessPurchase:pASS.Product:'{0}'", args.purchasedProduct.definition.id));}//Or...anunknownproducthasbeenpurchasedbythisuser.Fillinadditionalproductshere. else { Debug.Log(string.Format("ProcessPurchase:FAIL.Unrecognizedproduct:'{0}'", args.purchasedProduct.definition.id));}//Returnaflagindicatingwitherthisproducthascompletelybeenreceived,oriftheapplicationneedstoberemindedofthispurchaseatnextapplaunch.Isusefulwhensavingpurchasedproductstothecloud,andwhenthatsaveisdelayed. return PurchaseProcessingResult.Complete; }

public void OnPurchaseFailed(Product product, PurchaseFailureReason failureReason) { //Aproductpurchaseattemptdidnotsucceed.CheckfailureReasonformoredetail.Considersharingthisreasonwiththeuser. Debug.Log(string.Format("OnPurchaseFailed:FAIL.Product:'{0}',PurchaseFailureReason:{1}",product.definition.storeSpecificId, failureReason));} }

Please let me know which Noobish mistake I've made :)

Cheers

Diego

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
â–¼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image diegomh7 · May 19, 2016 at 12:23 PM 0
Share

Update :

I changed the google play iap package name / created a new one, and ins$$anonymous$$d of na$$anonymous$$g it the consumable name 99p for example, I added the full com.myappname.ninetynine as the bundle name.

This changed the error message, it found my url link : Win Purchasing product asychronously: 'com.myappname.ninetynine'

It then says this : ProcessPurchase: FAIL. Unrecognized product: 'com.myappname.ninetynine'

I'll update again if I figure it out before someone replies.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

54 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

UnityIAP Android restroing problems,UnityIAP doesn't call ProcessPurchase when session closed (App reload) 0 Answers

[SOLVED] Unit IAP google play response to update result 1 Answer

GooglePlayServices Conflict With Unity IAP 0 Answers

Unity IAP Conflict With Google Play Services 0 Answers

I want clear SSL Error Handler 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges