@@ -53,6 +53,7 @@ var app = builder.Build();
5353
5454app .UseL402Paywall (" /api/premium" , new L402Options
5555{
56+ WalletId = " wal_..." ,
5657 Price = 10 ,
5758 Description = " API access" ,
5859});
@@ -74,7 +75,7 @@ app.Run();
7475[Route (" api/[controller]" )]
7576public class WeatherController : ControllerBase
7677{
77- [L402 (Price = 50 , Description = " Weather forecast" , ExpirySeconds = 3600 , Caveats = new [] { " tier=pro" })]
78+ [L402 (WalletId = " wal_... " , Price = 50 , Description = " Weather forecast" , ExpirySeconds = 3600 , Caveats = new [] { " tier=pro" })]
7879 [HttpGet (" forecast" )]
7980 public IActionResult GetForecast ()
8081 => Ok (new { forecast = " sunny" });
@@ -85,14 +86,15 @@ public class WeatherController : ControllerBase
8586
8687``` csharp
8788app .MapGet (" /api/premium/data" , () => Results .Ok (new { data = " premium" }))
88- .AddEndpointFilter (new L402EndpointFilter (price : 10 , description : " API access" ));
89+ .AddEndpointFilter (new L402EndpointFilter (" wal_... " , price : 10 , description : " API access" ));
8990```
9091
9192### Dynamic pricing
9293
9394``` csharp
9495app .UseL402Paywall (" /api/dynamic" , new L402Options
9596{
97+ WalletId = " wal_..." ,
9698 PriceFactory = context =>
9799 {
98100 if (context .Request .Path .StartsWithSegments (" /api/dynamic/bulk" ))
@@ -106,6 +108,7 @@ app.UseL402Paywall("/api/dynamic", new L402Options
106108
107109| Option | Type | Description |
108110| --- | --- | --- |
111+ | ` WalletId ` | ` string ` | Wallet ID for L402 operations |
109112| ` Price ` | ` int ` | Price in satoshis per request |
110113| ` PriceFactory ` | ` Func<HttpContext, Task<int>>? ` | Dynamic pricing callback (takes precedence over ` Price ` ) |
111114| ` Description ` | ` string? ` | Invoice memo shown in wallets |
@@ -142,6 +145,7 @@ builder.Services.AddSingleton(new LnBotClient("key_..."));
142145builder .Services .AddHttpClient (" paid-apis" )
143146 .AddL402Handler (new L402ClientOptions
144147 {
148+ WalletId = " wal_..." ,
145149 MaxPrice = 100 ,
146150 BudgetSats = 50_ 000 ,
147151 BudgetPeriod = BudgetPeriod .Day ,
@@ -167,7 +171,7 @@ using Microsoft.Extensions.DependencyInjection;
167171var services = new ServiceCollection ();
168172services .AddSingleton (new LnBotClient (" key_..." ));
169173services .AddSingleton <ITokenStore , MemoryTokenStore >();
170- services .AddHttpClient (" paid-apis" ).AddL402Handler ();
174+ services .AddHttpClient (" paid-apis" ).AddL402Handler (new L402ClientOptions { WalletId = " wal_... " } );
171175
172176var provider = services .BuildServiceProvider ();
173177var http = provider .GetRequiredService <IHttpClientFactory >().CreateClient (" paid-apis" );
@@ -220,11 +224,11 @@ services.AddSingleton<ITokenStore, RedisTokenStore>();
220224## How It Works
221225
222226** Server middleware** makes two SDK calls:
223- - ` client.L402.CreateChallengeAsync() ` — creates an invoice + macaroon when a client needs to pay
224- - ` client.L402.VerifyAsync() ` — verifies an L402 authorization token when a client presents one
227+ - ` client.Wallet(walletId). L402.CreateChallengeAsync() ` — creates an invoice + macaroon when a client needs to pay
228+ - ` client.Wallet(walletId). L402.VerifyAsync() ` — verifies an L402 authorization token when a client presents one
225229
226230** Client handler** makes one SDK call:
227- - ` client.L402.PayAsync() ` — pays a Lightning invoice and returns a ready-to-use Authorization header
231+ - ` client.Wallet(walletId). L402.PayAsync() ` — pays a Lightning invoice and returns a ready-to-use Authorization header
228232
229233---
230234
0 commit comments