Exemplo n.º 1
0
        private bool InitPayPal(string price)
        {
            try
            {
                //PayerID
                string currency      = "USD";
                string paypalClintId = "";
                var    option        = ListUtils.SettingsSiteList;
                if (option != null)
                {
                    currency      = option.PaypalCurrency ?? "USD";
                    paypalClintId = option.PaypalId;
                }

                if (string.IsNullOrEmpty(paypalClintId))
                {
                    return(false);
                }

                PayPalConfig = new PayPalConfiguration()
                               .ClientId(paypalClintId)
                               .LanguageOrLocale(AppSettings.Lang)
                               .MerchantName(AppSettings.ApplicationName)
                               .MerchantPrivacyPolicyUri(Android.Net.Uri.Parse(Client.WebsiteUrl + "/terms/privacy-policy"));

                switch (ListUtils.SettingsSiteList?.PaypalMode)
                {
                case "sandbox":
                    PayPalConfig.Environment(PayPalConfiguration.EnvironmentSandbox);
                    break;

                case "live":
                    PayPalConfig.Environment(PayPalConfiguration.EnvironmentProduction);
                    break;

                default:
                    PayPalConfig.Environment(PayPalConfiguration.EnvironmentProduction);
                    break;
                }

                PayPalPayment = new PayPalPayment(new BigDecimal(price), currency, "Pay the card", PayPalPayment.PaymentIntentSale);

                IntentService = new Intent(ActivityContext, typeof(PayPalService));
                IntentService.PutExtra(PayPalService.ExtraPaypalConfiguration, PayPalConfig);
                ActivityContext.StartService(IntentService);
                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(false);
            }
        }
        private void InitPayPal(string price, string payType, string credits, string id)
        {
            try
            {
                Price = price; PayType = payType; Credits = credits; Id = id;

                //PayerID
                string currency      = "USD";
                string paypalClintId = "";
                var    option        = ListUtils.SettingsSiteList.FirstOrDefault();
                if (option != null)
                {
                    currency      = option?.Currency ?? "USD";
                    paypalClintId = option?.PaypalId;
                }

                PayPalConfig = new PayPalConfiguration()
                               .ClientId(paypalClintId)
                               .LanguageOrLocale(AppSettings.Lang)
                               .MerchantName(AppSettings.ApplicationName)
                               .MerchantPrivacyPolicyUri(Android.Net.Uri.Parse(Client.WebsiteUrl + "/terms/privacy-policy"));

                if (option != null)
                {
                    switch (option.PaypalMode)
                    {
                    case "sandbox":
                        PayPalConfig.Environment(PayPalConfiguration.EnvironmentSandbox);
                        break;

                    case "live":
                        PayPalConfig.Environment(PayPalConfiguration.EnvironmentProduction);
                        break;

                    default:
                        PayPalConfig.Environment(PayPalConfiguration.EnvironmentProduction);
                        break;
                    }
                }

                PayPalPayment = new PayPalPayment(new BigDecimal(price), currency, "Pay the card", PayPalPayment.PaymentIntentSale);

                IntentService = new Intent(ActivityContext, typeof(PayPalService));
                IntentService.PutExtra(PayPalService.ExtraPaypalConfiguration, PayPalConfig);
                ActivityContext.StartService(IntentService);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemplo n.º 3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Main);

            config.Environment(ConfigEnvironment);
            var clientId = (ConfigEnvironment == PayPalConfiguration.EnvironmentProduction)
                                                                ? ProductionConfigClientId
                                                                : SandboxConfigClientId;

            config.ClientId(clientId);

            //The following are only used in PayPalFuturePaymentActivity.
            config.MerchantName("Hipster Store");
            config.MerchantPrivacyPolicyUri(Android.Net.Uri.Parse("https://www.example.com/privacy"));
            config.MerchantUserAgreementUri(Android.Net.Uri.Parse("https://www.example.com/legal"));

            var intent = new Intent(this, typeof(PayPalService));

            intent.PutExtra(PayPalService.ExtraPaypalConfiguration, config);
            StartService(intent);

            var btnBuyIt                 = FindViewById <Button>(Resource.Id.buyItBtn);
            var btnFuturePayment         = FindViewById <Button>(Resource.Id.futurePaymentBtn);
            var btnFuturePaymentPurchase = FindViewById <Button>(Resource.Id.futurePaymentPurchaseBtn);

            btnBuyIt.Click                 += OnBuyPressed;
            btnFuturePayment.Click         += OnFuturePaymentPressed;
            btnFuturePaymentPurchase.Click += OnFuturePaymentPurchasePressed;
        }
