示例#1
0
 public override void PayPalPaymentDidCancel(PayPalPaymentViewController paymentViewController)
 {
     Debug.WriteLine("PayPal Payment Cancelled");
     paymentViewController?.DismissViewController(true, null);
     OnCancelled?.Invoke();
     OnCancelled = null;
 }
示例#2
0
        partial void actPay(NSObject sender)
        {
            // Remove our last completed payment, just for demo purposes.
            CompletedPayment = null;

            var payment = new PayPalPayment
            {
                Amount           = new NSDecimalNumber("9.95"),
                CurrencyCode     = "USD",
                ShortDescription = "Hipster t-shirt",
                Intent           = PayPalPaymentIntent.Sale
            };

            if (!payment.Processable)
            {
                // This particular payment will always be processable. If, for
                // example, the amount was negative or the shortDescription was
                // empty, this payment wouldn't be processable, and you'd want
                // to handle that here.
            }

            _payPalConfig.AcceptCreditCards = AcceptCreditCards;

            _samplePayPalPaymentDelegate = new SamplePayPalPaymentDelegate(this);
            _paymentViewController       = new PayPalPaymentViewController(payment, _payPalConfig, _samplePayPalPaymentDelegate);

            if (_paymentViewController.Handle == IntPtr.Zero)
            {
                Debug.WriteLine("Failed to create PayPalPaymentViewController.");
                return;
            }

            PresentViewController(_paymentViewController, true, null);
        }
示例#3
0
        public void BuyItem(
            PayPal.Forms.Abstractions.PayPalItem item,
            Decimal xftax,
            Action onCancelled,
            Action <string> onSuccess,
            Action <string> onError,
            PayPal.Forms.Abstractions.ShippingAddress address
            )
        {
            OnCancelled = onCancelled;
            OnSuccess   = onSuccess;
            OnError     = onError;


            var             subTotal = new NSDecimalNumber(RoundNumber((double)item.Price));
            NSDecimalNumber amount   = subTotal.Add(new NSDecimalNumber(RoundNumber((double)xftax)));

            var paymentDetails = PayPalPaymentDetails.PaymentDetailsWithSubtotal(subTotal, new NSDecimalNumber(0), new NSDecimalNumber(RoundNumber((double)xftax)));

            var payment = PayPalPayment.PaymentWithAmount(amount, item.Currency, item.Name, PayPalPaymentIntent.Sale);

            payment.PaymentDetails = paymentDetails;
            payment.Items          = new NSObject[] {
                PayPalItem.ItemWithName(
                    item.Name,
                    1,
                    new  NSDecimalNumber(RoundNumber((double)item.Price)),
                    item.Currency,
                    item.SKU
                    )
            };

            if (address != null)
            {
                payment.ShippingAddress = PayPalShippingAddress.ShippingAddressWithRecipientName(
                    address.RecipientName,
                    address.Line1,
                    address.Line2,
                    address.City,
                    address.State,
                    address.PostalCode,
                    address.CountryCode
                    );
            }


            if (payment.Processable)
            {
                var paymentViewController = new PayPalPaymentViewController(payment, _payPalConfig, this);
                var top = GetTopViewController(UIApplication.SharedApplication.KeyWindow);
                top.PresentViewController(paymentViewController, true, null);
            }
            else
            {
                OnError?.Invoke("This particular payment will always be processable. If, for example, the amount was negative or the shortDescription was empty, this payment wouldn't be processable, and you'd want to handle that here.");
                OnError = null;
                Debug.WriteLine("Payment not processalbe:" + payment.Items);
            }
        }
        partial void actPay(NSObject sender)
        {
            // Remove our last completed payment, just for demo purposes.
            this.CompletedPayment = null;

            var payment = new PayPalPayment()
            {
                Amount           = new NSDecimalNumber("9.95"),
                CurrencyCode     = "USD",
                ShortDescription = "Hipster t-shirt"
            };

            if (!payment.Processable)
            {
                // This particular payment will always be processable. If, for
                // example, the amount was negative or the shortDescription was
                // empty, this payment wouldn't be processable, and you'd want
                // to handle that here.
            }

            // Any customer identifier that you have will work here. Do NOT use a device- or
            // hardware-based identifier.
            string customerId = "user-11723";

            // Set the environment:
            // - For live charges, use PayPalEnvironmentProduction (default).
            // - To use the PayPal sandbox, use PayPalEnvironmentSandbox.
            // - For testing, use PayPalEnvironmentNoNetwork.
            PayPalPaymentViewController.Environment = this.Environment;
            samplePayPalPaymentDelegate             = new SamplePayPalPaymentDelegate(this);

            paymentViewController = new PayPalPaymentViewController(kPayPalClientId,
                                                                    kPayPalReceiverEmail,
                                                                    customerId,
                                                                    payment,
                                                                    samplePayPalPaymentDelegate);

            if (paymentViewController.Handle == IntPtr.Zero)
            {
                Debug.WriteLine("Failed to create PayPalPaymentViewController.");
                return;
            }

            paymentViewController.HideCreditCardButton = !this.AcceptCreditCards;

            // Setting the languageOrLocale property is optional.
            //
            // If you do not set languageOrLocale, then the PayPalPaymentViewController will present
            // its user interface according to the device's current language setting.
            //
            // Setting languageOrLocale to a particular language (e.g., @"es" for Spanish) or
            // locale (e.g., @"es_MX" for Mexican Spanish) forces the PayPalPaymentViewController
            // to use that language/locale.
            //
            // For full details, including a list of available languages and locales, see PayPalPaymentViewController.h.
            paymentViewController.LanguageOrLocale = "en";

            this.PresentViewController(paymentViewController, true, null);
        }
 public override void PayPalPaymentDidCancel(PayPalPaymentViewController paymentViewController)
 {
     //throw new NotImplementedException ();
     Debug.WriteLine("PayPal Payment Cancelled");
     ResultText = "";
     //successView.hidden = true
     paymentViewController?.DismissViewController(true, null);
 }
