Webority.Payments.Abstractions 0.43.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Webority.Payments.Abstractions --version 0.43.1
                    
NuGet\Install-Package Webority.Payments.Abstractions -Version 0.43.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Webority.Payments.Abstractions" Version="0.43.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Webority.Payments.Abstractions" Version="0.43.1" />
                    
Directory.Packages.props
<PackageReference Include="Webority.Payments.Abstractions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Webority.Payments.Abstractions --version 0.43.1
                    
#r "nuget: Webority.Payments.Abstractions, 0.43.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Webority.Payments.Abstractions@0.43.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Webority.Payments.Abstractions&version=0.43.1
                    
Install as a Cake Addin
#tool nuget:?package=Webority.Payments.Abstractions&version=0.43.1
                    
Install as a Cake Tool

webority-payments

The shared gateway layer of the Webority billing spec (v3 §1.1): provider-neutral payment contracts plus the Razorpay, Paddle and Stripe implementations, published as NuGet packages. The domain layer (plans, subscriptions, invoicing, lifecycle, admin UI, SQL) is deliberately NOT here — each product owns its copy per the spec (~/.claude/conventions/webority-payments.md).

Five money surfaces and two reconciliation reads, one library:

Surface Seam Razorpay implementation
Recurring billing (subscriptions) IPaymentGatewayService + IPaymentGatewayFactory RazorpayPaymentGatewayService (plans, subscriptions, customers, invoices, refunds, tokens); Stripe: StripePaymentGatewayService (customers, prices, hosted Checkout subscriptions, invoices, refunds, payment methods)
One-time collection (orders + checkout) IPaymentCollectionService RazorpayPaymentCollectionService (Orders API, payment fetch, checkout-signature verify); Paddle: PaddlePaymentCollectionService (transaction with a one-time price, no checkout signature); Stripe: StripePaymentCollectionService (hosted Checkout in payment mode)
Payment links (hosted, shareable page) IPaymentLinkService RazorpayPaymentLinkService (create/get/cancel/notify, partial payments, redirect-signature verify)
Virtual accounts (a bank account or UPI address per customer: Smart Collect) IVirtualAccountService RazorpayVirtualAccountService (create/get/close, payments received)
Payouts (paying partners/vendors — Razorpay X) IPayoutGatewayService + IPayoutGatewayFactory RazorpayPayoutGatewayService (contacts, fund accounts, payouts with idempotency)
Settlements (what reached the bank, and what it was made of) ISettlementService RazorpaySettlementService (settlements by date, combined reconciliation report)
Payments by date (across every surface) IGatewayPaymentQueryService RazorpayPaymentQueryService (payments list over a date range)

Collection vs links: use IPaymentCollectionService when the payer is in our own UI and we open checkout against an order. Use IPaymentLinkService when the payer is elsewhere — a link is handed over out of band (email, SMS, WhatsApp, a printed QR) and paid whenever they get to it, so the gateway hosts the page and owns notification and reminders.

⚠️ The two sign their callbacks differently. An order/checkout callback signs order_id|payment_id; a payment-link redirect signs payment_link_id|reference_id|status|payment_id. Each seam exposes its own verify method — verifying a link redirect with VerifyCheckoutSignature rejects every genuine payment.

