PAYchat SDKOfficial Node.js SDK for PAYchat Partner API - Accept USDT payments via Telegram.
Features
💳 Create Payment Links - Generate USDT payment links instantly
💸 Send Withdrawals - Transfer USDT to any Telegram user
🔔 Webhooks - Real-time payment notifications
📊 Analytics - Track transactions and revenue
🔒 Secure - HMAC-SHA256 webhook verification
📝 TypeScript - Full type definitions included
Installation Quick Startimport PAYchatClient from 'paychat-sdk' ;
const client = new PAYchatClient ( 'pk_your_api_key' ) ;
const payment = await client. createPayment ( {
amount : 10 ,
description : 'Premium Subscription'
} ) ;
console. log ( payment. payment. payment_url) ;
Usage Examples Create Paymentconst payment = await client. createPayment ( {
amount : 25.50 ,
description : 'Product Purchase' ,
metadata : { orderId : '12345' } ,
idempotencyKey : 'unique-order-12345'
} ) ;
const paymentUrl = payment. payment. payment_url; Check Payment Statusconst status = await client. getPayment ( 'abc123' ) ;
if ( status. payment. status === 'completed' ) {
console. log ( ` Paid by: ${ status. payment. payer. telegram_id} ` ) ;
console. log ( ` Net amount: ${ status. payment. net_amount} USDT ` ) ;
} Send USDT to Userconst withdrawal = await client. createWithdrawal ( {
telegramId : '123456789' ,
amount : 5.00 ,
memo : 'Cashback reward'
} ) ;
console. log ( ` Sent ${ withdrawal. withdrawal. net_amount} USDT ` ) ; Check Balanceconst balance = await client. getBalance ( ) ;
console. log ( ` Available: ${ balance. balance. available} USDT ` ) ; Get Transaction Historyconst transactions = await client. getTransactions ( {
type : 'payment' ,
limit : 20
} ) ;
transactions. transactions. forEach ( tx => {
console. log ( ` ${ tx. type} : ${ tx. amount} USDT ` ) ;
} ) ; Webhook VerificationVerify 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' } ) ;
}
if ( payload. event === 'payment.completed' ) {
console. log ( 'Payment received:' , payload. data) ;
}
res. json ( { received : true } ) ;
} ) ; Webhook Events
Event
Description
payment.completed
Payment has been completed
withdraw.completed
Withdrawal has been processed
test
Test webhook
Payment Completed Payload{
"event" : "payment.completed" ,
"data" : {
"payment_id" : "abc123" ,
"amount" : 10.00 ,
"fee" : 0.10 ,
"net_amount" : 9.90 ,
"payer" : {
"telegram_id" : "123456789"
}
} ,
"created_at" : "2025-01-07T12:00:00Z"
} API Reference Constructornew PAYchatClient ( apiKey, options? )
Option
Type
Default
Description
baseUrl
string
https://paychat.me
API base URL
timeout
number
10000
Request timeout (ms)
Methods
Method
Description
createPayment(params)
Create a payment link
getPayment(id)
Get payment status
createWithdrawal(params)
Send USDT to a user
getBalance()
Get partner balance
getDepositAddress()
Get deposit address
getTransactions(params?)
Get transaction history
getDashboard()
Get dashboard summary
getStats(period?)
Get detailed statistics
getCredits()
Get credit usage
getPlans()
Get available plans
updateWebhook(url)
Set webhook URL
testWebhook()
Send test webhook
regenerateKeys()
Regenerate API keys
Static Methods
Method
Description
PAYchatClient.verifyWebhook(payload, signature, secretKey)
Verify webhook signature (sync, Node.js)
PAYchatClient.verifyWebhookAsync(payload, signature, secretKey)
Verify webhook signature (async, browser)
Error Handlingtry {
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
RATE_LIMIT_EXCEEDED
Too many requests
Rate Limits
Plan
Limit
Free / Basic
100 requests/min
Pro
500 requests/min
Support
LicenseMIT © PAYchat