Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@tapsilat/tapsilat-js

tapsilat258MIT1.0.7TypeScript support: included

Enterprise-grade TypeScript SDK for Tapsilat Payment Processing Platform

tapsilat, payment, payment-gateway, fintech, typescript, sdk, api, nodejs, e-commerce, turkey, financial-services

readme

Tapsilat TypeScript SDK

Tapsilat Logo

Enterprise-grade TypeScript SDK for Tapsilat Payment Processing Platform

About Tapsilat

Tapsilat is Turkey's leading fintech platform providing comprehensive payment processing solutions for businesses of all sizes. Our cutting-edge technology enables secure, fast, and reliable payment transactions with support for multiple payment methods, currencies, and advanced fraud protection.


Installation

npm install @tapsilat/tapsilat-js

Quick Start

Initialize the SDK

import { TapsilatSDK } from "@tapsilat/tapsilat-js";

const tapsilat = new TapsilatSDK({
  bearerToken: process.env.TAPSILAT_BEARER_TOKEN!,
  baseURL: "https://acquiring.tapsilat.dev/api/v1",
});

Create an Order

const order = await tapsilat.createOrder({
  amount: 150.75,
  currency: "TRY",
  locale: "tr",
  buyer: {
    name: "John",
    surname: "Doe",
    email: "john.doe@example.com",
    phone: "+9099999999",
  },
  description: "Premium subscription - Monthly plan",
  // Metadata must be an array of key-value pairs
  metadata: [
    { key: "productId", value: "PREMIUM-MONTHLY" },
    { key: "customerType", value: "new" }
  ]
});

console.log("Checkout URL:", order.checkout_url);

Check Order Status

const status = await tapsilat.getOrderStatus(order.reference_id);
console.log("Order status:", status.status);

API Methods & Examples

Order Management

Create Order

const order = await tapsilat.createOrder({
  amount: 299.99,
  currency: 'TRY',
  locale: 'tr',
  buyer: {
    name: 'John',
    surname: 'Doe',
    email: 'john-doe@example.com',
    phone: '+9099999999'
  },
  description: 'Product purchase',
  callbackUrl: 'https://mystore.com/success',
  metadata: [
    { key: 'productId', value: 'PROD_123' },
    { key: 'campaignCode', value: 'DISCOUNT20' }
  ]
});

Get Order Details

const order = await tapsilat.getOrder('order-reference-id');
console.log('Order amount:', order.amount);
console.log('Order status:', order.status);

Check Order Status

const status = await tapsilat.getOrderStatus('order-reference-id');
if (status.status === 'completed') {
  console.log('Payment successful!');
}

List Orders

const orders = await tapsilat.getOrders({ page: 1, per_page: 10 });
orders.rows.forEach(order => {
  console.log(`Order ${order.reference_id}: ${order.amount} ${order.currency}`);
});

Cancel Order

try {
  await tapsilat.cancelOrder('order-reference-id');
  console.log('Order cancelled successfully');
} catch (error) {
  console.error('Cannot cancel order:', error.message);
}

Payment Operations

Get Payment Details

const paymentDetails = await tapsilat.getOrderPaymentDetails('order-reference-id');
paymentDetails.forEach(detail => {
  console.log(`Payment: ${detail.amount} ${detail.currency}`);
});

Get Transaction History

const transactions = await tapsilat.getOrderTransactions('order-reference-id');
transactions.forEach(tx => {
  console.log(`${tx.type}: ${tx.amount} on ${tx.created_at}`);
});

Get Checkout URL

const checkoutUrl = await tapsilat.getCheckoutUrl('order-reference-id');
// Redirect customer to checkout
window.location.href = checkoutUrl;

Refund Operations

Process Partial Refund

const refund = await tapsilat.refundOrder({
  reference_id: 'order-reference-id',
  amount: 50.00,
  reason: 'Customer request',
  metadata: [
    { key: 'refundType', value: 'partial' },
    { key: 'ticketId', value: 'TICKET_789' }
  ]
});
console.log('Refund ID:', refund.id);

Process Full Refund

const fullRefund = await tapsilat.refundAllOrder('order-reference-id');
console.log('Full refund processed:', fullRefund.amount);

Webhook Handling

Verify Webhook Signature

import express from 'express';

const app = express();
app.use(express.raw({ type: 'application/json' }));

app.post('/webhooks/tapsilat', async (req, res) => {
  const payload = req.body.toString();
  const signature = req.headers['x-tapsilat-signature'];

  const isValid = await tapsilat.verifyWebhook(
    payload, 
    signature, 
    process.env.WEBHOOK_SECRET
  );

  if (!isValid) {
    return res.status(401).json({ error: 'Invalid signature' });
  }

  const event = JSON.parse(payload);

  switch (event.type) {
    case 'order.completed':
      console.log('Order completed:', event.data.reference_id);
      // Process successful payment
      break;
    case 'order.failed':
      console.log('Order failed:', event.data.reference_id);
      // Handle failed payment
      break;
  }

  res.json({ received: true });
});

Health Monitoring

API Health Check

const health = await tapsilat.healthCheck();
console.log('API Status:', health.status);
console.log('Timestamp:', health.timestamp);

�️ Advanced Configuration

The SDK can be customized with various configuration options:

const tapsilat = new TapsilatSDK({
  bearerToken: process.env.TAPSILAT_BEARER_TOKEN!,
  baseURL: "https://acquiring.tapsilat.dev/api/v1",
  timeout: 30000, // 30 seconds
  retryAttempts: 3, // Auto-retry on network errors
  debug: true, // Enable detailed logging
});

�🔐 Authentication

Use Bearer Token authentication:

const tapsilat = new TapsilatSDK({
  bearerToken: process.env.TAPSILAT_BEARER_TOKEN!,
});

Get your API token from the Tapsilat Dashboard → Settings → API Keys


License

This project is licensed under the MIT License - see the LICENSE file for details.


Resources

Type System

All TypeScript types are organized in src/types/index.ts with proper JSDoc documentation including:

  • @category - Logical grouping of related types
  • @summary - Brief description of what the type represents
  • @description - Detailed explanation with usage context
  • @typedef / @interface - Appropriate type annotations

Tapsilat

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

[Unreleased]

[1.0.4] - 2025-06-16

Changed

  • Standardized and improved code documentation across the SDK
  • Migrated all type/interface/type alias definitions from src/types.ts to src/types/index.ts
  • Improved error handling in refund methods for clarity
  • Organized type definitions with proper JSDoc annotations (@category, @summary, @description)
  • Deduplicated and consolidated type definitions

Removed

  • src/types.ts file (contents migrated to src/types/index.ts)

[1.0.3]

Added

  • Initial SDK implementation
  • Payment operations (create, get, list, cancel)
  • Refund operations (create, get, list)
  • Customer operations (CRUD)
  • Webhook verification
  • TypeScript support
  • Comprehensive error handling
  • Input validation and sanitization
  • Retry mechanism with exponential backoff
  • Zero external dependencies

Security

  • Automatic metadata sanitization
  • HMAC-SHA256 webhook verification
  • Input validation for all requests

[1.0.0] - 2024-12-XX

Added

  • Initial release of Tapsilat JS SDK
  • Full TypeScript support
  • Modern fetch-based HTTP client
  • Comprehensive test suite
  • Documentation and examples