JSPM

paychat-sdk

2.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6
  • Score
    100M100P100Q26354F
  • License MIT

Official PAYchat Partner API SDK for USDT payments via Telegram

Package Exports

  • paychat-sdk

Readme

PAYchat SDK

Official Node.js SDK for PAYchat Partner API - Accept USDT payments via Telegram.

npm version License: MIT

Features

  • 💳 Payment Links - Generate USDT payment links
  • QR Payments - Instant QR code payments
  • 🔒 Escrow - Secure buyer-seller transactions
  • 💸 Withdrawals - Send USDT to any Telegram user
  • 📊 Analytics - Track transactions and revenue
  • 🔔 Webhooks - Real-time payment notifications
  • 🔐 Secure - HMAC-SHA256 webhook verification
  • 📝 TypeScript - Full type definitions included

Installation

npm install paychat-sdk

Quick Start

import PAYchatClient from 'paychat-sdk';

// Initialize client
const client = new PAYchatClient('pk_your_api_key');

// Create a payment link
const payment = await client.createPayment({
  amount: 10,
  description: 'Premium Subscription'
});

console.log(payment.payment.payment_url);
// → https://t.me/paychat_aibot?start=abc123

Payment Types

Best for: Online stores, subscriptions, invoices

const payment = await client.createPayment({
  amount: 25.50,
  description: 'Product Purchase',
  metadata: { orderId: '12345' }
});

// Share this URL with your customer
const paymentUrl = payment.payment.payment_url;

2. QR Payments (Instant)

Best for: POS systems, in-person payments

// Create QR payment (expires in 5 minutes by default)
const qr = await client.createQRPayment({
  amount: 15.00,
  description: 'Coffee Shop Order',
  expiresIn: 300 // 5 minutes
});

// Display QR code to customer
console.log(qr.qr_payment.qr_url);

// Check status
const status = await client.getQRPayment(qr.qr_payment.id);
if (status.qr_payment.status === 'paid') {
  console.log('Payment received!');
}

3. Escrow Payments

Best for: Marketplaces, freelance platforms, P2P trades

// Create escrow between buyer and seller
const escrow = await client.createEscrow({
  amount: 100.00,
  buyerTelegramId: '123456789',
  sellerTelegramId: '987654321',
  description: 'Freelance Project'
});

// Buyer pays via payment_url
console.log(escrow.escrow.payment_url);

// After buyer confirms delivery, release funds to seller
await client.releaseEscrow(escrow.escrow.id);

// Or cancel and refund if there's a dispute
await client.cancelEscrow(escrow.escrow.id, 'Buyer requested refund');

Send USDT to Users

const withdrawal = await client.createWithdrawal({
  telegramId: '123456789',
  amount: 5.00,
  memo: 'Cashback reward'
});

console.log(`Sent ${withdrawal.withdrawal.amount} USDT`);

Check Balance

const balance = await client.getBalance();
console.log(`Available: ${balance.balance.available} USDT`);

Pricing

For pricing details, visit our website.

Webhook Verification

Verify incoming webhooks to ensure they're from PAYchat:

import express from 'express';
import { PAYchatClient } from 'paychat-sdk';

const app = express();
app.use(express.json());

app.post('/webhook', (req, res) => {
  const signature = req.headers['x-paychat-signature'];
  const payload = req.body;
  
  const isValid = PAYchatClient.verifyWebhook(
    payload,
    signature,
    'sk_your_secret_key'
  );
  
  if (!isValid) {
    return res.status(401).json({ error: 'Invalid signature' });
  }
  
  // Process webhook
  switch (payload.event) {
    case 'payment.completed':
      console.log('Payment received:', payload.data);
      break;
    case 'escrow.paid':
      console.log('Escrow funded:', payload.data);
      break;
    case 'escrow.released':
      console.log('Escrow released:', payload.data);
      break;
    case 'qr.paid':
      console.log('QR payment received:', payload.data);
      break;
  }
  
  res.json({ received: true });
});

Webhook Events

Event Description
payment.completed Payment link has been paid
withdraw.completed Withdrawal has been processed
escrow.created New escrow created
escrow.paid Buyer funded the escrow
escrow.released Funds released to seller
escrow.cancelled Escrow cancelled, buyer refunded
qr.created QR payment created
qr.paid QR payment completed
qr.expired QR payment expired
test Test webhook

API Reference

Constructor

new PAYchatClient(apiKey, options?)
Option Type Default Description
baseUrl string https://paychat.me API base URL
timeout number 10000 Request timeout (ms)

Methods

Payments

Method Description
createPayment(params) Create a payment link
getPayment(id) Get payment status

QR Payments

Method Description
createQRPayment(params) Create a QR payment
getQRPayment(id) Get QR payment status
listQRPayments(params?) List QR payments
cancelQRPayment(id) Cancel a QR payment

Escrows

Method Description
createEscrow(params) Create an escrow
getEscrow(id) Get escrow status
listEscrows(params?) List escrows
releaseEscrow(id) Release funds to seller
cancelEscrow(id, reason?) Cancel and refund buyer

Withdrawals & Deposits

Method Description
createWithdrawal(params) Send USDT to a user
createDeposit(params) Create deposit request
getDeposit(id) Get deposit status
listDeposits(params?) List deposits
cancelDeposit(id) Cancel pending deposit

Balance & Transactions

Method Description
getBalance() Get partner balance
getDepositAddress() Get deposit address
getTransactions(params?) Get transaction history

Dashboard & Stats

Method Description
getDashboard() Get dashboard summary
getStats(period?) Get detailed statistics
getPlans() Get available plans

Webhooks

Method Description
updateWebhook(url) Set webhook URL
testWebhook() Send test webhook
regenerateKeys() Regenerate API keys

Static Methods

Method Description
PAYchatClient.verifyWebhook(payload, signature, secretKey) Verify webhook (Node.js)
PAYchatClient.verifyWebhookAsync(payload, signature, secretKey) Verify webhook (Browser)

Error Handling

try {
  const payment = await client.createPayment({ amount: 10 });
} catch (error) {
  console.error('Error:', error.message);
  console.error('Code:', error.code);
  console.error('Status:', error.status);
}

Error Codes

Code Description
INVALID_API_KEY Invalid or missing API key
INVALID_AMOUNT Invalid payment amount
INSUFFICIENT_BALANCE Not enough balance
PAYMENT_NOT_FOUND Payment not found
ESCROW_NOT_FOUND Escrow not found
QR_NOT_FOUND QR payment not found
ESCROW_ALREADY_PAID Escrow already paid
ESCROW_ALREADY_COMPLETED Escrow already completed
ESCROW_ALREADY_CANCELLED Escrow already cancelled
CANNOT_WITHDRAW_TO_SELF Cannot withdraw to yourself
RATE_LIMIT_EXCEEDED Too many requests
TIMEOUT Request timeout

Rate Limits

Plan Limit
Founding Member 500 requests/min

Support

License

MIT © PAYchat