diff --git a/samples/Mollie.WebApplication.Blazor/Api/PaymentController.cs b/samples/Mollie.WebApplication.Blazor/Api/PaymentController.cs new file mode 100644 index 00000000..1c83f667 --- /dev/null +++ b/samples/Mollie.WebApplication.Blazor/Api/PaymentController.cs @@ -0,0 +1,27 @@ +using Microsoft.AspNetCore.Mvc; +using Mollie.Api.Client.Abstract; +using Mollie.Api.Models.Payment.Response; + +namespace Mollie.WebApplication.Blazor.Api; + +[ApiController] +[Route("api/payment")] +public class PaymentController : ControllerBase { + private readonly ILogger _logger; + private readonly IPaymentClient _paymentClient; + + public PaymentController(ILogger logger, IPaymentClient paymentClient) { + _logger = logger; + _paymentClient = paymentClient; + } + + [HttpPost] + public async Task Webhook([FromForm] string id) { + PaymentResponse payment = await _paymentClient.GetPaymentAsync(id); + _logger.LogInformation("Webhook called for PaymentId={PaymentId}, PaymentStatus={Status}", + id, + payment.Status); + + return Ok(); + } +} diff --git a/samples/Mollie.WebApplication.Blazor/Models/Payment/CreatePaymentModel.cs b/samples/Mollie.WebApplication.Blazor/Models/Payment/CreatePaymentModel.cs index 8d6fb01e..0d1a5a0d 100644 --- a/samples/Mollie.WebApplication.Blazor/Models/Payment/CreatePaymentModel.cs +++ b/samples/Mollie.WebApplication.Blazor/Models/Payment/CreatePaymentModel.cs @@ -18,6 +18,9 @@ public class CreatePaymentModel { [Url] public required string RedirectUrl { get; set; } + [Url] + public string? WebhookUrl { get; set; } + [Required] public required string Description { get; set; } diff --git a/samples/Mollie.WebApplication.Blazor/Pages/Payment/Create.razor b/samples/Mollie.WebApplication.Blazor/Pages/Payment/Create.razor index 31c19ba6..555ca176 100644 --- a/samples/Mollie.WebApplication.Blazor/Pages/Payment/Create.razor +++ b/samples/Mollie.WebApplication.Blazor/Pages/Payment/Create.razor @@ -45,6 +45,15 @@ +
+ + + +
+