apip.io Payment Gateway - BTC ETH USDT/USDC Payment Gateway SDK for Node.js
npm install @apip-io/walletimport { Apip } from '@apip-io/wallet';
// 从环境变量或配置中获取
const apip = new Apip({
uri: process.env.APIP_URL || 'https://apip.io/api/',
app_id: process.env.APIP_APP_ID,
app_key: process.env.APIP_APP_KEY
});在 .env 文件中添加:
APIP_URL=https://apip.io/api/
APIP_APP_ID=your_app_id_here
APIP_APP_KEY=your_app_key_here// 创建所有协议的钱包
await apip.create('test_label');
// 创建指定协议
await apip.create('test_label', 'erc20');
// 支持多个协议多个币种
await apip.create('test_label', 'bsc20,erc20');
await apip.create('test_label', 'bnb,bsc20');await apip.balance('test_label');await apip.import('bsc20', 'test_label', '0xwalletaddress', 'private_key');// 使用热钱包提现
await apip.withdraw('1.00', '0x0000towallet', 'bsc20_usdt');
// 指定发送钱包来提现
await apip.withdraw('1.00', '0x0000towallet', 'bsc20_usdt', '0x000from_wallet');// 获取单个数据
await apip.data('bsc20_usdt');
// 支持多个协议多个币种
await apip.data('bnb,bsc20_usdt');// 汇总指定币种
await apip.collect('bsc20_usdt');
// 支持多个协议多个币种
await apip.collect('bnb,bsc20_usdt');
// 使用默认参数 (bsc20_usdt,trc20_usdt)
await apip.collect();在处理支付回调时,验证签名和请求参数:
// 在回调处理函数中
try {
apip.validate(request.body);
// 签名验证通过,继续处理
} catch (error) {
// 签名验证失败
console.error('Invalid callback:', error.message);
}apip.formatUints('1000000000000000000', 18); // '1'
apip.formatUints('1000000', 6); // '1'apip.toUints('1', 18); // '1000000000000000000'
apip.toUints('1.5', 6); // '1500000'MIT