/v1The key's application, mode and scopes. Use it to check a key works.
Pay
Pay is noncustodial: your customer pays from their own wallet straight to your DigiByte or DigiDollar address. Pay creates the payment request, watches the DigiByte blockchain and tells your server when the payment is confirmed. It never holds the money and never has your keys.
shop.example.com) and create a sandbox key (dstest_...). It is shown once: keep it in your server's configuration.Create a checkout session (curl)
curl https://pay.digistamp.co/api/pay/v1/checkout/sessions \
-H "Authorization: Bearer $DIGISTAMP_PAY_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: checkout-order-1001" \
-d '{
"amount": "19.99",
"currency": "USD",
"order_ref": "order-1001",
"description": "Order 1001",
"success_url": "https://shop.example.com/thanks",
"cancel_url": "https://shop.example.com/cart"
}'Create a checkout session (JavaScript)
// Node 18+ (built-in fetch). On your server only: the key never goes to a browser.
const res = await fetch('https://pay.digistamp.co/api/pay/v1/checkout/sessions', {
method: 'POST',
headers: {
Authorization: 'Bearer ' + process.env.DIGISTAMP_PAY_API_KEY,
'Content-Type': 'application/json',
'Idempotency-Key': 'checkout-' + order.id,
},
body: JSON.stringify({
amount: order.total, // "19.99": a decimal string, never a float
currency: 'USD', // USD, DGB or DD
order_ref: order.id,
description: 'Order ' + order.id,
success_url: 'https://shop.example.com/thanks',
cancel_url: 'https://shop.example.com/cart',
}),
});
const session = await res.json();
if (!res.ok) throw new Error(session.error.code + ': ' + session.error.message + ' (' + session.error.request_id + ')');
// Save session.id with the order, then send the customer to session.url (HTTP 303 redirect).Create a checkout session (PHP)
<?php
$ch = curl_init('https://pay.digistamp.co/api/pay/v1/checkout/sessions');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('DIGISTAMP_PAY_API_KEY'),
'Content-Type: application/json',
'Idempotency-Key: checkout-' . $orderId,
],
CURLOPT_POSTFIELDS => json_encode([
'amount' => '19.99',
'currency' => 'USD',
'order_ref' => (string) $orderId,
'success_url' => 'https://shop.example.com/thanks',
'cancel_url' => 'https://shop.example.com/cart',
]),
]);
$session = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
if ($status !== 201 && $status !== 200) {
throw new RuntimeException($session['error']['code'] . ': ' . $session['error']['message']);
}
header('Location: ' . $session['url'], true, 303);Create a checkout session (Python)
# Python 3.8+, standard library only.
import json, os, urllib.request
body = {
"amount": "19.99",
"currency": "USD",
"order_ref": order_id,
"success_url": "https://shop.example.com/thanks",
"cancel_url": "https://shop.example.com/cart",
}
req = urllib.request.Request(
"https://pay.digistamp.co/api/pay/v1/checkout/sessions",
data=json.dumps(body).encode("utf-8"),
method="POST",
headers={
"Authorization": "Bearer " + os.environ["DIGISTAMP_PAY_API_KEY"],
"Content-Type": "application/json",
"Idempotency-Key": "checkout-" + order_id,
},
)
with urllib.request.urlopen(req, timeout=20) as res: # raises HTTPError on 4xx/5xx
session = json.loads(res.read())
# Save session["id"] with the order, then redirect the customer to session["url"].Create a checkout session (PowerShell)
# Windows PowerShell 5.1 or PowerShell 7
$headers = @{
Authorization = "Bearer $env:DIGISTAMP_PAY_API_KEY"
'Idempotency-Key' = "checkout-$orderId"
}
$body = @{
amount = '19.99'
currency = 'USD'
order_ref = $orderId
success_url = 'https://shop.example.com/thanks'
cancel_url = 'https://shop.example.com/cart'
} | ConvertTo-Json
$params = @{
Method = 'Post'
Uri = 'https://pay.digistamp.co/api/pay/v1/checkout/sessions'
Headers = $headers
ContentType = 'application/json'
Body = [Text.Encoding]::UTF8.GetBytes($body)
}
$session = Invoke-RestMethod @params
$session.urlurl (https://pay.digistamp.co/c/cs_...). They choose DGB or DigiDollar and pay there.checkout.completed (and payment.confirmed) when the payment has the confirmations it needs. Verify the signature on the raw body (see Webhooks).Check a session against your order (curl)
curl https://pay.digistamp.co/api/pay/v1/checkout/sessions/cs_4fJkW2mQx9Lr7TbV0pZs1yNd \
-H "Authorization: Bearer $DIGISTAMP_PAY_API_KEY"Check a session against your order (JavaScript)
// Called from your webhook handler (or a "check payment" job), never trusted from the browser.
async function isOrderPaid(order) {
const res = await fetch('https://pay.digistamp.co/api/pay/v1/checkout/sessions/' + encodeURIComponent(order.sessionId), {
headers: { Authorization: 'Bearer ' + process.env.DIGISTAMP_PAY_API_KEY },
});
if (!res.ok) throw new Error('Pay API ' + res.status); // retry later
const s = await res.json();
return s.status === 'complete'
&& s.payment !== null && (s.payment.status === 'confirmed' || s.payment.status === 'overpaid')
&& s.order_ref === order.id
&& s.amount_currency === order.currency // "USD"
&& s.amount.value === order.total; // "19.99"
}Check a session against your order (PHP)
<?php
function digistamp_order_is_paid(array $order): bool
{
$ch = curl_init('https://pay.digistamp.co/api/pay/v1/checkout/sessions/' . rawurlencode($order['session_id']));
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('DIGISTAMP_PAY_API_KEY')],
]);
$s = json_decode(curl_exec($ch), true);
if (curl_getinfo($ch, CURLINFO_RESPONSE_CODE) !== 200) {
throw new RuntimeException('Pay API error'); // retry later
}
return $s['status'] === 'complete'
&& $s['payment'] !== null && in_array($s['payment']['status'], ['confirmed', 'overpaid'], true)
&& $s['order_ref'] === (string) $order['id']
&& $s['amount_currency'] === $order['currency']
&& $s['amount']['value'] === $order['total'];
}Check a session against your order (Python)
import json, os, urllib.parse, urllib.request
def order_is_paid(order):
req = urllib.request.Request(
"https://pay.digistamp.co/api/pay/v1/checkout/sessions/" + urllib.parse.quote(order["session_id"], safe=""),
headers={"Authorization": "Bearer " + os.environ["DIGISTAMP_PAY_API_KEY"]},
)
with urllib.request.urlopen(req, timeout=20) as res:
s = json.loads(res.read())
p = s["payment"]
return (s["status"] == "complete" and p is not None and p["status"] in ("confirmed", "overpaid")
and s["order_ref"] == order["id"] and s["amount_currency"] == order["currency"]
and s["amount"]["value"] == order["total"])Check a session against your order (PowerShell)
$uri = 'https://pay.digistamp.co/api/pay/v1/checkout/sessions/' + [Uri]::EscapeDataString($sessionId)
$s = Invoke-RestMethod -Uri $uri -Headers @{ Authorization = "Bearer $env:DIGISTAMP_PAY_API_KEY" }
$paid = ($s.status -eq 'complete') -and ($null -ne $s.payment) -and
($s.payment.status -in @('confirmed', 'overpaid')) -and ($s.order_ref -eq $orderId) -and
($s.amount_currency -eq 'USD') -and ($s.amount.value -eq '19.99')complete, its payment status is confirmed or overpaid, and amount, currency and order_ref match. Record the event id so a repeated delivery does nothing.The redirect proves nothing
?session_id=cs_... once the payment is confirmed, but anyone can open that URL. Show a "we're confirming your payment" page and fulfil only from the verified webhook or your own API check.In the sandbox nothing real moves: complete the payment with the simulator (Sandbox). When it works, create a live key (dslive_...) and a LIVE webhook endpoint, and switch.
Every request carries your secret key: Authorization: Bearer dslive_... (or the header X-Api-Key). The API reads no cookies.
dslive_... keys act on real payments; dstest_... keys reach only the sandbox. A key never sees the other mode's objects.X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset. Over the limit: 429 with Retry-After. Repeated invalid keys from one address are refused for a while.A key holds only the scopes you give it. No scope can move money, change your receiving addresses, approve a refund destination or settle fees.
| Scope | Allows | Sandbox |
|---|---|---|
payments:read | Read payment requests, their transactions, and events | yes |
payments:write | Create and cancel payment requests (and simulate, in the sandbox) | yes |
checkout:write | Create, read and expire hosted checkout sessions | yes |
invoices:read | Read invoices | no |
invoices:write | Create, send and cancel invoices | no |
links:write | Create payment links | no |
receipts:read | Read receipts | no |
reports:read | Read merchant reports | no |
refunds:write | Record a refund request (you still approve and send it from your own wallet) | no |
Never in a browser or an app
Base URL: https://pay.digistamp.co/api/pay/v1. JSON in (Content-Type: application/json, at most 64 KB), JSON out.
"19.99" or "125.5"; in an answer {"value": "19.99", "minor": "1999"} (DGB has 8 decimals and minor units are satoshis; USD and DigiDollar have 2 and minor units are cents).{"object": "list", "data": [...], "has_more", "next_cursor"}, newest first. Pass limit (1 to 100, default 20) and starting_after=<next_cursor> for the next page.Idempotency-Key (8 to 128 letters, digits or _ . : -) on every POST you might retry. The same key with the same body returns the first answer for 24 hours (with Idempotent-Replayed: true); with a different body it is refused (409 idempotency_key_reused); while the first is still running, 409 idempotency_in_progress. A 5xx frees the key so you can retry.X-Request-Id; errors repeat it as request_id. Quote it when you ask for help./v1The key's application, mode and scopes. Use it to check a key works.
/v1/paymentsA payment request (an address and an exact amount to pay), without a hosted checkout. With a sandbox key it is a test payment (id test_...).
currencyamountamount_usddescriptionorder_refmetadataexpires_in_minutescustomer_email/v1/paymentsYour payments, newest first.
limitstarting_afterstatusorder_ref/v1/payments/{id}One payment, with its transactions and confirmation counts.
/v1/payments/{id}/transactionsThe payment's on-chain outputs (txid, vout, amount, state, confirmations).
/v1/payments/{id}/receiptThe receipt of a confirmed payment (404 receipt_not_issued before that).
/v1/payments/{id}/cancelCancels a payment request that has received nothing.
/v1/payments/{id}/simulateSandbox only: plays one simulated chain step on a test payment and emits the same events as a real one.
action/v1/checkout/sessionsA hosted checkout session. Send the customer to its url.
amountcurrencyacceptsuccess_urlcancel_urlorder_refdescriptioncustomer_emailmetadataexpires_in_minutes/v1/checkout/sessionsYour checkout sessions of this mode, newest first.
limitstarting_afterorder_ref/v1/checkout/sessions/{id}One session with its payment (the paid one, else the latest). This is the call to verify an order with.
/v1/checkout/sessions/{id}/expireEnds an open session now. Refused (409 pay_payment_underway) once a payment for it has been seen.
/v1/invoicesAn invoice (a draft unless send is true).
currencyitemscustomerissue_date, due_dateterms, notes, instructionsdiscount_kind, discount_valueshippingallow_partial, accept_dgb, accept_ddsend, send_email/v1/invoicesYour invoices.
limitstarting_afterstatus/v1/invoices/{id}One invoice with its lines and the ids of its payments (payments).
/v1/invoices/{id}/sendIssues a draft (and e-mails the customer unless send_email is false).
send_email/v1/invoices/{id}/cancelCancels an invoice.
/v1/linksA payment link (pay.digistamp.co/p/<id>).
titlecurrenciesamount_modefixed_dgb, fixed_dddescription, single_use, expires_at, reference/v1/receipts/{id}A receipt, with its document and the public verify_url.
/v1/reportsTotals, sources, daily figures, refunds, fees, outstanding invoices, links and campaigns for a date range. format=csv returns CSV.
from, toformat/v1/refundsRecords a refund request. It moves nothing: send claim_url to the payer, then approve and send the refund from your own wallet in the dashboard.
paymentamountreasondestination / address/v1/eventsEvents of this mode, newest first: the same objects your webhooks receive.
limitstarting_aftertypeobject/v1/events/{id}One event.
Abridged where marked. Payer names, e-mails and messages are never in an API object (you see them in the dashboard).
payment (GET /v1/payments/{id})
{
"id": "Xb3kP0qN7vR2sT9wY1zA4c",
"object": "payment",
"livemode": true,
"status": "confirmed",
"paid": true,
"currency": "DGB",
"amount": {
"value": "1580.25000000",
"minor": "158025000000"
},
"amount_due": {
"value": "1580.25000000",
"minor": "158025000000"
},
"fee": {
"value": "7.90125000",
"minor": "790125000"
},
"fee_paid_by": "merchant",
"merchant_net": {
"value": "1572.34875000",
"minor": "157234875000"
},
"received": {
"confirmed": {
"value": "1580.25000000",
"minor": "158025000000"
},
"pending": {
"value": "0.00000000",
"minor": "0"
}
},
"usd_estimate_cents": "1999",
"address": "dgb1qexampleaddressxxxxxxxxxxxxxxxxxxxxxxx",
"attribution": "unique_address",
"confirmations_required": 6,
"late": false,
"description": "Order 1001",
"order_ref": "order-1001",
"metadata": {
"order_id": "order-1001"
},
"checkout_session": "cs_4fJkW2mQx9Lr7TbV0pZs1yNd",
"invoice": null,
"link": null,
"receipt": "Kp7Ys1Ue9Wi3Oa5Ss7Dd9g",
"hosted_url": "https://pay.digistamp.co/r/Xb3kP0qN7vR2sT9wY1zA4c",
"expires_at": "2026-11-26T15:30:00.000Z",
"first_seen_at": "2026-11-26T15:02:11.000Z",
"paid_at": "2026-11-26T15:04:03.000Z",
"created_at": "2026-11-26T15:00:00.000Z",
"transactions": [
{
"txid": "9f2c...64 hex characters...e1a0",
"vout": 0,
"amount": {
"value": "1580.25000000",
"minor": "158025000000"
},
"state": "confirmed",
"block_height": 21004321,
"confirmations": 6,
"late": false,
"first_seen_at": "2026-11-26T15:02:11.000Z"
}
]
}checkout.session (GET /v1/checkout/sessions/{id})
{
"id": "cs_4fJkW2mQx9Lr7TbV0pZs1yNd",
"object": "checkout.session",
"livemode": true,
"status": "complete",
"url": "https://pay.digistamp.co/c/cs_4fJkW2mQx9Lr7TbV0pZs1yNd",
"order_ref": "order-1001",
"description": "Order 1001",
"amount": {
"value": "19.99",
"minor": "1999"
},
"amount_currency": "USD",
"currencies": [
"DD",
"DGB"
],
"success_url": "https://shop.example.com/thanks",
"cancel_url": "https://shop.example.com/cart",
"metadata": {
"order_id": "order-1001"
},
"payment": "{ ...the payment object above... }",
"expires_at": "2026-11-26T16:00:00.000Z",
"completed_at": "2026-11-26T15:04:03.000Z",
"created_at": "2026-11-26T15:00:00.000Z"
}event (GET /v1/events/{id}, and every webhook body)
{
"id": "evt_Wq3m9ZpL0xT7cB2nV5kR8sYd1f",
"object": "event",
"type": "checkout.completed",
"api_version": "2026-11-26",
"created": "2026-11-26T15:04:03.000Z",
"livemode": true,
"data": {
"object": "{ ...the checkout.session, with its payment... }"
}
}list
{
"object": "list",
"data": [
"{ ...objects, newest first... }"
],
"has_more": true,
"next_cursor": "Xb3kP0qN7vR2sT9wY1zA4c"
}api (GET /v1)
{
"object": "api",
"version": "v1",
"livemode": false,
"application": {
"id": "0b5c6f0e-...",
"name": "My shop",
"domains": [
"shop.example.com"
]
},
"scopes": [
"checkout:write",
"payments:read",
"payments:write"
]
}payment_link (POST /v1/links)
{
"id": "Ln5Bv7Cx9Zq1Wr3Et5Yu7i",
"object": "payment_link",
"livemode": true,
"url": "https://pay.digistamp.co/p/Ln5Bv7Cx9Zq1Wr3Et5Yu7i",
"title": "Sticker pack",
"description": null,
"currencies": [
"DGB"
],
"amount_mode": "fixed",
"fixed_amount": {
"DGB": {
"value": "250.00000000",
"minor": "25000000000"
},
"DD": null
},
"single_use": false,
"uses": 0,
"status": "active",
"reference": "sku-42",
"expires_at": null,
"created_at": "2026-11-26T15:00:00.000Z"
}receipt (GET /v1/receipts/{id})
{
"id": "Kp7Ys1Ue9Wi3Oa5Ss7Dd9g",
"object": "receipt",
"livemode": true,
"number": "R-000123",
"status": "valid",
"payment": "Xb3kP0qN7vR2sT9wY1zA4c",
"document": "{ ...the receipt document... }",
"document_hash": "5e1f...64 hex characters...",
"verify_url": "https://pay.digistamp.co/v/Kp7Ys1Ue9Wi3Oa5Ss7Dd9g",
"created_at": "2026-11-26T15:04:03.000Z"
}refund (POST /v1/refunds)
{
"id": "Rf4Tg6Yh8Uj0Ik2Ol4Pm6n",
"object": "refund",
"livemode": true,
"payment": "Xb3kP0qN7vR2sT9wY1zA4c",
"status": "awaiting_destination",
"currency": "DGB",
"amount": "158025000000",
"claim_url": "https://pay.digistamp.co/refund/<private token>",
"next_steps": "Send the claim_url to the payer privately so they can give a refund address, then approve and send the refund from your own wallet in the Pay dashboard."
}error
{
"error": {
"type": "invalid_request_error",
"code": "parameter_invalid",
"message": "limit is 1 to 100.",
"param": "limit",
"request_id": "req_3nV8kQ1mZ7xW5pL2"
}
}Invoices follow the invoice view of the dashboard: number, status (draft, open, overdue, paid, canceled), currency, subtotal, discount, tax, shipping, total, amount_paid, amount_remaining, accepts, dates, bill_to, hosted_url and lines. Reports carry range, totals, bySource, daily, refunds, fees, outstandingInvoices, links and campaigns, and say plainly that they are operational records, not an accounting or tax record.
POST /v1/checkout/sessions): the amount in USD, DGB or DigiDollar, the currencies offered, your order_ref, and success and cancel URLs on one of your application's registered domains.https://pay.digistamp.co/c/<session id>. The page shows your business name, the order and the amount.complete in the same database transaction that emits payment.confirmed and checkout.completed. Other unpaid requests of the session are cancelled, so nobody is asked to pay twice.success_url with ?session_id=cs_.... Your server verifies (webhook or API) and fulfils.open, then complete or expired (after expires_in_minutes, or POST .../expire). A payment that arrives for an expired session still completes it: the money arrived.pay_currency_not_accepted.Register an https endpoint in your dashboard (Developers), for live or sandbox events, for every event type or a chosen list. Its signing secret (whsec_...) is shown once. Pay posts each event to each matching endpoint of the same mode. An event is written in the same database transaction as the change it reports, so it exists exactly when the change happened.
| Type | Meaning |
|---|---|
payment.created | A payment request was created (by the API, a checkout, a link or your page). |
payment.detected | The full amount is seen on the network, not yet in a block. |
payment.confirming | The full amount is in a block, below the confirmation depth. |
payment.partial | Less than the amount has been seen (fresh-address payments only). |
payment.confirmed | Paid at its confirmation depth: the event to fulfil on. Also sent for an overpayment, and again if a payment confirms again after a reorganization. |
payment.overpaid | Confirmed with more than asked (after or with payment.confirmed). |
payment.expired | Expired unpaid, or with less than the amount. |
payment.reorged | A confirmed payment was reorganized out of the chain: hold or undo what you fulfilled until it confirms again. |
payment.canceled | Cancelled by you, or an unused request of a completed checkout. |
payment.refunded | A refund you sent is confirmed on chain. |
invoice.paid | An invoice is paid in full. |
invoice.overdue | An invoice is past its due date, unpaid (sent once). |
fee.settled | A fee settlement you paid is verified on chain. |
checkout.completed | A checkout session's payment is confirmed. data.object is the session with its payment. |
checkout.expired | A checkout session expired unpaid. |
webhook.test | Sent only by "Send test event" in the dashboard, to check your receiver. |
POST to your URL with Content-Type: application/json; the body is the event object (below), the same as GET /v1/events/{id}.DigiStamp-Signature: t=<unix seconds>,v1=<hex>: HMAC-SHA256 with your signing secret (the whole string, whsec_ included, as the key) over <t>.<raw body>. During a secret rotation a second v1 (from the previous secret) is sent; either may match.DigiStamp-Event-Id (evt_...), DigiStamp-Event-Type, DigiStamp-Delivery-Id (one per endpoint and event), DigiStamp-Api-Version (2026-11-26).Event body
{
"id": "evt_Wq3m9ZpL0xT7cB2nV5kR8sYd1f",
"object": "event",
"type": "checkout.completed",
"api_version": "2026-11-26",
"created": "2026-11-26T15:04:03.000Z",
"livemode": true,
"data": {
"object": "{ ...the checkout.session, with its payment... }"
}
}express.raw({ type: 'application/json' }); PHP: file_get_contents('php://input')). A re-serialized body will not match.,; take t and every v1.t is more than 300 seconds from your clock (either way). Keep your server's clock synchronized.t + "." + raw body) as hex and compare it with each v1 in constant time.Verify a webhook signature (Shell (openssl))
#!/usr/bin/env bash
# Verifies a DigiStamp Pay webhook signature with openssl (exit 0: valid, 1: invalid, 2: usage).
# DIGISTAMP_WEBHOOK_SECRET=whsec_... ./verify-webhook.sh <raw-body-file> "<DigiStamp-Signature header>"
# DigiStamp-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<raw body>"> (two v1 values during a rotation).
set -f
body_file="$1"
header="$2"
secret="$DIGISTAMP_WEBHOOK_SECRET"
tolerance=300
if [ -z "$body_file" ] || [ -z "$header" ] || [ -z "$secret" ]; then
echo 'Usage: DIGISTAMP_WEBHOOK_SECRET=whsec_... ./verify-webhook.sh <raw-body-file> "<DigiStamp-Signature>"' >&2
exit 2
fi
t=""
sigs=""
for part in $(printf '%s' "$header" | tr ',' ' '); do
key=$(printf '%s' "$part" | cut -d= -f1)
val=$(printf '%s' "$part" | cut -d= -f2)
if [ "$key" = "t" ] && printf '%s' "$val" | grep -Eq '^[0-9]{1,12}$'; then t="$val"; fi
if [ "$key" = "v1" ] && printf '%s' "$val" | grep -Eq '^[0-9a-f]{64}$'; then sigs="$sigs $val"; fi
done
if [ -z "$t" ] || [ -z "$sigs" ]; then echo "invalid: malformed"; exit 1; fi
now=$(date +%s)
age=$((now - 10#$t))
if [ "$age" -lt 0 ]; then age=$((0 - age)); fi
if [ "$age" -gt "$tolerance" ]; then echo "invalid: timestamp"; exit 1; fi
# The HMAC key is the whole secret string, "whsec_" included; the message is "<t>." followed by the raw body bytes.
expected=$({ printf '%s.' "$t"; cat "$body_file"; } | openssl dgst -sha256 -hmac "$secret" -r | cut -d' ' -f1)
# Constant-time comparison: compare HMACs of both values under a random one-time key.
nonce=$(openssl rand -hex 32)
want=$(printf '%s' "$expected" | openssl dgst -sha256 -hmac "$nonce" -r | cut -d' ' -f1)
for s in $sigs; do
got=$(printf '%s' "$s" | openssl dgst -sha256 -hmac "$nonce" -r | cut -d' ' -f1)
if [ "$got" = "$want" ]; then echo "valid"; exit 0; fi
done
echo "invalid: signature"
exit 1Verify a webhook signature (JavaScript (Node))
import { createHmac, timingSafeEqual } from 'node:crypto';
// DigiStamp-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<raw body>"> (two v1 values during a secret rotation).
// rawBody must be the exact bytes received (a Buffer), never a re-serialized JSON object.
export function verifyDigiStampSignature(rawBody, header, secret, toleranceSeconds = 300, nowSeconds = Math.floor(Date.now() / 1000)) {
if (!header || !secret) return { ok: false, reason: 'missing' };
let t = null;
const sigs = [];
for (const part of String(header).split(',')) {
const [k, v] = part.trim().split('=', 2);
if (k === 't' && /^\d{1,12}$/.test(v || '')) t = Number(v);
else if (k === 'v1' && /^[0-9a-f]{64}$/.test(v || '')) sigs.push(v);
}
if (t === null || sigs.length === 0) return { ok: false, reason: 'malformed' };
if (Math.abs(nowSeconds - t) > toleranceSeconds) return { ok: false, reason: 'timestamp' };
const body = Buffer.isBuffer(rawBody) ? rawBody : Buffer.from(String(rawBody), 'utf8');
const expected = createHmac('sha256', secret).update(t + '.').update(body).digest();
const ok = sigs.some((s) => {
const given = Buffer.from(s, 'hex');
return given.length === expected.length && timingSafeEqual(given, expected);
});
return ok ? { ok: true, timestamp: t } : { ok: false, reason: 'signature' };
}Verify a webhook signature (PHP)
<?php
// DigiStamp-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<raw body>"> (two v1 values during a secret rotation).
// $rawBody must be the exact bytes received (file_get_contents('php://input')), never a re-encoded array.
function digistamp_verify_signature(string $rawBody, ?string $header, string $secret, int $tolerance = 300, ?int $now = null): string
{
if (!$header || $secret === '') {
return 'missing';
}
$t = null;
$sigs = [];
foreach (explode(',', $header) as $part) {
$kv = explode('=', trim($part));
if (count($kv) < 2) {
continue;
}
if ($kv[0] === 't' && preg_match('/^[0-9]{1,12}$/D', $kv[1])) {
$t = (int) $kv[1];
} elseif ($kv[0] === 'v1' && preg_match('/^[0-9a-f]{64}$/D', $kv[1])) {
$sigs[] = $kv[1];
}
}
if ($t === null || !$sigs) {
return 'malformed';
}
$now = $now ?? time();
if (abs($now - $t) > $tolerance) {
return 'timestamp';
}
$expected = hash_hmac('sha256', $t . '.' . $rawBody, $secret);
$ok = false;
foreach ($sigs as $s) {
if (hash_equals($expected, $s)) {
$ok = true;
}
}
return $ok ? 'valid' : 'signature';
}Verify a webhook signature (Python)
import hashlib
import hmac
import re
import time
# DigiStamp-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<raw body>"> (two v1 values during a secret rotation).
# raw_body must be the exact bytes received, never a re-serialized JSON object.
def verify_signature(raw_body, header, secret, tolerance_seconds=300, now=None):
if not header or not secret:
return False, "missing"
t = None
sigs = []
for part in header.split(","):
k, _, v = part.strip().partition("=")
v = v.split("=", 1)[0]
if k == "t" and re.fullmatch(r"[0-9]{1,12}", v):
t = int(v)
elif k == "v1" and re.fullmatch(r"[0-9a-f]{64}", v):
sigs.append(v)
if t is None or not sigs:
return False, "malformed"
now = int(time.time()) if now is None else now
if abs(now - t) > tolerance_seconds:
return False, "timestamp"
expected = hmac.new(secret.encode("utf-8"), str(t).encode("ascii") + b"." + raw_body, hashlib.sha256).hexdigest()
ok = False
for s in sigs:
ok = hmac.compare_digest(s, expected) or ok
return (True, "ok") if ok else (False, "signature")Verify a webhook signature (PowerShell)
# DigiStamp-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<raw body>"> (two v1 values during a secret rotation).
# $Body must be the exact bytes received, never a re-serialized object.
function Test-DigiStampSignature {
param([byte[]]$Body, [string]$Header, [string]$Secret, [int]$ToleranceSeconds = 300, [long]$Now = [DateTimeOffset]::UtcNow.ToUnixTimeSeconds())
if (-not $Header -or -not $Secret) { return 'missing' }
$t = $null
$sigs = @()
foreach ($part in $Header.Split(',')) {
$kv = $part.Trim().Split('=')
if ($kv.Count -lt 2) { continue }
if ($kv[0] -ceq 't' -and $kv[1] -cmatch '^[0-9]{1,12}$') { $t = [long]$kv[1] }
elseif ($kv[0] -ceq 'v1' -and $kv[1] -cmatch '^[0-9a-f]{64}$') { $sigs += $kv[1] }
}
if ($null -eq $t -or $sigs.Count -eq 0) { return 'malformed' }
if ([Math]::Abs($Now - $t) -gt $ToleranceSeconds) { return 'timestamp' }
$prefix = [Text.Encoding]::ASCII.GetBytes([string]$t + '.')
$data = New-Object byte[] ($prefix.Length + $Body.Length)
[Array]::Copy($prefix, 0, $data, 0, $prefix.Length)
[Array]::Copy($Body, 0, $data, $prefix.Length, $Body.Length)
$hmac = New-Object System.Security.Cryptography.HMACSHA256 (, [Text.Encoding]::UTF8.GetBytes($Secret))
try { $expected = $hmac.ComputeHash($data) } finally { $hmac.Dispose() }
$ok = $false
foreach ($s in $sigs) {
$diff = 0
for ($i = 0; $i -lt 32; $i++) { $diff = $diff -bor ($expected[$i] -bxor [Convert]::ToByte($s.Substring($i * 2, 2), 16)) }
if ($diff -eq 0) { $ok = $true }
}
if ($ok) { return 'valid' }
return 'signature'
}order_ref against your own order.webhook.test event.GET /v1/events lists the same events; process them through the same idempotent code.List events (curl)
curl "https://pay.digistamp.co/api/pay/v1/events?type=payment.confirmed&limit=50" \
-H "Authorization: Bearer $DIGISTAMP_PAY_API_KEY"
# the next page: starting_after = the previous answer's next_cursor
curl "https://pay.digistamp.co/api/pay/v1/events?limit=50&starting_after=evt_Qm9yZXN0aW5nRXZlbnRJZEhlcmU" \
-H "Authorization: Bearer $DIGISTAMP_PAY_API_KEY"Rotate in the dashboard (fresh Digi-ID sign-in). The new secret is shown once; the old one keeps signing alongside it for a grace period you choose (0 to 72 hours, default 24), so deploy the new secret within that time.
Errors are {"error": {"type", "code", "message", "param"?, "request_id"}} with an HTTP status. Branch on the status and type; log code and request_id; show message only to yourself. Codes from Pay's own rules start with pay_; new codes may be added, so treat an unknown code by its status.
| Status | type | code |
|---|---|---|
| 400 | invalid_request_error | parameter_invalid (see param), invalid_json, idempotency_key_invalid, destination_not_allowed, pay_invalid_input, pay_invalid_amount, pay_invalid_url, pay_currency_not_accepted |
| 401 | authentication_error | missing_api_key, invalid_api_key (unknown, revoked or expired, or the application is disabled) |
| 403 | permission_error | missing_scope, live_mode_only, test_mode_only, pay_page_suspended |
| 404 | invalid_request_error | unknown_endpoint, resource_missing (also for another page's objects), receipt_not_issued |
| 405 | invalid_request_error | method_not_allowed |
| 409 | idempotency_error | idempotency_key_reused, idempotency_in_progress |
| 409 | invalid_request_error | a state conflict, for example pay_checkout_closed, pay_payment_underway, pay_not_cancelable |
| 413 | invalid_request_error | body_too_large (64 KB) |
| 415 | invalid_request_error | unsupported_media_type (send JSON) |
| 429 | rate_limit_error | rate_limited (wait for Retry-After), too_many_failed_attempts, pay_busy (sandbox: 1,000 test payments an hour) |
| 500 | api_error | internal_error: safe to retry with the same Idempotency-Key |
| 503 | api_error | unavailable: Pay is temporarily unavailable; retry later |
Two answers come from the platform in front of the API and have a simpler shape: 429 {"error": "RATE_LIMITED"} when one address sends too many requests, and 403 {"error": "CROSS_ORIGIN_REFUSED"} for a write sent from a browser page of another site. Call the API from your server.
Pay's chain watcher is the only authority for a payment's status; it never trusts a browser or a transaction id typed by a payer. A payment counts as paid after confirmations_required confirmations (6 by default; DigiByte makes a block about every 15 seconds).
| status | Meaning |
|---|---|
awaiting_payment | Open, nothing seen yet. |
detected | The full amount is seen, unconfirmed. Do not fulfil. |
confirming | The full amount is in a block, below the confirmation depth. Do not fulfil. |
partially_paid | Some of the amount is seen (fresh-address payments only); the payer can send the rest. |
confirmed | Paid at the confirmation depth. Fulfil (paid: true). |
overpaid | Paid with more than asked, at depth. Fulfil (paid: true); settle the difference with the payer yourself. |
expired | Expired with nothing received. |
underpaid | Expired with less than the amount. |
reorged | A confirmed payment's block was replaced; waiting to confirm again. Hold fulfilment. |
needs_review | A confirmed payment was reorganized out and not seen again (or is held for review). Hold fulfilment. |
canceled | Cancelled before anything was received. |
What to fulfil on
payment.confirmed or checkout.completed event, or a payment whose status is confirmed or overpaid (the API's paid field is true exactly then), after checking amount, currency and order_ref. On payment.reorged, put the order on hold; a later payment.confirmed for the same payment releases it.A transaction in transactions is mempool, confirmed, reorged or dropped (left the network unconfirmed). A payment after expiry to its own fresh address still counts within a late window and is marked late.
attribution: unique_address), so partial payments and several transactions add up correctly.attribution: exact_amount). The payer must send exactly that amount; anything else is held for review.fee, fee_paid_by (merchant or customer, your page setting) and merchant_net.fee.settled). No API key can settle fees.dstest_... key and a TEST webhook endpoint. Sandbox keys can hold payments:read, payments:write and checkout:write; invoices, links, receipts, reports and refunds are live only.test_ and livemode: false. Their addresses are DigiByte testnet-form addresses that a mainnet wallet refuses, made from a key nobody holds. No real money can be sent, no fee accrues, and no report counts them. Hosted pages show them under a TEST banner.http://localhost with a sandbox key.POST /v1/payments/{id}/simulate with action detect, confirm, partial, overpay, expire or reorg. Each step uses the same status rules as real payments and sends the same events to your TEST endpoints. For a checkout, the customer first chooses a currency on the hosted page; the session's payment.id is then the test payment.Simulate a payment (curl)
# 1. a sandbox payment without a checkout (or take session.payment.id after choosing a currency on /c/cs_...)
curl https://pay.digistamp.co/api/pay/v1/payments \
-H "Authorization: Bearer $DIGISTAMP_PAY_TEST_KEY" \
-H "Content-Type: application/json" \
-d '{"currency": "DGB", "amount_usd": "19.99", "order_ref": "order-1001"}'
# 2. play the chain: detect, then confirm (also: partial, overpay, expire, reorg)
curl https://pay.digistamp.co/api/pay/v1/payments/test_q8Wn3vB5kT0cR7yL2sXf4a/simulate \
-H "Authorization: Bearer $DIGISTAMP_PAY_TEST_KEY" \
-H "Content-Type: application/json" \
-d '{"action": "confirm"}'Simulate a payment (JavaScript)
const api = (method, path, body) => fetch('https://pay.digistamp.co/api/pay/v1' + path, {
method,
headers: { Authorization: 'Bearer ' + process.env.DIGISTAMP_PAY_TEST_KEY, 'Content-Type': 'application/json' },
body: body ? JSON.stringify(body) : undefined,
}).then((r) => r.json());
const p = await api('POST', '/payments', { currency: 'DGB', amount_usd: '19.99', order_ref: 'order-1001' });
await api('POST', '/payments/' + p.id + '/simulate', { action: 'detect' }); // -> detected
const done = await api('POST', '/payments/' + p.id + '/simulate', { action: 'confirm' });
console.log(done.status); // "confirmed": your TEST webhook endpoint received payment.confirmedorder_ref of the session or payment against your own order before fulfilling. Re-fetch it with your key rather than trusting a request body.Idempotency-Key with every POST you might retry.Pay has no published plugin for any shop platform yet. A WooCommerce gateway is being prepared but has not been tested in a live shop. The platforms below are opportunities, not products: none of these integrations exists today.
Any of them would work the same way, with what is documented on this page:
order_ref and an Idempotency-Key, and redirects the customer.payment.reorged puts the order on hold.