Ejemplo n.º 1
0
        public void RetrieveProducts(ReadOnlyCollection <ProductDefinition> products, Action <bool, string> callback)
        {
            if (m_Bridge != null)
            {
                if (m_RetrieveProductsCallbackCache != null)
                {
                    callback(false, "{ \"error\" : \"already retrieving products\" }");
                    return;
                }

                m_RetrieveProductsCallbackCache = callback;
                Action <bool, object> retrieveCallback = OnInventoryQueried;

                var           retrieveProductsMethod = UdpIapBridgeInterface.GetRetrieveProductsMethod();
                List <string> ids = new List <String>();
                foreach (var product in products)
                {
                    ids.Add(product.storeSpecificId);
                }
                retrieveProductsMethod.Invoke(m_Bridge, new object[] { new ReadOnlyCollection <string>(ids), retrieveCallback });
            }
            else
            {
                Debug.LogError("Cannot Retrieve Products from UDP. Please make sure your UDP package is installed and up-to-date");
                throw new NotImplementedException();
            }
        }
Ejemplo n.º 2
0
 public void FinishTransaction(ProductDefinition productDefinition, string transactionID)
 {
     if (m_Bridge != null)
     {
         var finishTransactionMethod = UdpIapBridgeInterface.GetFinishTransactionMethod();
         finishTransactionMethod.Invoke(m_Bridge, new object[] { transactionID });
     }
     else
     {
         Debug.LogError("Cannot Complete transaction for UDP. Please make sure your UDP package is installed and up-to-date");
         throw new NotImplementedException();
     }
 }
Ejemplo n.º 3
0
 public void Purchase(string productId, Action <bool, string> callback, string developerPayload = null)
 {
     if (m_Bridge != null)
     {
         var purchaseMethod = UdpIapBridgeInterface.GetPurchaseMethod();
         purchaseMethod.Invoke(m_Bridge, new object[] { productId, callback, developerPayload });
     }
     else
     {
         Debug.LogError("Cannot Purchase via UDP. Please make sure your UDP package is installed and up-to-date");
         throw new NotImplementedException();
     }
 }
Ejemplo n.º 4
0
 public void Initialize(Action <bool, string> callback)
 {
     if (m_Bridge != null)
     {
         var initMethod = UdpIapBridgeInterface.GetInitMethod();
         initMethod.Invoke(m_Bridge, new object[] { callback });
     }
     else
     {
         Debug.LogError("Cannot Initialize UDP store module. Please make sure your UDP package is installed and up-to-date");
         throw new NotImplementedException();
     }
 }
Ejemplo n.º 5
0
        public UDPBindings()
        {
            Type udpIapBridge = UdpIapBridgeInterface.GetClassType();

            if (udpIapBridge != null)
            {
                m_Bridge = Activator.CreateInstance(udpIapBridge);
            }
            else
            {
                Debug.LogError("Failed to access UDP. Please make sure your UDP package is installed and up-to-date");
                throw new NotImplementedException();
            }
        }
Ejemplo n.º 6
0
        private INativeStore GetAndroidStoreHelper(IUnityCallback callback, AppStore store, IPurchasingBinder binder,
                                                   IUtil util)
        {
            switch (store)
            {
            case AppStore.AmazonAppStore:
                using (var pluginClass = new AndroidJavaClass("com.unity.purchasing.amazon.AmazonPurchasing"))
                {
                    // Switch Android callbacks to the scripting thread, via ScriptingUnityCallback.
                    var proxy    = new JavaBridge(new ScriptingUnityCallback(callback, util));
                    var instance = pluginClass.CallStatic <AndroidJavaObject> ("instance", proxy);
                    // Hook up our amazon specific functionality.
                    var extensions = new AmazonAppStoreStoreExtensions(instance);
                    binder.RegisterExtension <IAmazonExtensions> (extensions);
                    binder.RegisterConfiguration <IAmazonConfiguration> (extensions);
                    return(new AndroidJavaStore(instance));
                }

            case AppStore.UDP:
            {
                Type udpIapBridge = UdpIapBridgeInterface.GetClassType();
                if (udpIapBridge != null)
                {
                    UDPImpl     udpImpl     = new UDPImpl();
                    UDPBindings udpBindings = new UDPBindings();
                    udpImpl.SetNativeStore(udpBindings);
                    binder.RegisterExtension <IUDPExtensions>(udpImpl);
                    return(udpBindings);
                }
                else
                {
                    Debug.LogError("Cannot set Android target to UDP. Make sure you have installed UDP in your project");
                    throw new NotImplementedException();
                }
            }
            }

            throw new NotImplementedException();
        }