public static bool TestClient(BraintreeServerSettings settings, BraintreeClientSettings braintreeClientSettings)
        {
            var client = GetBraintreeGateway(settings);

            var dummyCreditCard = new TestCreditCards(TestCreditCards.TestCreditCardSetting.Braintree).Visa;

            var braintreeEncrypter = new BraintreeEncrypter(braintreeClientSettings.ClientKey);

            return(TokenizedCreditCard(client, braintreeEncrypter.Encrypt(dummyCreditCard.Number),
                                       braintreeEncrypter.Encrypt(dummyCreditCard.ExpirationDate.ToString("MM/yyyy", CultureInfo.InvariantCulture)),
                                       braintreeEncrypter.Encrypt(dummyCreditCard.AvcCvvCvv2 + "")
                                       ).IsSuccessful);
        }
Exemplo n.º 2
0
        private static BraintreeGateway GetBraintreeGateway(BraintreeServerSettings settings)
        {
            var env = Environment.SANDBOX;

            if (!settings.IsSandbox)
            {
                env = Environment.PRODUCTION;
            }

            return(new BraintreeGateway
            {
                Environment = env,
                MerchantId = settings.MerchantId,
                PublicKey = settings.PublicKey,
                PrivateKey = settings.PrivateKey
            });
        }