示例#6
0
		public override void PayPalPaymentDidCancel (PayPalPaymentViewController paymentViewController)
		{
			//throw new NotImplementedException ();
			Debug.WriteLine("PayPal Payment Cancelled");
			ResultText = "";
			//successView.hidden = true
			paymentViewController?.DismissViewController(true, null);
		}
 public override void PayPalPaymentViewController(PayPalPaymentViewController paymentViewController, PayPalPayment completedPayment)
 {
     //throw new NotImplementedException ();
     Debug.WriteLine("PayPal Payment Success !");
     paymentViewController.DismissViewController(true, () => {
         // send completed confirmaion to your server
         Debug.WriteLine("Here is your proof of payment:" + completedPayment.Confirmation + "Send this to your server for confirmation and fulfillment.");
         ResultText = completedPayment.Description;
     });
 }
示例#8
0
		public override void PayPalPaymentViewController (PayPalPaymentViewController paymentViewController, PayPalPayment completedPayment)
		{
			//throw new NotImplementedException ();
			Debug.WriteLine("PayPal Payment Success !");
			paymentViewController.DismissViewController (true, () => {
				// send completed confirmaion to your server
				Debug.WriteLine ("Here is your proof of payment:" + completedPayment.Confirmation + "Send this to your server for confirmation and fulfillment.");
				ResultText = completedPayment.Description;
			});
		}
示例#9
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var config = new PayPalConfiguration()
            {
                AcceptCreditCards        = true,
                LanguageOrLocale         = "en",
                MerchantName             = "Merchant",
                MerchantPrivacyPolicyURL = new NSUrl("https://www.paypal.com/webapps/mpp/ua/privacy-full"),
                MerchantUserAgreementURL = new NSUrl("https://www.paypal.com/webapps/mpp/ua/useragreement-full")
            };

            var item1 = new PayPalItem()
            {
                Name     = "DoofesDing",
                Price    = new NSDecimalNumber("10.00"),
                Currency = "EUR",
                Quantity = 1,
                Sku      = "FOO-29376"
            };

            var item2 = new PayPalItem()
            {
                Name     = "DoofesDing2",
                Price    = new NSDecimalNumber("15.00"),
                Currency = "EUR",
                Quantity = 1,
                Sku      = "FOO-23476"
            };

            var items = new PayPalItem[] { item1, item2 };

            var payment = new PayPalPayment()
            {
                Amount           = new NSDecimalNumber("25.00"),
                CurrencyCode     = "EUR",
                ShortDescription = "Stuffz",
                Items            = items
            };

            myDelegate = new PPDelegate(this);

            paypalVC = new PayPalPaymentViewController(payment, config, myDelegate);

            var payBtn = new UIButton(new RectangleF(60, 100, 200, 60));

            payBtn.SetTitle("Pay", UIControlState.Normal);
            payBtn.BackgroundColor = UIColor.Blue;
            payBtn.TouchUpInside  += (object sender, EventArgs e) => {
                this.PresentViewController(paypalVC, true, null);
            };
            Add(payBtn);
        }
