Quickstart
From a test key to a signed charge, in curl and Node.
This takes you from a test key to a successful test charge.
1. Get a test key
Keys are issued per project and environment, from the merchant dashboard or by Duevance. You get two values:
| Value | Example | Notes |
|---|---|---|
| Key | dv_test_key_0D4mXq… | Public. Sent in the Duevance-Key header. |
| Secret | dv_test_sk_9fQ2… | Shown once. Never sent; it signs your requests. |
Store the secret like a private key. If it leaks, roll the key: there is no way to show a secret again.
2. Sign a request
Every request carries three headers:
Duevance-Key: dv_test_key_…
Duevance-Timestamp: 1764756000 (Unix seconds, within 300 s of our clock)
Duevance-Signature: hex(HMAC-SHA256(secret, "{timestamp}.{METHOD}.{path?query}.{sha256hex(body)}"))
path?queryis the path and query string exactly as you send them, such as/v1/payments?limit=10. Don't re-order or re-encode the query.sha256hex(body)is the hex SHA-256 of the exact body bytes. With no body, hash the empty string (e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855).
The full rules are on Authentication.
3. Charge a test card (curl and openssl)
KEY='dv_test_key_…'
SECRET='dv_test_sk_…'
TS=$(date +%s)
BODY='{"amount":1999,"currency":"EUR","reference":"order-1001","card":{"number":"4242424242424242","expiry":"12/34","cvc":"123","holder":"Jane Doe"}}'
BODY_HASH=$(printf '%s' "$BODY" | openssl dgst -sha256 -hex | awk '{print $NF}')
SIGNATURE=$(printf '%s' "$TS.POST./v1/payments.$BODY_HASH" \
| openssl dgst -sha256 -hmac "$SECRET" -hex | awk '{print $NF}')
curl -s https://api.duevance.com/v1/payments \
-H "Content-Type: application/json" \
-H "Duevance-Key: $KEY" \
-H "Duevance-Timestamp: $TS" \
-H "Duevance-Signature: $SIGNATURE" \
-H "Idempotency-Key: order-1001-attempt-1" \
--data-raw "$BODY"
--data-raw sends the body byte for byte, so the hash you signed is the hash we compute.
3b. The same in Node
import crypto from "node:crypto";
const key = process.env.DUEVANCE_KEY;
const secret = process.env.DUEVANCE_SECRET;
async function duevance(method, target, body, idempotencyKey) {
const raw = body === undefined ? "" : JSON.stringify(body);
const timestamp = Math.floor(Date.now() / 1000).toString();
const bodyHash = crypto.createHash("sha256").update(raw).digest("hex");
const signature = crypto
.createHmac("sha256", secret)
.update(`${timestamp}.${method}.${target}.${bodyHash}`)
.digest("hex");
const headers = {
"Duevance-Key": key,
"Duevance-Timestamp": timestamp,
"Duevance-Signature": signature,
};
if (raw) headers["Content-Type"] = "application/json";
if (idempotencyKey) headers["Idempotency-Key"] = idempotencyKey;
const response = await fetch(`https://api.duevance.com${target}`, { method, headers, body: raw || undefined });
return { status: response.status, body: await response.json() };
}
const charge = await duevance("POST", "/v1/payments", {
amount: 1999,
currency: "EUR",
reference: "order-1001",
card: { number: "4242424242424242", expiry: "12/34", cvc: "123", holder: "Jane Doe" },
}, "order-1001-attempt-1");
console.log(charge.status, charge.body.status);
Sign the string you send: serialize the body once and use the same string for the hash and the request.
4. Read the answer
A test charge with 4242 4242 4242 4242 answers 201 Created:
{
"id": "pay_0D4mXqk2…",
"object": "payment",
"environment": "test",
"status": "succeeded",
"amount": 1999,
"currency": "EUR",
"captured_amount": 1999,
"refunded_amount": 0,
"reference": "order-1001",
"card": { "brand": "visa", "last4": "4242" },
"next_action": null,
"created_at": "2026-12-03T10:00:00.123Z"
}
The HTTP status already tells you the outcome:
| Status | Meaning | What to do |
|---|---|---|
201 | Succeeded, authorized, or needs 3-D Secure (requires_action) | Fulfil, or send the buyer to next_action.url |
402 | Declined or failed; the body is the payment | Show a failure; read decline_code |
202 | The acquirer's answer is unknown (processing) | Wait for the webhook, or poll the payment |
4xx other | Your request was refused; nothing was charged | Fix the request (see Errors) |
Every outcome is listed on Statuses.
5. Get told, don't poll
Create a webhook endpoint to learn when a processing payment settles, a
refund completes or a checkout session is paid. Never treat a buyer's browser coming back to
your site as proof of payment: check the payment or wait for the event.