public async Task <string> TokenizeCard(string panNumber = "4111111111111111", string expirationMonth = "12", string expirationYear = "2018", string cvv = null)
        {
            payTcs = new TaskCompletionSource <string>();
            if (CanPay)
            {
                var cardClient = new BTCardClient(apiClient: braintreeClient);
                var card       = new BTCard(panNumber, expirationMonth, expirationYear, cvv);

                cardClient.TokenizeCard(card, (BTCardNonce tokenizedCard, Foundation.NSError error) =>
                {
                    if (error == null)
                    {
                        OnTokenizationSuccessful?.Invoke(this, tokenizedCard.Nonce);
                        payTcs.TrySetResult(tokenizedCard.Nonce);
                    }
                    else
                    {
                        OnTokenizationError?.Invoke(this, error.Description);
                        payTcs.TrySetException(new Exception(error.Description));
                    }
                });
            }
            else
            {
                OnTokenizationError?.Invoke(this, "Platform is not ready to accept payments");
                payTcs.TrySetException(new Exception("Platform is not ready to accept payments"));
            }

            return(await payTcs.Task);
        }
        public override void GetNoncenBrainTree(BrainTreeCard brainTreeCard, Action <object> action)
        {
            BTAPIClient  BTAPIClient  = new BTAPIClient(brainTreeCard.Token);
            BTCardClient BTCardClient = new BTCardClient(BTAPIClient);
            BTCard       BTCard       = new BTCard();

            BTCard.Number          = brainTreeCard.CardNumber;
            BTCard.Cvv             = brainTreeCard.Cvv;
            BTCard.PostalCode      = brainTreeCard.PostalCode;
            BTCard.ExpirationYear  = brainTreeCard.ExpirationDate.ToString("yyyy");
            BTCard.ExpirationMonth = brainTreeCard.ExpirationDate.ToString("MM");
            BTCard.ShouldValidate  = false;

            BTCardClient.TokenizeCard(BTCard, (arg1, arg2) =>
            {
                if (arg1 != null && !string.IsNullOrEmpty(arg1.Nonce))
                {
                    if (action != null)
                    {
                        action(arg1.Nonce);
                    }
                }
                else
                {
                    if (action != null)
                    {
                        action(new Exception(arg2.LocalizedFailureReason + "\n" + arg2.LocalizedDescription));
                    }
                }
            });
        }
		public Task<BTPaymentMethodNonce> TokenizeCardAsync(BTCard card)
		{
			var tcs = new TaskCompletionSource<BTPaymentMethodNonce>();

			TokenizeCard(card, (nonce, error) =>
				{
					if(error != null)
					{
						var exception = new NSErrorException(error);

						tcs.TrySetException(exception);
					}

					tcs.TrySetResult((BTPaymentMethodNonce)nonce);
				});
			return tcs.Task;
		}
Esempio n. 4
0
        public Task <BTPaymentMethodNonce> TokenizeCardAsync(BTCard card)
        {
            var tcs = new TaskCompletionSource <BTPaymentMethodNonce>();

            TokenizeCard(card, (nonce, error) =>
            {
                if (error != null)
                {
                    var exception = new NSErrorException(error);

                    tcs.TrySetException(exception);
                }

                tcs.TrySetResult((BTPaymentMethodNonce)nonce);
            });
            return(tcs.Task);
        }
Esempio n. 5
0
        public static bool IsCardPartOfStrongerHand(this List <BTCard> cards, BTCard BTCard)
        {
            if (!cards.Contains(BTCard))
            {
                throw new ArgumentOutOfRangeException("We don't have a " + BTCard.GetCardName());
            }

            // check if it's part of a pair, this return true for trips and quads as well.
            var isAtleastPair = cards.GetSameValuedCards(BTPokerHands.Double)
                                .Any(g => g
                                     .Any(c => c.Value == BTCard.Value)
                                     );


            // todo: check if it's part of a poker hand


            // not part of stronger hand.
            return(isAtleastPair);
        }
Esempio n. 6
0
 // Player Extensions
 public static string GetName(this BTCard c)
 {
     return(c.GetCardName());
 }
Esempio n. 7
0
 public static string Selected(this BTCard card)
 {
     return($"✔️ {card.GetCardName()}");
 }