use of uk.gov.pay.connector.events.eventdetails.dispute.DisputeCreatedEventDetails in project pay-connector by alphagov.
the class QueueMessageContractTest method verifyDisputeCreatedEvent.
@PactVerifyProvider("a dispute created event")
public String verifyDisputeCreatedEvent() throws JsonProcessingException {
DisputeCreatedEventDetails eventDetails = new DisputeCreatedEventDetails(1500L, 1644883199L, "a-gateway-account-id", 6500L, 8000L, "duplicate");
DisputeCreated disputeCreated = new DisputeCreated("resource-external-id", "external-id", "service-id", true, eventDetails, toUTCZonedDateTime(1642579160L));
return disputeCreated.toJsonString();
}
use of uk.gov.pay.connector.events.eventdetails.dispute.DisputeCreatedEventDetails in project pay-connector by alphagov.
the class StripeWebhookTaskHandlerTest method shouldReadPayloadProperly.
@Test
void shouldReadPayloadProperly() throws JsonProcessingException {
LedgerTransaction transaction = aValidLedgerTransaction().withExternalId("external-id").withGatewayAccountId(1000L).withGatewayTransactionId("gateway-transaction-id").isLive(true).build();
StripeNotification stripeNotification = objectMapper.readValue(payload, StripeNotification.class);
StripeDisputeData stripeDisputeData = objectMapper.readValue(stripeNotification.getObject(), StripeDisputeData.class);
when(ledgerService.getTransactionForProviderAndGatewayTransactionId(any(), any())).thenReturn(Optional.of(transaction));
stripeWebhookTaskHandler.process(stripeNotification);
verify(eventService).emitEvent(disputeCreatedArgumentCaptor.capture());
DisputeCreated disputeCreated = disputeCreatedArgumentCaptor.getValue();
assertThat(disputeCreated.getEventType(), is("DISPUTE_CREATED"));
assertThat(disputeCreated.getResourceType(), is(ResourceType.DISPUTE));
assertThat(disputeCreated.getTimestamp(), is(stripeDisputeData.getDisputeCreated()));
DisputeCreatedEventDetails eventDetails = (DisputeCreatedEventDetails) disputeCreated.getEventDetails();
assertThat(eventDetails.getReason(), is("general"));
assertThat(eventDetails.getFee(), is(1500L));
assertThat(eventDetails.getAmount(), is(6500L));
assertThat(eventDetails.getNetAmount(), is(8000L));
}
Aggregations