WayForPaySDK 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package WayForPaySDK --version 1.0.2
                    
NuGet\Install-Package WayForPaySDK -Version 1.0.2
                    
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="WayForPaySDK" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="WayForPaySDK" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="WayForPaySDK" />
                    
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 WayForPaySDK --version 1.0.2
                    
#r "nuget: WayForPaySDK, 1.0.2"
                    
#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 WayForPaySDK@1.0.2
                    
#: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=WayForPaySDK&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=WayForPaySDK&version=1.0.2
                    
Install as a Cake Tool

WayForPaySDK

NuGet License: MIT .NET

A modern .NET SDK for WayForPay payment gateway integration. This library provides a type-safe, async-first API for all WayForPay operations.

Features

Complete API Coverage

  • Purchase operations (standard and with regular payments)
  • Charge operations (with token and regular payments)
  • Refund and Settlement operations
  • Transaction status checks and verification
  • Invoice creation
  • 3D-Secure support

Developer Experience

  • Async/await pattern throughout
  • Strong typing with nullable reference types
  • Comprehensive XML documentation
  • Dependency injection support
  • Multi-framework targeting (.NET 8.0, 9.0, 10.0)
  • ASP.NET Core webhook middleware

Production Ready

  • Secure MD5 signature generation
  • Automatic request/response validation
  • Structured error handling
  • Comprehensive test coverage

Installation

dotnet add package WayForPaySDK

Or via Package Manager Console:

Install-Package WayForPaySDK

Quick Start

1. Configuration

Add WayForPay settings to your appsettings.json:

{
  "WayForPay": {
    "MerchantAccount": "your_merchant_account",
    "MerchantSecretKey": "your_secret_key",
    "MerchantDomainName": "example.com"
  }
}

2. Service Registration

Register WayForPaySDK in your DI container:

// Program.cs or Startup.cs
builder.Services.AddWayForPay(configuration.GetSection("WayForPay"));

3. Basic Usage

public class PaymentService
{
    private readonly IWayForPayClient _client;

    public PaymentService(IWayForPayClient client)
    {
        _client = client;
    }

    public async Task<PurchaseResponse> CreatePaymentAsync()
    {
        var request = new PurchaseRequest
        {
            OrderReference = "ORDER-12345",
            Amount = 100.50m,
            Currency = Currency.UAH,
            OrderDate = DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
            ProductName = ["Test Product"],
            ProductCount = [1],
            ProductPrice = [100.50m]
        };

        return await _client.CreatePurchaseAsync(request);
    }
}

Usage Examples

Creating a Payment

var purchase = await _client.CreatePurchaseAsync(new PurchaseRequest
{
    OrderReference = $"ORDER-{DateTime.UtcNow:yyyyMMddHHmmss}",
    Amount = 250.00m,
    Currency = Currency.UAH,
    OrderDate = DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
    ProductName = ["Premium Subscription"],
    ProductCount = [1],
    ProductPrice = [250.00m],
    ClientFirstName = "John",
    ClientLastName = "Doe",
    ClientEmail = "john.doe@example.com",
    ClientPhone = "380501234567"
});

Charging with Token

var charge = await _client.ChargeWithTokenAsync(new ChargeRequest
{
    OrderReference = "ORDER-67890",
    Amount = 50.00m,
    Currency = Currency.UAH,
    OrderDate = DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
    Token = "saved_card_token"
});

Refunding a Transaction

var refund = await _client.RefundAsync(new RefundRequest
{
    OrderReference = "ORDER-12345",
    Amount = 100.50m,
    Currency = Currency.UAH,
    Comment = "Customer requested refund"
});

Checking Transaction Status

var status = await _client.CheckStatusAsync(new StatusRequest
{
    OrderReference = "ORDER-12345"
});

if (status.TransactionStatus == TransactionStatus.Approved)
{
    // Payment successful
}

Webhook Handling (ASP.NET Core)

// Register webhook handler
builder.Services.AddWayForPayWebhooks();

// In your controller
[ApiController]
[Route("api/webhooks")]
public class WebhookController : ControllerBase
{
    private readonly IWayForPayWebhookHandler _handler;

    public WebhookController(IWayForPayWebhookHandler handler)
    {
        _handler = handler;
    }

    [HttpPost("wayforpay")]
    public async Task<IActionResult> HandleWebhook([FromBody] WebhookRequest webhook)
    {
        if (!_handler.VerifySignature(webhook))
        {
            return Unauthorized();
        }

        // Process the webhook
        return Ok();
    }
}

Documentation

For detailed documentation, see the docs folder:

Supported Operations

Operation Method Description
Purchase CreatePurchaseAsync Create a new payment
Charge ChargeAsync Charge a card
Charge with Token ChargeWithTokenAsync Charge using saved token
Refund RefundAsync Refund a transaction
Settlement SettleAsync Settle a transaction
Void VoidAsync Cancel a transaction
Check Status CheckStatusAsync Check transaction status
Verify VerifyAsync Verify merchant signature
Create Invoice CreateInvoiceAsync Create payment invoice
Complete 3DS Complete3DSAsync Complete 3D-Secure

Requirements

  • .NET 8.0, 9.0, or 10.0
  • Microsoft.Extensions.DependencyInjection 9.0+
  • Microsoft.Extensions.Http 9.0+
  • Microsoft.AspNetCore.App (for webhook support)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

Acknowledgments

  • Built for the Ukrainian payment ecosystem
  • Powered by WayForPay
Product Compatible and additional computed target framework versions.
.NET 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 is compatible.  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 is compatible.  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. 
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.3.1 102 3/10/2026
1.3.0 101 3/9/2026
1.2.2 98 2/19/2026
1.2.1 103 1/15/2026
1.2.0 106 1/12/2026
1.1.0 104 1/12/2026
1.0.3 108 1/12/2026
1.0.2 111 1/9/2026
1.0.1 106 1/9/2026
1.0.0 108 1/9/2026

Initial release with full WayForPay API support. See CHANGELOG.md for details.