Bullmark.Sdk 0.1.0

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

Bullmark.Sdk

Honour a Bullmark voucher from your own checkout.

A customer arrives holding a voucher for your product. This library is how your server finds out what it is worth, and how you tell Bullmark you have given them that price.

Full documentation: https://developer.bullmark.net

dotnet add package Bullmark.Sdk

The shape of it

Redemption is two steps, and you own the second one. The holder reserves; the voucher burns when you say you gave the value. Nothing is spent before that, so a failed payment costs your customer nothing.

var bm = new BullmarkClient(new BullmarkOptions { ApiKey = config["Bullmark:ApiKey"]! });

// 1. What do I owe them?
var found = await bm.Vouchers.InspectAsync(code, ct);
// found.Voucher.ProductKey  → "plan.pro"
// found.Voucher.PriceUsd    → 20      (instead of RetailPriceUsd 25)

// 2. I gave them that price. Burn it.
var receipt = await bm.Vouchers.RedeemAsync(
    new RedeemRequest(ExternalRef: order.Id.ToString(), Code: code), ct);

If you only ever call RedeemAsync, you have integrated correctly.

Server-side only

The key burns vouchers. Keep it in your server's configuration — never in anything a browser downloads.

Register the client once; it is thread-safe and holds no per-request state:

services.AddHttpClient("bullmark");
services.AddSingleton(sp => new BullmarkClient(
    new BullmarkOptions { ApiKey = cfg["Bullmark:ApiKey"]! },
    sp.GetRequiredService<IHttpClientFactory>().CreateClient("bullmark")));

ExternalRef is not paperwork

It is your own order or invoice reference, and it is required, because it is the idempotency key.

// ✅ the SAME reference on every attempt
await retry.ExecuteAsync(() => bm.Vouchers.RedeemAsync(
    new RedeemRequest(ExternalRef: order.Id.ToString(), Code: code), ct));

If your HTTP client times out and retries, sending the same ExternalRef returns the first receipt with AlreadyConfirmed = true — a success, not an error. Generating a fresh reference per attempt defeats the whole mechanism and costs your customer a second voucher.

RedeemAsync throws ArgumentException before making a request when ExternalRef is missing, so this is not a mistake you can ship.

Holding one while you take payment

Optional, and worth it when payment can take a while. Always release in a finally — a reservation you forget about is a voucher your customer cannot use until it lapses.

var held = await bm.Vouchers.ReserveAsync(code, ct);
try
{
    await Charge(customer, found.Voucher.PriceUsd);
    await bm.Vouchers.RedeemAsync(
        new RedeemRequest(ExternalRef: order.Id.ToString(), Ticket: held.Token), ct);
}
finally
{
    await bm.Vouchers.ReleaseAsync(held.Token, "payment_failed", ct);
}

ReleaseAsync is safe to call when there is nothing left to release — that is what makes it safe in a finally.

Errors

try
{
    await bm.Vouchers.RedeemAsync(request, ct);
}
catch (BullmarkException ex) when (ex.Unreachable)
{
    // We never got an answer. Do NOT tell the customer their voucher is invalid —
    // it may be perfectly real.
}
catch (BullmarkException ex)
{
    // ex.Message is Bullmark's own words, written for a person: "this voucher has
    // already been used". Show it. ex.Status has the HTTP status if you need it.
}

Verifying us

Every redemption is sealed on an append-only chain. bm.Integrity.ChainAsync(code) returns that chain with the canonical payloads, so you can recompute the hashes yourself rather than take our word for it. On .NET, Axowl.Sdk.Integrity.Hashing computes the same document; the algorithm and its conformance vectors are at https://developer.bullmark.net/reference/seal-hash/.

Things worth knowing

  • BenefitMonths == 0 does not mean one month. It means the listing never stated a term. Fall back to your own pricing rules rather than inventing one.
  • Match on ProductKey, not ProductName. The display name is something a marketer can change between the voucher being issued and it being presented.
  • A voucher belonging to another brand answers 404, not 403 — "wrong brand" would confirm that a guessed code is a real one.

Licence

MIT

Product Compatible and additional computed target framework versions.
.NET 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.
  • net10.0

    • No dependencies.

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
0.1.0 120 10/4/2026