SilverLabs.SilverDotPay.Sdk 1.3.0
SilverDotPay SDK
Typed .NET client for the SilverDotPay payment gateway.
Install
dotnet add package SilverLabs.SilverDotPay.Sdk
The SilverLABS NuGet feed must be configured. In nuget.config:
<add key="silverlabs" value="https://nuget.silverlabs.uk/v3/index.json" />
Quick start
services.AddSilverDotPaySdk(opts =>
{
opts.BaseAddress = "https://silverdotpay.silverlabs.uk";
opts.Mode = SilverDotPayClientMode.ApiKey;
opts.ApiKey = configuration["SilverDotPay:ApiKey"];
opts.Timeout = TimeSpan.FromSeconds(30);
})
.AddPublicClient() // ICurrenciesClient + exchange rates, no auth
.AddMerchantClient() // orders, balances, withdrawals, webhooks
.AddAdminClient() // applications, keys, secrets, escrow, settings
.AddCardClient(); // card rail: charge-saved, setup, saved cards (1.3.0)
Then inject any of:
ISilverDotPayClient— narrow legacy surface (order create, get, escrow release/refund) — used by Crowding-style integrations.ISilverDotPayPublicClient— currencies, exchange rates. No auth.ISilverDotPayMerchantClient— orders, my balance, withdrawals, webhook config.ISilverDotPayAdminClient— applications, API keys, webhook secret rotation, balances, escrow, settings.ISilverDotPayCardClient— card rail: rail status, charge saved card, setup-mode capture, list/remove saved cards.
Auth modes
Pick one per HttpClient:
SilverDotPayClientMode.ApiKey— setsX-API-Keyheader fromopts.ApiKey. Used by service accounts and admin keys.SilverDotPayClientMode.PassportBearer— forwards a Passport SSO token from a pluggableITokenSource. Used in ASP.NET Core hosts where the inbound user's token is propagated downstream.
Inbound webhook validation
services.AddSingleton<ISilverDotPayWebhookValidator>(sp =>
new SilverDotPayWebhookValidator(secret: cfg["SilverDotPay:WebhookSecret"], logger));
Validator parses X-SilverDotPay-Signature: t=<unix>,v1=<hex>, recomputes
HMAC-SHA256("<unix>.<raw body>", secret), and rejects if the timestamp falls
outside a 5-minute replay window. Fails closed when no secret is configured.
See docs/WEBHOOKS.md in the silverdotpay repo for the wire format.
Card rail (1.3.0)
- Card checkout:
CreateOrderAsyncwithRail = SilverDotPayRail.Card, GBPAmount,BuyerIdentifier(tenant id),SuccessUrl,CancelUrl; redirect the buyer toCreateOrderResponse.PaymentUrl. The card is saved for renewals. payment_confirmedcarriespayment_method.ref— store it and pass it asPaymentMethodReftoISilverDotPayCardClient.ChargeSavedAsyncfor renewals (optionally withBuyerIdentifieras an ownership check). Use a newExternalOrderIdper attempt; reuse it only to retry the same attempt (never double-charges).ChargeSavedResponse.Statusis one ofSilverDotPayChargeStatus.processingmeans the outcome is unknown: do not treat it as failed and do not start another attempt; reconcile viaPOST /api/orders/{id}/reconcile.payment_failedcarriesfailure.reason(SilverDotPayFailureReason) and, forauthentication_required,failure.action_url— send the customer there to authenticate.payment_method_saved(setup mode) has noorder; key it onpayment_method.buyer_identifier.- A 503 (
SilverDotPayException.StatusCode == 503) orGetCardRailStatusAsync().IsConfigured == falsemeans cards are not configured for this application: hide the card option.
Versioning
SemVer. Major versions track breaking API contract changes on the silverdotpay backend.
No packages depend on SilverLabs.SilverDotPay.Sdk.
.NET 9.0
- Microsoft.Extensions.Http (>= 9.0.10)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.10)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.10)