Example #1
0
        public void OnSuccess(Token token)
        {
            try
            {
                // Send token to your own web service
                //var stripeBankAccount = token.BankAccount;
                //var stripeCard = token.Card;
                //var stripeCreated = token.Created;
                TokenId = token.Id;
                //var stripeLiveMode = token.Livemode;
                //var stripeType = token.Type;
                //var stripeUsed = token.Used;
                var currencyCode = ListUtils.SettingsSiteList?.StripeCurrency ?? "USD";

                CustomerSession.InitCustomerSession(this);
                CustomerSession.Instance.SetCustomerShippingInformation(this, new ShippingInformation());
                CustomerSession.Instance.AddProductUsageTokenIfValid(TokenId);

                // Create the PaymentSession
                PaymentSession = new PaymentSession(this);
                PaymentSession.Init(this, GetPaymentSessionConfig());

                var priceInt = Convert.ToInt32(Price) * 100;
                Stripe.CreateSource(SourceParams.CreateAlipaySingleUseParams(priceInt, currencyCode.ToLower(), EtName.Text, UserDetails.Email, "stripe://payment_intent_return"), this);
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
                AndHUD.Shared.Dismiss(this);
            }
        }
Example #2
0
        public void OnCreate(Bundle savedInstanceState, StripeConfig stripeConfig)
        {
            _stripeConfig = stripeConfig;

            PaymentConfiguration.Init(_stripeConfig.ApiKey);

            var stripeRemoteService =
                new StripeRemoteService(_stripeConfig, _restHttpClient, _logManager, _jsonSerializer);

            CustomerSession.InitCustomerSession(new StripeEphemeralKeyProvider(stripeRemoteService));

            _paymentSession = new PaymentSession(CrossCurrentActivity.Current.Activity);
            var config = new PaymentSessionConfig.Builder()
                         .SetShippingInfoRequired(false)
                         .SetShippingMethodsRequired(false)
                         .Build();

            _paymentSession.Init(new PaymentSessionListener(), config, savedInstanceState);

            StripeManager.Initialize(stripeRemoteService, _stripeConfig);
        }