HTechPay
Home / Developers

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

  1. 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_ and sk_test_.

  2. 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.

  3. Create the payment from your server

    Send the token, amount and currency with your secret key and an idempotency key.

  4. Handle the webhook

    Verify the signature, then fulfil the order when you receive payment.authorised or payment.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}` });

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 endingOutcomeWhat to check in your integration
…0001ApprovedOrder fulfilled on payment.authorised
…0091Soft decline on first route, approved on secondYour rules include a second route; one result is returned
…0043Hard decline (stolen card)No retry; your checkout shows a neutral message
…31553-D Secure challenge requiredChallenge window renders and completes
…0504Provider timeoutCascade to next route; no duplicate charge
…0500Simulated acquirer outageHealth check skips the route

Full test numbers are listed in the documentation. Never use real card numbers in the sandbox.

Request sandbox keys

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.failed
  • payment.retried, with details of each attempt
  • refund.succeeded, refund.failed
  • dispute.opened, dispute.closed
  • payment_method.updated, when a network token or the account updater refreshes a card
  • provider.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.

Review mode. Highlighted text needs confirmation from H Tech Pay Solutions before publication. Hover a highlight to see what to check.