public void BuyBeer(BeerPaymentViewModel beerPaymentModel) { PaymentViewModel judoModel = new PaymentViewModel() { Amount = beerPaymentModel.GetSubTotal(), Currency = "GBP", ConsumerReference = "ImHereForTheBeer01", Card = new CardViewModel() }; JudoSuccessCallback successCallback = SuccessPayment; JudoFailureCallback failureCallback = FailurePayment; if (String.IsNullOrEmpty(Client.Instance.PaymentToken.CardToken)) { Judo.Instance.Payment(judoModel, successCallback, failureCallback); } else { TokenPaymentViewModel tokenModel = new TokenPaymentViewModel() { Amount = beerPaymentModel.GetSubTotal(), Currency = "GBP", ConsumerReference = "ImHereForTheBeer01", Token = Client.Instance.PaymentToken.CardToken, ConsumerToken = Client.Instance.PaymentToken.ConsumerToken, LastFour = Client.Instance.PaymentToken.CardLastfour, CardType = (CardType)Client.Instance.PaymentToken.CardType }; Judo.Instance.TokenPayment(tokenModel, successCallback, failureCallback); } }
public void BuyBeer (BeerPaymentViewModel beerPaymentModel) { PaymentViewModel judoModel = new PaymentViewModel () { Amount = beerPaymentModel.GetSubTotal (), Currency = "GBP", ConsumerReference = "ImHereForTheBeer01", Card = new CardViewModel () }; JudoSuccessCallback successCallback = SuccessPayment; JudoFailureCallback failureCallback = FailurePayment; if (String.IsNullOrEmpty (Client.Instance.PaymentToken.CardToken)) { Judo.Instance.Payment (judoModel, successCallback, failureCallback); } else { TokenPaymentViewModel tokenModel = new TokenPaymentViewModel () { Amount = beerPaymentModel.GetSubTotal (), Currency = "GBP", ConsumerReference = "ImHereForTheBeer01", Token = Client.Instance.PaymentToken.CardToken, ConsumerToken = Client.Instance.PaymentToken.ConsumerToken, LastFour = Client.Instance.PaymentToken.CardLastfour, CardType = (CardType)Client.Instance.PaymentToken.CardType }; Judo.Instance.TokenPayment (tokenModel, successCallback, failureCallback); } }
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); }
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; }