Exemplo n.º 1
0
        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"));
        }
Exemplo n.º 2
0
		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");
		}