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|"));
}
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()));
}
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));
}
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()));
}
Aggregations