Exemplo n.º 1
0
        private void CheckoutWithApplePay(object sender, EventArgs e)
        {
            var request = GetPaymentRequest();

            applePayHelper = new BUYApplePayHelpers(client, checkout, shop);

            var paymentController = new PKPaymentAuthorizationViewController(request);

            // Add additional methods if needed and forward the callback to BUYApplePayHelpers
            paymentController.DidAuthorizePayment += (_, args) => {
                applePayHelper.DidAuthorizePayment(paymentController, args.Payment, args.Completion);

                checkout = applePayHelper.Checkout;
                GetCompletedCheckout(null);
            };
            paymentController.PaymentAuthorizationViewControllerDidFinish += (_, args) => {
                applePayHelper.PaymentAuthorizationViewControllerDidFinish(paymentController);
            };
            paymentController.DidSelectShippingAddress += (_, args) => {
                applePayHelper.DidSelectShippingAddress(paymentController, args.Address, args.Completion);
            };
            paymentController.DidSelectShippingContact += (_, args) => {
                applePayHelper.DidSelectShippingContact(paymentController, args.Contact, args.Completion);
            };
            paymentController.DidSelectShippingMethod += (_, args) => {
                applePayHelper.DidSelectShippingMethod(paymentController, args.ShippingMethod, args.Completion);
            };

            /**
             *
             *  Alternatively we can set the delegate to applePayHelper.
             *
             *  If you do not care about any IPKPaymentAuthorizationViewControllerDelegate callbacks
             *  uncomment the code below to let BUYApplePayHelpers take care of them automatically.
             *  You can then also safely remove the IPKPaymentAuthorizationViewControllerDelegate
             *  events above.
             *
             *  // paymentController.Delegate = applePayHelper;
             *
             *  If you keep the events as the delegate, you have a chance to intercept the
             *  IPKPaymentAuthorizationViewControllerDelegate callbacks and add any additional logging
             *  and method calls as you need. Ensure that you forward them to the BUYApplePayHelpers
             *  class by calling the delegate methods on BUYApplePayHelpers which already implements
             *  the IPKPaymentAuthorizationViewControllerDelegate interface.
             *
             */

            PresentViewController(paymentController, true, null);
        }
        private void CheckoutWithApplePay(object sender, EventArgs e)
        {
            var request = GetPaymentRequest ();

            applePayHelper = new BUYApplePayHelpers (client, checkout, shop);

            var paymentController = new PKPaymentAuthorizationViewController (request);

            // Add additional methods if needed and forward the callback to BUYApplePayHelpers
            paymentController.DidAuthorizePayment += (_, args) => {
                applePayHelper.DidAuthorizePayment (paymentController, args.Payment, args.Completion);

                checkout = applePayHelper.Checkout;
                GetCompletedCheckout (null);
            };
            paymentController.PaymentAuthorizationViewControllerDidFinish += (_, args) => {
                applePayHelper.PaymentAuthorizationViewControllerDidFinish (paymentController);
            };
            paymentController.DidSelectShippingAddress += (_, args) => {
                applePayHelper.DidSelectShippingAddress (paymentController, args.Address, args.Completion);
            };
            paymentController.DidSelectShippingContact += (_, args) => {
                applePayHelper.DidSelectShippingContact (paymentController, args.Contact, args.Completion);
            };
            paymentController.DidSelectShippingMethod += (_, args) => {
                applePayHelper.DidSelectShippingMethod (paymentController, args.ShippingMethod, args.Completion);
            };

            /**
             *
             *  Alternatively we can set the delegate to applePayHelper.
             *
             *  If you do not care about any IPKPaymentAuthorizationViewControllerDelegate callbacks
             *  uncomment the code below to let BUYApplePayHelpers take care of them automatically.
             *  You can then also safely remove the IPKPaymentAuthorizationViewControllerDelegate
             *  events above.
             *
             *  // paymentController.Delegate = applePayHelper;
             *
             *  If you keep the events as the delegate, you have a chance to intercept the
             *  IPKPaymentAuthorizationViewControllerDelegate callbacks and add any additional logging
             *  and method calls as you need. Ensure that you forward them to the BUYApplePayHelpers
             *  class by calling the delegate methods on BUYApplePayHelpers which already implements
             *  the IPKPaymentAuthorizationViewControllerDelegate interface.
             *
             */

            PresentViewController (paymentController, true, null);
        }