Ejemplo n.º 1
0
        public HttpResponseMessage PaidInFullPollTrigger(
            //Trigger State -
            string triggerState,
            //Probability
            double probability)
        {
            if (triggerState != "RUN")
            {
                return(Request.EventWaitPoll(new TimeSpan(0, 1, 0)));                       //Wait 1 minute
            }
            //Check payment status etc.
            Random rnd = new Random();

            PaymentConfirmation pc = new PaymentConfirmation();

            pc.OrderId     = rnd.Next();
            pc.PaymentDate = DateTime.Now;
            if (rnd.NextDouble() < 0.2)
            {
                throw new ApplicationException("Error in App");
            }
            if (rnd.NextDouble() > probability)
            {
                pc.PaymentType = "AMEX";
                return(Request.EventTriggered(values: pc));
            }
            else
            {
                pc.PaymentType = "FAILED";
                return(Request.EventTriggered(values: pc));
                //return Request.EventWaitPoll(new TimeSpan(0, 1, 0));
            }
        }
Ejemplo n.º 2
0
        public async Task <Order> AddPaymentConfirmation(int orderId, PaymentConfirmation confirmation)
        {
            var order = await _orderRepository.GetByIdAsync(orderId);

            order.AddPaymentConfirmation(confirmation);

            await _orderRepository.UpdateAsync(order);

            return(order);
        }