示例#10
0
        public static void Buy(CompletionHandler callback)
        {
            Prepare();

            var payment = GetPayment();

            var paypal = new PayPalPaymentViewController(payment, Config, new PaypalDelegate(callback));

            var fixDel = paypal.PaymentDelegate;

            AppTools.RootNavigationController.PresentViewController(paypal, true, null);
        }
        public void BuySomething()
        {
            // Remove our last completed payment, just for demo purposes.
            ResultText = "";

            // Note: For purposes of illustration, this example shows a payment that includes
            //       both payment details (subtotal, shipping, tax) and multiple items.
            //       You would only specify these if appropriate to your situation.
            //       Otherwise, you can leave payment.items and/or payment.paymentDetails nil,
            //       and simply set payment.amount to your total charge.

            // Optional: include multiple items
            var item1 = PayPalItem.ItemWithName("Old jeans with holes", 2, new  NSDecimalNumber("84.99"), "USD", "Hip-0037");
            var item2 = PayPalItem.ItemWithName("Free rainbow patch", 1, new NSDecimalNumber("0.00"), "USD", "Hip-00066");
            var item3 = PayPalItem.ItemWithName("Long-sleeve plaid shirt (mustache not included)", 1, new NSDecimalNumber("37.99"), "USD", "Hip-00291");

            var items = new PayPalItem[] {
                item1, item2, item3
            };
            var subtotal = PayPalItem.TotalPriceForItems(items);

            // Optional: include payment details
            var shipping       = new NSDecimalNumber("5.99");
            var tax            = new NSDecimalNumber("2.50");
            var paymentDetails = PayPalPaymentDetails.PaymentDetailsWithSubtotal(subtotal, shipping, tax);

            var total = subtotal.Add(shipping).Add(tax);

            var payment = PayPalPayment.PaymentWithAmount(total, "USD", "Hipster Clothing", PayPalPaymentIntent.Sale);

            payment.Items          = items;
            payment.PaymentDetails = paymentDetails;
            if (payment.Processable)
            {
                var paymentViewController = new PayPalPaymentViewController(payment, _payPalConfig, this);
                var top = GetTopViewController(UIApplication.SharedApplication.KeyWindow);
                top.PresentViewController(paymentViewController, true, null);
            }
            else
            {
                // This particular payment will always be processable. If, for
                // example, the amount was negative or the shortDescription was
                // empty, this payment wouldn't be processable, and you'd want
                // to handle that here.
                Debug.WriteLine("Payment not processalbe:" + payment.Items);
            }
        }
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            UIEdgeInsets insets                        = new UIEdgeInsets(0, 15f, 0, 14f);
            UIImage      payBackgroundImage            = UIImage.FromBundle("button_secondary.png").CreateResizableImage(insets);
            UIImage      payBackgroundImageHighlighted = UIImage.FromBundle("button_secondary_selected.png").CreateResizableImage(insets);

            this.payButton.SetBackgroundImage(payBackgroundImage, UIControlState.Normal);
            this.payButton.SetBackgroundImage(payBackgroundImageHighlighted, UIControlState.Highlighted);
            this.payButton.SetTitleColor(UIColor.DarkGray, UIControlState.Normal);
            this.payButton.SetTitleColor(UIColor.DarkGray, UIControlState.Highlighted);

            // Optimization: Prepare for display of the payment UI by getting network work done early
            PayPalPaymentViewController.Environment = this.Environment;
            PayPalPaymentViewController.PrepareForPaymentUsingClientId(kPayPalClientId);
        }
