コード例 #1
0
        private string getSetupDataString(string token)
        {
            JSONObject jsonObject = new JSONObject();

            jsonObject.Put("merchantAccount", paymentSetupRequest.getMerchantAccount()); // Not required when communicating with merchant server
            jsonObject.Put("shopperLocale", paymentSetupRequest.getShopperLocale());
            jsonObject.Put("token", token);
            jsonObject.Put("returnUrl", "example-shopping-app://");
            jsonObject.Put("countryCode", paymentSetupRequest.getCountryCode());
            JSONObject amount = new JSONObject();

            amount.Put("value", paymentSetupRequest.getAmount().Value);
            amount.Put("currency", paymentSetupRequest.getAmount().Currency);
            jsonObject.Put("amount", amount);
            jsonObject.Put("channel", "android");
            jsonObject.Put("reference", "Android Checkout SDK Payment: " + DateTime.Now.ToString());
            jsonObject.Put("shopperReference", "example-customer@exampleprovider");

            short maxNumberOfInstallments = Short.ParseShort(paymentSetupRequest.getMaxNumberOfInstallments());

            if (maxNumberOfInstallments > 1)
            {
                JSONObject configuration = new JSONObject();
                JSONObject installments  = new JSONObject();
                installments.Put("maxNumberOfInstallments", maxNumberOfInstallments);
                configuration.Put("installments", installments);
                jsonObject.Put("configuration", configuration);
            }

            return(jsonObject.ToString());
        }