Exemple #1
0
        async Task <InforAutosStripeCharge> ICustomStripeService.MakePayment(StripeCardInfo cardInfo, double Amount)
        {
            //var _token  = CreateToken(cardInfo.CardNumber, cardInfo.Month, cardInfo.Year, cardInfo.CCV);
            InforAutosStripeCharge result = new InforAutosStripeCharge();

            return(result);
        }
        async Task <InforAutosStripeCharge> ICustomStripeService.MakePayment(StripeCardInfo cardInfo, double Amount)
        {
            //var _token  = CreateToken(cardInfo.CardNumber, cardInfo.Month, cardInfo.Year, cardInfo.CCV);
            InforAutosStripeCharge result = new InforAutosStripeCharge();

            try
            {
                var myCharge = new StripeChargeCreateOptions();
                var myToken  = new StripeTokenCreateOptions();
                myToken.Card = new StripeCreditCardOptions()
                {
                    Number          = cardInfo.CardNumber,
                    ExpirationMonth = cardInfo.Month,
                    ExpirationYear  = cardInfo.Year,
                    Cvc             = cardInfo.CCV
                };
                // Stripe amount transformation from double with 2 decimals
                //Amount = 1;
                myCharge.Amount = Int32.Parse((Amount * Int32.Parse("100")).ToString());

                myCharge.Currency = "EUR";
                var chargeService = new StripeChargeService(API_KEY);
                var tokenService  = new StripeTokenService(API_KEY);
                var token         = tokenService.Create(myToken);
                myCharge.SourceTokenOrExistingSourceId = token.Id;
                StripeCharge stripeCharge = await chargeService.CreateAsync(myCharge);

                result.FailureMessage = stripeCharge.FailureMessage;
                result.IsPaid         = stripeCharge.Paid;
                result.ID             = stripeCharge.Id;
            }
            catch (System.Exception ex)
            {
                // result.FailureMessage = "Payment Successful";
                result.FailureMessage = ex.Message;
            }

            return(result);
        }
Exemple #3
0
 async void ICustomStripeService.MakePayment1(StripeCardInfo cardInfo, double Amount)
 {
 }
        public async void PackageDetails()
        {
            try
            {
                await Navigation.PushPopupAsync(new LoadPopup());



                var result = await CommonLib.GetPackage(CommonLib.ws_MainUrlMain + "PackageApi/GetPackage");

                if (result != null && result.Status != 0)
                {
                    price = result.details.PackagePrice;

                    try
                    {
                        string msg = string.Empty;
                        if (string.IsNullOrEmpty(txtcardNumber.Text))
                        {
                            msg += Resx.AppResources.entercard + Environment.NewLine;
                        }
                        else
                        {
                            if (txtcardNumber.Text.Length != 16)
                            {
                                msg += Resx.AppResources.entervalidcard + Environment.NewLine;
                            }
                        }
                        if (string.IsNullOrEmpty(txtCVVNumber.Text))
                        {
                            msg += Resx.AppResources.entercvv + Environment.NewLine;
                        }
                        else
                        {
                            if (txtCVVNumber.Text.Length != 3)
                            {
                                msg += Resx.AppResources.entervalidcvv + Environment.NewLine;
                            }
                        }
                        if (string.IsNullOrEmpty(txtMonth.Text))
                        {
                            msg += Resx.AppResources.entermonth + Environment.NewLine;
                        }
                        else
                        {
                            if (Convert.ToInt32(txtMonth.Text) > 12)
                            {
                                msg += Resx.AppResources.entervalidmonth + Environment.NewLine;
                            }
                        }
                        if (string.IsNullOrEmpty(txtYear.Text))
                        {
                            msg += Resx.AppResources.enteryear + Environment.NewLine;
                        }
                        else
                        {
                            int curYear = Convert.ToInt32(DateTime.Now.Year.ToString().Substring(1));
                            if (Convert.ToInt32(txtYear.Text) < curYear)
                            {
                                msg += Resx.AppResources.entervalidyear + Environment.NewLine;
                            }
                        }
                        if (!string.IsNullOrEmpty(msg))
                        {
                            LoadPopup.CloseAllPopup3();
                            await App.Current.MainPage.DisplayAlert("", msg, "OK");

                            return;
                        }


                        StripeCardInfo cardInfo = new StripeCardInfo();
                        cardInfo.CardNumber = txtcardNumber.Text;
                        cardInfo.CCV        = txtCVVNumber.Text;
                        cardInfo.Month      = Convert.ToInt32(txtMonth.Text);
                        cardInfo.Year       = Convert.ToInt32(txtYear.Text);


                        double Amount = Convert.ToDouble(price);


                        var paymentresult = await DependencyService.Get <ICustomStripeService>().MakePayment(cardInfo, Amount);


                        if (!paymentresult.IsPaid)
                        {
                            LoadPopup.CloseAllPopup3();
                            MyProfilePage.checkPremimun = false;

                            await App.Current.MainPage.DisplayAlert("", paymentresult.FailureMessage, "OK");



                            return;
                        }
                        else
                        {
                            await App.Current.MainPage.DisplayAlert("", Resx.AppResources.PaymentSuccessful, "OK");


                            MyProfilePage.checkPremimun = true;
                            PremimumUser();
                        }
                    }
                    catch (Exception)
                    {
                    }


                    LoadPopup.CloseAllPopup1();
                }

                else
                {
                    LoadPopup.CloseAllPopup1();
                }
            }
            catch (Exception ex)
            {
                await App.Current.MainPage.DisplayAlert("", ex.Message, "OK");

                LoadPopup.CloseAllPopup1();
            }
        }