Package Contents
Webority.Payments.Abstractions The seam interfaces above, IWebhookSignatureVerifier, IWebhookEventMapper, GatewayCapabilities, GatewayEventType (subscription + payment + refund + order + payment-link + payout + dispute + virtual-account vocabulary), GatewayWebhookEnvelope, neutral gateway DTOs, PaymentGateway/BillingInterval enums, default GetMaxBillingCycles
Webority.Payments.Razorpay IRazorpayClient/RazorpayClient (thin HttpClient via IHttpClientFactory, no SDK, in Webority.Payments.Razorpay.Http), the seven adapters, webhook HMAC verifier, webhook event mapper (incl. payout.* / order.paid / payment_link.* / virtual_account.*), typed RazorpayApiException carrying error.code/error.description, DI: AddRazorpay() / AddRazorpayGateway() / AddRazorpayWebhooks() / AddRazorpayPaymentCollection() / AddRazorpayPaymentLinks() / AddRazorpayVirtualAccounts() / AddRazorpayPayouts() / AddRazorpaySettlements() / AddRazorpayPaymentQueries()
Webority.Payments.Paddle IPaddleClient/PaddleClient (thin HttpClient over Paddle Billing v1, no SDK, Webority.Payments.Paddle.Http), PaddlePaymentGatewayService (recurring surface: customers, prices, checkout transactions, subscriptions, transactions-as-invoices, adjustments-as-refunds, saved payment methods), PaddlePaymentCollectionService (one-time collection), PaddleWebhookSignatureVerifier (Paddle-Signature ts+HMAC with replay window), PaddleWebhookEventMapper, DI: AddPaddle() / AddPaddleGateway() / AddPaddleWebhooks() / AddPaddlePaymentCollection() (the default-gateway helper UseDefaultPaymentGateway() lives in Webority.Payments.Abstractions)
Webority.Payments.Stripe IStripeClient/StripeClient (thin HttpClient over the Stripe REST API, no SDK, Webority.Payments.Stripe.Http), StripePaymentGatewayService (recurring surface: customers, prices, hosted Checkout subscriptions, invoices, refunds, payment methods), StripePaymentCollectionService (one-time collection through hosted Checkout), StripeWebhookSignatureVerifier (Stripe-Signature HMAC with a timestamp tolerance), StripeWebhookEventMapper, DI: AddStripe() / AddStripeGateway() / AddStripeWebhooks() / AddStripePaymentCollection()
Webority.Payments.Testing Razorpay, Paddle and Stripe webhook fixtures (embedded JSON, reproduced from each provider's documented payloads; a capture from a live account is still owed on the Razorpay side, and Stripe's fixtures are reconstructed from its API reference) + three framework-agnostic orchestrator scenario assertions. No EF, no product types, no xunit/nunit dependency. Products call scenarios with their own process delegates

Layout

Project folders sit flat at the repo root (Webority.Payments.Abstractions/, Webority.Payments.Razorpay/, Webority.Payments.Stripe/, Webority.Payments.Testing/, Webority.Payments.Tests/) per the fleet .NET layout, with no src/ or tests/ wrapper. Inside the Razorpay package, Http/ holds the wire layer (client + wire DTOs + RazorpayApiException); configuration and domain mapping live at the package root. The Stripe package follows the same split: Http/ holds the client and wire DTOs.

Boundary rule: nothing that references a DbContext, a tenancy type, or a product domain entity enters this repo. A helper with a domain dependency belongs in the product.

Consume

Packages are public on nuget.org — zero auth:

dotnet add package Webority.Payments.Razorpay   # INR-domestic products
dotnet add package Webority.Payments.Paddle     # merchant-of-record, global USD/EUR products
dotnet add package Webority.Payments.Stripe     # products that take payment through Stripe's hosted Checkout
# optional: product billing test suite
dotnet add package Webority.Payments.Testing

Paddle

