PayPayiOSTest.PayPalManager.BuySomething C# (CSharp) Method

BuySomething() public method

public BuySomething ( ) : void
return void
		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);
			}
		}

Usage Example

 void BtnTest_TouchUpInside(object sender, EventArgs e)
 {
     MainManager.BuySomething();
 }