public Task <EventsPageResponse> RetrieveEvents(RetrieveEventsRequest eventsRequest, CancellationToken cancellationToken = default) { CheckoutUtils.ValidateParams("eventsRequest", eventsRequest); return(ApiClient.Query <EventsPageResponse>(EventsPath, SdkAuthorization(), eventsRequest, cancellationToken)); }
private async Task ShouldRetrieveEventsByPaymentId_andRetrieveEventById_andGetNotification() { var webhook = await RegisterWebhook(); var payment = await MakeCardPayment(); payment.ShouldNotBeNull(); var retrieveEventsRequest = new RetrieveEventsRequest { PaymentId = payment.Id }; //Retrieve events EventsPageResponse events = await Retriable(async() => await PreviousApi.EventsClient().RetrieveEvents(retrieveEventsRequest)); events.ShouldNotBeNull(); events.TotalCount.ShouldBe(1); events.Data.ShouldNotBeNull(); events.Data.Count.ShouldBe(1); var summaryResponse = events.Data[0]; summaryResponse.Id.ShouldNotBeNull(); summaryResponse.CreatedOn.ShouldNotBeNull(); summaryResponse.Type.ShouldBe("payment_approved"); //Retrieve event var eventResponse = await PreviousApi.EventsClient().RetrieveEvent(summaryResponse.Id); eventResponse.ShouldNotBeNull(); eventResponse.Id.ShouldNotBeNull(); eventResponse.Data.ShouldNotBeNull(); eventResponse.Type.ShouldBe("payment_approved"); //Get notification var eventNotification = await PreviousApi.EventsClient() .RetrieveEventNotification(eventResponse.Id, eventResponse.Notifications[0].Id); eventNotification.ShouldNotBeNull(); eventNotification.Id.ShouldNotBeNull(); eventNotification.Url.ShouldNotBeNull(); eventNotification.Success.ShouldNotBeNull(); // Retry Webhooks // Webhooks are not being re attempted. Adding the call to ensure. await PreviousApi.EventsClient().RetryWebhook(summaryResponse.Id, webhook.Id); await PreviousApi.EventsClient().RetryAllWebhooks(summaryResponse.Id); }
private async Task ShouldRetrieveEvents() { var request = new RetrieveEventsRequest(); var eventsPageResponse = new EventsPageResponse(); _apiClient.Setup(apiClient => apiClient.Query <EventsPageResponse>("events", _authorization, request, CancellationToken.None)) .ReturnsAsync(() => eventsPageResponse); IEventsClient client = new EventsClient(_apiClient.Object, _configuration.Object); var response = await client.RetrieveEvents(request); response.ShouldNotBeNull(); response.ShouldBeSameAs(eventsPageResponse); }