Quick start

The API is JSON over HTTPS. Amounts are whole cents, times are ISO 8601 with their zone, and every request carries a key.

Base URL
https://mzbkaiqhtvfgmgsbxwjz.supabase.co/functions/v1/capture
  1. Make a test secret key

    The business makes it in the dashboard: API keys, then Make a key, with Secret key and Test. It’s shown once, so copy it into your server’s settings.

  2. Check the connection

    Run this once from your server. An answer with "ok": true means you’re connected, and the business’s dashboard marks the install step done.

    POST /ping
    curl -X POST https://mzbkaiqhtvfgmgsbxwjz.supabase.co/functions/v1/capture/ping \
      -H "Authorization: Bearer cs_sk_test_…"
    200
    { "ok": true, "kind": "secret", "mode": "test", "installed": true }
  3. Send each sale when it closes

    One request per sale, from your server, as soon as the check or order closes. The whole record is below, under Recording a sale.

  4. Go live

    Once the business presses Go live in the dashboard, swap in a live secret key. Nothing else changes.

Keys

Send the key as Authorization: Bearer … on every request. Each key belongs to one business and reaches nothing else. ChargeSecured keeps only its hash, so a lost key is revoked and replaced, never recovered.

KeyWhere it goesWhat it does
cs_sk_test_…Your server, while you buildRecords test sales, kept apart from real ones
cs_sk_live_…Your server, once the business is liveRecords real sales
cs_pk_test_…A checkout page, any addressRuns the checkout script on staging sites
cs_pk_live_…The checkout page on the business’s own websiteRuns the checkout script; refused on any other website

Secret keys never go on a web page, a receipt or an app people download. A request from a browser with a secret key is refused. If one was ever on a public page, revoke it on the dashboard’s API keys tab.

Live keys work once the business is live. Until then, use the test keys.

Recording a sale

POST /sales with a secret key, at close. The more of the record you send, the stronger the answer to a dispute.

POST /sales
curl -X POST https://mzbkaiqhtvfgmgsbxwjz.supabase.co/functions/v1/capture/sales \
  -H "Authorization: Bearer cs_sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{
    "schema": 1,
    "order_id": "VR-20931",
    "transaction_id": "TRxxxxxxxxxxxxxxxx",
    "occurred_at": "2026-11-15T03:19:00Z",
    "timezone": "America/New_York",
    "amount": 148000,
    "currency": "USD",
    "subtotal": 110000,
    "tax": 9763,
    "service_charge": 22000,
    "tip": 6237,
    "tip_chosen_by": "customer",
    "card": {
      "brand": "visa",
      "last4": "4242",
      "approval_code": "083311",
      "entry_mode": "contactless"
    },
    "items": [
      { "name": "Premium vodka, 750 ml", "quantity": 2, "unit_amount": 55000 }
    ],
    "location": { "name": "Velvet Room", "area": "Main floor", "table": "VIP 4" },
    "staff": { "server_id": "Server 118" },
    "receipt": { "signed": true, "signed_at": "2026-11-15T03:20:00Z" }
  }'
201
{
  "id": "6f0c…",
  "duplicate": false,
  "sha256": "9a41…",
  "receivedAt": "2026-11-15T03:20:02Z"
}

201 means it was saved. The same record sent again answers 200 with "duplicate": true, so retrying after a timeout is safe. A changed record with the same order_id is kept beside the first one: nothing is ever overwritten.

sha256 is the record’s place in the business’s chain of records, each one linked to the one before. A dispute response cites it, so the bank can see the record wasn’t changed after the fact.

The fields

FieldWhat it isWhy it helps
schema requiredAlways 1The version of this record
order_id requiredYour register’s id for the check or order, up to 80 charactersTies every record of one order together
occurred_at requiredWhen the sale happened, ISO 8601 with its zoneThe time of sale on the response
amount, currency requiredThe total charged, in cents, and its three-letter currencyChecked against what the processor charged
transaction_idYour payment processor’s id for the chargeMatches the sale to its dispute exactly
timezoneWhere the sale happened, as an IANA zone like America/New_YorkTimes on the response read as local time
opened_at, closed_atWhen a tab or check opened and closedShows how long the customer was there
subtotal, tax, service_charge, tipThe parts of the total, in centsAnswers “wrong amount”
tip_chosen_by, tip_chosen_atcustomer when they picked the tip on the payment screen, or staffAnswers “I never agreed to that tip”
cardbrand, last4, approval_code, and entry_mode: chip, contactless, swiped or keyedA chip or tap read answers most fraud claims
itemsUp to 200 lines: name, quantity, unit_amount in cents, and served_atAnswers “not as described” and “I don’t recognize this”
locationname, area and table of the venueShows the sale happened in person
staffserver_id and manager_id: who served and who approvedSomeone who can speak to the sale
customername, email and phone, when they gave themMastercard counts the email and phone
reservationid, name and party_sizeThe customer booked under their own name
receiptsigned and signed_at, emailed and emailed_atThe customer’s own agreement to the total
termsshown, accepted_at and the terms’ versionWhat the customer agreed to before paying
onlineThe checkout script’s id and the customer’s details for an online sale: Online checkoutVisa Compelling Evidence 3.0 and Mastercard First-Party Trust

