示例#1
0
        private async Task CashFree(CashFreeGetStatusObject statusObject, string request)
        {
            try
            {
                if (Methods.CheckConnectivity())
                {
                    var keyValues = new Dictionary <string, string>
                    {
                        { "txStatus", statusObject.TxStatus },
                        { "orderAmount", statusObject.OrderAmount },
                        { "referenceId", statusObject.ReferenceId },
                        { "paymentMode", statusObject.PaymentMode },
                        { "txMsg", statusObject.TxMsg },
                        { "txTime", statusObject.TxTime },

                        { "signature", CashFreeObject.Signature },
                        { "orderId", CashFreeObject.OrderId },
                    };

                    switch (request)
                    {
                    case "fund":
                        keyValues.Add("amount", Price);
                        keyValues.Add("fund_id", Id);
                        break;

                    case "upgrade":
                        keyValues.Add("pro_type", Id);
                        break;

                    case "wallet":
                        keyValues.Add("amount", Price);
                        break;
                    }

                    var(apiStatus, respond) = await RequestsAsync.Global.CashFreeAsync(request, keyValues);

                    switch (apiStatus)
                    {
                    case 200:
                        AndHUD.Shared.Dismiss(ActivityContext);

                        switch (request)
                        {
                        case "fund":
                            Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_Donated), ToastLength.Long)?.Show();
                            FundingViewActivity.GetInstance()?.StartApiService();
                            break;

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

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

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

                        case "wallet":
                            Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_PaymentSuccessfully), ToastLength.Long)?.Show();
                            break;
                        }

                        StopCashFree();
                        break;

                    default:
                        Methods.DisplayAndHudErrorResult(ActivityContext, respond);
                        break;
                    }
                }
                else
                {
                    Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long)?.Show();
                }
            }
            catch (Exception e)
            {
                AndHUD.Shared.Dismiss(ActivityContext);
                Methods.DisplayReportResultTrack(e);
            }
        }
        private async Task PaySera(string request)
        {
            try
            {
                if (Methods.CheckConnectivity())
                {
                    var keyValues = new Dictionary <string, string>();

                    switch (request)
                    {
                    case "fund":
                        keyValues.Add("amount", Price);
                        keyValues.Add("fund_id", Id);
                        break;

                    case "upgrade":
                        keyValues.Add("pro_type", Id);
                        break;

                    case "wallet":
                        keyValues.Add("amount", Price);
                        break;
                    }

                    (int apiStatus, var respond) = await RequestsAsync.Global.PaySera(request, keyValues);

                    if (apiStatus == 200)
                    {
                        switch (request)
                        {
                        case "fund":
                            Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_Donated), ToastLength.Long)?.Show();
                            FundingViewActivity.GetInstance()?.StartApiService();
                            break;

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

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

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

                        case "wallet":
                            Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_PaymentSuccessfully), ToastLength.Long)?.Show();
                            break;
                        }

                        StopPaySera();
                    }
                    else
                    {
                        Methods.DisplayReportResult(ActivityContext, respond);
                    }
                }
                else
                {
                    Toast.MakeText(ActivityContext, ActivityContext.GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long)?.Show();
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(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);
            }
        }