public async void OnSuccess(Token token)
        {
            try
            {
                // Send token to your own web service
                //var stripeBankAccount = token.BankAccount;
                //var stripeCard = token.Card;
                //var stripeCreated = token.Created;
                //var stripeId = token.Id;
                //var stripeLiveMode = token.Livemode;
                //var stripeType = token.Type;
                //var stripeUsed = token.Used;

                //send api
                if (PayType == "Funding")
                {
                    (int apiStatus, var respond) = await RequestsAsync.Funding.FundingPay(Id, Price).ConfigureAwait(false);

                    if (apiStatus == 200)
                    {
                        RunOnUiThread(() =>
                        {
                            try
                            {
                                Toast.MakeText(this, GetText(Resource.String.Lbl_Donated), ToastLength.Long).Show();
                                Finish();
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine(e);
                            }
                        });
                    }
                    else
                    {
                        Methods.DisplayReportResult(this, respond);
                    }
                }
                else if (PayType == "membership")
                {
                    if (Methods.CheckConnectivity())
                    {
                        (int apiStatus, var respond) = await RequestsAsync.Global.SetProAsync(Id).ConfigureAwait(false);

                        if (apiStatus == 200)
                        {
                            RunOnUiThread(() =>
                            {
                                var dataUser = ListUtils.MyProfileList.FirstOrDefault();
                                if (dataUser != null)
                                {
                                    dataUser.IsPro = "1";

                                    var sqlEntity = new SqLiteDatabase();
                                    sqlEntity.Insert_Or_Update_To_MyProfileTable(dataUser);
                                    sqlEntity.Dispose();
                                }

                                Toast.MakeText(this, GetText(Resource.String.Lbl_Done), ToastLength.Long).Show();
                                Finish();
                            });
                        }
                        else
                        {
                            Methods.DisplayReportResult(this, respond);
                        }
                    }
                    else
                    {
                        Toast.MakeText(this, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long).Show();
                    }
                }
                else if (PayType == "AddFunds")
                {
                    var tabbedWallet = TabbedWalletActivity.GetInstance();
                    if (Methods.CheckConnectivity() && tabbedWallet != null)
                    {
                        (int apiStatus, var respond) = await RequestsAsync.Global.SendMoneyWalletAsync(tabbedWallet.SendMoneyFragment?.UserId, tabbedWallet.SendMoneyFragment?.TxtAmount.Text).ConfigureAwait(false);

                        if (apiStatus == 200)
                        {
                            RunOnUiThread(() =>
                            {
                                try
                                {
                                    tabbedWallet.SendMoneyFragment.TxtAmount.Text = string.Empty;
                                    tabbedWallet.SendMoneyFragment.TxtEmail.Text  = string.Empty;

                                    Toast.MakeText(this, GetText(Resource.String.Lbl_Done), ToastLength.Long).Show();
                                }
                                catch (Exception e)
                                {
                                    Console.WriteLine(e);
                                }
                            });
                        }
                        else
                        {
                            Methods.DisplayReportResult(this, respond);
                        }
                    }
                    else
                    {
                        Toast.MakeText(this, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long).Show();
                    }
                }
                else if (PayType == "SendMoney")
                {
                    var tabbedWallet = TabbedWalletActivity.GetInstance();
                    if (Methods.CheckConnectivity() && tabbedWallet != null)
                    {
                        (int apiStatus, var respond) = await RequestsAsync.Global.SendMoneyWalletAsync(tabbedWallet.SendMoneyFragment?.UserId, tabbedWallet.SendMoneyFragment?.TxtAmount.Text).ConfigureAwait(false);

                        if (apiStatus == 200)
                        {
                            RunOnUiThread(() =>
                            {
                                try
                                {
                                    tabbedWallet.SendMoneyFragment.TxtAmount.Text = string.Empty;
                                    tabbedWallet.SendMoneyFragment.TxtEmail.Text  = string.Empty;

                                    Toast.MakeText(this, GetText(Resource.String.Lbl_Done), ToastLength.Long).Show();
                                }
                                catch (Exception e)
                                {
                                    Console.WriteLine(e);
                                }
                            });
                        }
                        else
                        {
                            Methods.DisplayReportResult(this, respond);
                        }
                    }
                    else
                    {
                        Toast.MakeText(this, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long).Show();
                    }
                }

                AndHUD.Shared.Dismiss(this);

                Finish();

                //ShowFragmentStripe();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                AndHUD.Shared.Dismiss(this);
            }
        }
        //Result
        protected override async void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            try
            {
                base.OnActivityResult(requestCode, resultCode, data);

                if (requestCode == LoadPaymentDataRequestCode)
                {
                    switch (resultCode)
                    {
                    case Result.Ok:
                        PaymentData paymentData = PaymentData.GetFromIntent(data);
                        // You can get some data on the user's card, such as the brand and last 4 digits
                        //CardInfo info = paymentData.CardInfo;
                        // You can also pull the user address from the PaymentData object.
                        //UserAddress address = paymentData.ShippingAddress;
                        // This is the raw string version of your Stripe token.
                        string rawToken = paymentData.PaymentMethodToken.Token;

                        // Now that you have a Stripe token object, charge that by using the id
                        Token stripeToken = Token.FromString(rawToken);
                        if (stripeToken != null)
                        {
                            // This chargeToken function is a call to your own server, which should then connect
                            // to Stripe's API to finish the charge.
                            // chargeToken(stripeToken.getId());
                            //var stripeBankAccount = stripeToken.BankAccount;
                            //var stripeCard = stripeToken.Card;
                            //var stripeCreated = stripeToken.Created;
                            //var stripeId = stripeToken.Id;
                            //var stripeLiveMode = stripeToken.Livemode;
                            //var stripeType = stripeToken.Type;
                            //var stripeUsed = stripeToken.Used;

                            //send api
                            if (PayType == "Funding")
                            {
                                (int apiStatus, var respond) = await RequestsAsync.Funding.FundingPay(Id, Price).ConfigureAwait(false);

                                if (apiStatus == 200)
                                {
                                    RunOnUiThread(() =>
                                    {
                                        try
                                        {
                                            Toast.MakeText(this, GetText(Resource.String.Lbl_Donated), ToastLength.Long).Show();
                                            Finish();
                                        }
                                        catch (Exception e)
                                        {
                                            Console.WriteLine(e);
                                        }
                                    });
                                }
                                else
                                {
                                    Methods.DisplayReportResult(this, respond);
                                }
                            }
                            else if (PayType == "membership")
                            {
                                if (Methods.CheckConnectivity())
                                {
                                    (int apiStatus, var respond) = await RequestsAsync.Global.SetProAsync(Id).ConfigureAwait(false);

                                    if (apiStatus == 200)
                                    {
                                        RunOnUiThread(() =>
                                        {
                                            var dataUser = ListUtils.MyProfileList.FirstOrDefault();
                                            if (dataUser != null)
                                            {
                                                dataUser.IsPro = "1";

                                                var sqlEntity = new SqLiteDatabase();
                                                sqlEntity.Insert_Or_Update_To_MyProfileTable(dataUser);
                                                sqlEntity.Dispose();
                                            }

                                            Toast.MakeText(this, GetText(Resource.String.Lbl_Done), ToastLength.Long).Show();
                                            Finish();
                                        });
                                    }
                                    else
                                    {
                                        Methods.DisplayReportResult(this, respond);
                                    }
                                }
                                else
                                {
                                    Toast.MakeText(this, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long).Show();
                                }
                            }
                            else if (PayType == "AddFunds")
                            {
                                var tabbedWallet = TabbedWalletActivity.GetInstance();
                                if (Methods.CheckConnectivity() && tabbedWallet != null)
                                {
                                    (int apiStatus, var respond) = await RequestsAsync.Global.SendMoneyWalletAsync(tabbedWallet.SendMoneyFragment?.UserId, tabbedWallet.SendMoneyFragment?.TxtAmount.Text).ConfigureAwait(false);

                                    if (apiStatus == 200)
                                    {
                                        RunOnUiThread(() =>
                                        {
                                            try
                                            {
                                                tabbedWallet.SendMoneyFragment.TxtAmount.Text = string.Empty;
                                                tabbedWallet.SendMoneyFragment.TxtEmail.Text  = string.Empty;

                                                Toast.MakeText(this, GetText(Resource.String.Lbl_Done), ToastLength.Long).Show();
                                            }
                                            catch (Exception e)
                                            {
                                                Console.WriteLine(e);
                                            }
                                        });
                                    }
                                    else
                                    {
                                        Methods.DisplayReportResult(this, respond);
                                    }
                                }
                                else
                                {
                                    Toast.MakeText(this, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long).Show();
                                }
                            }
                            else if (PayType == "SendMoney")
                            {
                                var tabbedWallet = TabbedWalletActivity.GetInstance();
                                if (Methods.CheckConnectivity() && tabbedWallet != null)
                                {
                                    (int apiStatus, var respond) = await RequestsAsync.Global.SendMoneyWalletAsync(tabbedWallet.SendMoneyFragment?.UserId, tabbedWallet.SendMoneyFragment?.TxtAmount.Text).ConfigureAwait(false);

                                    if (apiStatus == 200)
                                    {
                                        RunOnUiThread(() =>
                                        {
                                            try
                                            {
                                                tabbedWallet.SendMoneyFragment.TxtAmount.Text = string.Empty;
                                                tabbedWallet.SendMoneyFragment.TxtEmail.Text  = string.Empty;

                                                Toast.MakeText(this, GetText(Resource.String.Lbl_Done), ToastLength.Long).Show();
                                            }
                                            catch (Exception e)
                                            {
                                                Console.WriteLine(e);
                                            }
                                        });
                                    }
                                    else
                                    {
                                        Methods.DisplayReportResult(this, respond);
                                    }
                                }
                                else
                                {
                                    Toast.MakeText(this, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long).Show();
                                }
                            }
                        }
                        break;

                    case Result.Canceled:
                        Toast.MakeText(this, GetText(Resource.String.Lbl_Canceled), ToastLength.Long).Show();
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Пример #3
0
        public async void OnSuccess(Source p0)
        {
            try
            {
                Console.WriteLine(p0);
                Console.WriteLine(p0.Status);

                if (p0.Status.Contains("succeeded"))
                {
                    switch (PayType)
                    {
                    //send api
                    case "Funding":
                    {
                        var(apiStatus, respond) = await RequestsAsync.Funding.FundingPayAsync(Id, Price);

                        switch (apiStatus)
                        {
                        case 200:
                            Toast.MakeText(this, GetText(Resource.String.Lbl_Donated), ToastLength.Long)?.Show();
                            FundingViewActivity.GetInstance()?.StartApiService();
                            break;

                        default:
                            Methods.DisplayReportResult(this, respond);
                            break;
                        }

                        break;
                    }

                    case "membership" when Methods.CheckConnectivity():
                    {
                        var(apiStatus, respond) = await RequestsAsync.Global.SetProAsync(Id);

                        switch (apiStatus)
                        {
                        case 200:
                        {
                            var dataUser = ListUtils.MyProfileList?.FirstOrDefault();
                            if (dataUser != null)
                            {
                                dataUser.IsPro = "1";

                                var sqlEntity = new SqLiteDatabase();
                                sqlEntity.Insert_Or_Update_To_MyProfileTable(dataUser);
                            }

                            Toast.MakeText(this, GetText(Resource.String.Lbl_Upgraded), ToastLength.Long)?.Show();
                            break;
                        }

                        default:
                            Methods.DisplayReportResult(this, respond);
                            break;
                        }

                        break;
                    }

                    case "membership":
                        Toast.MakeText(this, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long)?.Show();
                        break;

                    case "AddFunds":
                    {
                        var tabbedWallet = TabbedWalletActivity.GetInstance();
                        if (Methods.CheckConnectivity() && tabbedWallet != null)
                        {
                            var(apiStatus, respond) = await RequestsAsync.Global.SendMoneyWalletAsync(tabbedWallet.SendMoneyFragment?.UserId, tabbedWallet.SendMoneyFragment?.TxtAmount.Text);

                            switch (apiStatus)
                            {
                            case 200:
                                tabbedWallet.SendMoneyFragment.TxtAmount.Text = string.Empty;
                                tabbedWallet.SendMoneyFragment.TxtEmail.Text  = string.Empty;

                                Toast.MakeText(this, GetText(Resource.String.Lbl_Sent_successfully), ToastLength.Long)?.Show();
                                break;

                            default:
                                Methods.DisplayReportResult(this, respond);
                                break;
                            }
                        }
                        else
                        {
                            Toast.MakeText(this, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long)?.Show();
                        }

                        break;
                    }
                    }

                    AndHUD.Shared.Dismiss(this);
                    Finish();
                }

                //await Task.Run(() =>
                //{
                //    try
                //    {
                //      var sourceIdParams =  PaymentIntentParams.CreateConfirmPaymentIntentWithSourceIdParams(p0.Id, p0.ClientSecret, "stripe://payment_intent_return");

                //        PaymentIntent paymentIntent = Stripe.ConfirmPaymentIntentSynchronous(sourceIdParams, "pk_test_1ujWeV5SjafkpuEK7NMpURNz");
                //        Methods.DisplayReportResultTrack(paymentIntent);
                //    }
                //    catch (Exception e)
                //    {
                //        Methods.DisplayReportResultTrack(e);
                //    }
                //});
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
Пример #4
0
 public override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     // Create your fragment here
     GlobalContext = (TabbedWalletActivity)Activity;
 }
 public FragmentBottomNavigationView(Activity context)
 {
     Context = (TabbedWalletActivity)context;
 }