Ir al contenido

Buscar en el Ecosistema EricksonLopez.*

Escribe el nombre de una librería, ID de paquete NuGet, tipo .NET o concepto arquitectónico para buscar en el portal.

Guías y Recetas — Webhooks

Recetas verificadas de firma y configuración compiladas en .NET 10 (ImplicitUsings=disable, Nullable=enable).

using System;
using EricksonLopez.Webhooks;
namespace Example.WebhooksQuickStart;
public static class WebhookSigningRecipe
{
public static bool SignAndVerify(string webhookSecret)
{
const string payload = "{\"event\":\"invoice.paid\"}";
long timestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
string signature = WebhookSigner.ComputeSignature(webhookSecret, timestamp, payload);
return WebhookSigner.VerifySignature(
webhookSecret,
timestamp,
payload,
signature,
WebhookReceiverProtocol.EricksonLopez);
}
}
using System;
using EricksonLopez.Webhooks;
using Microsoft.Extensions.DependencyInjection;
namespace Example.WebhooksQuickStart;
public static class OutboundSenderRecipe
{
public static ServiceProvider BuildSenderProvider()
{
var services = new ServiceCollection();
services.AddLogging();
services.AddWebhooks(options =>
{
options.Timeout = TimeSpan.FromSeconds(10);
options.EnableSsrfProtection = true;
options.MaxPayloadSizeBytes = 1024 * 1024;
options.Protocol = WebhookSenderProtocol.EricksonLopez;
});
return services.BuildServiceProvider(
new ServiceProviderOptions { ValidateOnBuild = true, ValidateScopes = true });
}
}