use of uk.gov.pay.connector.gateway.stripe.json.StripePayout in project pay-connector by alphagov.
the class PayoutReconcileProcess method emitPayoutCreatedEvent.
private void emitPayoutCreatedEvent(PayoutReconcileMessage payoutReconcileMessage, BalanceTransaction balanceTransaction) {
Payout payoutObject = (Payout) balanceTransaction.getSourceObject();
StripePayout stripePayout = StripePayout.from(payoutObject);
payoutEmitterService.emitPayoutEvent(PayoutCreated.class, stripePayout.getCreated(), payoutReconcileMessage.getConnectAccountId(), stripePayout);
emitTerminalPayoutEvent(payoutReconcileMessage.getConnectAccountId(), stripePayout);
}
use of uk.gov.pay.connector.gateway.stripe.json.StripePayout in project pay-connector by alphagov.
the class PayoutEmitterServiceTest method setUp.
@Before
public void setUp() {
GatewayAccountEntity gatewayAccountEntity = GatewayAccountEntityFixture.aGatewayAccountEntity().withId(1234L).build();
when(mockConnectorConfiguration.getEmitPayoutEvents()).thenReturn(true);
when(mockGatewayAccountCredentialsService.findStripeGatewayAccountForCredentialKeyAndValue(STRIPE_ACCOUNT_ID_KEY, connectAccount)).thenReturn(gatewayAccountEntity);
payoutEmitterService = new PayoutEmitterService(mockEventService, mockConnectorConfiguration, mockGatewayAccountCredentialsService);
payout = new StripePayout("po_123", 1213L, 1589846400L, null, "pending", "card", null);
}
use of uk.gov.pay.connector.gateway.stripe.json.StripePayout in project pay-connector by alphagov.
the class PayoutReconcileProcessTest method shouldEmitAdditionalPayoutFailedEventIfPayoutStatusIsFailed.
@Test
public void shouldEmitAdditionalPayoutFailedEventIfPayoutStatusIsFailed() throws Exception {
PayoutReconcileMessage payoutReconcileMessage = setupQueueMessage();
ArgumentCaptor<Class<? extends PayoutEvent>> captor = ArgumentCaptor.forClass(Class.class);
ArgumentCaptor<StripePayout> captorForStripePayout = ArgumentCaptor.forClass(StripePayout.class);
setupMockBalanceTransactions("failed");
when(connectorConfiguration.getEmitPayoutEvents()).thenReturn(true);
payoutReconcileProcess.processPayouts();
verify(payoutEmitterService, times(2)).emitPayoutEvent(captor.capture(), any(), any(), captorForStripePayout.capture());
StripePayout stripePayoutForFailedEvent = captorForStripePayout.getAllValues().get(1);
assertThat(captor.getAllValues().get(0), is(PayoutCreated.class));
assertThat(captor.getAllValues().get(1), is(PayoutFailed.class));
assertThat(stripePayoutForFailedEvent.getFailureCode(), is("account_closed"));
assertThat(stripePayoutForFailedEvent.getFailureMessage(), is("The bank account has been closed"));
assertThat(stripePayoutForFailedEvent.getFailureBalanceTransaction(), is("ba_1GkZtqDv3CZEaFO2CQhLrluk"));
verify(payoutReconcileQueue).markMessageAsProcessed(payoutReconcileMessage.getQueueMessage());
}
use of uk.gov.pay.connector.gateway.stripe.json.StripePayout in project pay-connector by alphagov.
the class PayoutUpdatedTest method shouldSerializePayoutUpdatedEventWithCorrectEventDetails.
@Test
public void shouldSerializePayoutUpdatedEventWithCorrectEventDetails() throws JsonProcessingException {
StripePayout payout = new StripePayout("po_123", 1000L, 1589395533L, 1589395500L, "pending", "card", "SERVICE NAME");
String payoutEventJson = PayoutUpdated.from(parse("2020-05-13T18:45:33Z"), payout).toJsonString();
assertThat(payoutEventJson, hasJsonPath("$.event_type", equalTo("PAYOUT_UPDATED")));
assertThat(payoutEventJson, hasJsonPath("$.resource_type", equalTo("payout")));
assertThat(payoutEventJson, hasJsonPath("$.resource_external_id", equalTo(payout.getId())));
assertThat(payoutEventJson, hasJsonPath("$.timestamp", equalTo("2020-05-13T18:45:33.000000Z")));
assertThat(payoutEventJson, hasJsonPath("$.event_details.gateway_status", equalTo(payout.getStatus())));
}
use of uk.gov.pay.connector.gateway.stripe.json.StripePayout in project pay-connector by alphagov.
the class QueueMessageContractTest method verifyPayoutFailedEvent.
@PactVerifyProvider("a payout failed message")
public String verifyPayoutFailedEvent() throws JsonProcessingException {
StripePayout payout = new StripePayout("po_failed_1234567890", "failed", "account_closed", "The bank account has been closed", "ba_aaaaaaaaaa");
PayoutFailed payoutFailed = PayoutFailed.from(parse("2020-05-13T18:50:00Z"), payout);
return payoutFailed.toJsonString();
}
Aggregations