Exemplo n.º 1
0
        public bool AuthorizePayment(string Amount)
        {
            if (!PKPaymentAuthorizationViewController.CanMakePayments)
            {
                ShowAuthorizationAlert();
            }

            if (!PKPaymentAuthorizationViewController.CanMakePaymentsUsingNetworks(supportedNetworks))
            {
                ShowAuthorizationAlert();
            }

            NSString[] paymentNetworks = new NSString[] { PKPaymentNetwork.Visa, PKPaymentNetwork.Discover,

                                                          PKPaymentNetwork.MasterCard, PKPaymentNetwork.Amex };
            var merchantID = "merchant.com.orem.grylloo";
            // Enter merchant ID registered in apple.developer.com

            PKPaymentRequest paymentRequest = new PKPaymentRequest();

            paymentRequest.MerchantIdentifier   = merchantID;
            paymentRequest.SupportedNetworks    = paymentNetworks;
            paymentRequest.MerchantCapabilities = PKMerchantCapability.ThreeDS;
            paymentRequest.CountryCode          = "US";
            paymentRequest.CurrencyCode         = "USD";

            paymentRequest.PaymentSummaryItems = new PKPaymentSummaryItem[] {
                new PKPaymentSummaryItem()
                {
                    Label  = "Payable Amount",
                    Amount = new NSDecimalNumber(Amount)
                }
            };
            Task.Delay(10000);
            PKPaymentAuthorizationViewController controller = new
                                                              PKPaymentAuthorizationViewController(paymentRequest);

            controller.Delegate = (PassKit.IPKPaymentAuthorizationViewControllerDelegate)Self;
            var rootController = UIApplication.SharedApplication.
                                 KeyWindow.RootViewController;

            rootController.PresentViewController(controller,
                                                 true, null);


            Task.Delay(50000);

            return(false);
        }
Exemplo n.º 2
0
        public async Task <bool> Show(XPayRequest request)
        {
            NSString[] paymentNetworks = new NSString[] { PKPaymentNetwork.MasterCard, PKPaymentNetwork.Visa };

            if (!PKPaymentAuthorizationViewController.CanMakePayments || !PKPaymentAuthorizationViewController.CanMakePaymentsUsingNetworks(paymentNetworks))
            {
                throw new NotSupportedException();
            }

            List <PKPaymentSummaryItem> items = new List <PKPaymentSummaryItem>();

            for (int i = 0; i < request.Items.Count; i++)
            {
                XPayRequestItem requestItem = request.Items[i];
                items.Add(PKPaymentSummaryItem.Create(requestItem.Label, new NSDecimalNumber(requestItem.Amount.ToString())));
            }

            // add the total PKPaymentSummaryItem by summing together all the amounts
            items.Add(PKPaymentSummaryItem.Create(request.PayTo ?? "Payee", new NSDecimalNumber(items.Sum(x => x.Amount.FloatValue).ToString())));

            PKPaymentRequest paymentRequest = new PKPaymentRequest();

            paymentRequest.PaymentSummaryItems  = items.ToArray();
            paymentRequest.MerchantIdentifier   = request.MerchantIdentifier;
            paymentRequest.MerchantCapabilities = PKMerchantCapability.ThreeDS;
            paymentRequest.CountryCode          = request.CountryCode;
            paymentRequest.CurrencyCode         = request.CurrencyCode;
            paymentRequest.SupportedNetworks    = paymentNetworks;

            this.paymentController          = new PKPaymentAuthorizationViewController(paymentRequest);
            this.paymentController.Delegate = this;

            UIWindow         window = UIApplication.SharedApplication.KeyWindow;
            UIViewController vc     = window.RootViewController;

            while (vc.PresentedViewController != null)
            {
                vc = vc.PresentedViewController;
            }

            await vc.PresentViewControllerAsync(this.paymentController, true);

            return(true);
        }
