One API for every provider you'll ever connect
Integrate once, against a predictable REST API with idempotent writes, signed webhooks and the same response shape whichever acquirer handled the payment. Then let your payments team tune routing without filing a ticket.
Quickstart: take a test payment in four steps
Create a sandbox account
You get a publishable key for client-side code and a secret key for your server. Test keys start with
pk_test_andsk_test_.Add hosted fields to your checkout
Our script renders secure card inputs in isolated iframes and returns a token. Card data never touches your page's JavaScript.
Create the payment from your server
Send the token, amount and currency with your secret key and an idempotency key.
Handle the webhook
Verify the signature, then fulfil the order when you receive
payment.authorisedorpayment.captured.
<!-- checkout.html --> <div id="card"></div> <script src="https://js.htechpay.co.uk/v1/fields.js"></script> <script> const fields = HTechPay.fields("pk_test_..."); fields.mount("#card"); form.onsubmit = async (e) => { e.preventDefault(); const { token } = await fields.tokenise(); await fetch("/pay", { method: "POST", body: token }); }; </script>
import HTechPay from "@htechpay/node"; const htp = new HTechPay(process.env.HTECHPAY_SECRET_KEY); const payment = await htp.payments.create({ amount: 4999, // minor units: £49.99 currency: "GBP", payment_method: token, reference: order.id, }, { idempotencyKey: `order-${order.id}` });
import os, htechpay htp = htechpay.Client(os.environ["HTECHPAY_SECRET_KEY"]) payment = htp.payments.create( amount=4999, # minor units: £49.99 currency="GBP", payment_method=token, reference=order.id, idempotency_key=f"order-{order.id}", )
curl https://api.htechpay.co.uk/v1/payments \ -H "Authorization: Bearer sk_test_..." \ -H "Idempotency-Key: order-10423" \ -d amount=4999 -d currency=GBP \ -d payment_method=tok_7Hq2vX9pLm -d reference=10423
Endpoints and package names shown reflect the planned v1 API.
A sandbox that fails on purpose
Real integrations break on declines and outages, not on the happy path. The sandbox lets you trigger every outcome deterministically, so you can test your error handling and routing rules before going live.
| Test card ending | Outcome | What to check in your integration |
|---|---|---|
…0001 | Approved | Order fulfilled on payment.authorised |
…0091 | Soft decline on first route, approved on second | Your rules include a second route; one result is returned |
…0043 | Hard decline (stolen card) | No retry; your checkout shows a neutral message |
…3155 | 3-D Secure challenge required | Challenge window renders and completes |
…0504 | Provider timeout | Cascade to next route; no duplicate charge |
…0500 | Simulated acquirer outage | Health check skips the route |
Full test numbers are listed in the documentation. Never use real card numbers in the sandbox.
Webhooks you can trust
Every webhook is signed with HMAC-SHA256 using your endpoint secret, and includes a timestamp so you can reject replays. If your endpoint doesn't return a 2xx, we retry with exponential back-off for up to 72 hours, and you can replay any event from the dashboard.
Events are delivered at least once, so make your handler idempotent by recording the event ID.
Core events
payment.authorised,payment.captured,payment.failedpayment.retried, with details of each attemptrefund.succeeded,refund.faileddispute.opened,dispute.closedpayment_method.updated, when a network token or the account updater refreshes a cardprovider.health_changed
import crypto from "node:crypto"; function verify(rawBody, header, secret) { // header: "t=1764500000,v1=5f2b..." const { t, v1 } = Object.fromEntries( header.split(",").map(p => p.split("="))); if (Math.abs(Date.now()/1000 - Number(t)) > 300) throw new Error("Webhook timestamp too old"); const expected = crypto.createHmac("sha256", secret) .update(`${t}.${rawBody}`).digest("hex"); return crypto.timingSafeEqual( Buffer.from(expected), Buffer.from(v1)); }
API conventions
Versioning
The version is pinned per account. Breaking changes ship as new versions with at least 12 months' support for the previous one, announced in the changelog.
Errors
Every error has an HTTP status, a stable machine-readable code, a human-readable message and a request ID to quote to support.
Rate limits
Limits are generous and per account, published in the documentation. A 429 response includes Retry-After.
Amounts
Always integers in the currency's minor unit, such as pence or cents, with ISO 4217 currency codes. No floating-point rounding surprises.
Pagination
Cursor-based, stable under concurrent writes. Filter by date, status, provider or your own reference.
Metadata
Attach your own key-value pairs to payments and route on them. Never put card data or sensitive personal data in metadata.
Developer questions
Can I use my own payment form instead of hosted fields?
You can send card data to our API directly from your server, but then card data passes through your systems and your PCI DSS scope grows significantly, usually to SAQ D. We recommend hosted fields or our mobile SDKs, which can be fully styled to match your checkout.
Do you support mobile apps?
Yes. Native iOS and Android SDKs provide secure card entry, Apple Pay and Google Pay, and in-app 3-D Secure challenges.
Is there an OpenAPI specification?
Yes. The OpenAPI 3 specification is published alongside the reference documentation, so you can generate clients and import it into your API tools.
Where do I report a security issue?
Please follow our Vulnerability Disclosure Policy. Don't open a support ticket for security issues.
Ready to build?
Sandbox keys are free. Talk to us when you're ready to connect live providers.