public override async Task<Tuple<ChargeDetails, string>> Charge (UIViewController parent, Invoice invoice) { tcs = new TaskCompletionSource<Tuple<ChargeDetails, string>> (); PATransactionHandler.DataHolder.Delegate = new HandlerDelegate (tcs, invoice); PATransactionHandler.DataHolder.IsEmailOn = false; PATransactionHandler.DataHolder.AppName = "Affinity"; PATransactionHandler.DataHolder.LoginId = Settings.Shared.PayAnywhereLogin; PATransactionHandler.DataHolder.MerchantId = Settings.Shared.PayAnywhereMerchantId; PATransactionHandler.DataHolder.PassWord = Settings.Shared.PayAnywherePw; PATransactionHandler.DataHolder.UserName = Settings.Shared.PayAnywhereUserId; PATransactionHandler.DataHolder.Amount = invoice.CardPayment.Amount.ToString (); PATransactionHandler.DataHolder.Invoice = invoice.Id; PATransactionHandler.DataHolder.IsEmailOn = true; PATransactionHandler.DataHolder.IsSignatureOn = true; PATransactionHandler.DataHolder.IsSignatureRequired = true; PATransactionHandler.DataHolder.TransactionType = Transactions.NewCharge; PATransactionHandler.DataHolder.Submit (); return await tcs.Task; }
public override async Task<Tuple<ChargeDetails, string>> Charge (UIViewController parent,Invoice invoice) { this.invoice = invoice; if(!App.CanOpenUrl("paypalhere://takePayment")) { return new Tuple<ChargeDetails, string> (null, "Paypal Here not installed"); } else if(string.IsNullOrEmpty(Settings.Shared.PaypalId)) return new Tuple<ChargeDetails, string> (null, "Please set the paypal email in the settings"); var paypal = new PaypalRoot{ merchantEmail = Settings.Shared.PaypalId, currencyCode = "USD", paymentTerms = "DueOnReceipt", itemList = new ItemList{ item = { new PaypalItem{ name = "KiD to KiD of Anchorage", description = "Payment for invoice " + invoice.Id, quantity = "1", unitPrice = invoice.CardPayment.Amount.ToString() } } } }; var returnUrl = HttpUtility.UrlEncode("myapp://paypalHandler?{result}?Type={Type}&InvoiceId={InvoiceId}&Tip={Tip}&Email={Email}&TxId={TxId}"); var invoiceJson = Newtonsoft.Json.JsonConvert.SerializeObject (paypal); var url = string.Format ("paypalhere://takePayment?accepted=card,paypal&returnUrl={0}&invoice={1}&step=choosePayment",returnUrl,invoiceJson); tcs = new TaskCompletionSource<Tuple<ChargeDetails, string>> (); if(App.OpenUrl (url)) return await tcs.Task; return new Tuple<ChargeDetails, string> (null, "Unknown Error"); }
public void Checkout () { var isReady = Invoice.IsReadyForPayment (); if (!isReady.Item1) { App.ShowAlert ("Error", isReady.Item2); return; } PaymentViewController paymentVc = null; NavigationController.PushViewController (paymentVc = new PaymentViewController {Invoice = Invoice, InvoicePosted = () => { Invoice.DeleteLocal (); Invoice = new Invoice (); paymentVc.Dispose (); } }, true); }
void NewInvoice () { Invoice.DeleteLocal (); Invoice = new Invoice (); }
public HandlerDelegate(TaskCompletionSource<Tuple<ChargeDetails, string>> tcs, Invoice invoice) { this.invoice = invoice; this.tcs = tcs; }
public abstract Task<Tuple<ChargeDetails, string>> Charge(UIViewController parent, Invoice invoice);
public PaymentView() { const float rowHeight = 80; BackgroundColor = UIColor.FromPatternImage(UIImage.FromBundle("homeScreen")); Add(backgroundView = new UIView { BackgroundColor = UIColor.Black.ColorWithAlpha(.5f), ClipsToBounds = true, Layer = { BorderColor = UIColor.White.ColorWithAlpha(.75f).CGColor, BorderWidth = .5f, CornerRadius = 5, }, }); backgroundView.Add(TotalLabel = new UILabel()); backgroundView.Add(tableView = new ObservableTableView(UITableViewStyle.Grouped) { ContentInset = new UIEdgeInsets(-36, 0, 0, 0), BackgroundColor = UIColor.Clear, CellIdentifier = PaymentCell.Key, CreateCellFunc = () => new PaymentCell(), RowHeight = rowHeight, BindCellAction = (cell, item) => { (cell as PaymentCell).Payment = item as Payment; }, ItemTapped = (p) => { Invoice.PaymentSelected(p as Payment); }, }); var bgColor = UIColor.Black.ColorWithAlpha(.3f); backgroundView.Add(rightTableView = new UITableView(RectangleF.Empty, UITableViewStyle.Grouped) { ContentInset = new UIEdgeInsets(-36, 0, 0, 0), SectionHeaderHeight = 0, BackgroundColor = UIColor.Clear, ScrollEnabled = false, RowHeight = 60, Source = new CellTableViewSource { (onAccountCell = new SubTotalCell { Frame = new RectangleF(0, 0, 320, 50), TextLabel = { Text = "On Account" }, BackgroundColor = bgColor }), (totalCell = new SubTotalCell { Frame = new RectangleF(0, 0, 320, 50), TextLabel = { Text = "Total" }, BackgroundColor = bgColor }), (remaining = new TotalCell { Frame = new RectangleF(0, 0, 320, 65), TextLabel = { Text = "Remaining", TextColor = Theme.Current.PayColor, }, DetailTextLabel = { Font = UIFont.BoldSystemFontOfSize(25), }, BackgroundColor = bgColor }), (change = new TotalCell { Frame = new RectangleF(0, 0, 320, rowHeight), TextLabel = { Text = "Change", TextColor = UIColor.White, }, DetailTextLabel = { TextColor = UIColor.White, }, BackgroundColor = bgColor, SeparatorInset = new UIEdgeInsets(0, 0, 0, 0), }), new PayCell { Frame = new RectangleF(0, 0, 320, 76), Text = "Post", Tapped = async() => { if (PostInvoice != null) { PostInvoice(); } } } } }); backgroundView.Add(five = new TintedButton { Title = "$5", TitleColor = UIColor.White.ColorWithAlpha(.75f), SelectedTintColor = Theme.Current.PayColor, }); five.TouchUpInside += (object sender, EventArgs e) => { Invoice.CashPayment.Amount = 5; }; five.SizeToFit(); backgroundView.Add(ten = new TintedButton { Title = "$10", TitleColor = UIColor.White.ColorWithAlpha(.75f), SelectedTintColor = Theme.Current.PayColor, }); ten.TouchUpInside += (object sender, EventArgs e) => { Invoice.CashPayment.Amount = 10; }; ten.SizeToFit(); backgroundView.Add(twenty = new TintedButton { Title = "$20", TitleColor = UIColor.White.ColorWithAlpha(.75f), SelectedTintColor = Theme.Current.PayColor, }); twenty.TouchUpInside += (object sender, EventArgs e) => { Invoice.CashPayment.Amount = 20; }; twenty.SizeToFit(); backgroundView.Add(fifty = new TintedButton { Title = "$50", TitleColor = UIColor.White.ColorWithAlpha(.75f), SelectedTintColor = Theme.Current.PayColor, }); fifty.TouchUpInside += (object sender, EventArgs e) => { Invoice.CashPayment.Amount = 50; }; fifty.SizeToFit(); backgroundView.Add(hundred = new TintedButton { Title = "$100", TitleColor = UIColor.White.ColorWithAlpha(.75f), SelectedTintColor = Theme.Current.PayColor, }); hundred.TouchUpInside += (object sender, EventArgs e) => { Invoice.CashPayment.Amount = 100; }; hundred.SizeToFit(); }