Send it at close, not later. A record that arrives after a dispute has opened is flagged for a second look.

Never send full card numbers, security codes or passwords. Anything that looks like a full card number is refused, wherever it appears in the record. A field this table doesn’t list is refused too, so nothing unexpected is kept. A record can be up to 64 KB.

Tap receipts

Add ?receipt=1 to the same request. The answer carries a link for this sale: show it as a QR code on the customer display, print it on the receipt, or text it.

200 or 201, with ?receipt=1
{
  "id": "6f0c…",
  "duplicate": false,
  "sha256": "9a41…",
  "receivedAt": "2026-11-15T03:20:02Z",
  "receipt": {
    "url": "https://chargesecured.com/portal/receipt#…",
    "expiresAt": "2026-11-29T03:20:02Z"
  }
}

The customer checks the bill and the tip on their own phone. Looks right records their confirmation, which a dispute response then cites. Something’s wrong tells the business at once, while the charge can still be put right. Each link lasts 14 days, and each request makes a new one.

Online checkout

For “I didn’t make this purchase”, Visa looks at the customer’s earlier visits. One script on your checkout page records them.

1. On your checkout page, with a publishable key:

Checkout page
<script src="https://chargesecured.com/capture/v1.js" data-key="cs_pk_live_…"
        data-api="https://mzbkaiqhtvfgmgsbxwjz.supabase.co/functions/v1/capture" async></script>

<form data-chargesecured-checkout …>
  <div data-chargesecured-terms data-version="2026-11">Your terms of sale</div>
  <label><input type="checkbox" data-chargesecured-accept> I agree</label>
</form>

It records the checkout when the page opens, and again when the terms box is ticked, and keeps the latest id in a hidden chargesecured_checkout_id field on the form. It keeps a random device id in your website’s own storage, with no fingerprinting and nothing shared across websites, and ChargeSecured adds the IP address it sees. It never reads card or other form fields, never delays the checkout, and gives up after 2.5 seconds.

A page that sends its orders itself can call it directly:

JavaScript
const { checkoutId } = await ChargeSecured.checkout({
  terms: { version: '2026-11', text: 'Your terms of sale', accepted: true },
});

2. With each online sale, add online to the sale record, with the customer’s email and phone. Visa uses the device, the IP address, the account and the shipping address; Mastercard also counts the email, the phone and the billing address.

Part of the sale record
"customer": { "email": "[email protected]", "phone": "+1 512 555 0142" },
"online": {
  "checkout_id": "the chargesecured_checkout_id from the form",
  "account_id": "cust_884",
  "shipping": {
    "line1": "12 Pier St",
    "city": "Austin",
    "region": "TX",
    "postal_code": "78701",
    "country": "US"
  },
  "billing": { "line1": "12 Pier St", "postal_code": "78701", "country": "US" }
}

Errors

Every refusal answers with a code and a sentence. A record that was refused was not saved, so fix it and send it again.

422
{
  "error": {
    "code": "invalid_record",
    "message": "That record wasn’t saved.",
    "problems": [{ "field": "card.last4", "problem": "must be exactly the last 4 digits" }]
  }
}
  • 200 "duplicate": trueThe same record arrived twice. Nothing to do.
  • 400 invalid_requestThe body isn’t a JSON object, or it’s over 64 KB.
  • 401 invalid_keyThe key is mistyped, revoked, or missing its Bearer prefix.
  • 403 secret_key_in_browserA secret key was used from a web page. Revoke it, and use a publishable key there.
  • 403 secret_key_requiredA publishable key was sent to /sales. Sale records come from your server, with a secret key.
  • 403 origin_not_allowedA live publishable key was used on another website. It works only on the business’s own.
  • 403 not_liveA live key was used before the business went live. Use the test key until then.
  • 403 business_closedThe business’s account is closed.
  • 422 invalid_recordThe answer lists each field to fix, like above.
  • 422 card_number_not_allowedSomething looked like a full card number. Send only the last 4. Give long numeric ids a prefix, like cust_884.
  • 500 server_errorSomething went wrong on our side. Send the same record again in a minute: it’s saved once.

Contact supportBook a demo