Docs/SDK & Libraries
v1.0.0

SDK & Libraries

Integrate tiqopay into your application with our official Node.js/TypeScript SDK. Full typing, elegant error handling, and webhook verification included.

npm install @tiqopay/sdk
TypeScriptESM + CJSNode.js ≥ 180 dependencies

Quick start

Create your first escrow transaction in a few lines.

Installation

bash
# npm
npm install @tiqopay/sdk

# yarn
yarn add @tiqopay/sdk

# pnpm
pnpm add @tiqopay/sdk

Initialization

typescript
import { Tiqopay } from '@tiqopay/sdk';

const escrow = new Tiqopay({
  apiKey: 'sk_test_...',
});

// Create a transaction
const tx = await escrow.transactions.create({
  amount: 50000,       // 500.00 MAD
  description: 'Achat iPhone 15',
  buyer_email: 'buyer@example.com',
});

console.log(tx.id); // txn_...

Features

Everything you need to integrate tiqopay in production.

Native TypeScript

Complete types for all resources. Autocompletion and compile-time checking.

Webhook Verification

Built-in HMAC-SHA256 validation with replay attack protection.

Zero dependencies

Uses only native fetch() and Node.js crypto module. Lightweight and fast.

ESM & CommonJS

Compatible with both module systems. Import or require, your choice.

Error handling

Typed tiqopayError with HTTP status and error code for precise handling.

Full API coverage

Transactions, Payment Links, Webhooks, Events, and Payouts — everything is covered.

Available resources

The SDK covers the entire tiqopay API.

Transactions

Create, track, and manage the complete lifecycle of an escrow transaction.

escrow.transactions8 methods

Payment Links

Generate shareable payment links, reusable or single-use.

escrow.paymentLinks5 methods

Webhook Endpoints

Register and manage your endpoints to receive real-time notifications.

escrow.webhookEndpoints4 methods

Events

View the history of all events triggered on your account.

escrow.events2 methods

Payouts

Track outgoing transfers to your bank account.

escrow.payouts2 methods

Notifications

In-app notifications for account events. List, read, and mark as read.

escrow.notifications4 methods

Examples

Transactions

Manage the full cycle: creation → payment → delivery → release.

typescript
// Create a transaction
const tx = await escrow.transactions.create({
  amount: 150000,
  description: 'MacBook Pro M3',
  buyer_email: 'ahmed@example.com',
  buyer_name: 'Ahmed B.',
  deadline: '2026-04-01',
  metadata: { order_id: 'ORD-123' },
});
typescript
// List transactions
const list = await escrow.transactions.list({
  limit: 20,
});

// Mark as delivered
await escrow.transactions.deliver(tx.id, {
  delivery_proof: 'https://tracking.example.com/123',
});

// Release funds
await escrow.transactions.release(tx.id);

Payment Links

Create payment links without writing client-side code.

typescript
// Create a reusable payment link
const link = await escrow.paymentLinks.create({
  title: 'Monthly subscription',
  description: 'Consulting service',
  amount: 300000, // 3,000.00 MAD
  is_reusable: true,
  delivery_deadline_days: 7,
});

console.log(link.url); // https://tiqopay.com/pay/abc123

// Deactivate the link
await escrow.paymentLinks.update(link.id, { is_active: false });

Webhook Verification

Validate HMAC-SHA256 signatures to secure your endpoints.

Express.js

typescript
import { verifyWebhook } from '@tiqopay/sdk/webhooks';

app.post('/webhooks', express.raw({ type: '*/*' }), (req, res) => {
  try {
    const event = verifyWebhook(
      req.body.toString(),
      req.headers['tiqopay-signature'] as string,
      process.env.WEBHOOK_SECRET!,
    );

    switch (event.type) {
      case 'transaction.funded':
        // Buyer has paid
        break;
      case 'transaction.released':
        // Funds released to seller
        break;
      case 'transaction.disputed':
        // Dispute opened
        break;
    }

    res.json({ received: true });
  } catch (err) {
    res.status(400).json({ error: 'Invalid signature' });
  }
});

Register an endpoint

typescript
// Create a webhook endpoint
const wh = await escrow.webhookEndpoints.create({
  url: 'https://example.com/webhooks',
  enabled_events: [
    'transaction.funded',
    'transaction.delivered',
    'transaction.released',
    'transaction.disputed',
    'transaction.refunded',
  ],
  description: 'Production webhook',
});

// Get the secret
console.log(wh.secret); // whsec_...

// List endpoints
const endpoints = await escrow.webhookEndpoints.list();

Error handling

All API errors are wrapped in tiqopayError with the HTTP status and error code.

typescript
import { Tiqopay, TiqopayError } from '@tiqopay/sdk';

try {
  await escrow.transactions.create({
    amount: 100,
    description: 'Test',
    buyer_email: 'invalid',
  });
} catch (err) {
  if (err instanceof tiqopayError) {
    console.log(err.status);  // 422
    console.log(err.code);    // 'validation_error'
    console.log(err.message); // 'Invalid email format'
  }
}

Other languages

No native SDK? The tiqopay REST API works with any HTTP language.

Python

python
import requests

resp = requests.post(
    'https://tiqopay.com/api/api/v1/transactions',
    headers={
        'Authorization': 'Bearer sk_test_...',
        'Content-Type': 'application/json',
    },
    json={
        'amount': 50000,
        'description': 'Online purchase',
        'buyer_email': 'buyer@example.com',
    },
)

tx = resp.json()
print(tx['id'])

PHP

php
$ch = curl_init(
  'https://tiqopay.com/api/api/v1/transactions'
);
curl_setopt_array($ch, [
  CURLOPT_POST => true,
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer sk_test_...',
    'Content-Type: application/json',
  ],
  CURLOPT_POSTFIELDS => json_encode([
    'amount' => 50000,
    'description' => 'Online purchase',
    'buyer_email' => 'buyer@example.com',
  ]),
]);

$response = curl_exec($ch);
$tx = json_decode($response, true);
echo $tx['id'];

cURL

bash
curl -X POST \
  https://tiqopay.com/api/api/v1/transactions \
  -H 'Authorization: Bearer sk_test_...' \
  -H 'Content-Type: application/json' \
  -d '{
    "amount": 50000,
    "description": "Online purchase",
    "buyer_email": "buyer@example.com"
  }'

Ready to integrate tiqopay?

Follow the quickstart guide for your first transaction in 5 minutes.