Paddle is a merchant of record: it is the seller on the customer's invoice, collects the tax, and pays the merchant out. Three consequences shape the adapter, and a product's orchestrator has to know them:

  • No server-side subscription create. CreateSubscriptionAsync creates a transaction and returns its id as CreateSubscriptionResult.CheckoutReference (plus RedirectUrl when the account has a default payment link). The browser opens that transaction with Paddle.js (Paddle.Checkout.open({ transactionId })); Paddle creates the subscription when checkout completes and names it in transaction.completed / subscription.created. The Metadata passed to create travels as custom_data and comes back on envelope.Subscription.Metadata, so a product keys it with its own account id to recognise the subscription it never saw created.
  • The charge event is transaction.completed, mapped to SubscriptionCharged when it names a subscription. Payment.Id is the transaction id (txn_…): it is what refunds key on and the only stable identity, since payment attempts inside a transaction come and go. Invoice.Number is Paddle's own invoice number, the tax document the customer received.
  • Refunds are adjustments that await Paddle's approval on a live account, so ImmediateRefund is not advertised and CreateRefundAsync returns Pending; the outcome arrives as adjustment.updated (RefundProcessed / RefundFailed).
  • Trials are configured on the price, not per checkout. Pass CreatePlanRequest.TrialDays and Paddle attaches a trial_period to the price, so the subscription created from it starts trialing. Paddle therefore does not advertise TrialOnSubscriptionCreate, and a TrialEndDateTimeUtc on CreateSubscriptionAsync throws NotSupportedByGatewayException: honouring it was impossible, and dropping it charged the card while the caller recorded a trial. Razorpay advertises the flag and maps that trial end onto the subscription's start_at.
  • One-time collection is a transaction with a one-time price. AddPaddlePaymentCollection() registers PaddlePaymentCollectionService. Set Paddle:OneTimeProductId to a catalogue product (and list it in Paddle:ProductIds if the app filters, or the webhook mapper drops its own orders). The order id is the transaction id; the browser opens it with Paddle.Checkout.open({ transactionId }). Paddle returns no checkout signature, so VerifyCheckoutSignature throws NotSupportedByGatewayException; confirm payment with GetOrderAsync (status Paid) or the transaction.completed webhook. AutoCapture = false throws, because Paddle captures at checkout.

