//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 == "purchaseVideo") { if (Methods.CheckConnectivity()) { (int apiStatus, var respond) = await RequestsAsync.Global.BuyVideoAsync(Id); if (apiStatus == 200) { if (respond is MessageObject result) { FragmentTransaction ft = SupportFragmentManager.BeginTransaction(); if (GlobalContext.RestrictedVideoPlayerFragment != null && GlobalContext.RestrictedVideoPlayerFragment.IsAdded) { ft.Hide(GlobalContext.RestrictedVideoPlayerFragment); } if (GlobalContext.YouTubeFragment != null) { if (GlobalContext.YouTubeFragment.IsAdded) { if (GlobalContext.YoutubePlayer != null && GlobalContext.YoutubePlayer.IsPlaying) { GlobalContext.YoutubePlayer?.Pause(); } ft.Hide(GlobalContext.YouTubeFragment).AddToBackStack(null).Commit(); GlobalContext.YouTubeFragment.View.Visibility = ViewStates.Gone; if (GlobalContext.VideoActionsController.SimpleExoPlayerView.Visibility == ViewStates.Gone) { GlobalContext.VideoActionsController.SimpleExoPlayerView.Visibility = ViewStates.Visible; } } } GlobalContext.PaymentVideoObject.IsPurchased = "1"; GlobalContext.StartPlayVideo(GlobalContext.PaymentVideoObject); Toast.MakeText(this, GetText(Resource.String.Lbl_Done), ToastLength.Long).Show(); StopService(new Intent(this, typeof(PayPalService))); } } else { Methods.DisplayReportResult(this, respond); } } else { Toast.MakeText(this, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long).Show(); } } else if (PayType == "Subscriber") { if (Methods.CheckConnectivity()) { TabbedMainActivity.GetInstance()?.UserChannelFragment?.SetSubscribeChannelWithPaid(); } else { Toast.MakeText(this, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long).Show(); } } else if (PayType == "SubscriberVideo") { if (Methods.CheckConnectivity()) { if (GlobalPlayerActivity.OnOpenPage) { GlobalPlayerActivity.GetInstance()?.SetSubscribeChannelWithPaid(); } else { TabbedMainActivity.GetInstance()?.VideoDataWithEventsLoader.SetSubscribeChannelWithPaid(); } } else { Toast.MakeText(this, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long).Show(); } } else if (PayType == "RentVideo") { if (Methods.CheckConnectivity()) { (int apiStatus, var respond) = await RequestsAsync.Video.RentVideo_Http(Id).ConfigureAwait(false); if (apiStatus == 200) { RunOnUiThread(() => { Toast.MakeText(this, GetText(Resource.String.Lbl_VideoSuccessfullyPaid), ToastLength.Long).Show(); }); } else { Methods.DisplayReportResult(this, respond); } } else { Toast.MakeText(this, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long).Show(); } } else if (PayType == "DonateVideo") { Toast.MakeText(this, GetText(Resource.String.Lbl_DonatedSuccessfully), ToastLength.Long).Show(); } else if (PayType == "GoPro") { if (Methods.CheckConnectivity()) { (int apiStatus, var respond) = await RequestsAsync.Global.UpgradeAsync(); if (apiStatus == 200) { var dataUser = ListUtils.MyChannelList.FirstOrDefault(); if (dataUser != null) { dataUser.IsPro = "1"; var sqlEntity = new SqLiteDatabase(); sqlEntity.InsertOrUpdate_DataMyChannel(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(); } } } break; case Result.Canceled: Toast.MakeText(this, GetText(Resource.String.Lbl_Canceled), ToastLength.Long).Show(); break; } } } catch (Exception e) { Console.WriteLine(e); } }
//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); } }
//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; if (Methods.CheckConnectivity()) { (int apiStatus, var respond) = await RequestsAsync.Auth.PayStripeAsync(stripeId, PayType, "Pay the card " + Price, Price).ConfigureAwait(false); if (apiStatus == 200) { if (respond is AmountObject result) { RunOnUiThread(() => { var dataUser = ListUtils.MyUserInfo.FirstOrDefault(a => a.Id == UserDetails.UserId); if (dataUser != null) { if (PayType != "membership") { dataUser.Balance = result.CreditAmount.ToString(); } else { dataUser.VerifiedFinal = true; dataUser.IsPro = "1"; } var sqlEntity = new SqLiteDatabase(); sqlEntity.InsertOrUpdate_DataMyInfo(dataUser); sqlEntity.Dispose(); } if (HomeActivity.GetInstance().ProfileFragment.WalletNumber != null) { HomeActivity.GetInstance().ProfileFragment.WalletNumber.Text = result.CreditAmount.ToString(); } Toast.MakeText(this, GetText(Resource.String.Lbl_Done), ToastLength.Long).Show(); }); } } 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); } }