Beispiel #1
0
        private static void setupStripe(PurchaseConfig purchaseConfig)
        {
            StripeConfiguration.SetApiKey(purchaseConfig.stripeConfig.secretKey);

            customerService = new CustomerService();
            chargeService   = new ChargeService();
        }
    //初始化数据
    void initDate(string text)
    {
        PurchaseConfig purchaseConfig = JsonUtility.FromJson <PurchaseConfig>(text);

        //投放模式开关
        GlobalValues.openPurchase = purchaseConfig.onoff == 1 ? true : false;
        //审核开关(直接进入程序)
        GlobalValues.need_display_uurcahse = purchaseConfig.need_display_uurcahse == 1 ? true : false;

        NormalPayment normalPayment = purchaseConfig.normal_purchases;
        WeeklyOne     weeklyOne     = normalPayment.weeklyOne;
        WeeklyTwo     weeklyTwo     = normalPayment.weeklyTwo;
        string        weeklyOne_id  = weeklyOne.purchase_product_id;
        string        weeklyTwo_id  = weeklyTwo.purchase_product_id;

        Debug.LogWarning("weeklyOne_id=====>>>>>>" + weeklyOne_id + "        weeklyTwo_id=====>>>>>>" + weeklyTwo_id);
        if (!string.IsNullOrEmpty(weeklyOne_id) && !string.IsNullOrEmpty(weeklyTwo_id))
        {
            //根据审核开关  选择对应的价格
            if (GlobalValues.need_display_uurcahse)
            {
                PlayerPrefs.SetString("purchase_product_id", weeklyOne_id);
                GlobalValues.purchaseProductId = weeklyOne_id;
                GlobalValues.price             = weeklyOne.price;
            }
            else
            {
                PlayerPrefs.SetString("purchase_product_id", weeklyTwo_id);
                GlobalValues.purchaseProductId = weeklyTwo_id;
                GlobalValues.price             = weeklyTwo.price;
            }
        }
        else
        {
            PlayerPrefs.SetString("purchase_product_id", purchaseConfig.purchase_product_id);
            GlobalValues.purchaseProductId = purchaseConfig.purchase_product_id;
            GlobalValues.price             = purchaseConfig.price;
        }
        Debug.LogWarning("purchaseProductId=====>>>>>>" + GlobalValues.purchaseProductId);

        StartCoroutine(LoadMainOrPurScene());
    }
Beispiel #3
0
        private static void readConfigAndData()
        {
            string configJSON = null;
            string dataJSON   = null;

            string purchaseRepoPath = Environment.CurrentDirectory;
            char   pathDirSep       = Path.DirectorySeparatorChar;
            string configPath       = String.Format("{0}Repositories{0}Purchase{0}config.json", pathDirSep);
            string dataPath         = String.Format("{0}Repositories{0}Purchase{0}data.json", pathDirSep);

            using (
                StreamReader
                configFile = new StreamReader(purchaseRepoPath + configPath),
                dataFile = new StreamReader(purchaseRepoPath + dataPath))
            {
                configJSON = configFile.ReadToEnd();
                dataJSON   = dataFile.ReadToEnd();
            }

            PaymentController.purchaseConfig     = JsonConvert.DeserializeObject <PurchaseConfig>(configJSON);
            PaymentController.countryToPurchases = JsonConvert.DeserializeObject <Dictionary <string, List <PurchaseData> > >(dataJSON);
        }