Developer docs
Accept DigiByte from your own code
Prefer clicking to curl? Download the Postman collection
(variables for baseUrl and apiKey).
Quickstart — 5 minutes#
The API lives at https://api.pay.dgbwallet.app; the hosted checkout and the JS embed are served from
https://pay.dgbwallet.app. Every request body is JSON, and authenticated calls send
Authorization: Bearer <your API key>.
1. Get an API key#
Sign in with Digi-ID (scan a QR with your DigiByte wallet; no password),
open the dashboard's API keys tab and create a key. The full key (dgp_…) is shown once: put it in your
secrets manager.
Setting up without a browser (self-hosting, CI)? One unauthenticated call creates an account, its first store and a key. It is limited to 5 sign-ups per hour from one address.
curl -X POST https://api.pay.dgbwallet.app/v1/pay/merchants \
-H "Content-Type: application/json" \
-d '{ "displayName": "My Shop", "addressOrXpub": "dgb1q...", "webhookUrl": "https://shop.example/digipay/webhook" }'
The response contains apiKey, storeId and, because a webhook URL was given, webhookSecret. Both secrets are shown only in this response. Accounts made this way already have a receive address, so skip to step 3.
2. Set a receive address#
A Digi-ID account starts with a Default Store that has nowhere to send money yet: creating a session now returns
400 with store has no receive address or xpub configured. Get the store id from
GET /v1/pay/stores, then give it an account-level xpub (a fresh address for every invoice) or a single
dgb1… address, plus your webhook URL:
curl -X PATCH https://api.pay.dgbwallet.app/v1/pay/stores/$STORE_ID \
-H "Authorization: Bearer $DIGIPAY_KEY" \
-H "Content-Type: application/json" \
-d '{ "addressOrXpub": "xpub6...", "webhookUrl": "https://shop.example/digipay/webhook" }'
The first time a webhook URL is saved, the response includes webhookSecret. Save it now: later responses
return null. Lost it? Rotate the secret
to get a new one. (The dashboard's Store settings and Webhook tabs do the same without curl.)
3. Create a session#
From your server, create a payment session with the amount in DGB:
curl -X POST https://api.pay.dgbwallet.app/v1/pay/sessions \
-H "Authorization: Bearer $DIGIPAY_KEY" \
-H "Idempotency-Key: order-4201" \
-H "Content-Type: application/json" \
-d '{ "amount": 12.5, "label": "Order #4201" }'
The response (shortened here) carries everything the buyer needs:
{
"id": "ses_8kq2x7m4n9p3r6t1",
"storeId": "sto_4fj8w2k9m3n7p5q1",
"address": "dgb1qexampleaddress",
"amount": 12.5,
"status": "pending",
"uri": "digibyte:dgb1qexampleaddress?amount=12.5&label=Order%20%234201",
"checkoutUrl": "https://pay.dgbwallet.app/pay/ses_8kq2x7m4n9p3r6t1",
"expiresAt": "2026-11-26T12:30:00Z"
}
Send the buyer to checkoutUrl, or show uri as a QR code in your own page. Keep id with your order.
4. Pay it on a testnet store, without real coins#
Make a second store on testnet (or regtest), give it a testnet address and your
webhook URL, and create the session there. The sandbox can then play the buyer: each advance call moves
the session one step, pending → seen → paid → confirmed, sends the same webhooks a real payment would and
updates any open checkout.
# 1. A testnet store (note its id), then its address and your webhook URL
curl -X POST https://api.pay.dgbwallet.app/v1/pay/stores \
-H "Authorization: Bearer $DIGIPAY_KEY" -H "Content-Type: application/json" \
-d '{ "name": "Testnet", "network": "testnet" }'
curl -X PATCH https://api.pay.dgbwallet.app/v1/pay/stores/$TEST_STORE_ID \
-H "Authorization: Bearer $DIGIPAY_KEY" -H "Content-Type: application/json" \
-d '{ "addressOrXpub": "dgbt1q...", "webhookUrl": "https://shop.example/digipay/webhook" }'
# 2. A session on that store (note its id)
curl -X POST https://api.pay.dgbwallet.app/v1/pay/sessions \
-H "Authorization: Bearer $DIGIPAY_KEY" -H "Content-Type: application/json" \
-d '{ "amount": 12.5, "storeId": "sto_..." }'
# 3. Play the buyer. Run it three times: seen, paid (1 confirmation), confirmed (6)
curl -X POST https://api.pay.dgbwallet.app/v1/pay/test/sessions/$SESSION_ID/advance \
-H "Authorization: Bearer $DIGIPAY_KEY"
To jump straight to a step, send a body. to is seen, paid or
confirmed; confirmations sets the count (6 is final):
{
"to": "paid",
"confirmations": 3
}
Every call answers with where the session is now:
{
"id": "ses_8kq2x7m4n9p3r6t1",
"status": "paid",
"confirmations": 3,
"receivedSatoshis": 1250000000,
"paidTxid": "c4de7f12a34bc6de3e9f1d7b5a2c3f7e8b4d1a6c9e5f2a8d3b7c1e4f6a9d2c5"
}
Only test stores. Advancing a session on a mainnet store answers 400
(advance only works on testnet or regtest stores), so it can never fake a real payment. The call needs the
API key of the account that owns the session.
No account yet? POST /v1/pay/test/demo-session makes a throwaway ses_demo_…
session that anyone can advance without a key. It's for watching the checkout; demo stores have no webhook.
5. Receive and verify the webhooks#
The calls in step 4 sent session.seen, session.paid and
session.confirmed to your webhook URL. On your side, check the X-DigiPay-Signature
header against an HMAC-SHA256 of the raw request body before you parse it. Reject anything that doesn't match with
401:
const crypto = require('crypto');
const express = require('express');
const app = express();
function verifyDigiPay(rawBody, header, secret) {
if (typeof header !== 'string' || !header.startsWith('sha256=')) return false;
const expected = Buffer.from(
crypto.createHmac('sha256', secret).update(rawBody).digest('hex'));
const provided = Buffer.from(header.slice('sha256='.length));
// timingSafeEqual throws on different lengths, so check that first.
return provided.length === expected.length &&
crypto.timingSafeEqual(expected, provided);
}
app.post('/digipay/webhook', express.raw({ type: 'application/json' }), (req, res) => {
const ok = verifyDigiPay(req.body, req.headers['x-digipay-signature'],
process.env.DIGIPAY_WEBHOOK_SECRET);
if (!ok) return res.status(401).end();
const event = JSON.parse(req.body.toString('utf8'));
// De-duplicate on event.session.id + event.event, then update the order.
res.status(200).end();
});
Nothing arrived? Ask DigiPay to send a signed webhook.test event right now. The response tells you what your
server answered, and the dashboard's Webhooks tab lists every delivery:
curl -X POST https://api.pay.dgbwallet.app/v1/pay/stores/$TEST_STORE_ID/webhook/test \
-H "Authorization: Bearer $DIGIPAY_KEY"
# -> { "ok": true, "webhookUrl": "https://shop.example/digipay/webhook", "deliveryId": "wdel_...", "statusCode": 200, "error": null }
That's a working integration. When a real payment lands on your mainnet store you'll receive the same events the same way. Python, PHP and C# versions are in the API reference, and the SDKs ship a ready-made verifier.
Testing without real money#
- Testnet store + sandbox (step 4): the full flow, webhooks included, with no coins at all.
advancemoves your own testnet or regtest sessions and fires the real events. - Testnet coins: the same store also takes real DigiByte testnet payments. DigiPay watches testnet for it, so a testnet payment produces the same states and events as a mainnet one. Receive addresses are checked against the store's network.
- Test webhook (step 5): check that your receiver is reachable and verifies signatures. Test events are sent once and never retried.
- Demo sessions: see the checkout UI change state without an account. No key, no webhooks (try it (opens in a new tab)).
- A small real payment: the final check before you go live. You can record a refund afterwards (see refunds).
Developing locally#
Running DigiPay yourself? Start the API in Development with DigiPay:DevSignIn=true and the
sign-in page shows a Sign in as dev merchant button, so you can use the dashboard without a Digi-ID wallet. The button
never appears outside Development. Create a regtest or testnet store there and step 4 works the same against your local API.
The web app asks the API from its own server, so to the API every merchant signing in looks like one client. Set the same secret as
DigiPay:TrustedClientKey on both the API and the web app, and the web app passes on each visitor's address,
so the sign-in limit (10 a minute) counts each visitor separately. Without it, everyone signing in through the web app shares that
limit. The Development settings of both apps already set a local key.
The Pay with DigiByte Wallet and Sign in with DigiByte Wallet buttons open https://dgbwallet.app.
To point them at another deployment of the wallet (for example a staging one), set DigiPay:WalletUrl on the web app.
The wallet checks the address network, so the mainnet dgbwallet.app can't pay a testnet store; scan the QR code with a testnet wallet instead.
Sign-in through the wallet needs an API the wallet can reach, so it doesn't complete against localhost.
Both buttons tell the wallet how to come back: the pay link is {wallet}/pay?return={this page}#digibyte:… and the
sign-in link adds &return={the dashboard page being signed in to}. Once the payment is sent or the sign-in approved, the wallet shows
Return to {host}; it never goes back by itself. In the installed wallet app it opens that page in the browser, not inside the wallet. It accepts only https addresses (http only on localhost), and for sign-in only an
address on the same site as the Digi-ID domain (localhost may use another port, so web on 5252 and API on 5008 work).
How a payment flows#
Each session moves through these states. Your webhook hears every change.
| Status | Meaning | Checkout shows |
|---|---|---|
pending | Waiting for a payment. | Waiting |
seen | A payment is in the mempool, not yet in a block. | Detected |
paid | One confirmation (about 15 seconds on DigiByte). Safe to fulfil most orders. | Paid |
confirmed | Six confirmations. Fully settled. | Confirmed |
underpaid | Less than 99% of the amount arrived. | Underpaid |
expired | Nothing arrived before expiresAt (30 minutes unless the store or request sets another). | Expired |
refunded | You recorded a refund for a paid session. | Refunded |
voided | You cancelled an unpaid session. | Cancelled |
The hosted checkout shows a QR code, an Open in wallet button for an installed wallet app, a Pay with DigiByte Wallet button that opens the DigiByte Wallet in the browser with the address and amount filled in, a countdown and a live status pill that updates as the transaction moves. Once a payment is detected the QR code is replaced by the confirmation progress. DigiPay derives a fresh address for every invoice in xpub mode, so payments can't be linked to each other.
Stores and receive addresses#
An account owns one or more stores. Each store has its own receive address, webhook, default expiry and sessions, which suits several shops, a tip jar, or a separate testnet store.
- Xpub (recommended). Paste your BIP84 account-level extended public key (
xpub6…). DigiPay derives a new address for every invoice: no reuse. - Single address. Paste one
dgb1…. Every invoice shares it, so your payment history is linked. Fine for a tip jar.
In the DigiByte Wallet app, copy the xpub from Settings → Share xpub (watch-only). It can watch payments; it can't spend them.
Hosted checkout and the embed#
Redirect the buyer to checkoutUrl, or open the checkout over your own page with the JS embed (live demo (opens in a new tab)):
<script src="https://pay.dgbwallet.app/embed/digipay.js"></script>
<button data-digipay-checkout data-session-id="ses_...">Pay with DigiByte</button>
Match your shop's theme (optional). The checkout follows the shopper's own light or dark setting. To fix it, add
data-theme="light" or "dark" to the button, pass theme to
DigiPay.checkout(), or append ?theme=light to checkoutUrl.
Other values are ignored, and the shopper's own setting is never changed.
<button data-digipay-checkout data-session-id="ses_..." data-theme="light">Pay with DigiByte</button>
<script>DigiPay.checkout({ sessionId: 'ses_...', theme: 'dark' });</script>
<!-- or redirect to: https://pay.dgbwallet.app/pay/ses_...?theme=light -->
Know when it's paid. Give DigiPay.checkout() an onStatus callback to follow
every status change, and onSuccess to act once the payment is confirmed. The modal stays open for
closeDelay milliseconds (2500 by default) so the buyer sees "Payment confirmed", then closes:
<script src="https://pay.dgbwallet.app/embed/digipay.js"></script>
<script>
DigiPay.checkout({
sessionId: 'ses_...',
// Every status change: pending, seen, paid, confirmed, underpaid, expired, refunded, voided
onStatus: function (e) {
document.getElementById('order-status').textContent = e.status;
},
// Once, when the payment is confirmed (6 confirmations)
onSuccess: function (e) {
window.location.href = '/orders/thanks?session=' + encodeURIComponent(e.sessionId);
},
closeDelay: 1500 // ms the modal stays open after "confirmed"
});
</script>
Without onSuccess, the modal closes and the page goes to the session's returnUrl, if you
set one when creating it. A browser callback is a hint, not proof: fulfil orders from the webhook (or check
GET /v1/pay/sessions/{id}). All options and the raw embed messages
are in the API reference.
Safe retries#
Send an Idempotency-Key header on the create call (any string up to 255 characters; your order id is a natural fit).
Calling again with the same key within 24 hours returns the same session, so a double-clicked Buy button never makes two invoices.
Webhooks#
Every state change sends a signed POST to the store's webhook URL. Events:
session.seen, session.paid, session.confirmed,
session.underpaid, session.expired, session.refunded,
session.voided, and webhook.test when you ask for one.
The events table says exactly when each fires.
X-DigiPay-Event: the event name (also in the body asevent).X-DigiPay-Signature:sha256=followed by the hex HMAC-SHA256 of the raw body, keyed with the store's webhook secret.X-DigiPay-Delivery: the id of this delivery attempt (wdel_…). Each retry or replay gets a new one, so use it for logging, not for de-duplication.
Retries. If your server can't be reached, times out, or answers 5xx, 408 or
429, DigiPay tries again after 1 minute, 5 minutes, 30 minutes, 2 hours and 6 hours, then stops. Other
4xx answers aren't retried. Every attempt appears in the dashboard's delivery log, where Replay sends it again.
De-duplicate on the session. Retries and replays mean you can receive the same event more than once, and each one is rebuilt from
the session's current state. Treat session.id plus event as the key, and let
session.status decide what your order should look like. Answer 200 to events you don't use.
Late payments#
If a buyer pays after expiry, DigiPay still reconciles: it keeps watching expired sessions for three days. The session moves to
paid or confirmed and the usual event fires, so your server needs no special case.
If the payment already has six confirmations when DigiPay sees it, you get session.confirmed without a
session.paid first.
Donation button#
A tip jar needs no server and no session. Link to DigiPay's hosted tip page with your address, or let the embed script draw the button.
Only to is required; amount (DGB), name and label are optional.
<a href="https://pay.dgbwallet.app/pay/button?to=dgb1q...&name=My%20Blog&label=Thanks!">Tip in DGB</a>
<script src="https://pay.dgbwallet.app/embed/digipay.js"></script>
<span data-digipay-button data-address="dgb1q..." data-name="My Blog" data-amount="5">Tip DGB</span>
The embed swaps the element for a button that opens the tip page in a new tab (add data-theme to fix its theme,
and data-logo="dgb" or data-logo="https://…" to show the DigiByte logo or your own image on it).
Using an xpub store? GET /v1/pay/stores/{id}/donation-address returns a stable address reserved for donations,
and the dashboard's Donation tab builds the snippet for you.
Accepting DigiDollar too? Add store (your store id) to the link, or data-store to the embed: the tip page then
offers DGB and DigiDollar, using your store's fixed DD donation address, and drops DigiDollar again if you turn it off. currency=DD
(data-currency) opens it on DigiDollar, and ddAmount (data-dd-amount) suggests an amount in
dollars; a DGB amount is never shown as DD. The Donation tab's Accept DigiDollar too option builds this for you.
<script src="https://pay.dgbwallet.app/embed/digipay.js"></script>
<span data-digipay-button data-address="dgb1q..." data-store="sto_..." data-currency="DD" data-dd-amount="5">Tip in DGB or DD</span>
DigiDollar (beta)#
A store can also accept DigiDollar (DD), the USD-pegged stablecoin: 1 DD = $1. Turn it on in the dashboard's Settings under
Accept DigiDollar. For now, DD is offered only through the API: create a session with "currency": "DD"
and amountCentsDd (100 to 10,000,000 cents), and each session gets a fresh DD… address.
Once DigiPay switches DigiDollar on beyond the API, a store with it on also gets DD on the POS till, in payment links
and one-off payments (priced in dollars, with no rate), as its default currency, and in the sales totals and CSV export, always kept apart
from DGB. Payments priced in a regular currency (payment links and POS sales, or your own code with buyerChoice: true)
also let the buyer pick DGB or DD at checkout: whichever they pay in locks the payment, and anything they send in the other currency is
flagged for you to refund. The donation page can take DD tips too (see Donation button).
DigiDollar goes straight to your own wallet, like DGB. In your DigiByte Wallet, open Settings → DigiDollar key for DigiPay, copy the key and paste it into the store's DigiDollar card in the dashboard. DigiPay shows the first address the key gives: check it matches the one your wallet shows, then save. Every DD payment then gets a new address from that key, and DigiPay never holds DD or any private key. You can use the same key for several stores; they share one address sequence, so no address is used twice. If a buyer sends DD by mistake (an extra payment in the other currency), it's already in your wallet: refund it from there. Because DigiPay gives out a new address for every payment, including ones never paid, use Look further for DigiDollar on your wallet's recovery page if some DD you were paid doesn't show. DigiPay reads DigiDollar payments from the public DigiByte explorer; while it can't be reached, DD payments wait and confirm once it's back, and DGB keeps working.
SDKs#
On Node, Python or .NET, the official SDKs wrap all of the above (sessions, stores, webhook verification, deliveries, CSV export) behind a typed client, and raise one DigiPayError type with the HTTP status.
- Node:
npm install @dgbwallet/digipay(Node 18+, ESM and CJS) - Python:
pip install digipay(Python 3.10+) - .NET:
dotnet add package DigiPay(net8.0 and net9.0)
Running WooCommerce? Use the WooCommerce plugin instead of writing code.
Selling in person#
Taking DGB at a counter rather than on a website? The POS guide covers pairing a tablet, taking a payment, refunds, closing a shift and the audit trail.
Next#
- Read the API reference for every endpoint and field.
- Pick an SDK, or clone a sample store (opens in a new tab).
- Sign in and create your first key.