Ejemplo n.º 3
0
        //Result
        protected override async void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            try
            {
                base.OnActivityResult(requestCode, resultCode, data);

                if (AppSettings.ShowInAppBilling && Client.IsExtended)
                {
                    BillingPayment?.Handler?.HandleActivityResult(requestCode, resultCode, data);
                }

                if (requestCode == InitPayPalPayment?.PayPalDataRequestCode)
                {
                    switch (resultCode)
                    {
                    case Result.Ok:
                        var confirmObj = data.GetParcelableExtra(PaymentActivity.ExtraResultConfirmation);
                        PaymentConfirmation configuration = Android.Runtime.Extensions.JavaCast <PaymentConfirmation>(confirmObj);
                        if (configuration != null)
                        {
                            //string createTime = configuration.ProofOfPayment.CreateTime;
                            //string intent = configuration.ProofOfPayment.Intent;
                            //string paymentId = configuration.ProofOfPayment.PaymentId;
                            //string state = configuration.ProofOfPayment.State;
                            //string transactionId = configuration.ProofOfPayment.TransactionId;

                            if (PayType == "membership")
                            {
                                await SetProAsync();
                            }
                        }

                        break;

                    case Result.Canceled:
                        Toast.MakeText(this, GetText(Resource.String.Lbl_Canceled), ToastLength.Long)?.Show();
                        break;
                    }
                }
                else if (requestCode == PaymentActivity.ResultExtrasInvalid)
                {
                    Toast.MakeText(this, GetText(Resource.String.Lbl_Invalid), ToastLength.Long)?.Show();
                }
                else if (requestCode == 1001 && resultCode == Result.Ok && AppSettings.ShowInAppBilling && Client.IsExtended)
                {
                    await SetProAsync();
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
        public async Task GetConfirmation()
        {
            player.Play("GetConfirmation");

            var payment1      = Payments.Payment1;
            var confirmation1 = Payments.Confirmation1;

            Payment created = await CreatePayment(payment1);

            PaymentConfirmation gotten = await client.GetPaymentConfirmationAsync(created.Id);

            Assert.AreEqual(gotten, confirmation1);
        }
        public ActionResult paymenform(tbl_paymentValidation payment)
        {
            try
            {
                if (payment.UserImageFIle == null)
                {
                    ModelState.AddModelError("NoFile", "Upload File");
                }
                else
                {
                    PaymentConfirmation    pay   = new PaymentConfirmation();
                    List <TranscationType> lists = db.TranscationTypes.ToList();
                    ViewBag.transaction = new SelectList(lists, "TranscationTypeId", "TransactionType");

                    List <Bank> listt = db.Banks.ToList();
                    ViewBag.bank = new SelectList(listt, "BankId", "BankName");
                    string filename  = Path.GetFileNameWithoutExtension(payment.UserImageFIle.FileName);
                    string extension = Path.GetExtension(payment.UserImageFIle.FileName);
                    filename    = DateTime.Now.ToString("yymmssff") + extension;
                    pay.SlipUrl = "~/Content/img/" + filename;

                    filename = Path.Combine(Server.MapPath("~/Content/img/"), filename);
                    payment.UserImageFIle.SaveAs(filename);


                    pay.BankId     = payment.BankId;
                    pay.Account_No = payment.Account_No;

                    pay.TransactionTypeId     = payment.TransactionTypeId;
                    pay.UserId                = Convert.ToInt32(Session["Cliente"]);
                    pay.TransactionSlipNumber = payment.TransactionSlipNumber;
                    pay.IBAN = payment.IBAN;
                    db.PaymentConfirmations.Add(pay);

                    db.SaveChanges();
                    ModelState.Clear();
                    ViewBag.Message = "Data Submitted";
                }
            }
            catch (Exception ex)
            {
                ViewBag.Message = "Not Submitted";
                return(View());
            }
            return(View());
        }
Ejemplo n.º 6
0
        public void CreatePaymentConfirmation(string orderNo, int bankId, int paymentMethodId, DateTime paymentDate,
                                              string senderName, decimal payAmount, string notes)
        {
            var order = GetOrder(orderNo);

            if (order != null)
            {
                var paymentConf = new PaymentConfirmation();
                paymentConf.OrderId         = order.Id;
                paymentConf.PaymentMethodId = paymentMethodId;
                paymentConf.BankId          = bankId;
                paymentConf.Amount          = payAmount;
                paymentConf.Date            = paymentDate;
                paymentConf.Notes           = notes;
                SetAuditFields(paymentConf);
                context.Add(paymentConf);
                context.SaveChanges();
            }
        }
Ejemplo n.º 7
0
        static void PaymentOption(double value) // teste classes Pagamento/Avista/Parcelado
        {
            var purchasePrice = new Payment(value);
            var confirmation  = new PaymentConfirmation();


            purchasePrice.DisplayPaymentMethods();
            byte option = byte.Parse(Console.ReadLine());

            if (option <= 1)
            {
                var descount = new CashPayment(purchasePrice);
                confirmation.GetConfirmationOfClient();
                var newRequest = new Order(7, confirmation.Confirmation);
            }
            else if (option >= 2)
            {
                purchasePrice.GetNumberOfInstallments();
                int numberOfInstallments = int.Parse(Console.ReadLine());
                var intallmentMethods    = new PaymentInInstallments(purchasePrice, numberOfInstallments);
                confirmation.GetConfirmationOfClient();
                var newRequest = new Order(7, confirmation.Confirmation);
            }
        }
Ejemplo n.º 8
0
        //Result
        protected override async void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            try
            {
                base.OnActivityResult(requestCode, resultCode, data);

                if (AppSettings.ShowInAppBilling && Client.IsExtended)
                {
                    BillingPayment?.Handler?.HandleActivityResult(requestCode, resultCode, data);
                }

                if (requestCode == 253 && resultCode == Result.Ok)
                {
                    if (string.IsNullOrEmpty(data.GetStringExtra("itemData")))
                    {
                        return;
                    }
                    var item = JsonConvert.DeserializeObject <FundingDataObject>(data.GetStringExtra("itemData"));
                    if (item != null)
                    {
                        DataObject = item;

                        TxtUsername.Text = Methods.FunString.DecodeString(item.UserData.Name);

                        TxtTime.Text = GetString(Resource.String.Lbl_Last_seen) + " " + Methods.Time.TimeAgo(Convert.ToInt32(item.Time), true);

                        TxtTitle.Text       = Methods.FunString.DecodeString(item.Title);
                        TxtDescription.Text = Methods.FunString.DecodeString(item.Description);

                        ProgressBar.Progress = Convert.ToInt32(item.Bar);

                        //$0 Raised of $1000000
                        TxtFundRaise.Text = "$" + item.Raised.ToString(CultureInfo.InvariantCulture) + " " + GetString(Resource.String.Lbl_RaisedOf) + " " + "$" + item.Amount;
                    }
                }
                else if (requestCode == InitPayPalPayment?.PayPalDataRequestCode)
                {
                    switch (resultCode)
                    {
                    case Result.Ok:
                        var confirmObj = data.GetParcelableExtra(PaymentActivity.ExtraResultConfirmation);
                        PaymentConfirmation configuration = Android.Runtime.Extensions.JavaCast <PaymentConfirmation>(confirmObj);
                        if (configuration != null)
                        {
                            //string createTime = configuration.ProofOfPayment.CreateTime;
                            //string intent = configuration.ProofOfPayment.Intent;
                            //string paymentId = configuration.ProofOfPayment.PaymentId;
                            //string state = configuration.ProofOfPayment.State;
                            //string transactionId = configuration.ProofOfPayment.TransactionId;

                            if (Methods.CheckConnectivity())
                            {
                                (int apiStatus, var respond) = await RequestsAsync.Funding.FundingPay(DataObject.Id, DataObject.Amount).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
                            {
                                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;
                    }
                }
                else if (requestCode == PaymentActivity.ResultExtrasInvalid)
                {
                    Toast.MakeText(this, GetText(Resource.String.Lbl_Invalid), ToastLength.Long).Show();
                }
                else if (requestCode == 1001 && resultCode == Result.Ok && AppSettings.ShowInAppBilling && Client.IsExtended)
                {
                    if (Methods.CheckConnectivity())
                    {
                        (int apiStatus, var respond) = await RequestsAsync.Funding.FundingPay(DataObject.Id, DataObject.Amount).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
                    {
                        Toast.MakeText(this, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long).Show();
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 9
0
        //Result
        protected override async void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            try
            {
                base.OnActivityResult(requestCode, resultCode, data);
                switch (TypeOpenPayment)
                {
                case "AddFundsFragment" when requestCode == InitPayPalPayment.PayPalDataRequestCode:
                    switch (resultCode)
                    {
                    case Result.Ok:
                        var confirmObj = data.GetParcelableExtra(PaymentActivity.ExtraResultConfirmation);
                        PaymentConfirmation configuration = Android.Runtime.Extensions.JavaCast <PaymentConfirmation>(confirmObj);
                        if (configuration != null)
                        {
                            //string createTime = configuration.ProofOfPayment.CreateTime;
                            //string intent = configuration.ProofOfPayment.Intent;
                            //string paymentId = configuration.ProofOfPayment.PaymentId;
                            //string state = configuration.ProofOfPayment.State;
                            //string transactionId = configuration.ProofOfPayment.TransactionId;
                            if (Methods.CheckConnectivity())
                            {
                                var(apiStatus, respond) = await RequestsAsync.Global.TopUpWalletAsync(UserDetails.UserId, AddFundsFragment?.TxtAmount.Text).ConfigureAwait(false);

                                switch (apiStatus)
                                {
                                case 200:
                                    RunOnUiThread(() =>
                                    {
                                        try
                                        {
                                            AddFundsFragment.TxtAmount.Text = string.Empty;

                                            Toast.MakeText(this, GetText(Resource.String.Lbl_PaymentSuccessfully), ToastLength.Long)?.Show();
                                        }
                                        catch (Exception e)
                                        {
                                            Methods.DisplayReportResultTrack(e);
                                        }
                                    });
                                    break;

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

                        break;

                    case (int)Result.Canceled:
                        Toast.MakeText(this, GetText(Resource.String.Lbl_Canceled), ToastLength.Long)?.Show();
                        break;
                    }

                    break;

                case "AddFundsFragment":
                {
                    switch (requestCode)
                    {
                    case PaymentActivity.ResultExtrasInvalid:
                        Toast.MakeText(this, GetText(Resource.String.Lbl_Invalid), ToastLength.Long)?.Show();
                        break;
                    }

                    break;
                }

                default:
                {
                    switch (requestCode)
                    {
                    case 1202 when resultCode == Result.Ok:
                    {
                        var userObject = data.GetStringExtra("DataUser");
                        switch (string.IsNullOrEmpty(userObject))
                        {
                        case false:
                        {
                            var userData = JsonConvert.DeserializeObject <UserDataObject>(userObject);
                            if (userData != null)
                            {
                                SendMoneyFragment.TxtEmail.Text = WoWonderTools.GetNameFinal(userData);
                                SendMoneyFragment.UserId        = userData.UserId;
                            }

                            break;
                        }
                        }

                        break;
                    }
                    }

                    break;
                }
                }
            }
            catch (Exception e)
            {
                Methods.DisplayReportResultTrack(e);
            }
        }
        //Result
        protected override async void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            try
            {
                base.OnActivityResult(requestCode, resultCode, data);
                if (requestCode == InitPayPalPayment?.PayPalDataRequestCode)
                {
                    switch (resultCode)
                    {
                    case Result.Ok:
                        var confirmObj = data.GetParcelableExtra(PaymentActivity.ExtraResultConfirmation);
                        PaymentConfirmation configuration = Android.Runtime.Extensions.JavaCast <PaymentConfirmation>(confirmObj);
                        if (configuration != null)
                        {
                            //string createTime = configuration.ProofOfPayment.CreateTime;
                            //string intent = configuration.ProofOfPayment.Intent;
                            //string paymentId = configuration.ProofOfPayment.PaymentId;
                            //string state = configuration.ProofOfPayment.State;
                            //string transactionId = configuration.ProofOfPayment.TransactionId;

                            if (Methods.CheckConnectivity())
                            {
                                (int apiStatus, var respond) = await RequestsAsync.User.UpgradeMembershipAsync(UserDetails.UserId.ToString());

                                if (apiStatus == 200)
                                {
                                    var dataUser = ListUtils.MyUserInfoList.FirstOrDefault();
                                    if (dataUser != null)
                                    {
                                        dataUser.IsPro = 1;

                                        var sqlEntity = new SqLiteDatabase();
                                        sqlEntity.InsertOrUpdate_DataMyInfo(dataUser);
                                        sqlEntity.Dispose();

                                        if (AppSettings.ShowGoPro && dataUser.IsPro != 1)
                                        {
                                            return;
                                        }
                                        var mainFragmentProIcon = HomeActivity.GetInstance()?.MainFragment?.ProIcon;
                                        if (mainFragmentProIcon != null)
                                        {
                                            mainFragmentProIcon.Visibility = ViewStates.Gone;
                                        }
                                    }

                                    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;
                    }
                }
                else if (requestCode == PaymentActivity.ResultExtrasInvalid)
                {
                    Toast.MakeText(this, GetText(Resource.String.Lbl_Invalid), ToastLength.Long).Show();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        //SendInvoicePaymentConfirmation
        public static void SendInvoicePaymentConfirmation(string email, string login, PaymentConfirmation pc)
        {
            UniMail.Template template = new UniMail.Template(HttpContext.Current.Server.MapPath(@"~\Templates\Mail\InvoicePaymentConfirmation.txt"));
            template.Encoding = System.Text.Encoding.UTF8;
            template.ToEmail  = email;

            StringBuilder table = new StringBuilder();

            if (pc.IsShipping)
            {
                table.AppendFormat("We will be shipping out your item{0} and sending you a shipping confirmation email within 8 business days.", pc.Quantity > 1 ? "s" : "");
            }
            else
            {
                table.AppendFormat("Your item{0} will be held at will call and will be available Monday - Friday, 9AM - 4PM<br /><b>{1}</b><br /><b>{2}</b><br />", pc.Quantity > 1 ? "s" : "", Consts.CompanyTitleName, Consts.CompanyAddress);
            }
            template.Data.Add("{{text_title}}", table.ToString());

            table = new StringBuilder();

            if (!String.IsNullOrEmpty(pc.TransactionID))
            {
                table.Append("<span style='color:Navy'><strong>Transaction information</strong></span><br />");
                table.AppendFormat("{0} Transaction ID# <strong>{1}</strong>", (pc.PaymentType == Consts.PaymentType.Paypal ? "Express Checkout Payment" : "Paid by Credit Card"), pc.TransactionID);
            }
            else
            {
                table.Append("<span style='color:Navy'><strong>Paid from the Account Balance</strong></span>");
            }

            template.Data.Add("{{Transaction}}", table.ToString());

            #region Billing & Shipping
            table = new StringBuilder();
            table.Append("<colgroup>");
            table.AppendLine("<col width=\"355px\" /><col width=\"360px\" />");
            table.Append("</colgroup>");
            table.AppendLine("<tr>");
            table.AppendFormat("<td style='background-color:#002868;color:#FFFFFF;font-weight:bold;border:0px solid black;padding-left:10px;padding: 5px 0px 5px 10px;'>Billing information</td>");
            table.AppendFormat("<td style='background-color:#002868;color:#FFFFFF;font-weight:bold;border:0px solid black;padding-left:10px;padding: 5px 0px 5px 10px;'>Shipping information</td>");
            table.AppendLine("</tr>");
            table.AppendLine("<tr>");
            table.AppendFormat("<td style='border-top:solid 1px #DDD;border-left:solid 1px #DDD;border-right:solid 1px #DDD;padding: 5px 0px 5px 10px;background-color:#FFF;'>{0} (<b>{1}</b>)</td>", pc.Address_Billing.FullName, login.ToUpper());
            if (pc.IsShipping)
            {
                table.AppendFormat("<td style='border-top: solid 1px #DDD;border-right:solid 1px #DDD; padding: 5px 0px 5px 10px; background-color: White;'>{0} (<b>{1}</b>)</td>", pc.Address_Shipping.FullName, login.ToUpper());
            }
            else
            {
                table.AppendFormat("<td style='border-top: solid 1px #DDD;border-right:solid 1px #DDD; padding-left: 10px;padding-right:10px; background-color: White;vertical-align:top' rowspan='{0}'>", ((!String.IsNullOrEmpty(pc.Address_Billing.WorkPhone) || (pc.Address_Shipping != null && !String.IsNullOrEmpty(pc.Address_Shipping.WorkPhone)))) ? "8" : "7");
                table.AppendFormat("Your item{0} will be held at will call and will be available Monday - Friday, 9AM - 4PM <br />", pc.Quantity > 1 ? "s" : "");
                table.AppendFormat("<b>{0}</b><br />", Consts.CompanyTitleName);
                table.AppendFormat("<b>{0}</b></td>", Consts.CompanyAddress);
            }
            table.AppendLine("</tr>");
            table.AppendLine("<tr>");
            table.AppendFormat("<td style='border-top:solid 1px #DDD;border-left:solid 1px #DDD;border-right:solid 1px #DDD;padding: 5px 0px 5px 10px;background-color:#FFF;'>{0}&nbsp;</td>", pc.Address_Billing.Address_1);
            if (pc.IsShipping)
            {
                table.AppendFormat("<td style='border-top: solid 1px #DDD;border-right:solid 1px #DDD; padding: 5px 0px 5px 10px; background-color: White;'>{0}&nbsp;</td>", pc.Address_Shipping.Address_1);
            }
            table.AppendLine("</tr>");
            table.AppendLine("<tr>");
            table.AppendFormat("<td style='border-top:solid 1px #DDD;border-left:solid 1px #DDD;border-right:solid 1px #DDD;padding: 5px 0px 5px 10px;background-color:#FFF;'>{0}&nbsp;</td>", pc.Address_Billing.Address_2);
            if (pc.IsShipping)
            {
                table.AppendFormat("<td style='border-top: solid 1px #DDD;border-right:solid 1px #DDD;padding: 5px 0px 5px 10px;background-color: White;'>{0}&nbsp;</td>", pc.Address_Shipping.Address_2);
            }
            table.AppendLine("</tr>");
            table.AppendLine("<tr>");
            table.AppendFormat("<td style='border-top:solid 1px #DDD;border-left:solid 1px #DDD;border-right:solid 1px #DDD;padding: 5px 0px 5px 10px;background-color:#FFF;'>{0},&nbsp;{1}</td>", pc.Address_Billing.City, pc.Address_Billing.State);
            if (pc.IsShipping)
            {
                table.AppendFormat("<td style='border-top: solid 1px #DDD;border-right:solid 1px #DDD; padding: 5px 0px 5px 10px; background-color: White;'>{0},&nbsp;{1}</td>", pc.Address_Shipping.City, pc.Address_Shipping.State);
            }
            table.AppendLine("</tr>");
            table.AppendLine("<tr>");
            table.AppendFormat("<td style='border-top:solid 1px #DDD;border-left:solid 1px #DDD;border-right:solid 1px #DDD;padding: 5px 0px 5px 10px;background-color:#FFF;'>{0}&nbsp;</td>", pc.Address_Billing.Zip);
            if (pc.IsShipping)
            {
                table.AppendFormat("<td style='border-top: solid 1px #DDD;border-right:solid 1px #DDD; padding: 5px 0px 5px 10px; background-color: White;'>{0}&nbsp;</td>", pc.Address_Shipping.Zip);
            }
            table.AppendLine("</tr>");
            table.AppendLine("<tr>");
            table.AppendFormat("<td style='border-top:solid 1px #DDD;border-left:solid 1px #DDD;border-right:solid 1px #DDD;padding: 5px 0px 5px 10px;background-color:#FFF;'>{0}&nbsp;</td>", pc.Address_Billing.Country);
            if (pc.IsShipping)
            {
                table.AppendFormat("<td style='border-top: solid 1px #DDD;border-right:solid 1px #DDD; padding: 5px 0px 5px 10px; background-color: White;'>{0}</td>", pc.Address_Shipping.Country);
            }
            table.AppendLine("</tr>");
            if (!String.IsNullOrEmpty(pc.Address_Billing.WorkPhone) || (pc.Address_Shipping != null && !String.IsNullOrEmpty(pc.Address_Shipping.WorkPhone)))
            {
                table.AppendLine("<tr>");
                table.AppendFormat("<td style='border-top:solid 1px #DDD;border-left:solid 1px #DDD;border-right:solid 1px #DDD;padding: 5px 0px 5px 10px;;background-color:#FFF;'>{0}&nbsp;</td>", pc.Address_Billing.HomePhone);
                if (pc.IsShipping)
                {
                    table.AppendFormat("<td style='border-top: solid 1px #DDD;border-right:solid 1px #DDD; padding: 5px 0px 5px 10px; background-color: White;'>{0}&nbsp;</td>", pc.Address_Shipping.HomePhone);
                }
                table.AppendLine("</tr>");
            }
            else
            {
                table.AppendLine("<tr>");
                table.AppendFormat("<td style='border-top: solid 1px #DDD;border-right:solid 1px #DDD;border-left:solid 1px #DDD;border-bottom:solid 1px #DDD;padding: 5px 0px 5px 10px;background-color:#FFF;'>{0}&nbsp;</td>", pc.Address_Billing.HomePhone);
                if (pc.IsShipping)
                {
                    table.AppendFormat("<td style='border-top: solid 1px #DDD;border-right: solid 1px #DDD;border-bottom: solid 1px #DDD;padding: 5px 0px 5px 10px; background-color: White;'>{0}&nbsp;</td>", pc.Address_Shipping.HomePhone);
                }
                table.AppendLine("</tr>");
            }
            if (!String.IsNullOrEmpty(pc.Address_Billing.WorkPhone) || (pc.Address_Shipping != null && !String.IsNullOrEmpty(pc.Address_Shipping.WorkPhone)))
            {
                table.AppendLine("<tr>");
                table.AppendFormat("<td style='border-top: solid 1px #DDD;border-right:solid 1px #DDD;border-left:solid 1px #DDD;border-bottom:solid 1px #DDD;padding: 5px 0px 5px 10px;background-color:#FFF;'>{0}&nbsp;</td>", pc.Address_Billing.WorkPhone);
                if (pc.IsShipping)
                {
                    table.AppendFormat("<td style='border-top: solid 1px #DDD;border-right: solid 1px #DDD;border-bottom: solid 1px #DDD;padding: 5px 0px 5px 10px; background-color: White;'>{0}&nbsp;</td>", pc.Address_Shipping.WorkPhone);
                }
                table.AppendLine("</tr>");
            }
            template.Data.Add("{{billing_info}}", table.ToString());
            #endregion

            #region Invoices
            table = new StringBuilder();
            string tableBL  = "border-left:solid 1px #DDD; border-bottom:solid 1px #DDD;padding-left:10px;background-color:White;";
            string tableBLR = "border-right:solid 1px #DDD;border-left:solid 1px #DDD;border-bottom:solid 1px #DDD;padding-left:10px;background-color:White;";
            foreach (InvoiceDetail invoice in pc.Invoices)
            {
                table.AppendLine("<tr>");
                table.AppendFormat("<td style='font-size:14px;font-weight:bold;padding: 5px 0px 5px 10px;background-color:#F2F2F2;border: solid 1px #e2e2e2'>{0}</td>", invoice.LinkParams.Lot);
                table.AppendFormat("<td style='font-size:14px;font-weight:bold;padding: 5px 0px 5px 10px;background-color:#F2F2F2;border: solid 1px #e2e2e2'>{0}</td>", invoice.DateCreated.ToShortDateString());
                table.AppendFormat("<td style='font-size:14px;font-weight:bold;padding: 5px 0px 5px 10px;background-color:#F2F2F2;border: solid 1px #e2e2e2'>{0}</td>", invoice.LinkParams.Title);
                table.AppendFormat("<td style='font-size:14px;font-weight:bold;padding: 5px 0px 5px 10px;background-color:#F2F2F2;border: solid 1px #e2e2e2'>{0}</td>", invoice.Quantity);
                table.AppendFormat("<td style='font-size:14px;font-weight:bold;font-weight:bold;padding: 5px 0px 5px 10px;background-color:#F2F2F2;border: solid 1px #e2e2e2'>{0}</td>", invoice.TotalCostWithoutCouponDiscount.GetCurrency());
                table.AppendLine("</tr>");

                table.AppendLine("<tr><td colspan='5' style='font-size:14px;background-color:#DEEBF7;padding:5px'><table style='margin: 0px; table-layout: fixed;' cellpadding='0' cellspacing='0'><colgroup><col width='245px' /><col width='365px' /><col width='120px' /></colgroup>");
                table.AppendFormat("<tr><td>&nbsp;</td><td style='border-top:solid 1px #DDDDDD;border-left:solid 1px #DDDDDD;border-bottom:solid 1px #DDDDDD;padding-left:10px;background-color:White;'>Winning Bid {0}</td><td style='border:solid 1px #DDDDDD;padding-left:10px;background-color:White;'>{1}</td></tr>", (invoice.Quantity > 1) ? String.Format("<span style='display: table-row-group; float: right;'>{0} x {1} = </span>", invoice.Quantity, ((decimal)(invoice.Amount / invoice.Quantity)).GetCurrency()) : String.Empty, invoice.Amount.GetCurrency());
                if (invoice.AuctionType != (long)Consts.AuctionType.DealOfTheWeek && (invoice.BuyerPremium > 0 || invoice.RealBP.HasValue))
                {
                    table.AppendFormat("<tr><td>&nbsp;</td><td style='{0}'>Buyer's premium</td><td style='{1}'>{2}</td></tr>", tableBL, tableBLR, invoice.RealBP.GetValueOrDefault(invoice.BuyerPremium).GetCurrency());
                }
                if (invoice.Shipping > 0 || invoice.RealSh.HasValue)
                {
                    table.AppendFormat("<tr><td>&nbsp;</td><td style='{0}'>Shipping and handling</td><td style='{1}'>{2}</td></tr>", tableBL, tableBLR, invoice.RealSh.GetValueOrDefault(invoice.Shipping).GetCurrency());
                    table.AppendFormat("<tr><td>&nbsp;</td><td style='{0}'>Insurance</td><td style='{1}'>{2}</td></tr>", tableBL, tableBLR, invoice.Insurance.GetCurrency());
                }
                if (invoice.Tax > 0)
                {
                    table.AppendFormat("<tr><td>&nbsp;</td><td style='{0}'>Tax</td><td style='{1}'>{2}</td></tr>", tableBL, tableBLR, invoice.Tax.GetCurrency());
                }
                if (invoice.Discount > 0 && invoice.TotalOrderDiscount.GetValueOrDefault(0) != invoice.Discount)
                {
                    table.AppendFormat("<tr><td>&nbsp;</td><td style='{0}'>Tax</td><td style='{1}'>{2}</td></tr>", tableBL, tableBLR, (invoice.Discount - invoice.TotalOrderDiscount.GetValueOrDefault(0)).GetCurrency());
                }
                table.AppendLine("</table>");
                table.AppendLine("</td>");
                table.AppendLine("</tr>");
            }
            template.Data.Add("{{invoices_info}}", table.ToString());
            #endregion

            if (pc.HasDiscount)
            {
                table = new StringBuilder();
                table.AppendFormat("<br /><tr><td style='background-color:#01347E;color:#FFFFFF;padding: 5px 0px 5px 10px;font-size:14px;' colspan=4>{0}&nbsp;Paid:&nbsp;</td><td style='font-weight:bold;background-color:#01347E;color:#FFFFFF;padding: 5px 0px 5px 10px;font-size:14px;'>{1}</td></tr>", "Subtotal", pc.TotalCostWithoutDiscount.GetCurrency());
                table.AppendFormat("<br /><tr><td style='font-weight:bold;background-color:#400000;border:solid 1px #400000;color:#FFFFFF;padding: 5px 0px 5px 10px;font-size:14px;text-align:right' colspan=4>{0}:&nbsp;</td><td style='font-weight:bold;background-color:#400000;border:solid 1px #400000;color:#FFFFFF;padding: 5px 0px 5px 10px;font-size:14px;'>{1}</td></tr>", "Promo Discount", pc.DiscountAmount.GetCurrency());
                template.Data.Add("{{discount_info}}", table.ToString());
            }
            else
            {
                template.Data.Add("{{discount_info}}", String.Empty);
            }

            template.Data.Add("{{TotalDue}}", pc.TotalCost.GetCurrency());

            if (pc.Deposit > 0)
            {
                table = new StringBuilder();
                table.AppendFormat("<br /><tr><td style='font-weight:bold;background-color:#400000;border:solid 1px #400000;color:#FFFFFF;padding: 5px 0px 5px 10px;font-size:14px;text-align:right' colspan=4>{0}:&nbsp;</td><td style='font-weight:bold;background-color:#400000;border:solid 1px #400000;color:#FFFFFF;padding: 5px 0px 5px 10px;font-size:14px;'>{1}</td></tr>", (pc.TotalCost - pc.Deposit > 0) ? "Deposit" : "Paid from Account Balance", (pc.TotalCost - pc.Deposit < 0) ? pc.TotalCost.GetCurrency() : pc.Deposit.GetCurrency());
                if (pc.TotalCost - pc.Deposit > 0)
                {
                    table.AppendFormat("<br /><tr><td style='font-weight:bold;background-color:#DEEBF7;border:solid 1px #e2e2e2;color:#333333;padding: 5px 0px 5px 10px;font-size:14px;text-align:right' colspan=4>{0}&nbsp;Paid:&nbsp;</td><td style='font-weight:bold;background-color:#DEEBF7;border:solid 1px #e2e2e2;color:#333333;padding: 5px 0px 5px 10px;font-size:14px;'>{1}</td></tr>", (pc.Deposit == 0) ? "Total" : "Balance", (pc.TotalCost - pc.Deposit < 0) ? "(" + (pc.Deposit - pc.TotalCost).GetCurrency() + ")" : (pc.TotalCost - pc.Deposit).GetCurrency());
                }
                else if (pc.DepositLimit >= 0)
                {
                    table.AppendFormat("<br /><tr><td style='font-weight:bold;background-color:#DEEBF7;border:solid 1px #e2e2e2;color:#333333;padding: 5px 0px 5px 10px;font-size:14px;text-align:right' colspan=4>{0}&nbsp;</td><td style='font-weight:bold;background-color:#DEEBF7;border:solid 1px #e2e2e2;color:#333333;padding: 5px 0px 5px 10px;font-size:14px;'>{1}</td></tr>", !pc.IsDepositRefunded ? "Account Balance:" : "Refunded Amount:", pc.DepositLimit.GetCurrency(false));
                }
                template.Data.Add("{{deposits}}", table.ToString());
            }
            else
            {
                template.Data.Add("{{deposits}}", String.Empty);
            }

            ParseCommonData(template);
            UniMail.Mailer.Enqueue(template.RenderHTML());
        }
Ejemplo n.º 12
0
        //Result
        protected override async void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            try
            {
                base.OnActivityResult(requestCode, resultCode, data);

                if (AppSettings.ShowInAppBilling)
                {
                    BillingPayment?.Handler?.HandleActivityResult(requestCode, resultCode, data);
                }

                if (requestCode == 108 || requestCode == CropImage.CropImageActivityRequestCode)
                {
                    if (Methods.CheckConnectivity())
                    {
                        var result = CropImage.GetActivityResult(data);
                        if (result.IsSuccessful)
                        {
                            var resultPathImage = result.Uri.Path;
                            if (!string.IsNullOrEmpty(resultPathImage))
                            {
                                if (TypeAvatar == OpenGalleryDialogFor.Avatar)
                                {
                                    GlideImageLoader.LoadImage(this, resultPathImage, ProfileFragment?.ProfileImage, ImageStyle.CircleCrop, ImagePlaceholders.Drawable);
                                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                        () => ApiRequest.UpdateAvatarApi(this, resultPathImage)
                                    });
                                }
                                else
                                {
                                    //sent api
                                    PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                        () => RequestsAsync.Users.UploadMediaFileUserAsync(resultPathImage)
                                    });
                                }

                                var reviewMediaFiles = ListUtils.SettingsSiteList.FirstOrDefault()?.ReviewMediaFiles;
                                if (reviewMediaFiles == "1") //Uploaded successfully, file will be reviewed
                                {
                                    Toast.MakeText(this, GetText(Resource.String.Lbl_UploadedSuccessfullyWithReviewed), ToastLength.Long).Show();
                                }
                                else
                                {
                                    Toast.MakeText(this, GetText(Resource.String.Lbl_UploadedSuccessfully), ToastLength.Long).Show();
                                }
                            }
                        }
                    }
                    else
                    {
                        Toast.MakeText(this, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long).Show();
                    }
                }
                else if (requestCode == 1050) //1050
                {
                    //Get Location And Get Data Api
                    TrendingFragment?.CheckAndGetLocation();
                }
                else if (requestCode == InitPayPalPayment?.PayPalDataRequestCode)
                {
                    switch (resultCode)
                    {
                    case Result.Ok:
                        var confirmObj = data.GetParcelableExtra(PaymentActivity.ExtraResultConfirmation);
                        PaymentConfirmation configuration = Android.Runtime.Extensions.JavaCast <PaymentConfirmation>(confirmObj);
                        if (configuration != null)
                        {
                            //string createTime = configuration.ProofOfPayment.CreateTime;
                            //string intent = configuration.ProofOfPayment.Intent;
                            //string paymentId = configuration.ProofOfPayment.PaymentId;
                            //string state = configuration.ProofOfPayment.State;
                            //string transactionId = configuration.ProofOfPayment.TransactionId;

                            if (InitPayPalPayment?.PayType != "membership")
                            {
                                if (Methods.CheckConnectivity())
                                {
                                    (int apiStatus, var respond) = await RequestsAsync.Auth.SetCreditAsync(InitPayPalPayment?.Credits, InitPayPalPayment?.Price, "PayPal").ConfigureAwait(false);

                                    if (apiStatus == 200)
                                    {
                                        if (respond is SetCreditObject result)
                                        {
                                            RunOnUiThread(() =>
                                            {
                                                try
                                                {
                                                    var dataUser = ListUtils.MyUserInfo.FirstOrDefault(a => a.Id == UserDetails.UserId);
                                                    if (dataUser != null)
                                                    {
                                                        dataUser.Balance = result.Balance;

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

                                                    if (ProfileFragment.WalletNumber != null)
                                                    {
                                                        ProfileFragment.WalletNumber.Text = result.Balance;
                                                    }

                                                    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 (Methods.CheckConnectivity())
                                {
                                    (int apiStatus, var respond) = await RequestsAsync.Auth.SetProAsync(InitPayPalPayment?.Id, InitPayPalPayment?.Price, "PayPal").ConfigureAwait(false);

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

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

                                                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;
                    }
                }
                else if (requestCode == PaymentActivity.ResultExtrasInvalid)
                {
                    Toast.MakeText(this, GetText(Resource.String.Lbl_Invalid), ToastLength.Long).Show();
                }
                else if (requestCode == 1001 && resultCode == Result.Ok && AppSettings.ShowInAppBilling)
                {
                    if (BillingPayment?.PayType != "membership")
                    {
                        if (Methods.CheckConnectivity())
                        {
                            (int apiStatus, var respond) = await RequestsAsync.Auth.SetCreditAsync(BillingPayment?.Credits, BillingPayment?.Price, "Google InApp").ConfigureAwait(false);

                            if (apiStatus == 200)
                            {
                                if (respond is SetCreditObject result)
                                {
                                    RunOnUiThread(() =>
                                    {
                                        try
                                        {
                                            var dataUser = ListUtils.MyUserInfo.FirstOrDefault();
                                            if (dataUser != null)
                                            {
                                                dataUser.Balance = result.Balance;

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

                                            if (ProfileFragment.WalletNumber != null)
                                            {
                                                ProfileFragment.WalletNumber.Text = result.Balance.Replace(".00", "");
                                            }

                                            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 (Methods.CheckConnectivity())
                        {
                            (int apiStatus, var respond) = await RequestsAsync.Auth.SetProAsync(BillingPayment?.Id, BillingPayment?.Price, "Google InApp").ConfigureAwait(false);

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

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

                                        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();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 13
0
        /// <param name='triggerState'>
        /// Required.
        /// </param>
        /// <param name='probability'>
        /// Required.
        /// </param>
        /// <param name='cancellationToken'>
        /// Cancellation token.
        /// </param>
        public async Task <HttpOperationResponse <PaymentConfirmation> > PaidInFullPollTriggerByTriggerstateAndProbabilityWithOperationResponseAsync(string triggerState, double probability, CancellationToken cancellationToken = default(System.Threading.CancellationToken))
        {
            // Validate
            if (triggerState == null)
            {
                throw new ArgumentNullException("triggerState");
            }

            // Tracing
            bool   shouldTrace  = ServiceClientTracing.IsEnabled;
            string invocationId = null;

            if (shouldTrace)
            {
                invocationId = ServiceClientTracing.NextInvocationId.ToString();
                Dictionary <string, object> tracingParameters = new Dictionary <string, object>();
                tracingParameters.Add("triggerState", triggerState);
                tracingParameters.Add("probability", probability);
                ServiceClientTracing.Enter(invocationId, this, "PaidInFullPollTriggerByTriggerstateAndProbabilityAsync", tracingParameters);
            }

            // Construct URL
            string url = "";

            url = url + "/api/PaidInFull";
            List <string> queryParameters = new List <string>();

            queryParameters.Add("triggerState=" + Uri.EscapeDataString(triggerState));
            queryParameters.Add("probability=" + Uri.EscapeDataString(probability.ToString()));
            if (queryParameters.Count > 0)
            {
                url = url + "?" + string.Join("&", queryParameters);
            }
            string baseUrl = this.Client.BaseUri.AbsoluteUri;

            // Trim '/' character from the end of baseUrl and beginning of url.
            if (baseUrl[baseUrl.Length - 1] == '/')
            {
                baseUrl = baseUrl.Substring(0, baseUrl.Length - 1);
            }
            if (url[0] == '/')
            {
                url = url.Substring(1);
            }
            url = baseUrl + "/" + url;
            url = url.Replace(" ", "%20");

            // Create HTTP transport objects
            HttpRequestMessage httpRequest = new HttpRequestMessage();

            httpRequest.Method     = HttpMethod.Get;
            httpRequest.RequestUri = new Uri(url);

            // Set Credentials
            if (this.Client.Credentials != null)
            {
                cancellationToken.ThrowIfCancellationRequested();
                await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false);
            }

            // Send Request
            if (shouldTrace)
            {
                ServiceClientTracing.SendRequest(invocationId, httpRequest);
            }
            cancellationToken.ThrowIfCancellationRequested();
            HttpResponseMessage httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false);

            if (shouldTrace)
            {
                ServiceClientTracing.ReceiveResponse(invocationId, httpResponse);
            }
            HttpStatusCode statusCode = httpResponse.StatusCode;

            cancellationToken.ThrowIfCancellationRequested();
            string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);

            if (statusCode != HttpStatusCode.OK)
            {
                HttpOperationException <object> ex = new HttpOperationException <object>();
                ex.Request  = httpRequest;
                ex.Response = httpResponse;
                ex.Body     = null;
                if (shouldTrace)
                {
                    ServiceClientTracing.Error(invocationId, ex);
                }
                throw ex;
            }

            // Create Result
            HttpOperationResponse <PaymentConfirmation> result = new HttpOperationResponse <PaymentConfirmation>();

            result.Request  = httpRequest;
            result.Response = httpResponse;

            // Deserialize Response
            if (statusCode == HttpStatusCode.OK)
            {
                PaymentConfirmation resultModel = new PaymentConfirmation();
                JToken responseDoc = null;
                if (string.IsNullOrEmpty(responseContent) == false)
                {
                    responseDoc = JToken.Parse(responseContent);
                }
                if (responseDoc != null)
                {
                    resultModel.DeserializeJson(responseDoc);
                }
                result.Body = resultModel;
            }

            if (shouldTrace)
            {
                ServiceClientTracing.Exit(invocationId, result);
            }
            return(result);
        }
Ejemplo n.º 14
0
        public void OnActivityResult(int requestCode, Result resultCode, Android.Content.Intent data)
        {
            if (requestCode == PayPalManager.REQUEST_CODE_PAYMENT)
            {
                if (resultCode == Result.Ok)
                {
                    PaymentConfirmation confirm =
                        (PaymentConfirmation)data.GetParcelableExtra(PaymentActivity.ExtraResultConfirmation);
                    if (confirm != null)
                    {
                        try {
                            System.Diagnostics.Debug.WriteLine(confirm.ToJSONObject().ToString(4));
                            System.Diagnostics.Debug.WriteLine(confirm.Payment.ToJSONObject().ToString(4));

                            /**
                             *  TODO: send 'confirm' (and possibly confirm.getPayment() to your server for verification
                             * or consent completion.
                             * See https://developer.paypal.com/webapps/developer/docs/integration/mobile/verify-mobile-payment/
                             * for more details.
                             *
                             * For sample mobile backend interactions, see
                             * https://github.com/paypal/rest-api-sdk-python/tree/master/samples/mobile_backend
                             */
                            Toast.MakeText(
                                Context.ApplicationContext,
                                "PaymentConfirmation info received from PayPal", ToastLength.Short)
                            .Show();
                        } catch (JSONException e) {
                            System.Diagnostics.Debug.WriteLine("an extremely unlikely failure occurred: " + e.Message);
                        }
                    }
                }
                else if (resultCode == Result.Canceled)
                {
                    System.Diagnostics.Debug.WriteLine("The user canceled.");
                }
                else if ((int)resultCode == PaymentActivity.ResultExtrasInvalid)
                {
                    System.Diagnostics.Debug.WriteLine(
                        "An invalid Payment or PayPalConfiguration was submitted. Please see the docs.");
                }
            }
            else if (requestCode == REQUEST_CODE_FUTURE_PAYMENT)
            {
                if (resultCode == Result.Ok)
                {
                    PayPalAuthorization auth = (Xamarin.PayPal.Android.PayPalAuthorization)data.GetParcelableExtra(PayPalFuturePaymentActivity.ExtraResultAuthorization);
                    if (auth != null)
                    {
                        try {
                            System.Diagnostics.Debug.WriteLine(auth.ToJSONObject().ToString(4));

                            String authorization_code = auth.AuthorizationCode;
                            System.Diagnostics.Debug.WriteLine(authorization_code);

                            sendAuthorizationToServer(auth);
                            Toast.MakeText(
                                Context.ApplicationContext,
                                "Future Payment code received from PayPal", ToastLength.Long)
                            .Show();
                        } catch (JSONException e) {
                            System.Diagnostics.Debug.WriteLine("an extremely unlikely failure occurred: " + e.Message);
                        }
                    }
                }
                else if (resultCode == Result.Ok)
                {
                    System.Diagnostics.Debug.WriteLine("The user canceled.");
                }
                else if ((int)resultCode == PayPalFuturePaymentActivity.ResultExtrasInvalid)
                {
                    System.Diagnostics.Debug.WriteLine(
                        "Probably the attempt to previously start the PayPalService had an invalid PayPalConfiguration. Please see the docs.");
                }
            }
            else if (requestCode == REQUEST_CODE_PROFILE_SHARING)
            {
                if (resultCode == Result.Ok)
                {
                    PayPalAuthorization auth = (Xamarin.PayPal.Android.PayPalAuthorization)data.GetParcelableExtra(PayPalProfileSharingActivity.ExtraResultAuthorization);
                    if (auth != null)
                    {
                        try {
                            System.Diagnostics.Debug.WriteLine(auth.ToJSONObject().ToString(4));

                            String authorization_code = auth.AuthorizationCode;
                            System.Diagnostics.Debug.WriteLine(authorization_code);

                            sendAuthorizationToServer(auth);
                            Toast.MakeText(
                                Context.ApplicationContext,
                                "Profile Sharing code received from PayPal", ToastLength.Short)
                            .Show();
                        } catch (JSONException e) {
                            System.Diagnostics.Debug.WriteLine("an extremely unlikely failure occurred: " + e.Message);
                        }
                    }
                }
                else if (resultCode == Result.Canceled)
                {
                    System.Diagnostics.Debug.WriteLine("The user canceled.");
                }
                else if ((int)resultCode == PayPalFuturePaymentActivity.ResultExtrasInvalid)
                {
                    System.Diagnostics.Debug.WriteLine(
                        "Probably the attempt to previously start the PayPalService had an invalid PayPalConfiguration. Please see the docs.");
                }
            }
        }
        //Result
        protected override async void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            try
            {
                base.OnActivityResult(requestCode, resultCode, data);

                if (AppSettings.ShowInAppBilling && Client.IsExtended)
                {
                    BillingPayment?.Handler?.HandleActivityResult(requestCode, resultCode, data);
                }

                if (requestCode == InitPayPalPayment?.PayPalDataRequestCode)
                {
                    switch (resultCode)
                    {
                    case Result.Ok:
                        var confirmObj = data.GetParcelableExtra(PaymentActivity.ExtraResultConfirmation);
                        PaymentConfirmation configuration = Android.Runtime.Extensions.JavaCast <PaymentConfirmation>(confirmObj);
                        if (configuration != null)
                        {
                            //string createTime = configuration.ProofOfPayment.CreateTime;
                            //string intent = configuration.ProofOfPayment.Intent;
                            //string paymentId = configuration.ProofOfPayment.PaymentId;
                            //string state = configuration.ProofOfPayment.State;
                            //string transactionId = configuration.ProofOfPayment.TransactionId;

                            if (PayType == "membership")
                            {
                                if (Methods.CheckConnectivity())
                                {
                                    (int apiStatus, var respond) = await RequestsAsync.Global.SetProAsync(PayId).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();
                                            FinishPage();
                                        });
                                    }
                                    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;
                    }
                }
                else if (requestCode == PaymentActivity.ResultExtrasInvalid)
                {
                    Toast.MakeText(this, GetText(Resource.String.Lbl_Invalid), ToastLength.Long).Show();
                }
                else if (requestCode == 1001 && resultCode == Result.Ok && AppSettings.ShowInAppBilling && Client.IsExtended)
                {
                    if (Methods.CheckConnectivity())
                    {
                        (int apiStatus, var respond) = await RequestsAsync.Global.SetProAsync(PayId).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();
                                FinishPage();
                            });
                        }
                        else
                        {
                            Methods.DisplayReportResult(this, respond);
                        }
                    }
                    else
                    {
                        Toast.MakeText(this, GetText(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Long).Show();
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 16
0
 public void OnActivityResult(int requestCode, Result resultCode, global::Android.Content.Intent data)
 {
     if (requestCode == PayPalManager.REQUEST_CODE_PAYMENT)
     {
         if (resultCode == Result.Ok)
         {
             PaymentConfirmation confirm =
                 (PaymentConfirmation)data.GetParcelableExtra(PaymentActivity.ExtraResultConfirmation);
             if (confirm != null)
             {
                 try
                 {
                     OnSuccess?.Invoke(confirm.ToJSONObject().ToString());
                     OnSuccess = null;
                 }
                 catch (JSONException e)
                 {
                     OnError?.Invoke("an extremely unlikely failure occurred: " + e.Message);
                     OnError = null;
                     System.Diagnostics.Debug.WriteLine("an extremely unlikely failure occurred: " + e.Message);
                 }
             }
             OnError?.Invoke("Unknown Error");
             OnError = null;
         }
         else if (resultCode == Result.Canceled)
         {
             OnCancelled?.Invoke();
             OnCancelled = null;
             System.Diagnostics.Debug.WriteLine("The user canceled.");
         }
         else if ((int)resultCode == PaymentActivity.ResultExtrasInvalid)
         {
             OnError?.Invoke("An invalid Payment or PayPalConfiguration was submitted. Please see the docs.");
             OnError = null;
             System.Diagnostics.Debug.WriteLine(
                 "An invalid Payment or PayPalConfiguration was submitted. Please see the docs.");
         }
     }
     else if (requestCode == REQUEST_CODE_FUTURE_PAYMENT)
     {
         if (resultCode == Result.Ok)
         {
             PayPalAuthorization auth =
                 (PayPalAuthorization)data.GetParcelableExtra(PayPalFuturePaymentActivity.ExtraResultAuthorization);
             if (auth != null)
             {
                 try
                 {
                     OnSuccess?.Invoke(auth.ToJSONObject().ToString());
                     OnSuccess = null;
                 }
                 catch (JSONException e)
                 {
                     System.Diagnostics.Debug.WriteLine("an extremely unlikely failure occurred: " + e.Message);
                 }
             }
             OnError?.Invoke("Unknown Error");
             OnError = null;
         }
         else if (resultCode == Result.Canceled)
         {
             OnCancelled?.Invoke();
             OnCancelled = null;
             System.Diagnostics.Debug.WriteLine("The user canceled.");
         }
         else if ((int)resultCode == PayPalFuturePaymentActivity.ResultExtrasInvalid)
         {
             OnError?.Invoke("Probably the attempt to previously start the PayPalService had an invalid PayPalConfiguration. Please see the docs.");
             OnError = null;
             System.Diagnostics.Debug.WriteLine(
                 "Probably the attempt to previously start the PayPalService had an invalid PayPalConfiguration. Please see the docs.");
         }
     }
     else if (requestCode == REQUEST_CODE_PROFILE_SHARING)
     {
         if (resultCode == Result.Ok)
         {
             PayPalAuthorization auth =
                 (PayPalAuthorization)data.GetParcelableExtra(PayPalProfileSharingActivity.ExtraResultAuthorization);
             if (auth != null)
             {
                 try
                 {
                     OnSuccess?.Invoke(auth.ToJSONObject().ToString());
                     OnSuccess = null;
                 }
                 catch (JSONException e)
                 {
                     System.Diagnostics.Debug.WriteLine("an extremely unlikely failure occurred: " + e.Message);
                 }
             }
             OnError?.Invoke("Unknown Error");
             OnError = null;
         }
         else if (resultCode == Result.Canceled)
         {
             OnCancelled?.Invoke();
             OnCancelled = null;
             System.Diagnostics.Debug.WriteLine("The user canceled.");
         }
         else if ((int)resultCode == PayPalFuturePaymentActivity.ResultExtrasInvalid)
         {
             OnError?.Invoke("Probably the attempt to previously start the PayPalService had an invalid PayPalConfiguration. Please see the docs.");
             OnError = null;
             System.Diagnostics.Debug.WriteLine(
                 "Probably the attempt to previously start the PayPalService had an invalid PayPalConfiguration. Please see the docs.");
         }
     }
     else if (requestCode == REQUEST_CODE_CARD_SCAN)
     {
         if (data == null)
         {
             RetrieveCardCancelled?.Invoke();
             RetrieveCardCancelled = null;
             System.Diagnostics.Debug.WriteLine("The user canceled.");
             return;
         }
         var card = (CreditCard)data.GetParcelableExtra(CardIOActivity.ExtraScanResult);
         if (card != null)
         {
             RetrieveCardSuccess?.Invoke(card, CardIOActivity.GetCapturedCardImage(data));
             RetrieveCardSuccess = null;
         }
         else
         {
             RetrieveCardCancelled?.Invoke();
             RetrieveCardCancelled = null;
             System.Diagnostics.Debug.WriteLine("The user canceled.");
         }
     }
 }
Ejemplo n.º 17
0
        //Result
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            try
            {
                base.OnActivityResult(requestCode, resultCode, data);
                BillingPayment?.Handler?.HandleActivityResult(requestCode, resultCode, data);

                if (requestCode == InitPayPalPayment?.PayPalDataRequestCode)
                {
                    switch (resultCode)
                    {
                    case Result.Ok:
                        var confirmObj = data.GetParcelableExtra(PaymentActivity.ExtraResultConfirmation);
                        PaymentConfirmation configuration = Android.Runtime.Extensions.JavaCast <PaymentConfirmation>(confirmObj);
                        if (configuration != null)
                        {
                            //string createTime = configuration.ProofOfPayment.CreateTime;
                            //string intent = configuration.ProofOfPayment.Intent;
                            //string paymentId = configuration.ProofOfPayment.PaymentId;
                            //string state = configuration.ProofOfPayment.State;
                            //string transactionId = configuration.ProofOfPayment.TransactionId;

                            if (!Methods.CheckConnectivity())
                            {
                                Toast.MakeText(this, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                            }
                            else
                            {
                                PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                                    SetProApi
                                });
                            }
                        }
                        break;

                    case Result.Canceled:
                        Toast.MakeText(this, GetText(Resource.String.Lbl_Canceled), ToastLength.Long).Show();
                        break;
                    }
                }
                else if (requestCode == PaymentActivity.ResultExtrasInvalid)
                {
                    Toast.MakeText(this, GetText(Resource.String.Lbl_Invalid), ToastLength.Long).Show();
                }
                else if (requestCode == 1001 && resultCode == Result.Ok)
                {
                    if (!Methods.CheckConnectivity())
                    {
                        Toast.MakeText(this, GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short).Show();
                    }
                    else
                    {
                        PollyController.RunRetryPolicyFunction(new List <Func <Task> > {
                            SetProApi
                        });
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
        public Form GetForm(PurseContext context)
        {
            if (null == context)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var template =
                TemplateLoader.LoadSubmitFormTemplate(context.ExtensionManager, ExtensionCatalog.TakePayment);

            var origin =
                new AccountDropDownListOrigin(context.UnityContainer)
            {
                SelectedAccountNumber = context.Account.Number
            };

            origin.FilterCriteria.CurrencyCapabilities = CurrencyCapabilities.Transfer;

            var itemTemplates = AccountDisplayHelper.BuildAccountDropDownListItemTemplates(origin);

            var step1TemplateWrapper = new TakePaymentFormTemplateWrapper.Step1(template);

            step1TemplateWrapper.Control2StorePurse.Items.Clear();
            step1TemplateWrapper.Control2StorePurse.Items.AddRange(itemTemplates);

            var form = new SubmitForm();

            ErrorFormDisplayHelper.ApplyErrorAction(context.ExtensionManager, form);

            var incomeValuesWrapper =
                new TakePaymentFormValuesWrapper.Step1
            {
                Control2OrderId = context.Session.SettingsService.AllocateOrderId()
            };

            form.ApplyTemplate(template, incomeValuesWrapper.CollectIncomeValues());

            form.ServiceCommand += (sender, args) =>
            {
                if (!TakePaymentFormValuesWrapper.Step1.Control5WMIDCommandFindPassport.Equals(args.Command))
                {
                    return;
                }

                var identifierValue = (string)args.Argument;
                IdentifierDisplayHelper.ShowFindCertificateForm(form, context, identifierValue);
            };

            long   invoiceId = 0;
            string purse     = "";

            form.WorkCallback = (step, list) =>
            {
                var paymentService = context.UnityContainer.Resolve <IPaymentService>();

                switch (step)
                {
                case 0:
                    var step1ValuesWrapper = new TakePaymentFormValuesWrapper.Step1(list);

                    ExtendedIdentifier extendedIdentifier;

                    switch (step1ValuesWrapper.Control3IdentifierType)
                    {
                    case TakePaymentFormValuesWrapper.Step1.Control3IdentifierTypeValueWmid:
                        extendedIdentifier = new ExtendedIdentifier(ExtendedIdentifierType.WmId,
                                                                    step1ValuesWrapper.Control5WMID);
                        break;

                    case TakePaymentFormValuesWrapper.Step1.Control3IdentifierTypeValuePhone:
                        extendedIdentifier = new ExtendedIdentifier(ExtendedIdentifierType.Phone,
                                                                    step1ValuesWrapper.Control4Phone);
                        break;

                    case TakePaymentFormValuesWrapper.Step1.Control3IdentifierTypeValueEmail:
                        extendedIdentifier = new ExtendedIdentifier(ExtendedIdentifierType.Email,
                                                                    step1ValuesWrapper.Control6Email);
                        break;

                    default:
                        throw new InvalidOperationException(
                                  "step1ValuesWrapper.Control3IdentifierType == " +
                                  step1ValuesWrapper.Control3IdentifierType);
                    }

                    var originalExpressPayment = new OriginalExpressPayment(step1ValuesWrapper.Control2OrderId,
                                                                            step1ValuesWrapper.Control1StorePurse, step1ValuesWrapper.Control7PaymentAmount,
                                                                            step1ValuesWrapper.Control9Description, extendedIdentifier);

                    originalExpressPayment.ConfirmationType =
                        (ConfirmationType)Enum.Parse(typeof(ConfirmationType),
                                                     step1ValuesWrapper.Control8ConfirmationType);

                    purse = originalExpressPayment.TargetPurse;

                    var confirmationInstruction = paymentService.RequestPayment(originalExpressPayment);

                    invoiceId = confirmationInstruction.InvoiceId;

                    var step2IncomeValuesWrapper = new TakePaymentFormValuesWrapper.Step2();
                    step2IncomeValuesWrapper.Control1InvoiceId = confirmationInstruction.InvoiceId.ToString();
                    step2IncomeValuesWrapper.Control2Message   = confirmationInstruction.PublicMessage ?? string.Empty;

                    return(step2IncomeValuesWrapper.CollectIncomeValues());

                case 1:

                    var step2ValuesWrapper = new TakePaymentFormValuesWrapper.Step2(list);

                    var paymentConfirmation = new PaymentConfirmation(purse, invoiceId)
                    {
                        ConfirmationCode = step2ValuesWrapper.Control4CancelInvoice
                                ? "-1"
                                : step2ValuesWrapper.Control3Code
                    };

                    paymentService.ConfirmPayment(paymentConfirmation);

                    break;

                default:
                    throw new InvalidOperationException("step == " + step);
                }

                return(new Dictionary <string, object>());
            };

            return(form);
        }