示例#13
0
        public override void PayPalPaymentViewController(PayPalPaymentViewController paymentViewController, PayPalPayment completedPayment)
        {
            Debug.WriteLine("PayPal Payment Success !");
            paymentViewController.DismissViewController(true, () =>
            {
                NSError err     = null;
                NSData jsonData = NSJsonSerialization.Serialize(completedPayment.Confirmation, NSJsonWritingOptions.PrettyPrinted, out err);
                NSString first  = new NSString("");
                if (err == null)
                {
                    first = new NSString(jsonData, NSStringEncoding.UTF8);
                }
                else
                {
                    Debug.WriteLine(err.LocalizedDescription);
                }

                OnSuccess?.Invoke(first.ToString());
                OnSuccess = null;
            });
        }
示例#14
0
        private void BuyAnItemClicked(object sender, EventArgs e)
        {
            // Any customer identifier that you have will work here. Do NOT use a device- or
            // hardware-based identifier.
            string customerId = "user-11723";

            var payment = new PayPalPayment () {
                Amount = new NSDecimalNumber("9.95"),
                CurrencyCode = "USD",
                ShortDescription = "Hipster t-shirt"
            };

            // Set the environment:
            // - For live charges, use PayPalEnvironmentProduction (default).
            // - To use the PayPal sandbox, use PayPalEnvironmentSandbox.
            // - For testing, use PayPalEnvironmentNoNetwork.
            if (AppConfig.Instance.Env == PaypalForXamarin.Environment.Mock) {
                PayPalPaymentViewController.Environment = PayPalPaymentDelegate.PayPalEnvironmentNoNetwork;
            } else if (AppConfig.Instance.Env == PaypalForXamarin.Environment.Production) {
                PayPalPaymentViewController.Environment = PayPalPaymentDelegate.PayPalEnvironmentProduction;
            } else if (AppConfig.Instance.Env == PaypalForXamarin.Environment.Sandbox) {
                PayPalPaymentViewController.Environment = PayPalPaymentDelegate.PayPalEnvironmentSandbox;
            }

            samplePayPalPaymentDelegate = new SamplePayPalPaymentDelegate (this);

            var paymentViewController = new PayPalPaymentViewController (AppConfig.kPayPalClientId,
                AppConfig.kPayPalReceiverEmail,
                customerId,
                payment,
                samplePayPalPaymentDelegate);

            if (paymentViewController.Handle == IntPtr.Zero) {
                Debug.WriteLine ("Failed to create PayPalPaymentViewController.");
                return;
            }

            // Setting the languageOrLocale property is optional.
            //
            // If you do not set languageOrLocale, then the PayPalPaymentViewController will present
            // its user interface according to the device's current language setting.
            //
            // Setting languageOrLocale to a particular language (e.g., @"es" for Spanish) or
            // locale (e.g., @"es_MX" for Mexican Spanish) forces the PayPalPaymentViewController
            // to use that language/locale.
            //
            // For full details, including a list of available languages and locales, see PayPalPaymentViewController.h.
            paymentViewController.LanguageOrLocale = "en";

            this.PresentViewController (paymentViewController, true, null);
        }
示例#15
0
		public void BuyItem(
			PayPal.Forms.Abstractions.PayPalItem item,
			Deveel.Math.BigDecimal xftax,
			Action onCancelled,
			Action<string> onSuccess,
			Action<string> onError
		){

			OnCancelled = onCancelled;
			OnSuccess = onSuccess;
			OnError = onError;

			NSDecimalNumber amount = new NSDecimalNumber (DoFormat (item.Price.ToDouble ())).Add (new NSDecimalNumber (DoFormat (xftax.ToDouble ())));

			var paymentDetails = PayPalPaymentDetails.PaymentDetailsWithSubtotal (amount, new NSDecimalNumber(0), new NSDecimalNumber (xftax.ToString ()));

			var payment = PayPalPayment.PaymentWithAmount (amount, item.Currency, item.Name, PayPalPaymentIntent.Sale);
			payment.PaymentDetails = paymentDetails;
			payment.Items = new NSObject[]{
				PayPalItem.ItemWithName (
					item.Name,
					1,
					new  NSDecimalNumber (item.Price.ToString ()),
					item.Currency,
					item.SKU
				)
			};
			if (payment.Processable) {
				var paymentViewController = new PayPalPaymentViewController(payment, _payPalConfig, this);
				var top = GetTopViewController (UIApplication.SharedApplication.KeyWindow);
				top.PresentViewController (paymentViewController, true, null);
			}else {
				OnError?.Invoke ("This particular payment will always be processable. If, for example, the amount was negative or the shortDescription was empty, this payment wouldn't be processable, and you'd want to handle that here.");
				OnError = null;
				Debug.WriteLine("Payment not processalbe:"+payment.Items);
			}
		}