Exemplo n.º 3
0
        public void ApplyPayButtonClicked()
        {
            if (!PKPaymentAuthorizationViewController.CanMakePaymentsUsingNetworks(supportedNetworks))
            {
                ShowAuthorizationAlert();
                return;
            }

            // Set up our payment request.
            var paymentRequest = new PKPaymentRequest();

            // Our merchant identifier needs to match what we previously set up in
            // the Capabilities window (or the developer portal).
            paymentRequest.MerchantIdentifier = AppConfiguration.Merchant.Identififer;

            // Both country code and currency code are standard ISO formats. Country
            // should be the region you will process the payment in. Currency should
            // be the currency you would like to charge in.
            paymentRequest.CountryCode  = "US";
            paymentRequest.CurrencyCode = "USD";

            // The networks we are able to accept.
            paymentRequest.SupportedNetworks = supportedNetworks;

            // Ask your payment processor what settings are right for your app. In
            // most cases you will want to leave this set to ThreeDS.
            paymentRequest.MerchantCapabilities = PKMerchantCapability.ThreeDS;

            // An array of `PKPaymentSummaryItems` that we'd like to display on the
            // sheet (see the MakeSummaryItems method).
            paymentRequest.PaymentSummaryItems = MakeSummaryItems(false);

            // Request shipping information, in this case just postal address.
            paymentRequest.RequiredShippingAddressFields = PKAddressField.PostalAddress;

            // Display the view controller.
            var viewController = new PKPaymentAuthorizationViewController(paymentRequest);

            viewController.Delegate = this;
            PresentViewController(viewController, true, null);
        }
Exemplo n.º 4
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            ProductTitleLabel.Text      = Product.Name;
            ProductDescriptionView.Text = Product.Description;
            ProductPriceLabel.Text      = string.Format("${0}", Product.Price);

            // Display an Apple Pay button if a payment card is available. In your
            // app, you might divert the user to a more traditional checkout if
            // Apple Pay wasn't set up.

            if (PKPaymentAuthorizationViewController.CanMakePaymentsUsingNetworks(supportedNetworks))
            {
                var button = new PKPaymentButton(PKPaymentButtonType.Buy, PKPaymentButtonStyle.Black);
                button.TouchUpInside += ApplyPayButtonClicked;

                button.Center           = ApplePayView.Center;
                button.AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin;
                ApplePayView.AddSubview(button);
            }
        }
Exemplo n.º 5
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            ProductTitleLabel.Text      = "Donation";
            ProductDescriptionView.Text = "Thank you for donating to St. Mina Retreat Center!";
            ProductPriceLabel.Text      = string.Format("${0}", int.Parse(String.IsNullOrWhiteSpace(this.DonationAmount.Text) ? "10" : this.DonationAmount.Text));

            // Display an Apple Pay button if a payment card is available. In your
            // app, you might divert the user to a more traditional checkout if
            // Apple Pay wasn't set up.

            if (PKPaymentAuthorizationViewController.CanMakePaymentsUsingNetworks(supportedNetworks))
            {
                var button = new PKPaymentButton(PKPaymentButtonType.Buy, PKPaymentButtonStyle.Black);
                button.TouchUpInside += ApplyPayButtonClicked;

                button.Center           = ApplePayView.Center;
                button.AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin;
                ApplePayView.AddSubview(button);
            }
        }
Exemplo n.º 6
0
        partial void applePayPressed(UIButton sender)
        {
            if (!PKPaymentAuthorizationViewController.CanMakePaymentsUsingNetworks(supportedNetworks))
            {
                ShowAuthorizationAlert();
                return;
            }

            var paymentRequest = new PKPaymentRequest();

            paymentRequest.MerchantIdentifier   = "merchant.id.sample";
            paymentRequest.CountryCode          = "US";
            paymentRequest.CurrencyCode         = "USD";
            paymentRequest.MerchantCapabilities = PKMerchantCapability.ThreeDS;

            paymentRequest.PaymentSummaryItems = MakeSummaryItems();
            paymentRequest.SupportedNetworks   = supportedNetworks;

            var viewController = new PKPaymentAuthorizationViewController(paymentRequest);

            viewController.Delegate = this;
            PresentViewController(viewController, true, null);
        }
Exemplo n.º 7
0
 public bool GetIsSupported() => PKPaymentAuthorizationViewController.CanMakePaymentsUsingNetworks(supportedNetworks);