Search in sources :

Example 1 with Address

use of uk.gov.pay.connector.common.model.domain.Address in project pay-connector by alphagov.

the class SmartpayPaymentProviderTest method shouldSendSuccessfullyAnOrderForMerchantWithUsAddressInRequest.

@Test
public void shouldSendSuccessfullyAnOrderForMerchantWithUsAddressInRequest() throws Exception {
    PaymentProvider paymentProvider = getSmartpayPaymentProvider();
    Address usAddress = new Address();
    usAddress.setLine1("125 Kingsway");
    usAddress.setLine2("Aviation House");
    usAddress.setPostcode("90210");
    usAddress.setCity("Washington D.C.");
    usAddress.setCountry("US");
    AuthCardDetails authCardDetails = AuthCardDetailsFixture.anAuthCardDetails().withCardNo(VALID_SMARTPAY_CARD_NUMBER).withAddress(usAddress).build();
    CardAuthorisationGatewayRequest request = new CardAuthorisationGatewayRequest(chargeEntity, authCardDetails);
    GatewayResponse response = paymentProvider.authorise(request);
    assertTrue(response.isSuccessful());
}
Also used : GatewayResponse(uk.gov.pay.connector.gateway.model.response.GatewayResponse) PaymentProvider(uk.gov.pay.connector.gateway.PaymentProvider) SmartpayPaymentProvider(uk.gov.pay.connector.gateway.smartpay.SmartpayPaymentProvider) Address(uk.gov.pay.connector.common.model.domain.Address) AuthCardDetails(uk.gov.pay.connector.gateway.model.AuthCardDetails) CardAuthorisationGatewayRequest(uk.gov.pay.connector.gateway.model.request.CardAuthorisationGatewayRequest) Test(org.junit.Test)

Example 2 with Address

use of uk.gov.pay.connector.common.model.domain.Address 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));
}
Also used : ChargeEntity(uk.gov.pay.connector.charge.model.domain.ChargeEntity) Address(uk.gov.pay.connector.common.model.domain.Address) GatewayAccountEntity(uk.gov.pay.connector.gatewayaccount.model.GatewayAccountEntity) AddressEntity(uk.gov.pay.connector.charge.model.AddressEntity) GatewayAccountCredentialsEntityFixture.aGatewayAccountCredentialsEntity(uk.gov.pay.connector.gatewayaccountcredentials.model.GatewayAccountCredentialsEntityFixture.aGatewayAccountCredentialsEntity) GatewayAccountCredentialsEntity(uk.gov.pay.connector.gatewayaccountcredentials.model.GatewayAccountCredentialsEntity) CardDetailsEntity(uk.gov.pay.connector.charge.model.CardDetailsEntity) Test(org.junit.Test)

Example 3 with Address

use of uk.gov.pay.connector.common.model.domain.Address 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"));
}
Also used : ChargeEntity(uk.gov.pay.connector.charge.model.domain.ChargeEntity) Address(uk.gov.pay.connector.common.model.domain.Address) GatewayAccountEntity(uk.gov.pay.connector.gatewayaccount.model.GatewayAccountEntity) AddressEntity(uk.gov.pay.connector.charge.model.AddressEntity) GatewayAccountCredentialsEntityFixture.aGatewayAccountCredentialsEntity(uk.gov.pay.connector.gatewayaccountcredentials.model.GatewayAccountCredentialsEntityFixture.aGatewayAccountCredentialsEntity) GatewayAccountCredentialsEntity(uk.gov.pay.connector.gatewayaccountcredentials.model.GatewayAccountCredentialsEntity) CardDetailsEntity(uk.gov.pay.connector.charge.model.CardDetailsEntity) Test(org.junit.Test)

Example 4 with Address

use of uk.gov.pay.connector.common.model.domain.Address in project pay-connector by alphagov.

the class WorldpayPaymentProviderTest method shouldBeAbleToSendAuthorisationRequestForMerchantWithUsAddress.