示例#16
0
        public void BuyItems(
            PayPal.Forms.Abstractions.PayPalItem[] items,
            Decimal xfshipping,
            Decimal xftax,
            Action onCancelled,
            Action<string> onSuccess,
            Action<string> onError,
            PayPal.Forms.Abstractions.ShippingAddress address
        )
        {

            OnCancelled = onCancelled;
            OnSuccess = onSuccess;
            OnError = onError;

            List<PayPalItem> nativeItems = new List<PayPalItem>();
            foreach (var product in items)
            {
                nativeItems.Add(PayPalItem.ItemWithName(
                    product.Name,
                    (nuint)product.Quantity,
                    new NSDecimalNumber(RoundNumber((double)product.Price)),
                    product.Currency,
                    product.SKU)
                );
            }

            var subtotal = PayPalItem.TotalPriceForItems(nativeItems.ToArray());

            var shipping = new NSDecimalNumber(RoundNumber((double)xfshipping));
            var tax = new NSDecimalNumber(RoundNumber((double)xftax));
            var paymentDetails = PayPalPaymentDetails.PaymentDetailsWithSubtotal(subtotal, shipping, tax);

            var total = subtotal.Add(shipping).Add(tax);

            var payment = PayPalPayment.PaymentWithAmount(total, nativeItems.FirstOrDefault().Currency, "Multiple items", PayPalPaymentIntent.Sale);
            payment.Items = nativeItems.ToArray();
            payment.PaymentDetails = paymentDetails;

            if (address != null)
            {
                payment.ShippingAddress = PayPalShippingAddress.ShippingAddressWithRecipientName(
                    address.RecipientName,
                    address.Line1,
                    address.Line2,
                    address.City,
                    address.State,
                    address.PostalCode,
                    address.CountryCode
                );
            }

            if (payment.Processable)
            {
                var paymentViewController = new PayPalPaymentViewController(payment, _payPalConfig, this);
                var top = GetTopViewController(UIApplication.SharedApplication.KeyWindow);
                top.PresentViewController(paymentViewController, true, null);
            }
            else {
                OnError?.Invoke("This particular payment will always be processable. If, for example, the amount was negative or the shortDescription was empty, this payment wouldn't be processable, and you'd want to handle that here.");
                Debug.WriteLine("Payment not processalbe:" + payment.Items);
            }

        }
示例#17
0
		public void BuySomething()
		{
			// Remove our last completed payment, just for demo purposes.
			ResultText = "";

				// Note: For purposes of illustration, this example shows a payment that includes
				//       both payment details (subtotal, shipping, tax) and multiple items.
				//       You would only specify these if appropriate to your situation.
				//       Otherwise, you can leave payment.items and/or payment.paymentDetails nil,
				//       and simply set payment.amount to your total charge.

				// Optional: include multiple items
			var item1 = PayPalItem.ItemWithName("Old jeans with holes", 2, new  NSDecimalNumber("84.99"), "USD", "Hip-0037");
			var item2 = PayPalItem.ItemWithName ("Free rainbow patch", 1, new NSDecimalNumber ("0.00"), "USD", "Hip-00066");
			var item3 = PayPalItem.ItemWithName ("Long-sleeve plaid shirt (mustache not included)", 1, new NSDecimalNumber ("37.99"), "USD", "Hip-00291");

			var items = new PayPalItem[] {
				item1, item2, item3
			};
			var subtotal = PayPalItem.TotalPriceForItems (items);

				// Optional: include payment details
			var shipping = new NSDecimalNumber("5.99");
			var tax = new NSDecimalNumber ("2.50");
			var paymentDetails = PayPalPaymentDetails.PaymentDetailsWithSubtotal (subtotal, shipping, tax);

			var total = subtotal.Add (shipping).Add (tax);

			var payment = PayPalPayment.PaymentWithAmount (total, "USD", "Hipster Clothing", PayPalPaymentIntent.Sale);

			payment.Items = items;
			payment.PaymentDetails = paymentDetails;
			if (payment.Processable) {
				var paymentViewController = new PayPalPaymentViewController(payment, _payPalConfig, this);
				var top = GetTopViewController (UIApplication.SharedApplication.KeyWindow);
				top.PresentViewController (paymentViewController, true, null);
			}else {
					// This particular payment will always be processable. If, for
					// example, the amount was negative or the shortDescription was
					// empty, this payment wouldn't be processable, and you'd want
					// to handle that here.
				Debug.WriteLine("Payment not processalbe:"+payment.Items);
			}
		}
