Beispiel #1
0
        public bool AcknowledgePurchase(GxUserType gxStoreConfig, string productId, GxUserType gxPurchaseResult)
        {
            IStoreManager          storeMgr = null;
            int                    errCode  = GetManager(gxStoreConfig, 2, out storeMgr);
            GooglePlayStoreManager mgr      = (GooglePlayStoreManager)storeMgr;
            PurchaseResult         purchase = JSONHelper.Deserialize <PurchaseResult>(gxPurchaseResult.ToJSonString());

            try
            {
                return(mgr.AcknowledgePurchase(productId, purchase));
            }
            catch (StoreConfigurationException e)
            {
                errCode        = 3;
                ErrDescription = e.Message;
            }
            catch (StoreInvalidPurchaseException e)
            {
                errCode        = 2;
                ErrDescription = e.Message;
            }
            catch (StoreServerException e)
            {
                errCode        = 4;
                ErrDescription = e.Message;
            }
            catch (StoreException e)
            {
                errCode        = 10;
                ErrDescription = e.Message;
            }
            return(false);
        }
Beispiel #2
0
        public int GetManager(GxUserType gxStoreConfig, int platform, out IStoreManager mgr)
        {
            Init();
            JObject storeConfig = (JObject)gxStoreConfig.GetJSONObject();

            mgr = null;
            int errCode = 1;

            switch (platform)
            {
            case 2:
                string appleKey;
                if (GetConfigValue("appleKey", storeConfig, out appleKey))
                {
                    mgr     = new AppleStoreStoreManager(appleKey);
                    errCode = 0;
                }
                break;

            case 1:
                string sAccount, certPath, certPassword;

                if (GetConfigValue("googleServiceAccount", storeConfig, out sAccount) &&
                    GetConfigValue("googleCertificate", storeConfig, out certPath) &&
                    GetConfigValue("googleCertificatePassword", storeConfig, out certPassword))
                {
                    mgr = new GooglePlayStoreManager()
                    {
                        CertificatePassword = certPassword, CertificatePath = certPath, ServiceAccountEmail = sAccount
                    };
                    errCode = 0;
                }
                break;

            default:
                throw new StoreInvalidPurchaseException("StoreManager Platform not implemented");
            }
            ErrCode = errCode;
            return(errCode);
        }