PayBridge 1.0.0

dotnet add package PayBridge --version 1.0.0
                    
NuGet\Install-Package PayBridge -Version 1.0.0
                    
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="PayBridge" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PayBridge" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="PayBridge" />
                    
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 PayBridge --version 1.0.0
                    
#r "nuget: PayBridge, 1.0.0"
                    
#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 PayBridge@1.0.0
                    
#: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=PayBridge&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=PayBridge&version=1.0.0
                    
Install as a Cake Tool

PayBridge

Official .NET SDK for the Payment Aggregator Central API.

Use this package to create and manage payment intents, confirm or capture payments, issue refunds, manage stores, read store transactions, and validate merchant webhook payloads.

Installation

Install from NuGet:

dotnet add package PayBridge --version 1.0.0

Package Manager Console:

Install-Package PayBridge -Version 1.0.0

Requirements

  • .NET 8.0 or any platform compatible with .NET Standard 2.1
  • A Payment Aggregator API key for protected payment and store operations

Store registration does not require an API key. The registration response returns the store API key, and that key is used for the next SDK calls.

You do not need to configure BaseUrl; the SDK uses the hosted Payment Aggregator API by default.

Configure With Dependency Injection

For ASP.NET Core or any app using IServiceCollection, register the SDK once at startup. ApiKey is optional if the app only needs to register a store first:

using PaymentAggregator.Sdk.Extensions;

builder.Services.AddPaymentAggregatorClient(options =>
{
    options.ApiKey = builder.Configuration["PaymentAggregator:ApiKey"] ?? string.Empty;
    options.Timeout = TimeSpan.FromSeconds(30);
});

If you only need the default hosted API and will set the key later, you can register without options:

builder.Services.AddPaymentAggregatorClient();

Add configuration to appsettings.json:

{
  "PaymentAggregator": {
    "ApiKey": "your-store-api-key"
  }
}

Then inject the SDK services where needed:

using PaymentAggregator.Sdk.Models.Requests;
using PaymentAggregator.Sdk.Services;

public sealed class CheckoutService
{
    private readonly IPaymentsService _payments;

    public CheckoutService(IPaymentsService payments)
    {
        _payments = payments;
    }

    public async Task<Guid> CreatePaymentAsync(Guid storeId, CancellationToken ct = default)
    {
        var payment = await _payments.CreateIntentAsync(new CreatePaymentIntentRequest
        {
            StoreId = storeId.ToString(),
            OrderId = "ORDER-1001",
            AmountMinor = 49900,
            Currency = "INR",
            ProviderCode = "razorpay",
            Description = "Checkout order ORDER-1001",
            ReturnUrl = "https://merchant.example.com/payment/success",
            CancelUrl = "https://merchant.example.com/payment/cancel",
            Metadata = new
            {
                CustomerId = "CUST-1001"
            }
        }, ct);

        return payment.PaymentId;
    }
}

Register a Store First

POST /api/stores is public. You do not need an API key to register a store.

using PaymentAggregator.Sdk;
using PaymentAggregator.Sdk.Models.Requests;

var client = new PaymentAggregatorClient();

var store = await client.Stores.RegisterAsync(new RegisterStoreRequest
{
    Name = "Demo Store",
    WebhookUrl = "https://merchant.example.com/webhooks/payment-aggregator"
});

var storeId = store.Id;
var apiKey = store.ApiKey;

client.SetApiKey(apiKey);

After SetApiKey, the same client can call protected endpoints:

var gateways = await client.Stores.GetGatewaysAsync(storeId);

Regenerate a Store API Key

Use the current store API key to request a replacement key:

client.SetApiKey(currentApiKey);

var regenerated = await client.Stores.RegenerateApiKeyAsync(storeId);
var newApiKey = regenerated.ApiKey;

client.SetApiKey(newApiKey);

After regeneration, the old API key is no longer valid. Store the new key securely.

Configure Directly

For console apps, workers, or small integrations, create the client directly:

using PaymentAggregator.Sdk;
using PaymentAggregator.Sdk.Models.Requests;

var client = new PaymentAggregatorClient(options =>
{
    options.ApiKey = "your-store-api-key";
});

var payment = await client.Payments.CreateIntentAsync(new CreatePaymentIntentRequest
{
    StoreId = "2ed4ce99-6a35-4bb0-8bcf-5f3504c7899b",
    OrderId = "ORDER-1001",
    AmountMinor = 49900,
    Currency = "INR",
    ProviderCode = "razorpay"
});

ProviderCode accepts provider names or numeric provider code strings. The SDK serializes them to the enum value expected by the API:

ProviderCode = "payu";      // sends 12
ProviderCode = "12";        // sends 12
ProviderCode = "razorpay";  // sends 3

Payment Operations

Create a payment intent:

var payment = await client.Payments.CreateIntentAsync(new CreatePaymentIntentRequest
{
    StoreId = storeId.ToString(),
    OrderId = "ORDER-1001",
    AmountMinor = 49900,
    Currency = "INR",
    ProviderCode = "razorpay",
    ReturnUrl = "https://merchant.example.com/success",
    CancelUrl = "https://merchant.example.com/cancel"
});

Confirm a payment:

var confirmed = await client.Payments.ConfirmAsync(payment.PaymentId, new ConfirmPaymentRequest
{
    ProviderSpecific = new Dictionary<string, string>
    {
        ["payment_method"] = "card"
    }
});

Capture a payment:

var captured = await client.Payments.CaptureAsync(payment.PaymentId, new CapturePaymentRequest
{
    AmountMinor = 49900
});

Refund a payment:

var refund = await client.Payments.RefundAsync(payment.PaymentId, new RefundPaymentRequest
{
    AmountMinor = 49900,
    Reason = "Customer requested refund"
});

Get payment status:

var latest = await client.Payments.GetAsync(payment.PaymentId);

Store Operations

Register a store:

var store = await client.Stores.RegisterAsync(new RegisterStoreRequest
{
    Name = "Demo Store",
    WebhookUrl = "https://merchant.example.com/webhooks/payment-aggregator"
});

Get store details:

var storeDetails = await client.Stores.GetByIdAsync(store.Id);

Get enabled gateways for a store:

var gateways = await client.Stores.GetGatewaysAsync(store.Id);

List store transactions:

var transactions = await client.Stores.GetTransactionsAsync(store.Id, new GetTransactionsRequest
{
    Status = "succeeded",
    Currency = "INR",
    PageNumber = 1,
    PageSize = 20
});

Update webhook URL:

await client.Stores.UpdateWebhookUrl(store.Id, new UpdateWebhookRequest
{
    WebhookUrl = "https://merchant.example.com/webhooks/payment-aggregator"
});

Webhook Validation

Use IWebhooksService to verify that webhook payloads came from Payment Aggregator.

using PaymentAggregator.Sdk.Services;

app.MapPost("/webhooks/payment-aggregator", async (
    HttpRequest request,
    IWebhooksService webhooks,
    IConfiguration configuration) =>
{
    using var reader = new StreamReader(request.Body);
    var rawBody = await reader.ReadToEndAsync();

    var signature = request.Headers["X-Signature"].ToString();
    var secret = configuration["PaymentAggregator:WebhookSecret"]!;

    if (!webhooks.ValidateSignature(rawBody, signature, secret))
    {
        return Results.Unauthorized();
    }

    var webhookEvent = webhooks.ParseEvent(rawBody);
    if (webhookEvent is null)
    {
        return Results.BadRequest();
    }

    // Handle webhookEvent.EventType and webhookEvent.Status here.
    return Results.Ok();
});

Configuration Options

PaymentAggregatorClientOptions supports:

Option Default Description
BaseUrl Hosted Payment Aggregator API Optional override for private or staging deployments. Most users should not set this.
ApiKey Empty Store API key sent as the X-Api-Key header. Not required for store registration. Required for protected operations.
Timeout 30 seconds HTTP request timeout.
RetryCount 2 Retry count reserved for SDK retry behavior.
RetryDelay 1 second Retry delay reserved for SDK retry behavior.
ApiVersion api API path prefix. The SDK calls routes like /api/payments.

API Surface

The SDK exposes:

  • PaymentAggregatorClient.Payments
  • PaymentAggregatorClient.Stores
  • PaymentAggregatorClient.Webhooks
  • IPaymentsService
  • IStoresService
  • IWebhooksService

IStoresService includes RegenerateApiKeyAsync(storeId) for rotating a store API key.

Finding This Package on NuGet

Search for the package by ID:

PayBridge

Useful NuGet search queries:

PayBridge
PayBridge sdk
paybridge payment aggregator
paybridge dotnet
payment aggregator sdk dotnet
payment gateway orchestration dotnet
multi-gateway payment sdk
razorpay paypal stripe sdk
payu cashfree telr sdk
adyen mollie checkout sdk
tag:paybridge
tag:payment-aggregator
tag:payment-gateway
tag:payment-orchestration
tag:multi-gateway
id:PayBridge
packageid:PayBridge

The package is tagged across the following categories to make it easy to find:

Category Examples
Core concepts payment, payment-gateway, payment-aggregator, payment-orchestration, payment-routing, payment-hub, payment-switch
Operations checkout, refund, capture, payment-intent, transaction, webhook, webhook-validation
Major gateways stripe, paypal, razorpay, payu, cashfree, adyen, mollie, checkout.com, square, worldpay, paytabs, telr
Global gateways braintree, authorizenet, 2checkout, payfast, payoneer, paystack, flutterwave, klarna, afterpay, bambora, paymentwall
APAC gateways midtrans, xendit, omise, hitpay, ipay88, eway
India / UPI paytm, phonepe, upi, bhim, googlepay
Digital wallets applepay, googlepay, amazonpay
Buy-now-pay-later klarna, afterpay, clearpay, affirm, sezzle, zip
.NET ecosystem dotnet, dotnet8, netstandard2.1, aspnetcore, dependency-injection, ihttpclientfactory
Markets india, uae, gcc, uk, eu, us, global, international, cross-border
Business model fintech, saas-payments, platform-payments, marketplace-payments, merchant

NuGet search uses package metadata such as package ID, title, tags, author, description, summary, owner, and version. The package metadata is maintained in PaymentAggregator.Sdk.csproj.

Error Handling

SDK calls may throw:

  • PaymentAggregatorException for API or transport failures
  • PaymentAggregatorValidationException for validation failures
  • standard .NET exceptions such as ArgumentException when required options are missing

Example:

using PaymentAggregator.Sdk.Exceptions;

try
{
    var payment = await client.Payments.GetAsync(paymentId);
}
catch (PaymentAggregatorValidationException ex)
{
    // Handle validation errors.
}
catch (PaymentAggregatorException ex)
{
    // Handle API errors.
}

Supported Providers

Provider routing depends on your Payment Aggregator server configuration. Common provider codes include:

  • stripe
  • paypal
  • razorpay
  • payu
  • cashfree
  • paytabs
  • telr
  • mollie
  • checkout
  • adyen
  • square
  • worldpay

Pack and Publish

Build a .nupkg:

dotnet pack src/PaymentAggregator.Sdk/PaymentAggregator.Sdk.csproj -c Release -o ./nupkgs

Push to NuGet:

dotnet nuget push ./nupkgs/PayBridge.1.0.0.nupkg --api-key YOUR_NUGET_API_KEY --source https://api.nuget.org/v3/index.json

NuGet displays this README because the project includes PackageReadmeFile metadata.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 44 6/9/2026

Version 1.0.0 allows public store registration without an API key, uses the hosted API URL by default, adds SetApiKey for register-then-use flows, adds store API key regeneration, improves SDK error parsing, and documents the store API key workflow.