示例#18
0
 public override void PayPalPaymentViewController(PayPalPaymentViewController paymentViewController, PayPalPayment completedPayment)
 {
     paymentViewController.DismissViewController(true, () => _del?.Invoke(State.Succefull, completedPayment?.Confirmation));
 }
 public override void DidCancelPayment(PayPalPaymentViewController paymentViewController)
 {
     _hostViewController.PayPalPaymentDidCancel();
 }
示例#20
0
        public override void PayPalPaymentViewController(PayPalPaymentViewController paymentViewController, PayPalPayment completedPayment)
        {
            Debug.WriteLine("PayPal Payment Success !");
            paymentViewController.DismissViewController(true, () =>
            {
                NSError err = null;
                NSData jsonData = NSJsonSerialization.Serialize(completedPayment.Confirmation, NSJsonWritingOptions.PrettyPrinted, out err);
                NSString first = new NSString("");
                if (err == null)
                {
                    first = new NSString(jsonData, NSStringEncoding.UTF8);
                }
                else {
                    Debug.WriteLine(err.LocalizedDescription);
                }

                OnSuccess?.Invoke(first.ToString());
                OnSuccess = null;
            });
        }
示例#21
0
        public void BuyItems(
            PayPal.Forms.Abstractions.PayPalItem[] items,
            Decimal xfshipping,
            Decimal xftax,
            Action onCancelled,
            Action <string> onSuccess,
            Action <string> onError,
            PayPal.Forms.Abstractions.ShippingAddress address
            )
        {
            OnCancelled = onCancelled;
            OnSuccess   = onSuccess;
            OnError     = onError;

            List <PayPalItem> nativeItems = new List <PayPalItem>();

            foreach (var product in items)
            {
                nativeItems.Add(PayPalItem.ItemWithName(
                                    product.Name,
                                    (nuint)product.Quantity,
                                    new NSDecimalNumber(RoundNumber((double)product.Price)),
                                    product.Currency,
                                    product.SKU)
                                );
            }

            var subtotal = PayPalItem.TotalPriceForItems(nativeItems.ToArray());

            var shipping       = new NSDecimalNumber(RoundNumber((double)xfshipping));
            var tax            = new NSDecimalNumber(RoundNumber((double)xftax));
            var paymentDetails = PayPalPaymentDetails.PaymentDetailsWithSubtotal(subtotal, shipping, tax);

            var total = subtotal.Add(shipping).Add(tax);

            var payment = PayPalPayment.PaymentWithAmount(total, nativeItems.FirstOrDefault().Currency, "Multiple items", PayPalPaymentIntent.Sale);

            payment.Items          = nativeItems.ToArray();
            payment.PaymentDetails = paymentDetails;

            if (address != null)
            {
                payment.ShippingAddress = PayPalShippingAddress.ShippingAddressWithRecipientName(
                    address.RecipientName,
                    address.Line1,
                    address.Line2,
                    address.City,
                    address.State,
                    address.PostalCode,
                    address.CountryCode
                    );
            }

            if (payment.Processable)
            {
                var paymentViewController = new PayPalPaymentViewController(payment, _payPalConfig, this);
                var top = GetTopViewController(UIApplication.SharedApplication.KeyWindow);
                top.PresentViewController(paymentViewController, true, null);
            }
            else
            {
                OnError?.Invoke("This particular payment will always be processable. If, for example, the amount was negative or the shortDescription was empty, this payment wouldn't be processable, and you'd want to handle that here.");
                Debug.WriteLine("Payment not processalbe:" + payment.Items);
            }
        }
