public TestServerPaymentSettingsResponse Post(TestMonerisSettingsRequest request) { var response = new TestServerPaymentSettingsResponse { IsSuccessful = false, Message = "Moneris Settings are invalid" }; try { var cc = new TestCreditCards(TestCreditCards.TestCreditCardSetting.Moneris).Visa; var result = MonerisServiceClient.TestClient(request.MonerisPaymentSettings, cc.Number, cc.ExpirationDate, _logger, cc.ZipCode); if (result) { return(new TestServerPaymentSettingsResponse { IsSuccessful = true, Message = "Moneris Settings are valid" }); } } catch (Exception e) { response.Message += "\n" + e.Message; } return(response); }
public async void RemoveCreditCard() { var client = GetFakePaymentClient(); var sut = new AccountServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null, client); const string creditCardComapny = "visa"; const string nameOnCard = "Bob"; var creditCardId = Guid.NewGuid(); const string last4Digits = "4025"; const string expirationMonth = "5"; const string expirationYear = "2020"; const string label = "Personal"; var cc = new TestCreditCards(TestCreditCards.TestCreditCardSetting.Cmt); var tokenResponse = await client.Tokenize(cc.Discover.Number, cc.Discover.NameOnCard, cc.Discover.ExpirationDate, cc.Discover.AvcCvvCvv2.ToString(), null, cc.Discover.ZipCode, TestAccount); await sut.AddCreditCard(new CreditCardRequest { CreditCardCompany = creditCardComapny, NameOnCard = nameOnCard, CreditCardId = creditCardId, Last4Digits = last4Digits, ExpirationMonth = expirationMonth, ExpirationYear = expirationYear, Token = tokenResponse.CardOnFileToken, Label = label }); await sut.RemoveCreditCard(creditCardId, tokenResponse.CardOnFileToken); var creditCards = await sut.GetCreditCards(); Assert.IsEmpty(creditCards); }
protected BasePaymentClientFixture(TestCreditCards.TestCreditCardSetting settings) { TestCreditCards = new TestCreditCards(settings); var connectionString = ConfigurationManager.ConnectionStrings["MKWebDev"].ConnectionString; ContextFactory = () => new BookingDbContext(connectionString); ConfigurationContextFactory = () => new ConfigurationDbContext(connectionString); }
private void RunPapiTest(CmtPaymentSettings settings) { var cc = new TestCreditCards(TestCreditCards.TestCreditCardSetting.Cmt).Visa; var result = CmtPaymentClient.TestClient(settings, cc.Number, cc.ExpirationDate, _logger); if (result) { return; } throw new Exception("Papi connection failed"); }
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); }
public async void UpdateCreditCard() { var client = GetFakePaymentClient(); var sut = new AccountServiceClient(BaseUrl, SessionId, new DummyPackageInfo(), null, null, client); var creditCardId = Guid.NewGuid(); const string last4Digits = "4025"; const string label = "Personal"; var cc = new TestCreditCards(TestCreditCards.TestCreditCardSetting.Cmt); var tokenResponse = await client.Tokenize(cc.Discover.Number, cc.Discover.NameOnCard, cc.Discover.ExpirationDate, cc.Discover.AvcCvvCvv2.ToString(), null, cc.Discover.ZipCode, TestAccount); await sut.AddCreditCard(new CreditCardRequest { CreditCardCompany = "Discover", NameOnCard = "Bob", CreditCardId = creditCardId, Last4Digits = last4Digits, ExpirationMonth = cc.Discover.ExpirationDate.Month.ToString(), ExpirationYear = cc.Discover.ExpirationDate.Year.ToString(), Token = tokenResponse.CardOnFileToken, Label = label }); var tokenResponse2 = await client.Tokenize(cc.AmericanExpress.Number, cc.AmericanExpress.NameOnCard, cc.AmericanExpress.ExpirationDate, cc.AmericanExpress.AvcCvvCvv2.ToString(), null, cc.AmericanExpress.ZipCode, TestAccount); await sut.UpdateCreditCard(new CreditCardRequest { CreditCardCompany = "AmericanExpress", NameOnCard = "Bob2", CreditCardId = creditCardId, Last4Digits = "1234", ExpirationMonth = cc.AmericanExpress.ExpirationDate.Month.ToString(), ExpirationYear = cc.AmericanExpress.ExpirationDate.Year.ToString(), Token = tokenResponse2.CardOnFileToken, Label = "Business" }); var creditCards = await AccountService.GetCreditCards(); var creditcard = creditCards.First(x => x.CreditCardId == creditCardId); Assert.NotNull(creditcard); Assert.AreEqual(_creditCardTestAccount.Id, creditcard.AccountId); Assert.AreEqual("AmericanExpress", creditcard.CreditCardCompany); Assert.AreEqual(creditCardId, creditcard.CreditCardId); Assert.AreEqual("1234", creditcard.Last4Digits); Assert.AreEqual(tokenResponse2.CardOnFileToken, creditcard.Token); Assert.AreEqual("Business", creditcard.Label.ToString()); }