Beispiel #1
0
 private async void PaymentButton_Click(object sender, EventArgs e)
 {
     if (AllSet)
     {
         Control.Payment_Integration     payment  = new Control.Payment_Integration(CardNo.Text, Cvc.Text, ExpDateYear.Text, ExpDateMonth.Text, Amount.Text);
         Android.App.AlertDialog.Builder dialogue = new AlertDialog.Builder(this);
         AlertDialog alert = dialogue.Create();
         alert.SetTitle("Transaction in process");
         alert.SetMessage("Please wait while your transaction is being processed...");
         alert.Show();
         try
         {
             if (payment.StripePay(this))
             {
                 var addata = JsonConvert.DeserializeObject <AdsData>(Intent.GetStringExtra("adobject"));
                 if (addata != null)
                 {
                     if (await addata.StoreAd(addata))
                     {
                         Toast.MakeText(this, "Your ad has been posted", ToastLength.Long).Show();
                         Intent i = new Intent(this, typeof(FragmentHomeActivity));
                         StartActivity(i);
                     }
                     else
                     {
                         Toast.MakeText(this, "Your ad is not posted", ToastLength.Long).Show();
                         Intent i = new Intent(this, typeof(FragmentHomeActivity));
                         StartActivity(i);
                     }
                 }
                 Model.funds funds = new Model.funds();
                 funds.amount    = int.Parse(Amount.Text);
                 funds.user_id   = Control.UserInfoHolder.User_id;
                 funds.issue_id  = Control.UserInfoHolder.currentIssueContext;
                 funds.fund_date = DateTime.Now;
                 funds.postnewfund(funds);
                 Android.App.AlertDialog.Builder dialog = new AlertDialog.Builder(this);
                 AlertDialog alert1 = dialog.Create();
                 alert.Dismiss();
                 alert1.SetTitle("Payment Information");
                 alert1.SetMessage("Payment Succesfull");
                 alert1.SetButton("OK", (c, ev) =>
                 {
                     alert1.Dismiss();
                 });
                 alert1.Show();
             }
             else
             {
                 Toast.MakeText(this, "Payment Declined", ToastLength.Long).Show();
                 alert.Dismiss();
             }
         }
         catch (System.Exception)
         {
             Toast.MakeText(this, "Payment Declined", ToastLength.Long).Show();
             alert.Dismiss();
         }
     }
 }
        public async void postnewfund(funds fund)
        {
            HttpClient client   = new HttpClient();
            var        uri      = Control.Account.BaseAddressUri + "/api/userfunds/postnewfund";
            var        json     = JsonConvert.SerializeObject(fund);
            var        content  = new StringContent(json, Encoding.UTF8, "application/json");
            var        response = await client.PostAsync(uri, content);

            if (response.StatusCode == System.Net.HttpStatusCode.Accepted)
            {
                return;
            }
        }