示例#22
0
 public override void PayPalPaymentDidCancel(PayPalPaymentViewController paymentViewController)
 {
     paymentViewController.DismissViewController(true, () => _del?.Invoke(State.UserCancel, null));
 }
		private void PresentPayment ()
		{
			var partNameForReal = string.Format ("{0} {1} {2} {3}", part.Year, part.Make, part.Model, part.PartName);

			var payment = new PayPalPayment () {
				Amount = new NSDecimalNumber (part.Price.ToString ()),
				CurrencyCode = "USD",
				Intent = PayPalPaymentIntent.Sale,
				ShortDescription = partNameForReal,
				Items = new NSObject[] { new PayPalItem { Currency = "USD", Name = partNameForReal, Price = new NSDecimalNumber (part.Price), Quantity = 1  } }
			} ;

			if (!payment.Processable) {
				var alert = new UIAlertView ("Error", "Could not create payment for this item.", null, "Okay", null);
				alert.Show ();
			}

			var paymentViewController = new PayPalPaymentViewController (payment, paymentConfiguration, paymentDelegate);
			PresentViewController (paymentViewController, true, null);
		}
		public override void PayPalPaymentDidCancel (PayPalPaymentViewController paymentViewController)
		{
			paymentViewController.DismissViewController (true, null);
		}
 public override void DidCompletePayment(PayPalPaymentViewController paymentViewController, PayPalPayment completedPayment)
 {
     _hostViewController.PayPalPaymentDidComplete(completedPayment);
 }
 public override void DidCancelPayment(PayPalPaymentViewController paymentViewController)
 {
     _hostViewController.PayPalPaymentDidCancel();
 }
示例#27
0
 public override void DidCancelPayment(PayPalPaymentViewController paymentViewController)
 {
     Debug.WriteLine("Payment Cancelled");
     parent.DismissViewController(true, null);
 }
示例#28
0
 public override void PayPalPaymentDidCancel(PayPalPaymentViewController paymentViewController)
 {
     Debug.WriteLine("PayPal Payment Cancelled");
     paymentViewController?.DismissViewController(true, null);
     OnCancelled?.Invoke();
     OnCancelled = null;
 }
示例#29
0
 public override void DidCompletePayment(PayPalPaymentViewController paymentViewController, PayPalPayment completedPayment)
 {
     Debug.WriteLine("Payment Completed");
     parent.DismissViewController(true, null);
 }
示例#30
0
        public void BuyItem(
            PayPal.Forms.Abstractions.PayPalItem item,
            Decimal xftax,
            Action onCancelled,
            Action<string> onSuccess,
            Action<string> onError,
            PayPal.Forms.Abstractions.ShippingAddress address
        )
        {

            OnCancelled = onCancelled;
            OnSuccess = onSuccess;
            OnError = onError;


            var subTotal = new NSDecimalNumber(RoundNumber((double)item.Price));
            NSDecimalNumber amount = subTotal.Add(new NSDecimalNumber(RoundNumber((double)xftax)));

            var paymentDetails = PayPalPaymentDetails.PaymentDetailsWithSubtotal(subTotal, new NSDecimalNumber(0), new NSDecimalNumber(RoundNumber((double)xftax)));

            var payment = PayPalPayment.PaymentWithAmount(amount, item.Currency, item.Name, PayPalPaymentIntent.Sale);
            payment.PaymentDetails = paymentDetails;
            payment.Items = new NSObject[]{
                PayPalItem.ItemWithName (
                    item.Name,
                    1,
                    new  NSDecimalNumber (RoundNumber((double)item.Price)),
                    item.Currency,
                    item.SKU
                )
            };

            if (address != null)
            {
                payment.ShippingAddress = PayPalShippingAddress.ShippingAddressWithRecipientName(
                    address.RecipientName,
                    address.Line1,
                    address.Line2,
                    address.City,
                    address.State,
                    address.PostalCode,
                    address.CountryCode
                );
            }


            if (payment.Processable)
            {
                var paymentViewController = new PayPalPaymentViewController(payment, _payPalConfig, this);
                var top = GetTopViewController(UIApplication.SharedApplication.KeyWindow);
                top.PresentViewController(paymentViewController, true, null);
            }
            else {
                OnError?.Invoke("This particular payment will always be processable. If, for example, the amount was negative or the shortDescription was empty, this payment wouldn't be processable, and you'd want to handle that here.");
                OnError = null;
                Debug.WriteLine("Payment not processalbe:" + payment.Items);
            }
        }
