Search in sources :

Example 1 with EpdqCancelResponse

use of uk.gov.pay.connector.gateway.epdq.model.response.EpdqCancelResponse in project pay-connector by alphagov.

the class EpdqXMLUnmarshallerTest method shouldUnmarshallACancelErrorResponse.

@Test
public void shouldUnmarshallACancelErrorResponse() throws Exception {
    String payload = TestTemplateResourceLoader.load(EPDQ_CANCEL_ERROR_RESPONSE);
    EpdqCancelResponse response = XMLUnmarshaller.unmarshall(payload, EpdqCancelResponse.class);
    assertThat(response.cancelStatus(), is(BaseCancelResponse.CancelStatus.ERROR));
    assertThat(response.getTransactionId(), is("3014644340"));
    assertThat(response.getErrorCode(), is("50001127"));
    assertThat(response.getErrorMessage(), is("|this order is not authorized|"));
}
Also used : EpdqCancelResponse(uk.gov.pay.connector.gateway.epdq.model.response.EpdqCancelResponse) Test(org.junit.Test)

Example 2 with EpdqCancelResponse

use of uk.gov.pay.connector.gateway.epdq.model.response.EpdqCancelResponse in project pay-connector by alphagov.

the class EpdqXMLUnmarshallerTest method shouldUnmarshallACancelWaitingResponse.

@Test
public void shouldUnmarshallACancelWaitingResponse() throws Exception {
    String payload = TestTemplateResourceLoader.load(EPDQ_CANCEL_WAITING_RESPONSE);
    EpdqCancelResponse response = XMLUnmarshaller.unmarshall(payload, EpdqCancelResponse.class);
    assertThat(response.cancelStatus(), is(BaseCancelResponse.CancelStatus.SUBMITTED));
    assertThat(response.getTransactionId(), is("3014644340"));
    assertThat(response.getErrorCode(), is(nullValue()));
    assertThat(response.getErrorMessage(), is(nullValue()));
}
Also used : EpdqCancelResponse(uk.gov.pay.connector.gateway.epdq.model.response.EpdqCancelResponse) Test(org.junit.Test)

Example 3 with EpdqCancelResponse

use of uk.gov.pay.connector.gateway.epdq.model.response.EpdqCancelResponse in project pay-connector by alphagov.

the class ChargeCancelServiceTest method doSystemCancel_shouldCancelEPDQCharge_withStatus_awaitingCaptureRequest.

@Test
public void doSystemCancel_shouldCancelEPDQCharge_withStatus_awaitingCaptureRequest() throws Exception {
    String externalChargeId = "external-charge-id";
    Long gatewayAccountId = nextLong();
    ChargeEntity chargeEntity = aValidChargeEntity().withExternalId(externalChargeId).withTransactionId("transaction-id").withStatus(ChargeStatus.AWAITING_CAPTURE_REQUEST).build();
    EpdqCancelResponse epdqCancelResponse = mock(EpdqCancelResponse.class);
    when(epdqCancelResponse.cancelStatus()).thenReturn(BaseCancelResponse.CancelStatus.CANCELLED);
    GatewayResponse.GatewayResponseBuilder<EpdqCancelResponse> gatewayResponseBuilder = responseBuilder();
    GatewayResponse cancelResponse = gatewayResponseBuilder.withResponse(epdqCancelResponse).build();
    when(mockChargeDao.findByExternalIdAndGatewayAccount(externalChargeId, gatewayAccountId)).thenReturn(Optional.of(chargeEntity));
    when(mockPaymentProviders.byName(chargeEntity.getPaymentGatewayName())).thenReturn(mockPaymentProvider);
    when(mockPaymentProvider.cancel(argThat(aCancelGatewayRequestMatching(chargeEntity)))).thenReturn(cancelResponse);
    chargeCancelService.doSystemCancel(externalChargeId, gatewayAccountId);
    verify(chargeService).transitionChargeState(externalChargeId, SYSTEM_CANCELLED);
    verifyNoMoreInteractions(ignoreStubs(mockChargeDao));
}
Also used : GatewayResponse(uk.gov.pay.connector.gateway.model.response.GatewayResponse) ChargeEntityFixture.aValidChargeEntity(uk.gov.pay.connector.charge.model.domain.ChargeEntityFixture.aValidChargeEntity) ChargeEntity(uk.gov.pay.connector.charge.model.domain.ChargeEntity) RandomUtils.nextLong(org.apache.commons.lang.math.RandomUtils.nextLong) EpdqCancelResponse(uk.gov.pay.connector.gateway.epdq.model.response.EpdqCancelResponse) Test(org.junit.Test)

Example 4 with EpdqCancelResponse

use of uk.gov.pay.connector.gateway.epdq.model.response.EpdqCancelResponse in project pay-connector by alphagov.

the class EpdqXMLUnmarshallerTest method shouldUnmarshallACancelSuccessResponse.

@Test
public void shouldUnmarshallACancelSuccessResponse() throws Exception {
    String payload = TestTemplateResourceLoader.load(EPDQ_CANCEL_SUCCESS_RESPONSE);
    EpdqCancelResponse response = XMLUnmarshaller.unmarshall(payload, EpdqCancelResponse.class);
    assertThat(response.cancelStatus(), is(BaseCancelResponse.CancelStatus.CANCELLED));
    assertThat(response.getTransactionId(), is("3014644340"));
    assertThat(response.getErrorCode(), is(nullValue()));
    assertThat(response.getErrorMessage(), is(nullValue()));
}
Also used : EpdqCancelResponse(uk.gov.pay.connector.gateway.epdq.model.response.EpdqCancelResponse) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 EpdqCancelResponse (uk.gov.pay.connector.gateway.epdq.model.response.EpdqCancelResponse)4 RandomUtils.nextLong (org.apache.commons.lang.math.RandomUtils.nextLong)1 ChargeEntity (uk.gov.pay.connector.charge.model.domain.ChargeEntity)1 ChargeEntityFixture.aValidChargeEntity (uk.gov.pay.connector.charge.model.domain.ChargeEntityFixture.aValidChargeEntity)1 GatewayResponse (uk.gov.pay.connector.gateway.model.response.GatewayResponse)1