use of uk.gov.pay.connector.charge.model.CardDetailsEntity in project pay-connector by alphagov.
the class ChargeDaoCardDetailsIT method persist_shouldStoreNullCardTypeDetails.
@Test
public void persist_shouldStoreNullCardTypeDetails() {
GatewayAccountEntity testAccount = new GatewayAccountEntity(GatewayAccountType.TEST);
testAccount.setExternalId(randomUuid());
gatewayAccountDao.persist(testAccount);
GatewayAccountCredentialsEntity credentialsEntity = aGatewayAccountCredentialsEntity().withCredentials(Map.of("username", "theUsername", "password", "thePassword", "merchant_id", "theMerchantCode")).withGatewayAccountEntity(testAccount).withPaymentProvider(SANDBOX.getName()).withState(ACTIVE).withExternalId(randomUuid()).build();
gatewayAccountCredentialsDao.persist(credentialsEntity);
Address billingAddress = AddressFixture.anAddress().build();
ChargeEntity chargeEntity = ChargeEntityFixture.aValidChargeEntity().withGatewayAccountCredentialsEntity(credentialsEntity).build();
CardDetailsEntity cardDetailsEntity = new CardDetailsEntity(FirstDigitsCardNumber.of("123456"), LastDigitsCardNumber.of("1258"), "Mr. Pay Mc Payment", CardExpiryDate.valueOf("03/09"), "VISA", null, new AddressEntity(billingAddress));
chargeEntity.setCardDetails(cardDetailsEntity);
chargeDao.persist(chargeEntity);
Map<String, Object> cardDetailsSaved = databaseTestHelper.getChargeCardDetails(chargeEntity.getId());
assertThat(cardDetailsSaved, hasEntry("card_type", null));
}
use of uk.gov.pay.connector.charge.model.CardDetailsEntity in project pay-connector by alphagov.
the class ChargeDaoCardDetailsIT method findById_shouldFindCardDetails.
@Test
public void findById_shouldFindCardDetails() {
long chargeId = nextLong();
DatabaseFixtures.TestCardDetails testCardDetails = createCardDetailsForChargeWithId(chargeId);
Optional<ChargeEntity> chargeDaoOptional = chargeDao.findById(chargeId);
assertThat(chargeDaoOptional.isPresent(), is(true));
CardDetailsEntity cardDetailsEntity = chargeDaoOptional.get().getCardDetails();
assertThat(cardDetailsEntity.getCardHolderName(), is(testCardDetails.getCardHolderName()));
assertThat(cardDetailsEntity.getLastDigitsCardNumber(), is(testCardDetails.getLastDigitsCardNumber()));
assertThat(cardDetailsEntity.getFirstDigitsCardNumber(), is(testCardDetails.getFirstDigitsCardNumber()));
assertThat(cardDetailsEntity.getExpiryDate(), is(testCardDetails.getExpiryDate()));
assertThat(cardDetailsEntity.getBillingAddress().isPresent(), is(true));
assertThat(cardDetailsEntity.getBillingAddress().get().getLine1(), is(testCardDetails.getBillingAddress().getLine1()));
assertThat(cardDetailsEntity.getBillingAddress().get().getLine2(), is(testCardDetails.getBillingAddress().getLine2()));
assertThat(cardDetailsEntity.getBillingAddress().get().getPostcode(), is(testCardDetails.getBillingAddress().getPostcode()));
assertThat(cardDetailsEntity.getBillingAddress().get().getCity(), is(testCardDetails.getBillingAddress().getCity()));
assertThat(cardDetailsEntity.getBillingAddress().get().getCounty(), is(testCardDetails.getBillingAddress().getCounty()));
assertThat(cardDetailsEntity.getBillingAddress().get().getCountry(), is(testCardDetails.getBillingAddress().getCountry()));
}
use of uk.gov.pay.connector.charge.model.CardDetailsEntity in project pay-connector by alphagov.
the class ChargeDaoCardDetailsIT method persist_shouldStoreCardDetails.
@Test
public void persist_shouldStoreCardDetails() {
GatewayAccountEntity testAccount = new GatewayAccountEntity(GatewayAccountType.TEST);
testAccount.setExternalId(randomUuid());
gatewayAccountDao.persist(testAccount);
GatewayAccountCredentialsEntity credentialsEntity = aGatewayAccountCredentialsEntity().withCredentials(Map.of()).withGatewayAccountEntity(testAccount).withPaymentProvider(SANDBOX.getName()).withState(ACTIVE).build();
credentialsEntity.setExternalId(randomUuid());
gatewayAccountCredentialsDao.persist(credentialsEntity);
Address billingAddress = AddressFixture.anAddress().build();
ChargeEntity chargeEntity = ChargeEntityFixture.aValidChargeEntity().withGatewayAccountCredentialsEntity(credentialsEntity).build();
CardDetailsEntity cardDetailsEntity = new CardDetailsEntity(FirstDigitsCardNumber.of("123456"), LastDigitsCardNumber.of("1258"), "Mr. Pay Mc Payment", CardExpiryDate.valueOf("03/09"), "VISA", CardType.DEBIT, new AddressEntity(billingAddress));
chargeEntity.setCardDetails(cardDetailsEntity);
chargeDao.persist(chargeEntity);
Map<String, Object> cardDetailsSaved = databaseTestHelper.getChargeCardDetails(chargeEntity.getId());
assertThat(cardDetailsSaved, hasEntry("card_type", "DEBIT"));
}
use of uk.gov.pay.connector.charge.model.CardDetailsEntity in project pay-connector by alphagov.
the class CardServiceTest method createNewChargeWith.
protected ChargeEntity createNewChargeWith(Long chargeId, ChargeStatus status) {
ChargeEntity entity = ChargeEntityFixture.aValidChargeEntity().withId(chargeId).withStatus(status).withEvents(List.of(aChargeEventEntity().withChargeEntity(new ChargeEntity()).withStatus(ChargeStatus.CREATED).withUpdated(ZonedDateTime.now().minusHours(3)).build(), aChargeEventEntity().withChargeEntity(new ChargeEntity()).withStatus(ChargeStatus.AUTHORISATION_SUCCESS).withUpdated(ZonedDateTime.now()).build(), aChargeEventEntity().withChargeEntity(new ChargeEntity()).withStatus(ChargeStatus.ENTERING_CARD_DETAILS).withUpdated(ZonedDateTime.now().minusHours(2)).build(), aChargeEventEntity().withChargeEntity(new ChargeEntity()).withStatus(ChargeStatus.AUTHORISATION_TIMEOUT).withUpdated(ZonedDateTime.now().minusHours(1)).build(), aChargeEventEntity().withChargeEntity(new ChargeEntity()).withStatus(ChargeStatus.AUTHORISATION_ERROR).withUpdated(ZonedDateTime.now().minusHours(1)).build(), aChargeEventEntity().withChargeEntity(new ChargeEntity()).withStatus(ChargeStatus.AUTHORISATION_3DS_REQUIRED).withUpdated(ZonedDateTime.now().minusHours(1)).build(), aChargeEventEntity().withChargeEntity(new ChargeEntity()).withStatus(ChargeStatus.AUTHORISATION_CANCELLED).withUpdated(ZonedDateTime.now().minusHours(1)).build(), aChargeEventEntity().withChargeEntity(new ChargeEntity()).withStatus(ChargeStatus.AUTHORISATION_REJECTED).withUpdated(ZonedDateTime.now().minusHours(1)).build(), aChargeEventEntity().withChargeEntity(new ChargeEntity()).withStatus(ChargeStatus.AUTHORISATION_UNEXPECTED_ERROR).withUpdated(ZonedDateTime.now().minusHours(1)).build())).build();
entity.setCardDetails(new CardDetailsEntity());
return entity;
}
use of uk.gov.pay.connector.charge.model.CardDetailsEntity in project pay-connector by alphagov.
the class HistoricalEventEmitterServiceTest method setUp.
@Before
public void setUp() {
connectorConfiguration = new ConnectorConfiguration();
historicalEventEmitterService = new HistoricalEventEmitterService(chargeDao, refundDao, chargeEventDao, emittedEventDao, stateTransitionService, eventService, chargeService, connectorConfiguration);
CardDetailsEntity cardDetails = mock(CardDetailsEntity.class);
when(cardDetails.getLastDigitsCardNumber()).thenReturn(LastDigitsCardNumber.of("1234"));
chargeEntity = ChargeEntityFixture.aValidChargeEntity().withCardDetails(cardDetails).build();
ChargeEventEntity chargeEventEntity = ChargeEventEntityFixture.aValidChargeEventEntity().withTimestamp(ZonedDateTime.ofInstant(chargeEntity.getCreatedDate(), ZoneOffset.UTC)).withCharge(chargeEntity).withChargeStatus(ChargeStatus.CREATED).build();
chargeEntity.getEvents().add(chargeEventEntity);
}
Aggregations