One seller account serves several Webority products. A Paddle account is one legal entity with one catalog, one customer list and account-wide webhooks: every notification destination receives every product's events, and a person is one customer across all our products. The partition is the Paddle product id: each Webority product is one Paddle product, each app registers its own API key (least permissions), client token and notification destination, and lists the product ids it sells in Paddle:ProductIds. The mapper then drops transaction and subscription events for other products before a consumer stores anything; a payload with no readable product id passes through with a warning (a lost cancellation is worse than a stored no-op), and a basket mixing our products with another's is dropped with a warning rather than booked whole. Adjustments carry no product and pass through: the consumer stores the delivery, fails to resolve the id, and records it as a no-op, so other products' refunds do appear in its webhook log. The adapter also refuses a checkout whose price belongs to an unlisted product, so a live-set swap that forgets ProductIds fails at the first Subscribe click instead of dropping every completion. Scope customer-portal sessions with the subscriptionIds argument so a customer of two products sees only this one's subscription there (least surprise, not access control: Paddle's own receipt emails link the unscoped portal).

When swapping sandbox for live, change every value together: ApiKey, WebhookSecret, ClientToken, Environment AND ProductIds (live product ids differ), plus the price ids recorded on the product's price rows.

Config section Paddle: ApiKey, WebhookSecret (API head only), WebhookSecretPrevious (the secret being retired, set only during a rotation), ClientToken (the public Paddle.js token the SPA needs), Environment (sandbox | live, selects the base URL), ProductIds (the Paddle products this app sells; empty = no filtering), ProductId (optional catalog product for CreatePlanAsync), WebhookToleranceSeconds (60; a valid signature outside the window is logged as skew, distinct from a forged one). Sandbox and live are separate systems: keys, price ids and webhook secrets never cross.

services.AddPaddle();
services.AddPaddleGateway();      // adapter + webhook verify/map + factory; nominates no default
services.AddPaddleWebhooks();     // API head only — requires WebhookSecret once ApiKey is set
// services.UseDefaultPaymentGateway(PaymentGateway.Razorpay);  // products hosting several adapters (Webority.Payments.Abstractions)

IPaymentGatewayFactory.ResolveDefault() returns the one registered adapter when there is exactly one. No gateway package nominates a default, because a package that nominated itself silently changed the default of a product that added it as a second gateway. With several adapters and no nomination, ResolveDefault() throws rather than guessing: state the default with UseDefaultPaymentGateway(PaymentGateway.X) from Webority.Payments.Abstractions, or register new DefaultPaymentGateway(PaymentGateway.X) directly where that helper is not referenced.

IPayoutGatewayFactory.ResolveDefault() follows the same rule, with DefaultPayoutGateway as its nomination record. Registering only Razorpay payouts needs no nomination, because it is then the only adapter.

Config section Razorpay: KeyId + KeySecret (payments), WebhookSecret (inbound webhooks), WebhookSecretPrevious (the secret being retired, set only during a rotation), PayoutAccountNumber (the Razorpay X account number — payout heads only), BaseUrl (validated at start-up as an absolute https address), HttpTimeoutSeconds (default 30, must be greater than zero). Rejected webhooks and gateway errors are counted by the Webority.Payments meter; see docs/usage.md, Set up.

Typical DI (API head that hosts webhooks + recurring billing):

services.AddRazorpay();
services.AddRazorpayGateway();           // recurring adapter + webhook verify/map + factory
services.AddRazorpayWebhooks();          // API head only — requires WebhookSecret when keys are set
services.AddRazorpayPaymentCollection(); // if the head creates orders / term payments
// Product AddBillingServices: the orchestrator only: do not re-register Razorpay types

Stripe

Stripe takes payment on its own hosted Checkout page, and a few of its rules shape the adapter. A product's orchestrator has to know them:

  • Hosted Checkout, and the subscription id comes later. CreateSubscriptionAsync creates a Checkout Session. It returns the session's address as RedirectUrl and the session id as CreateSubscriptionResult.CheckoutReference. The result carries no subscription, because Stripe creates it when the customer pays, so its id arrives with the customer.subscription.created webhook. The Metadata passed to create is stored on the subscription and comes back on envelope.Subscription.Metadata, so a product keys it with its own account id, as it does for Paddle.
  • The charge event is invoice.paid. It maps to SubscriptionCharged, and Payment.Id is the PaymentIntent id (pi_...). The adapter finds that id with one read of the invoice's payments. An invoice paid without a Stripe payment (a zero total, a credit, or money paid outside Stripe) carries its invoice id as Payment.Id instead, with the method Unknown.
  • Lifecycle events come from customer.subscription.updated. Stripe has no "activated", "past due" or "halted" event. The adapter reads the status change in data.previous_attributes.status and sends SubscriptionActivated, SubscriptionPastDue or SubscriptionHalted from it. An update with no status change, such as a quantity change on an active subscription, arrives as SubscriptionUpdated, never as activated. So does an update whose previous status is paused: the resume itself arrives as SubscriptionResumed from customer.subscription.resumed.
  • Trials start on create. A TrialEndDateTimeUtc passed to CreateSubscriptionAsync becomes the subscription's trial end. Stripe keeps trials on the subscription, not the price, so CreatePlanRequest.TrialDays is not sent and GatewayPlan.TrialDays comes back null. Stripe refuses an invalid trial end, and the adapter passes that refusal on as an error.
  • A plan change. ChangeSubscriptionPlanAsync with AtPeriodEnd set changes the price now, with no proration, and bills the new price from the next cycle. Without it, Stripe prorates and invoices the difference at once. Quantity changes follow the same rule. A change that keeps the old price until the period ends needs subscription schedules, which this package does not use, so CancelScheduledPlanChange is not supported.
  • Money. Every amount is Stripe's own integer in the currency's smallest unit, and the adapter copies it unchanged in both directions. The adapter never scales an amount, so for a zero-decimal currency the whole unit is already the integer, and multiplying it by 100 overcharges the customer by a factor of 100. Stripe refuses an amount it cannot charge, and the adapter adds no rounding of its own.
  • The webhook endpoint. Create it at API version 2026-10-28.endive and subscribe it to these event types, and no others. The mapper refuses an event from any other API release, so an endpoint left on another version fails loudly rather than being read wrongly:
    • customer.subscription.created, customer.subscription.updated, customer.subscription.deleted, customer.subscription.paused, customer.subscription.resumed, customer.subscription.trial_will_end
    • invoice.paid, invoice.payment_failed
    • checkout.session.completed, checkout.session.async_payment_succeeded, checkout.session.async_payment_failed
    • payment_intent.payment_failed
    • refund.created, refund.updated, refund.failed
    • charge.dispute.created, charge.dispute.updated, charge.dispute.closed
  • Refunds need a PaymentIntent or charge id. CreateRefundAsync takes a pi_... or ch_... id and throws ArgumentException for anything else, including an invoice id. The adapter stores pi_... ids, and a refund or dispute names its PaymentIntent when Stripe sends one, so both carry the payment's id; one with no PaymentIntent falls back to its charge id (ch_...).

Config section Stripe: SecretKey (a secret or restricted key; its prefix shows test or live mode, so there is no environment key), WebhookSecret (whsec_..., required by the webhook head), WebhookSecretPrevious (the secret being retired, set only during a rotation), BaseUrl (default https://api.stripe.com), HttpTimeoutSeconds (default 30), WebhookToleranceSeconds (default 300), MaxListItems (default 5000), ProductId (optional catalogue product for CreatePlanAsync), CheckoutSuccessUrl and CheckoutCancelUrl (subscriptions), and PaymentSuccessUrl and PaymentCancelUrl (one-time collection). The return addresses must be absolute https addresses. ProductScope (none) is the marker for a Stripe account several products share; set it on each product, and an event or plan that is not tagged for that product is left out. A dispute or refund Stripe left untagged takes the tag of its payment intent, then of that payment intent's customer.

services.AddStripe();
services.AddStripeGateway();           // recurring adapter + webhook verify/map + factory; nominates no default
services.AddStripeWebhooks();          // webhook head only: requires WebhookSecret once SecretKey is set
services.AddStripePaymentCollection(); // one-time collection, if the head creates them

The Stripe webhook and API fixtures in Webority.Payments.Testing are reconstructed from Stripe's API reference, not captured from a sandbox account. Until a capture replaces them, the parser and its fixtures share one reading of the docs, so a field that Stripe sends differently would pass the tests and fail on the first live event.

Virtual accounts (Smart Collect)

A virtual account gives one customer their own bank account number and IFSC, and optionally a UPI address, to push money to by NEFT, RTGS, IMPS or UPI whenever they choose. Nothing is opened or redirected, so there is no callback signature to verify: the only confirmation is the webhook.

services.AddRazorpayVirtualAccounts();   // after AddRazorpay()

var account = await virtualAccounts.CreateVirtualAccountAsync(new CreateVirtualAccountRequest(
    CustomerId: customer.GatewayCustomerId,
    ReceiverTypes: [VirtualAccountReceiverType.BankAccount, VirtualAccountReceiverType.Vpa],
    Metadata: new Dictionary<string, string> { ["tenant"] = tenantId }), ct);
// hand account.BankAccountNumber, account.Ifsc, account.BeneficiaryName (or account.VpaAddress) to the payer
  • Subscribe the virtual_account.credited and virtual_account.closed webhook events. A credit maps to VirtualAccountCredited with ResourceId = the virtual account id, envelope.Payment the payment Razorpay created, and envelope.VirtualAccountCredit the payer's side: the UTR (or UPI reference) as PayerBankReference, the payer's account, IFSC and name, and the transfer mode.
  • Book a credit once per payment id. The same payment can also arrive as payment.captured, so a product that handles both events dedupes on VirtualAccountCredit.PaymentId.
  • The create has no idempotency key at Razorpay, so a create that timed out may still have made an account; look the customer's account up before making another. ListVirtualAccountPaymentsAsync recovers a credit whose webhook was missed.

Settlements and reconciliation

ISettlementService reads what Razorpay paid into the bank (ListSettlementsAsync(from, to)) and what each settlement was made of (GetReconciliationAsync(year, month, day): one GatewayReconciliationLine per payment, refund, adjustment or transfer, with its credit, debit, fee, tax, settlement id and UTR). IGatewayPaymentQueryService.ListPaymentsAsync(from, to) lists every payment over a date range, whichever surface took it.

services.AddRazorpaySettlements();       // ISettlementService
services.AddRazorpayPaymentQueries();    // IGatewayPaymentQueryService
  • Every list reads all pages. Pass a to in the past for a stable read: rows created while the pages are read can shift the paging.
  • Razorpay settles only in INR and its settlement carries no currency, so GatewaySettlement.Currency is always INR. Reconciliation lines carry the currency Razorpay sends per line.
  • An entry type the library does not know reads as Other, keeps its amounts and is logged, so a settlement's lines still net to what reached the bank.
  • ListPaymentsAsync does not resolve each payment's subscription (that is one extra call per row); InvoiceId names it, and IPaymentCollectionService.GetPaymentAsync resolves it for one payment.

Disputes

A customer dispute (chargeback) arrives as one of six events, each carrying envelope.Dispute (GatewayDispute: Id, PaymentId, AmountMinor, Currency, ReasonCode, RespondByDateTimeUtc, Status). ResourceId is the dispute id. Status is the gateway's own string, passed through unmapped.

Event Razorpay Paddle
DisputeCreated payment.dispute.created adjustment.created / adjustment.updated with action chargeback or chargeback_warning
DisputeUnderReview payment.dispute.under_review none
DisputeWon payment.dispute.won action chargeback_reverse
DisputeLost payment.dispute.lost none
DisputeClosed payment.dispute.closed none
DisputeActionRequired payment.dispute.action_required none
  • Razorpay: act before RespondByDateTimeUtc. The merchant submits evidence in the Razorpay dashboard by that date, so a product should surface it on DisputeCreated and DisputeActionRequired. The payload also carries the disputed payment, left on envelope.Payment.
  • Paddle: informational only. Paddle is the merchant of record and handles the dispute with the card network itself, so there is no evidence deadline (RespondByDateTimeUtc is null) and no reason code (ReasonCode carries Paddle's reason text). The product's job is to record that the payment was disputed and, on DisputeWon, that it was reversed. Paddle sends no under-review, lost, closed or action-required delivery.
  • Amounts are long minor units; an unreadable amount is 0, as on refunds.

Release

Merge development → main publishes packages to nuget.org at the Directory.Build.props VersionPrefix (the PR gate requires bumping it). Pushes use --skip-duplicate, so a re-run is a no-op. Prefer additive changes; a breaking change to the seam is a billing-spec version event, and every consuming product must be updated in the same pass. Record each one in CHANGELOG.md under ### Breaking.

Develop

dotnet build Webority.Payments.slnx
dotnet test --project Webority.Payments.Tests

To iterate against a product before releasing, switch the product's PackageReference to a local ProjectReference temporarily — never copy package sources back into a product.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on Webority.Payments.Abstractions:

Package Downloads
Webority.Payments.Paddle

Paddle Billing implementation of the Webority payment-gateway seam: thin HTTP client (no SDK), IPaymentGatewayService adapter over transactions/subscriptions/adjustments, Paddle-Signature webhook verifier, and webhook event mapper (Webority billing spec v3 §1.1).

Webority.Payments.Razorpay

Razorpay implementation of the Webority payment-gateway seam: thin HTTP client (no SDK), IPaymentGatewayService adapter, webhook HMAC signature verifier, and webhook event mapper (Webority billing spec v3 §1.1).

Webority.Payments.Testing

Razorpay, Paddle and Stripe webhook fixtures, reproduced from each provider's documented payloads, and framework-agnostic orchestrator scenario assertions for Webority billing products (billing spec v3 §1.1 anti-drift kit). No EF, no product types, no test-framework dependency.

Webority.Payments.Stripe

Stripe implementation of the Webority payment-gateway seam: thin HTTP client (no SDK), IPaymentGatewayService adapter over Checkout Sessions, subscriptions, invoices and refunds, one-time collection, Stripe-Signature webhook verifier, and webhook event mapper (Webority billing spec v3 §1.1).

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.45.3 0 11/24/2026
0.45.2 0 11/24/2026
0.45.1 0 11/24/2026
0.45.0 0 11/23/2026
0.44.1 47 11/23/2026
0.44.0 89 11/22/2026
0.43.1 91 11/22/2026
0.43.0 103 11/21/2026
0.42.0 115 11/20/2026
0.41.3 111 11/19/2026
0.41.2 110 11/19/2026
0.41.1 110 11/18/2026
0.41.0 148 11/18/2026
0.40.2 160 11/17/2026
0.40.1 733 11/15/2026
0.40.0 179 11/15/2026
0.39.2 186 11/15/2026
0.39.1 267 11/15/2026
0.39.0 230 11/14/2026
0.38.1 274 11/14/2026
Loading failed