use of uk.gov.pay.connector.gateway.PaymentProvider in project pay-connector by alphagov.
the class SmartpayPaymentProviderTest method shouldSuccessfullySendACaptureRequest.
@Test
public void shouldSuccessfullySendACaptureRequest() throws Exception {
PaymentProvider paymentProvider = getSmartpayPaymentProvider();
CardAuthorisationGatewayRequest request = getCardAuthorisationRequest(chargeEntity);
GatewayResponse<BaseAuthoriseResponse> response = paymentProvider.authorise(request);
assertTrue(response.isSuccessful());
assertThat(response.getBaseResponse().isPresent(), is(true));
SmartpayAuthorisationResponse smartpayAuthorisationResponse = (SmartpayAuthorisationResponse) response.getBaseResponse().get();
String transactionId = smartpayAuthorisationResponse.getPspReference();
assertThat(transactionId, is(not(nullValue())));
chargeEntity.setGatewayTransactionId(transactionId);
CaptureResponse captureGatewayResponse = paymentProvider.capture(CaptureGatewayRequest.valueOf(chargeEntity));
assertTrue(captureGatewayResponse.isSuccessful());
assertThat(captureGatewayResponse.state(), is(CaptureResponse.ChargeState.PENDING));
}
use of uk.gov.pay.connector.gateway.PaymentProvider in project pay-connector by alphagov.
the class SmartpayPaymentProviderTest method shouldSendSuccessfullyAnOrderForMerchantWithNoAddressInRequest.
@Test
public void shouldSendSuccessfullyAnOrderForMerchantWithNoAddressInRequest() throws Exception {
PaymentProvider paymentProvider = getSmartpayPaymentProvider();
AuthCardDetails authCardDetails = AuthCardDetailsFixture.anAuthCardDetails().withCardNo(VALID_SMARTPAY_CARD_NUMBER).withAddress(null).build();
CardAuthorisationGatewayRequest request = new CardAuthorisationGatewayRequest(chargeEntity, authCardDetails);
GatewayResponse response = paymentProvider.authorise(request);
assertTrue(response.isSuccessful());
}
use of uk.gov.pay.connector.gateway.PaymentProvider 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());
}
use of uk.gov.pay.connector.gateway.PaymentProvider in project pay-connector by alphagov.
the class SmartpayPaymentProviderTest method shouldFailRequestAuthorisationIfCredentialsAreNotCorrect.
@Test
public void shouldFailRequestAuthorisationIfCredentialsAreNotCorrect() throws Exception {
PaymentProvider paymentProvider = getSmartpayPaymentProvider();
GatewayAccountEntity accountWithInvalidCredentials = new GatewayAccountEntity();
accountWithInvalidCredentials.setId(11L);
accountWithInvalidCredentials.setGatewayAccountCredentials(List.of(aGatewayAccountCredentialsEntity().withCredentials(Map.of("merchant_id", "MerchantAccount", "username", "wrong-username", "password", "wrong-password")).withGatewayAccountEntity(accountWithInvalidCredentials).withPaymentProvider(SMARTPAY.getName()).withState(ACTIVE).build()));
accountWithInvalidCredentials.setType(TEST);
chargeEntity.setGatewayAccount(accountWithInvalidCredentials);
CardAuthorisationGatewayRequest request = getCardAuthorisationRequest(chargeEntity);
GatewayResponse<BaseAuthoriseResponse> response = paymentProvider.authorise(request);
assertFalse(response.isSuccessful());
assertNotNull(response.getGatewayError());
}
use of uk.gov.pay.connector.gateway.PaymentProvider in project pay-connector by alphagov.
the class EventFactoryTest method setUp.
@Before
public void setUp() {
chargeService = mock(ChargeService.class);
refundDao = mock(RefundDao.class);
refundService = mock(RefundService.class);
chargeEventDao = mock(ChargeEventDao.class);
paymentProviders = mock(PaymentProviders.class);
PaymentProvider paymentProvider = new SandboxPaymentProvider();
when(paymentProviders.byName(any(PaymentGatewayName.class))).thenReturn(paymentProvider);
eventFactory = new EventFactory(chargeService, refundDao, refundService, chargeEventDao, paymentProviders);
}
Aggregations