Exemplo n.º 4
0
        public object GetConfiguration()
        {
            var settings = Mvx.Resolve <IAppSettings>().Data;
            var localize = Mvx.Resolve <ILocalization>();

            var baseUri = settings.ServiceUrl.Replace("api/", string.Empty);

            var configuration = new PayPalConfiguration();

            configuration.AcceptCreditCards(false);
            configuration.LanguageOrLocale(localize.CurrentLanguage);
            configuration.MerchantName(settings.TaxiHail.ApplicationName);
            configuration.MerchantPrivacyPolicyUri(Android.Net.Uri.Parse(string.Format("{0}/company/privacy", baseUri)));
            configuration.MerchantUserAgreementUri(Android.Net.Uri.Parse(string.Format("{0}/company/termsandconditions", baseUri)));
            configuration.Environment(_environment);
            configuration.ClientId(_clientId);

            return(configuration);
        }
        private void InitPayPal(string price, string payType)
        {
            try
            {
                //PayerID
                string currency      = "USD";
                string paypalClintId = "";
                var    option        = ListUtils.SettingsSiteList;
                if (option != null)
                {
                    currency      = option.PaypalCurrency ?? "USD";
                    paypalClintId = option.PaypalId;
                }

                PayPalConfig = new PayPalConfiguration()
                               .ClientId(paypalClintId)
                               .LanguageOrLocale(AppSettings.Lang)
                               .MerchantName(AppSettings.ApplicationName)
                               .MerchantPrivacyPolicyUri(Android.Net.Uri.Parse(Client.WebsiteUrl + "/terms/privacy"));

                switch (option?.PaypalMode)
                {
                case "sandbox":
                    PayPalConfig.Environment(PayPalConfiguration.EnvironmentSandbox);
                    break;

                case "live":
                    PayPalConfig.Environment(PayPalConfiguration.EnvironmentProduction);
                    break;

                default:
                    PayPalConfig.Environment(PayPalConfiguration.EnvironmentProduction);
                    break;
                }

                string text;

                switch (payType)
                {
                case "PurchaseSong":
                    text = "Purchase the song";
                    break;

                case "PurchaseAlbum":
                    text = "Purchase the album";
                    break;

                case "membership":
                    text = "Upgrade";
                    break;

                default:
                    text = "Purchase the song";
                    break;
                }

                PayPalPayment = new PayPalPayment(new BigDecimal(price), currency, text, PayPalPayment.PaymentIntentSale);

                IntentService = new Intent(ActivityContext, typeof(PayPalService));
                IntentService.PutExtra(PayPalService.ExtraPaypalConfiguration, PayPalConfig);
                ActivityContext.StartService(IntentService);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemplo n.º 6
0
        private bool InitPayPal(string price, string payType)
        {
            try
            {
                //PayerID
                string currency      = "USD";
                string paypalClintId = "";
                string textPay;
                var    option = ListUtils.MySettingsList;
                if (option != null)
                {
                    currency      = option.PaypalCurrency ?? "USD";
                    paypalClintId = option.PaypalId;
                }

                PayPalConfig = new PayPalConfiguration()
                               .ClientId(paypalClintId)
                               .LanguageOrLocale(AppSettings.Lang)
                               .MerchantName(AppSettings.ApplicationName)
                               .MerchantPrivacyPolicyUri(Android.Net.Uri.Parse(Client.WebsiteUrl + "/terms/privacy-policy"));

                switch (option?.PaypalMode)
                {
                case "sandbox":
                    PayPalConfig.Environment(PayPalConfiguration.EnvironmentSandbox);
                    break;

                case "live":
                    PayPalConfig.Environment(PayPalConfiguration.EnvironmentProduction);
                    break;

                default:
                    PayPalConfig.Environment(PayPalConfiguration.EnvironmentProduction);
                    break;
                }

                switch (payType)
                {
                case "purchaseVideo":
                    textPay = "Pay the video";
                    break;

                case "Subscriber":
                case "SubscriberVideo":
                    textPay = "Pay to subscribe";
                    break;

                case "GoPro":
                    textPay = "Pay to pro member";
                    break;

                case "RentVideo":
                    textPay = "Pay to rent video";
                    break;

                case "DonateVideo":
                    textPay = "Pay to donate video";
                    break;

                default:
                    textPay = "Pay the card";
                    break;
                }

                PayPalPayment = new PayPalPayment(new BigDecimal(price), currency, textPay, PayPalPayment.PaymentIntentSale);

                IntentService = new Intent(ActivityContext, typeof(PayPalService));
                IntentService.PutExtra(PayPalService.ExtraPaypalConfiguration, PayPalConfig);
                ActivityContext.StartService(IntentService);
                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(false);
            }
        }
Exemplo n.º 7
0
        private bool InitPayPal(string price, string payType)
        {
            try
            {
                //PayerID
                string currency      = "USD";
                string paypalClintId = "";
                var    option        = ListUtils.SettingsSiteList;
                if (option != null)
                {
                    currency      = option.PaypalCurrency ?? "USD";
                    paypalClintId = option.PaypalId;
                }

                if (string.IsNullOrEmpty(paypalClintId))
                {
                    return(false);
                }

                PayPalConfig = new PayPalConfiguration()
                               .ClientId(paypalClintId)
                               .LanguageOrLocale(AppSettings.Lang)
                               .MerchantName(AppSettings.ApplicationName)
                               .MerchantPrivacyPolicyUri(Android.Net.Uri.Parse(Client.WebsiteUrl + "/terms/privacy-policy"));

                switch (ListUtils.SettingsSiteList?.PaypalMode)
                {
                case "sandbox":
                    PayPalConfig.Environment(PayPalConfiguration.EnvironmentSandbox);
                    break;

                case "live":
                    PayPalConfig.Environment(PayPalConfiguration.EnvironmentProduction);
                    break;

                default:
                    PayPalConfig.Environment(PayPalConfiguration.EnvironmentProduction);
                    break;
                }

                var name = payType switch
                {
                    "Funding" => "Donate to funding",
                    "membership" => "Account upgrade request",
                    "AddFunds" => "Add to balance",
                    _ => "Pay the card"
                };

                PayPalPayment = new PayPalPayment(new BigDecimal(price), currency, name, PayPalPayment.PaymentIntentSale);

                IntentService = new Intent(ActivityContext, typeof(PayPalService));
                IntentService.PutExtra(PayPalService.ExtraPaypalConfiguration, PayPalConfig);
                ActivityContext.StartService(IntentService);
                return(true);
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
                return(false);
            }
        }