SDKs and plugins
Official client libraries and store plugins built directly against this API contract. Each one wraps checkout, session lookup, payment links, invoices and signed webhook verification, so integrating does not mean re-reading the whole reference first.
Node.js
@torupay/node has zero runtime dependencies and targets Node 18 and later, using the global fetch and crypto.timingSafeEqual.
npm install @torupay/nodeimport { ToruPay, verifyWebhook } from '@torupay/node';
const torupay = new ToruPay({ apiKey: process.env.TORUPAY_API_KEY });
const session = await torupay.checkout.initialize({
amount: '1450.00',
order_id: 'ABC-01042:delivery:1',
success_url: 'https://shop.example/order/ABC-01042?paid=1',
cancel_url: 'https://shop.example/checkout?cancelled=1',
webhook_url: 'https://app.example/api/webhooks/torupay',
});
// Redirect the buyer to session.checkout_urlverifyWebhook({ rawBody, signature, secret }) checks the x-kronx-signature header in constant time and returns a boolean, matching the checks on the webhooks page.
PHP
torupay/torupay-php targets PHP 7.4 and later and needs only ext-curl and ext-json.
composer require torupay/torupay-phpuse ToruPay\ToruPay;
$torupay = new ToruPay(getenv('TORUPAY_API_KEY'));
$session = $torupay->initializeCheckout([
'amount' => '1450.00',
'order_id' => 'ABC-01042:delivery:1',
'success_url' => 'https://shop.example/order/ABC-01042?paid=1',
'cancel_url' => 'https://shop.example/checkout?cancelled=1',
'webhook_url' => 'https://app.example/webhooks/torupay.php',
]);
header('Location: ' . $session['checkout_url']);ToruPay::verifyWebhook($rawBody, $signature, $secret) is a static method built on hash_hmac and hash_equals, for use before anything in a callback body is trusted.
WooCommerce plugin
Adds ToruPay as a payment method at checkout: the buyer pays on a hosted ToruPay page and is redirected back, with a signed webhook marking the order paid. Settles in BDT only.
- Upload the
torupay-for-woocommercefolder towp-content/plugins/and activate it. - Go to WooCommerce, Settings, Payments, and enable ToruPay.
- Enter the API key and signing secret from ToruPay, Developers.
- Confirm the store currency (WooCommerce, Settings, General) is BDT.
- Run a test checkout with a
kp_test_key before switching to akp_live_key.
WHMCS module
A standard third-party gateway module: a Pay Now button on the invoice page, and a callback that verifies the signature, checks the invoice and transaction ID, and posts the payment.
- Copy
modules/gateways/torupay.phpinto your WHMCS install at the same path. - Copy
modules/gateways/callback/torupay.phpinto your WHMCS install at the same path. - In Setup, Payments, Payment Gateways, activate ToruPay from the All Payment Gateways list.
- Enter the API key, signing secret and base URL in its settings.
- Pay a test invoice in BDT with a
kp_test_key before switching to akp_live_key.