Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by bouemama · Aug 29, 2021 at 07:47 AM · iap

Last unity iap version bug !

unity IAP for UWP build "Initialized" but return google play error on windows 10 platform when try buying .

alt text

I use the Last "Sample IAP Project" and Last unityIap this is my code:

 using System;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.Purchasing;
 using UnityEngine.UI;
 using UnityEngine.Purchasing.Security;
 
 
 public class MyIAPManager : MonoBehaviour, IStoreListener
 {
     private static IStoreController m_StoreController;      
     private static IExtensionProvider m_StoreExtensionProvider; subsystems.
     private IAppleExtensions m_AppleExtensions;
     private IGooglePlayStoreExtensions m_GoogleExtensions;
     private IMicrosoftExtensions m_MicrosoftExtensions;
 
 
     public static string RemoveAds = "RemoveAds";
     public static string GOLD_50 = "gold50";
     public static string NONCONSUMABLE1 = "nonconsume1";
     public static string WEEKLYSUB = "weeklysub";
  
     public Text myText;
  
     void Awake()
     {
 
     }
 
  
     void Start()
     {
         // If we haven't set up the Unity Purchasing reference
         if (m_StoreController == null)
         {
             // Begin to configure our connection to Purchasing, can use button click instead
             //InitializePurchasing();
         }
     }
 
     public void MyInitialize()
     {
         InitializePurchasing();
     }
 
     public void InitializePurchasing()
     {
         if (IsInitialized())
         {
             return;
         }
 
         var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
         builder.Configure<IMicrosoftConfiguration>().useMockBillingSystem = true;
         builder.AddProduct(RemoveAds, ProductType.Consumable);
 
         MyDebug("Starting Initialized...");
         UnityPurchasing.Initialize(this, builder);
 
     }
 
 
     private bool IsInitialized()
     {
         return m_StoreController != null && m_StoreExtensionProvider != null;
     }
 
     public void BuySubscription()
     {
         BuyProductID(WEEKLYSUB);
     }
 
  
     public void BuyGold50()
     {
         BuyProductID(RemoveAds);
     }
 
     public void BuyNonConsumable()
     {
         BuyProductID(NONCONSUMABLE1);
     }
   
     public void RestorePurchases()
     {
         m_StoreExtensionProvider.GetExtension<IAppleExtensions>().RestoreTransactions(result => {
             if (result)
             {
                 MyDebug("Restore purchases succeeded.");
             }
             else
             {
                 MyDebug("Restore purchases failed.");
             }
          });
     }
 
     void BuyProductID(string productId)
     {
         if (IsInitialized())
         {
             UnityEngine.Purchasing.Product product = m_StoreController.products.WithID(productId);
 
             if (product != null && product.availableToPurchase)
             {
                 MyDebug(string.Format("Purchasing product:" + product.definition.id.ToString()));
                 m_StoreController.InitiatePurchase(product);
             }
             else
             {
                 MyDebug("BuyProductID: FAIL. Not purchasing product, either is not found or is not available for purchase");
             }
         }
         else
         {
             MyDebug("BuyProductID FAIL. Not initialized.");
         }
     }
 
     public void ListProducts()
     {
 
         foreach (UnityEngine.Purchasing.Product item in m_StoreController.products.all)
         {
             if (item.receipt != null)
             {
                 MyDebug("Receipt found for Product = " + item.definition.id.ToString());
             }
         }
     }
     public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
     {
         MyDebug("OnInitialized: PASS");
 
         m_StoreController = controller;
         m_StoreExtensionProvider = extensions;
         m_AppleExtensions = extensions.GetExtension<IAppleExtensions>();
         m_GoogleExtensions = extensions.GetExtension<IGooglePlayStoreExtensions>();
         m_MicrosoftExtensions = extensions.GetExtension<IMicrosoftExtensions>();
 
 
         m_GoogleExtensions?.SetDeferredPurchaseListener(OnPurchaseDeferred);
 
         Dictionary<string, string> dict = m_AppleExtensions.GetIntroductoryPriceDictionary();
 
         foreach (UnityEngine.Purchasing.Product item in controller.products.all)
         {
 
             if (item.receipt != null)
             {
                 string intro_json = (dict == null || !dict.ContainsKey(item.definition.storeSpecificId)) ? null : dict[item.definition.storeSpecificId];
 
                 if (item.definition.type == ProductType.Subscription)
                 {
                     SubscriptionManager p = new SubscriptionManager(item, intro_json);
                     SubscriptionInfo info = p.getSubscriptionInfo();
                     MyDebug("SubInfo: " + info.getProductId().ToString());
                     MyDebug("isSubscribed: " + info.isSubscribed().ToString());
                     MyDebug("isFreeTrial: " + info.isFreeTrial().ToString());
                 }
             }
         }
     }
 
     public void OnPurchaseDeferred(Product product)
     {
 
         MyDebug("Deferred product " + product.definition.id.ToString());
     }
 
     public void OnInitializeFailed(InitializationFailureReason error)
     {
         // Purchasing set-up has not succeeded. Check error for reason. Consider sharing this reason with the user.
         MyDebug("OnInitializeFailed InitializationFailureReason:" + error);
     }
 
 
     public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)
     {
 
         try
         {
             Debug.Log("Application.identifier="+ Application.identifier);
             var validator = new CrossPlatformValidator(GooglePlayTangle.Data(), AppleTangle.Data(), Application.identifier);
             var result = validator.Validate(args.purchasedProduct.receipt);
             MyDebug("Validate = " + result.ToString());
 
             foreach (IPurchaseReceipt productReceipt in result)
             {
                 MyDebug("Valid receipt for " + productReceipt.productID.ToString());
             }
         }
         catch (Exception e)
         {
             MyDebug("Error is " + e.Message.ToString());
         }
 
         MyDebug(string.Format("ProcessPurchase: " + args.purchasedProduct.definition.id));
 
         return PurchaseProcessingResult.Complete;
      
      }
 
 
     public void OnPurchaseFailed(UnityEngine.Purchasing.Product product, PurchaseFailureReason failureReason)
     {
         MyDebug(string.Format("OnPurchaseFailed: FAIL. Product: '{0}', PurchaseFailureReason: {1}", product.definition.storeSpecificId, failureReason));
     }
 
 
     private void MyDebug(string debug)
     {
       
         Debug.Log(debug);
         myText.text += "\r\n" + debug;
     }
 
 }

please help thnx.

sd.png (144.6 kB)
Comment
Add comment
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

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

125 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 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 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

Simple In App Purchase on iOS 9 Answers

In App Billing by Alipay, how to check if google services is not available 0 Answers

Authentication error when testing Unity IAP on an Android device 1 Answer

Can I remove READ_PHONE_STATE permission on android while using Unity IAP? 3 Answers

In App Purchase, after restart game 1 Answer


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