Sunbay.Nexus.Sdk
1.0.13
dotnet add package Sunbay.Nexus.Sdk --version 1.0.13
NuGet\Install-Package Sunbay.Nexus.Sdk -Version 1.0.13
<PackageReference Include="Sunbay.Nexus.Sdk" Version="1.0.13" />
<PackageVersion Include="Sunbay.Nexus.Sdk" Version="1.0.13" />
<PackageReference Include="Sunbay.Nexus.Sdk" />
paket add Sunbay.Nexus.Sdk --version 1.0.13
#r "nuget: Sunbay.Nexus.Sdk, 1.0.13"
#:package Sunbay.Nexus.Sdk@1.0.13
#addin nuget:?package=Sunbay.Nexus.Sdk&version=1.0.13
#tool nuget:?package=Sunbay.Nexus.Sdk&version=1.0.13
Sunbay Nexus SDK for .NET
Official .NET SDK for Sunbay Payment Platform
Features
- ✅ Async/await support for high performance
- ✅ Multi-target framework support (.NET Standard 2.0, .NET 6.0, .NET 8.0)
- ✅ Automatic retry for transient failures
- ✅ Comprehensive exception handling
- ✅ Minimal dependencies
- ✅ Thread-safe client
Installation
Package Manager
Install-Package Sunbay.Nexus.Sdk
.NET CLI
dotnet add package Sunbay.Nexus.Sdk --version 1.0.13
PackageReference
<PackageReference Include="Sunbay.Nexus.Sdk" Version="1.0.13" />
Quick Start
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Sunbay.Nexus.Sdk;
using Sunbay.Nexus.Sdk.Models.Requests;
using Sunbay.Nexus.Sdk.Models.Common;
using Sunbay.Nexus.Sdk.Exceptions;
class Program
{
static async Task Main(string[] args)
{
// Get API key from environment variable or configuration
// DO NOT hardcode sensitive information in source code
var apiKey = Environment.GetEnvironmentVariable("SUNBAY_API_KEY")
?? throw new InvalidOperationException("SUNBAY_API_KEY environment variable is required");
// Initialize logger factory (optional, but recommended for debugging)
// Note: Passing ILoggerFactory is the mainstream C# SDK pattern (used by Azure SDK, AWS SDK, etc.)
using var loggerFactory = LoggerFactory.Create(builder =>
builder.AddConsole().SetMinimumLevel(LogLevel.Information));
var logger = loggerFactory.CreateLogger<Program>();
// Initialize client with logger factory
var client = new NexusClient(new NexusClientOptions
{
ApiKey = apiKey,
BaseUrl = "https://open.sunbay.us"
}, loggerFactory);
try
{
// Create sale request
var request = new SaleRequest
{
AppId = "app_123456",
MerchantId = "mch_789012",
ReferenceOrderId = $"ORDER{DateTimeOffset.UtcNow.ToUnixTimeSeconds()}",
TransactionRequestId = Guid.NewGuid().ToString("N"),
Amount = new SaleAmount
{
OrderAmount = 10000L, // 100.00 USD in cents (smallest currency unit)
PriceCurrency = "USD"
},
Description = "Product purchase",
TerminalSn = "T1234567890"
};
logger.LogInformation("Sending sale request - ReferenceOrderId: {ReferenceOrderId}, TransactionRequestId: {TransactionRequestId}",
request.ReferenceOrderId, request.TransactionRequestId);
// Execute transaction
// If code != "0", SunbayBusinessException will be thrown
var response = await client.SaleAsync(request);
logger.LogInformation("Transaction successful - TransactionId: {TransactionId}", response.TransactionId);
}
catch (SunbayNetworkException ex)
{
logger.LogError(ex, "Network error occurred - Message: {Message}, IsRetryable: {IsRetryable}", ex.Message, ex.IsRetryable);
}
catch (SunbayBusinessException ex)
{
logger.LogError("API error occurred - Code: {Code}, Message: {Message}, TraceId: {TraceId}", ex.Code, ex.Message, ex.TraceId);
}
catch (Exception ex)
{
logger.LogError(ex, "Unexpected error occurred - Message: {Message}", ex.Message);
}
finally
{
await client.DisposeAsync();
}
}
}
Available API Methods
The SDK provides the following transaction methods:
SaleAsync- Execute a sale transactionAuthAsync- Authorization (pre-auth)ForcedAuthAsync- Forced authorizationIncrementalAuthAsync- Incremental authorizationPostAuthAsync- Post authorizationRefundAsync- Refund transactionVoidAsync- Void transactionAbortAsync- Abort transactionTipAdjustAsync- Adjust tip amountQueryAsync- Query transaction statusBatchCloseAsync- Batch close settlementBatchQueryAsync- Batch query settlement summary data
Configuration Options
var client = new NexusClient(new NexusClientOptions
{
ApiKey = "sk_test_xxx", // Required
BaseUrl = "https://open.sunbay.us", // Optional, default: https://open.sunbay.us
Timeout = TimeSpan.FromSeconds(30), // Optional, default: 30 seconds
MaxRetries = 3, // Optional, default: 3
MaxTotalConnections = 200, // Optional, default: 200
MaxConnectionsPerEndpoint = 20 // Optional, default: 20
});
Logging
The SDK integrates with the standard .NET logging abstractions (Microsoft.Extensions.Logging).
Logging is optional and fully controlled by the application.
Using ILoggerFactory (Recommended)
This is the mainstream approach in C# SDKs, allowing the SDK to create category-specific loggers internally.
using Microsoft.Extensions.Logging;
using Sunbay.Nexus.Sdk;
// Configure logger factory (example: console logging)
using var loggerFactory = LoggerFactory.Create(builder =>
{
builder.AddConsole()
.SetMinimumLevel(LogLevel.Information);
});
// Create client with logger factory
var client = new NexusClient(new NexusClientOptions
{
ApiKey = "sk_test_xxx",
BaseUrl = "https://open.sunbay.us"
}, loggerFactory);
Using Dependency Injection (ASP.NET Core)
In dependency injection scenarios, you can inject ILoggerFactory from the DI container:
// In Startup.cs or Program.cs
services.AddSingleton<ILoggerFactory>(sp =>
LoggerFactory.Create(builder => builder.AddConsole()));
// Then inject in your service
public class PaymentService
{
private readonly NexusClient _client;
public PaymentService(ILoggerFactory loggerFactory)
{
_client = new NexusClient(new NexusClientOptions
{
ApiKey = Environment.GetEnvironmentVariable("SUNBAY_API_KEY")!,
BaseUrl = "https://open.sunbay.us"
}, loggerFactory);
}
}
Without Logging
If you don't pass a logger factory, logging is disabled by default:
var client = new NexusClient(new NexusClientOptions
{
ApiKey = "sk_test_xxx",
BaseUrl = "https://open.sunbay.us"
});
// No logging will be performed
Notes:
- The SDK only depends on
Microsoft.Extensions.Logging.Abstractions(interfaces). - You can plug in any logging provider (Console, Serilog, NLog, Application Insights, etc.) via
ILoggerFactory. - The SDK creates category-specific loggers internally (e.g.,
"Sunbay.Nexus.Sdk.Http.HttpClientWrapper"). - This approach follows the mainstream C# SDK pattern used by Azure SDK, AWS SDK, and other major .NET libraries.
Exception Handling
The SDK throws two types of exceptions:
SunbayNetworkException
Network-related errors (connection timeout, network error, etc.)
IsRetryable: Indicates if the operation can be retried
SunbayBusinessException
Business logic errors (parameter validation, API business errors, etc.)
Code: Error codeMessage: Error messageTraceId: Trace ID for debugging
Requirements
- .NET Standard 2.0+ / .NET 6.0+ / .NET 8.0+
- System.Text.Json 8.0.0+ (for .NET Standard 2.0)
- Microsoft.Extensions.Http 8.0.0+
- (The SDK itself references
Microsoft.Extensions.Logging.Abstractions, but this is a transitive dependency of the NuGet package; you don't need to install it manually.)
Support
- Documentation: https://docs.sunbay.us
- Issues: https://github.com/sunbay-developer/sunbay-nexus-sdk-dotnet/issues
Publish to NuGet
- Update version in
src/Sunbay.Nexus.Sdk/Sunbay.Nexus.Sdk.csproj(<Version>). - Run:
python3 deploy.py
deploy.py will:
- read
PackageIdandVersionfrom the.csproj - pack Release
.nupkg - prompt for NuGet API Key (hidden input)
- push package to
https://api.nuget.org/v3/index.json
License
MIT License. Copyright (c) 2025 Sunbay
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. 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 | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Extensions.Http (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
- System.Text.Json (>= 8.0.0)
-
net6.0
- Microsoft.Extensions.Http (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
-
net8.0
- Microsoft.Extensions.Http (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.0)
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.13 | 99 | 8/3/2026 |
| 1.0.12 | 97 | 7/27/2026 |
| 1.0.11 | 98 | 7/14/2026 |
| 1.0.10 | 117 | 5/19/2026 |
| 1.0.9 | 134 | 4/1/2026 |
| 1.0.8 | 115 | 3/6/2026 |
| 1.0.7 | 124 | 2/26/2026 |
| 1.0.6 | 135 | 1/28/2026 |
| 1.0.5 | 135 | 1/12/2026 |
| 1.0.4 | 127 | 12/29/2025 |
| 1.0.3 | 208 | 12/25/2025 |
| 1.0.2 | 212 | 12/25/2025 |
| 1.0.1 | 207 | 12/24/2025 |
| 1.0.0 | 210 | 12/23/2025 |