TapPayments.Net 1.0.1

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

TapPayments.Net

License: MIT .NET GitHub stars NuGet

TapPayments.Net

The missing .NET SDK for Tap Payments — the payment gateway powering 100,000+ businesses across MENA (cards, mada, KNET, Benefit, Apple Pay, Google Pay).

using TapPayments;
using TapPayments.Models;

var client = new TapClient("sk_test_...");

// Create a charge — for 3DS / local schemes the response is INITIATED
// with a transaction.url: redirect the customer there.
var charge = await client.CreateChargeAsync(new CreateChargeRequest
{
    Amount = 150,
    Currency = "SAR",
    Description = "Order #1234",
    Customer = new TapCustomer
    {
        FirstName = "Ahmed",
        LastName = "Ali",
        Email = "ahmed@example.com",
        Phone = new TapPhone { CountryCode = "966", Number = "500000001" }
    },
    Source = new TapSource { Id = TapSources.All }, // hosted checkout
    Redirect = new TapRedirect { Url = "https://myshop.com/payment/return" },
    Post = new TapPost { Url = "https://myshop.com/payment/webhook" } // the reliable signal
});

if (charge.IsPendingRedirect)
    return Redirect(charge.Transaction.Url);

Always set post.url. Browser redirects are unreliable; the webhook is the only guaranteed notification of the final state.

Authorize then capture

// Hold funds without capturing (credit cards only)
var auth = await client.CreateAuthorizationAsync(new CreateAuthorizationRequest
{
    Amount = 500,
    Currency = "SAR",
    Customer = new TapCustomer { FirstName = "Ahmed", Email = "ahmed@example.com" },
    Source = new TapSource { Id = "tok_..." }, // single-use token
    Redirect = new TapRedirect { Url = "https://myshop.com/payment/return" },
    Post = new TapPost { Url = "https://myshop.com/payment/webhook" }
});

// ...later: capture the full or partial amount
var captured = await client.CaptureAuthorizationAsync(auth.Id, amount: 450, currency: "SAR");

// ...or release the hold
await client.VoidAuthorizationAsync(auth.Id);

Auto capture/void windows are also supported:

Auto = new TapAuto { Type = "VOID", Time = 48 } // auto-void after 48h (1–168h)

Refunds

var refund = await client.CreateRefundAsync(new CreateRefundRequest
{
    ChargeId = "chg_...",
    Amount = 50,          // partial refund; omit amount handling for full
    Currency = "SAR",
    Reason = "Customer requested"
});

Tokens

Tokens are single-use and expire within minutes — never store or reuse them.

var token = await client.CreateTokenAsync(new CreateTokenRequest
{
    Card = new TapCardDetails
    {
        Number = "4111111111111111",
        ExpMonth = 12, ExpYear = 2028, Cvc = "123",
        Name = "Ahmed Ali"
    }
});

// A saved card.id can NEVER be used as source.id — tokenize it first:
var reuse = await client.CreateTokenFromSavedCardAsync(new CreateTokenFromSavedCardRequest
{
    SavedCard = new TapSavedCard { CardId = "card_...", CustomerId = "cus_..." }
});

Customers

var customer = await client.CreateCustomerAsync(new CreateCustomerRequest
{
    FirstName = "Ahmed",
    LastName = "Ali",
    Email = "ahmed@example.com"
});

var stored = await client.RetrieveCustomerAsync(customer.Id);

Webhook validation

Every webhook carries a hashstring header — HMAC-SHA256 of a canonical field string, keyed with your secret API key. Verify before acting on any payload:

using TapPayments.Webhooks;

bool ok = TapWebhookValidator.IsValid(
    jsonPayload: rawBody,
    hashstringHeader: Request.Headers["hashstring"],
    secretKey: "sk_live_...",
    objectType: "charge" /* charge | authorize | refund | invoice */);

if (!ok) return Unauthorized();

The canonical string follows Tap's official scheme (x_id…x_amount…x_currency…x_gateway_reference…x_payment_reference…x_status…x_created), with the amount formatted to the currency's ISO decimals (3 for BHD/KWD/OMR/JOD, 2 for the rest).

ASP.NET Core DI

builder.Services.AddTapPayments("sk_test_...");
// ...or
builder.Services.AddTapPayments(o =>
{
    o.SecretKey = builder.Configuration["Tap:SecretKey"];
});

Test mode

Tap keys are self-serve from the Tap dashboard — sk_test_... for sandbox, sk_live_... for production. Integration tests use TAP_SECRET_KEY from the environment and skip gracefully when it is absent.

License

MIT — see LICENSE.

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 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. 
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.1 45 10/8/2026
1.0.0 43 10/8/2026