private ApplePayViewModel GetApplePayViewModel(BeerPaymentViewModel beerPaymentModel)
        {
               
            var summaryItems = new List <PKPaymentSummaryItem> ();

            foreach (KeyValuePair <BeerItem, int> item in beerPaymentModel.BeerBasket.ToList())
            {
                var summary = new  PKPaymentSummaryItem()
                {
                                        Amount = new NSDecimalNumber(item.Key.Price),
                                        Label  = item.Key.Name + @" X" + item.Value.ToString()
                };
                summaryItems.Add(summary);
            }
                       
            var applePayment = new ApplePayViewModel {
                                CurrencyCode      = new NSString("GBP"),
                                CountryCode       = new NSString(@"GB"),
                                SupportedNetworks = new NSString[3] {
                                        new NSString("Visa"),
                                        new NSString("MasterCard"),
                                        new NSString("Amex")
                },
                                SummaryItems     = summaryItems.ToArray(),
                                TotalSummaryItem = new PKPaymentSummaryItem()
                {
                                        Amount = new NSDecimalNumber(beerPaymentModel.GetSubTotal().ToString()),
                                        Label  = @"Beer Drinkin"
                },
                                ConsumerRef        = new NSString(@"ImHereForTheBeer"),
                                MerchantIdentifier = new NSString("merchant.com.micjames.beerdrinkin")
            };
                       
            return(applePayment);
        }
        public void ApplePayment(ApplePayViewModel viewModel, JudoSuccessCallback success, JudoFailureCallback failure, ApplePaymentType type)
        {
            if (!_clientService.ApplePayAvailable)
            {
                failure(new JudoError {
                    ApiError = new JudoPayDotNet.Errors.JudoApiErrorModel {
                        ErrorMessage = "Apple Pay is not enabled on device, application entitlement or setup by user.",
                        ErrorType    = JudoApiError.General_Error,
                        ModelErrors  = null
                    }
                });
            }
            try {
                var vc = GetCurrentViewController();

                if (JudoSDKManager.UIMode && vc == null)
                {
                    var error = new JudoError {
                        Exception = new Exception("Navigation controller cannot be null with UIMode enabled.")
                    };
                    failure(error);
                }
                else
                {
                    _paymentService.MakeApplePayment(viewModel, success, failure, vc as UINavigationController, type);
                }
            } catch (Exception ex) {
                HandleFailure(failure, ex);
            }
        }
Exemple #3
0
        ApplePayViewModel GetApplePayViewModel()
        {
            var summaryItems = new PKPaymentSummaryItem[] {
                new PKPaymentSummaryItem()
                {
                    Amount = new NSDecimalNumber("0.90"),
                    Label  = @"Judo Burrito"
                },
                new PKPaymentSummaryItem()
                {
                    Amount = new NSDecimalNumber("0.10"),
                    Label  = @"Extra Guac"
                }
            };

            var applePayment = new ApplePayViewModel {
                CurrencyCode      = new NSString("GBP"),
                CountryCode       = new NSString(@"GB"),
                SupportedNetworks = new NSString[3] {
                    new NSString("Visa"),
                    new NSString("MasterCard"),
                    new NSString("Amex")
                },
                SummaryItems     = summaryItems,
                TotalSummaryItem = new PKPaymentSummaryItem()
                {
                    Amount = new NSDecimalNumber("1.00"),
                    Label  = @"El Judorito"
                },
                ConsumerRef        = new NSString(@"GenerateYourOwnCustomerRefHere"),
                MerchantIdentifier = new NSString("merchant.com.judo.Xamarin")
            };

            return(applePayment);
        }
Exemple #4
0
        public void MakeApplePayment(ApplePayViewModel payment, JudoSuccessCallback success, JudoFailureCallback failure, UINavigationController controller, ApplePaymentType type)
        {
            try {
                PKPaymentRequest request = new PKPaymentRequest();

                request.CurrencyCode = payment.CurrencyCode;

                request.CountryCode = payment.CountryCode;

                request.MerchantCapabilities = (PKMerchantCapability)payment.MerchantCapabilities;


                request.SupportedNetworks = payment.SupportedNetworks;


                request.PaymentSummaryItems = payment.Basket;

                request.MerchantIdentifier = payment.MerchantIdentifier;// @"merchant.com.judo.Xamarin"; // do it with configuration/overwrite

                var pkDelegate = new JudoPKPaymentAuthorizationViewControllerDelegate(this, request, payment.ConsumerRef.ToString(), type, success, failure);



                PKPaymentAuthorizationViewController pkController = new PKPaymentAuthorizationViewController(request)
                {
                    Delegate = pkDelegate
                };
                controller.PresentViewController(pkController, true, null);
            } catch (Exception e) {
                Console.WriteLine(e.InnerException.ToString());

                var judoError = new JudoError()
                {
                    Exception = e
                };
                failure(judoError);
            }
        }
        ApplePayViewModel GetApplePayViewModel ()
        {
            var summaryItems = new PKPaymentSummaryItem[] {
                new PKPaymentSummaryItem () {
                    Amount = new NSDecimalNumber ("0.90"),
                    Label = @"Judo Burrito"

                },
                new PKPaymentSummaryItem () {
                    Amount = new NSDecimalNumber ("0.10"),
                    Label = @"Extra Guac"

                }
            };
			
            var applePayment = new ApplePayViewModel {
				
                CurrencyCode = new NSString ("GBP"),
                CountryCode = new NSString (@"GB"),
                SupportedNetworks = new NSString[3] {
                    new NSString ("Visa"),
                    new NSString ("MasterCard"),
                    new NSString ("Amex")
                },
                SummaryItems = summaryItems,
                TotalSummaryItem = new PKPaymentSummaryItem () {
                    Amount = new NSDecimalNumber ("1.00"),
                    Label = @"El Judorito"

                },
                ConsumerRef = new NSString (@"GenerateYourOwnCustomerRefHere"),
                MerchantIdentifier = new NSString ("merchant.com.judo.Xamarin")
            };
            return applePayment;
        }
        public void MakeApplePreAuth(ApplePayViewModel payment, JudoSuccessCallback success, JudoFailureCallback failure)
        {
            RootCheck(failure);

            _applePayMethods.ApplePayment(payment, success, failure, ApplePaymentType.PreAuth);
        }
        private ApplePayViewModel GetApplePayViewModel (BeerPaymentViewModel beerPaymentModel)
        {
               
            var summaryItems = new List<PKPaymentSummaryItem> ();

            foreach (KeyValuePair<BeerItem,int> item in beerPaymentModel.BeerBasket.ToList()) {
                var summary = new  PKPaymentSummaryItem () {
                                        Amount = new NSDecimalNumber (item.Key.Price),
                                        Label = item.Key.Name + @" X" + item.Value.ToString ()

                };
                summaryItems.Add (summary);
            }
                       
            var applePayment = new ApplePayViewModel {

                                CurrencyCode = new NSString ("GBP"),
                                CountryCode = new NSString (@"GB"),
                                SupportedNetworks = new NSString[3] {
                                        new NSString ("Visa"),
                                        new NSString ("MasterCard"),
                                        new NSString ("Amex")
                },
                                SummaryItems = summaryItems.ToArray (),
                                TotalSummaryItem = new PKPaymentSummaryItem () {
                                        Amount = new NSDecimalNumber (beerPaymentModel.GetSubTotal ().ToString ()),
                                        Label = @"Beer Drinkin"

                },
                                ConsumerRef = new NSString (@"ImHereForTheBeer"),
                                MerchantIdentifier = new NSString ("merchant.com.micjames.beerdrinkin")
            };
                       
            return applePayment;
        }