@Test
public void shouldBeAbleToSendAuthorisationRequestForMerchantWithUsAddress() {
    WorldpayPaymentProvider paymentProvider = getValidWorldpayPaymentProvider();
    Address usAddress = new Address();
    usAddress.setLine1("125 Kingsway");
    usAddress.setLine2("Aviation House");
    usAddress.setPostcode("90210");
    usAddress.setCity("Washington D.C.");
    usAddress.setCountry("US");
    AuthCardDetails authCardDetails = anAuthCardDetails().withAddress(usAddress).build();
    CardAuthorisationGatewayRequest request = getCardAuthorisationRequest(authCardDetails);
    GatewayResponse<WorldpayOrderStatusResponse> response = paymentProvider.authorise(request);
    assertTrue(response.getBaseResponse().isPresent());
}
Also used : WorldpayPaymentProvider(uk.gov.pay.connector.gateway.worldpay.WorldpayPaymentProvider) Address(uk.gov.pay.connector.common.model.domain.Address) AuthCardDetailsFixture.anAuthCardDetails(uk.gov.pay.connector.model.domain.AuthCardDetailsFixture.anAuthCardDetails) AuthCardDetails(uk.gov.pay.connector.gateway.model.AuthCardDetails) WorldpayOrderStatusResponse(uk.gov.pay.connector.gateway.worldpay.WorldpayOrderStatusResponse) CardAuthorisationGatewayRequest(uk.gov.pay.connector.gateway.model.request.CardAuthorisationGatewayRequest) Test(org.junit.Test)

Example 5 with Address

use of uk.gov.pay.connector.common.model.domain.Address in project pay-connector by alphagov.

the class WorldpayPaymentProviderTest method shouldBeAbleToSendAuthorisationRequestForMerchantWithCanadaAddress.

@Test
public void shouldBeAbleToSendAuthorisationRequestForMerchantWithCanadaAddress() {
    WorldpayPaymentProvider paymentProvider = getValidWorldpayPaymentProvider();
    Address canadaAddress = new Address();
    canadaAddress.setLine1("125 Kingsway");
    canadaAddress.setLine2("Aviation House");
    canadaAddress.setPostcode("X0A0A0");
    canadaAddress.setCity("Arctic Bay");
    canadaAddress.setCountry("CA");
    AuthCardDetails authCardDetails = anAuthCardDetails().withAddress(canadaAddress).build();
    CardAuthorisationGatewayRequest request = getCardAuthorisationRequest(authCardDetails);
    GatewayResponse<WorldpayOrderStatusResponse> response = paymentProvider.authorise(request);
    assertTrue(response.getBaseResponse().isPresent());
}
Also used : WorldpayPaymentProvider(uk.gov.pay.connector.gateway.worldpay.WorldpayPaymentProvider) Address(uk.gov.pay.connector.common.model.domain.Address) AuthCardDetailsFixture.anAuthCardDetails(uk.gov.pay.connector.model.domain.AuthCardDetailsFixture.anAuthCardDetails) AuthCardDetails(uk.gov.pay.connector.gateway.model.AuthCardDetails) WorldpayOrderStatusResponse(uk.gov.pay.connector.gateway.worldpay.WorldpayOrderStatusResponse) CardAuthorisationGatewayRequest(uk.gov.pay.connector.gateway.model.request.CardAuthorisationGatewayRequest) Test(org.junit.Test)

Aggregations

Address (uk.gov.pay.connector.common.model.domain.Address)57 Test (org.junit.Test)53 AuthCardDetails (uk.gov.pay.connector.gateway.model.AuthCardDetails)49 ConstraintViolation (javax.validation.ConstraintViolation)23 GatewayOrder (uk.gov.pay.connector.gateway.GatewayOrder)14 CardAuthorisationGatewayRequest (uk.gov.pay.connector.gateway.model.request.CardAuthorisationGatewayRequest)11 ChargeEntity (uk.gov.pay.connector.charge.model.domain.ChargeEntity)6 PaymentProvider (uk.gov.pay.connector.gateway.PaymentProvider)4 GatewayResponse (uk.gov.pay.connector.gateway.model.response.GatewayResponse)4 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)3 Before (org.junit.Before)3 CardDetailsEntity (uk.gov.pay.connector.charge.model.CardDetailsEntity)3 ChargeEntityFixture.aValidChargeEntity (uk.gov.pay.connector.charge.model.domain.ChargeEntityFixture.aValidChargeEntity)3 GatewayAccountEntity (uk.gov.pay.connector.gatewayaccount.model.GatewayAccountEntity)3 GatewayAccountCredentialsEntity (uk.gov.pay.connector.gatewayaccountcredentials.model.GatewayAccountCredentialsEntity)3 AuthCardDetailsFixture.anAuthCardDetails (uk.gov.pay.connector.model.domain.AuthCardDetailsFixture.anAuthCardDetails)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 UTC (java.time.ZoneOffset.UTC)2 ZonedDateTime (java.time.ZonedDateTime)2