partial         void actPay(NSObject sender)
        {
            // Remove our last completed payment, just for demo purposes.
            this.CompletedPayment = null;

            var payment = new PayPalPayment () {
                Amount = new NSDecimalNumber("9.95"),
                CurrencyCode = "USD",
                ShortDescription = "Hipster t-shirt"
            };

            if (!payment.Processable) {
                // This particular payment will always be processable. If, for
                // example, the amount was negative or the shortDescription was
                // empty, this payment wouldn't be processable, and you'd want
                // to handle that here.
            }

            // Any customer identifier that you have will work here. Do NOT use a device- or
            // hardware-based identifier.
            string customerId = "user-11723";

            // Set the environment:
            // - For live charges, use PayPalEnvironmentProduction (default).
            // - To use the PayPal sandbox, use PayPalEnvironmentSandbox.
            // - For testing, use PayPalEnvironmentNoNetwork.
            PayPalPaymentViewController.Environment = this.Environment;
            samplePayPalPaymentDelegate = new SamplePayPalPaymentDelegate (this);

            paymentViewController = new PayPalPaymentViewController (kPayPalClientId,
                                                                    kPayPalReceiverEmail,
                                                                    customerId,
                                                                    payment,
                                                                    samplePayPalPaymentDelegate);

            if (paymentViewController.Handle == IntPtr.Zero) {
                Debug.WriteLine ("Failed to create PayPalPaymentViewController.");
                return;
            }

            paymentViewController.HideCreditCardButton = !this.AcceptCreditCards;

            // Setting the languageOrLocale property is optional.
            //
            // If you do not set languageOrLocale, then the PayPalPaymentViewController will present
            // its user interface according to the device's current language setting.
            //
            // Setting languageOrLocale to a particular language (e.g., @"es" for Spanish) or
            // locale (e.g., @"es_MX" for Mexican Spanish) forces the PayPalPaymentViewController
            // to use that language/locale.
            //
            // For full details, including a list of available languages and locales, see PayPalPaymentViewController.h.
            paymentViewController.LanguageOrLocale = "en";

            this.PresentViewController (paymentViewController, true, null);
        }
 public override void DidCompletePayment(PayPalPaymentViewController paymentViewController, PayPalPayment completedPayment)
 {
     _hostViewController.PayPalPaymentDidComplete(completedPayment);
 }
		public override void DidCompletePayment (PayPalPaymentViewController paymentViewController, PayPalPayment completedPayment)
		{
			VerifyCompletedPayment (completedPayment);

			paymentViewController.DismissViewController (true, null);
		}
partial         void actPay(NSObject sender)
        {
            // Remove our last completed payment, just for demo purposes.
            CompletedPayment = null;

            var payment = new PayPalPayment
            {
                Amount = new NSDecimalNumber("9.95"),
                CurrencyCode = "USD",
                ShortDescription = "Hipster t-shirt",
                Intent = PayPalPaymentIntent.Sale
            };

            if (!payment.Processable) {
                // This particular payment will always be processable. If, for
                // example, the amount was negative or the shortDescription was
                // empty, this payment wouldn't be processable, and you'd want
                // to handle that here.
            }

            _payPalConfig.AcceptCreditCards = AcceptCreditCards;

            _samplePayPalPaymentDelegate = new SamplePayPalPaymentDelegate(this);
            _paymentViewController = new PayPalPaymentViewController(payment, _payPalConfig, _samplePayPalPaymentDelegate);

            if (_paymentViewController.Handle == IntPtr.Zero) {
                Debug.WriteLine ("Failed to create PayPalPaymentViewController.");
                return;
            }

            PresentViewController (_paymentViewController, true, null);
        }