Search in sources :

Example 1 with DisputeCreatedEventDetails

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();
}
Also used : DisputeCreated(uk.gov.pay.connector.events.model.dispute.DisputeCreated) DisputeCreatedEventDetails(uk.gov.pay.connector.events.eventdetails.dispute.DisputeCreatedEventDetails) PactVerifyProvider(au.com.dius.pact.provider.PactVerifyProvider)

Example 2 with DisputeCreatedEventDetails

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));
}
Also used : LedgerTransactionFixture.aValidLedgerTransaction(uk.gov.pay.connector.model.domain.LedgerTransactionFixture.aValidLedgerTransaction) LedgerTransaction(uk.gov.pay.connector.client.ledger.model.LedgerTransaction) DisputeCreated(uk.gov.pay.connector.events.model.dispute.DisputeCreated) StripeDisputeData(uk.gov.pay.connector.queue.tasks.dispute.StripeDisputeData) DisputeCreatedEventDetails(uk.gov.pay.connector.events.eventdetails.dispute.DisputeCreatedEventDetails) StripeNotification(uk.gov.pay.connector.gateway.stripe.response.StripeNotification) Test(org.junit.jupiter.api.Test)

Aggregations

DisputeCreatedEventDetails (uk.gov.pay.connector.events.eventdetails.dispute.DisputeCreatedEventDetails)2 DisputeCreated (uk.gov.pay.connector.events.model.dispute.DisputeCreated)2 PactVerifyProvider (au.com.dius.pact.provider.PactVerifyProvider)1 Test (org.junit.jupiter.api.Test)1 LedgerTransaction (uk.gov.pay.connector.client.ledger.model.LedgerTransaction)1 StripeNotification (uk.gov.pay.connector.gateway.stripe.response.StripeNotification)1 LedgerTransactionFixture.aValidLedgerTransaction (uk.gov.pay.connector.model.domain.LedgerTransactionFixture.aValidLedgerTransaction)1 StripeDisputeData (uk.gov.pay.connector.queue.tasks.dispute.StripeDisputeData)1