hstockplus/payeer.online-integration
About
A simple and easy-to-use Node.js payment gateway SDK for quick integration of payment functionality.
Business & FinanceWhat you can do
- ✅ Create orders (supports multiple payment methods)
- ✅ Query orders (single/list)
- ✅ Check order status (public endpoint)
- ✅ Get exchange rate information (public endpoint)
Measured star growth
- in 24h
- 0
- in 7 days
- -1
- in 15 days
- -59
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
OriginalSocialites Payment Gateway: Fast & Simple Node.js SDK
Effortlessly integrate payment functionality with Socialites Payment Gateway SDK – the lightweight Node.js solution designed for fast, seamless, and secure payment processing. Streamline your integration with our developer-friendly SDK and get started in minutes.
Features
- ✅ Create orders (supports multiple payment methods)
- ✅ Query orders (single/list)
- ✅ Check order status (public endpoint)
- ✅ Get exchange rate information (public endpoint)
- ✅ Automatic signature verification
- ✅ Comprehensive error handling
- ✅ TypeScript type support (planned)
Supported Payment Methods
| Payment Method | Code | Supported Currencies | Description |
|---|---|---|---|
| Alipay | alipay |
CNY, USD | Alipay mobile payment |
| WeChat Pay | wxpay |
CNY, USD | WeChat mobile payment |
Installation
npm install payment-gateway-sdk
Or install from local directory:
npm install ./githup
Quick Start
1. Initialize SDK
const PaymentGateway = require('payment-gateway-sdk');
const gateway = new PaymentGateway({
baseUrl: 'https://socialites.io', // API base URL
appId: 'your-app-id', // Application ID
apiKey: 'your-api-key', // API key
clientIp: '127.0.0.1' // Client IP (optional)
});
2. Create Order
try {
const order = await gateway.createOrder({
amount: 100.00,
currency: 'CNY',
paymentMethod: 'alipay',
description: 'Test order',
customerName: 'John Doe',
customerEmail: '[email protected]'
});
console.log('Order created:', order.data.orderId);
console.log('QR Code URL:', order.data.qrImageUrl);
console.log('Payment Method:', order.data.orderPaymentMethod);
} catch (error) {
console.error('Failed to create order:', error.message);
}
3. Query Order
// Query single order
try {
const result = await gateway.queryOrder({
orderId: 'abc123def456...'
});
console.log('Order:', result.data);
console.log('Status:', result.data.status_str);
} catch (error) {
console.error('Failed to query order:', error.message);
}
// Query order list
try {
const result = await gateway.queryOrder({
limit: 20,
page: 1
});
console.log('Orders:', result.data);
} catch (error) {
console.error('Failed to query orders:', error.message);
}
4. Check Order Status (Public Endpoint)
try {
const status = await gateway.checkOrderStatus('abc123def456...');
console.log('Status:', status.status); // pending, ready, paid, failed, cancelled
console.log('Status Code:', status.statusCode); // 0, 1, 2, 3, 4
} catch (error) {
console.error('Failed to check status:', error.message);
}
5. Get Exchange Rate
try {
const rate = await gateway.getExchangeRate();
console.log('USD to CNY:', rate.data.exchangeRate);
} catch (error) {
console.error('Failed to get exchange rate:', error.message);
}
API Documentation
PaymentGateway
Constructor
new PaymentGateway(config)
Parameters:
config.baseUrl(string, required) - API base URLconfig.appId(string, required) - Application IDconfig.apiKey(string, required) - API keyconfig.clientIp(string, optional) - Client IP address, defaults to environment variableCLIENT_IPconfig.timeout(number, optional) - Request timeout in milliseconds, default 30000
createOrder(options)
Create a payment order.
Parameters:
options.amount(number, required) - Order amountoptions.currency(string, required) - Currency type:CNYorUSDoptions.paymentMethod(string, required) - Payment method:alipayorwxpayoptions.description(string, optional) - Order descriptionoptions.clientOrderId(string, optional) - Client order IDoptions.customerName(string, optional) - Customer nameoptions.customerEmail(string, optional) - Customer emailoptions.customerPhone(string, optional) - Customer phone
Return Value:
{
code: 1,
message: "success",
data: {
orderId: "abc123def456...",
qrImageUrl: "https://socialites.io/images/qrcodes/xxx.png",
orderAmount: 100.00,
orderCurrency: "CNY",
orderPaymentMethod: "alipay",
orderDescription: "Test order",
status: 1,
statusString: "ready",
createdAt: "2025-01-01T00:00:00.000Z"
}
}
queryOrder(options)
Query order information.
Parameters:
options.orderId(string, optional) - Order ID (required when querying a single order)options.limit(number, optional) - Records per page (max 50, default 10)options.page(number, optional) - Page number (default 1)
Return Value:
Single order:
{
code: 1,
message: "success",
data: {
orderId: "abc123...",
amount: 100.00,
currency: "CNY",
status: 2,
status_str: "paid",
description: "Test order",
paymentMethod: "alipay",
createdAt: "2025-01-01T00:00:00.000Z",
completedTime: "2025-01-01T00:05:00.000Z",
updatedAt: "2025-01-01T00:05:00.000Z"
}
}
Order list:
{
code: 1,
message: "success",
data: [
{
orderId: "abc123...",
amount: 100.00,
currency: "CNY",
status: 2,
status_str: "paid",
...
},
...
]
}
checkOrderStatus(orderId)
Check order status (public endpoint, no authentication required).
Parameters:
orderId(string, required) - Order ID
Return Value:
{
status: "paid", // pending, ready, paid, failed, cancelled
statusCode: 2, // 0, 1, 2, 3, 4
orderId: "abc123..."
}
getExchangeRate()
Get current USD to CNY exchange rate (public endpoint, no authentication required).
Return Value:
{
code: 1,
message: "success",
data: {
exchangeRate: 7.2
}
}
Order Status
| Status Code | Status String | Description |
|---|---|---|
| 0 | pending |
Order created, waiting for processing |
| 1 | ready |
Order sent to payment provider, QR code generated |
| 2 | paid |
Payment successful |
| 3 | failed |
Payment failed |
| 4 | cancelled |
Order cancelled |
Error Handling
The SDK throws errors, it's recommended to use try-catch to handle them:
try {
const order = await gateway.createOrder({...});
} catch (error) {
console.error('Error:', error.message);
// Handle error
}
Common errors:
amount must be a positive number- Amount must be a positive numbercurrency must be CNY or USD- Invalid currency typepaymentMethod is required- Payment method is requiredpaymentMethod must be alipay or wxpay- Payment method must be alipay or wxpayCreate order failed- Failed to create order (may be signature error, parameter error, etc.)Network error: No response from server- Network error
Signature Mechanism
The SDK automatically handles signatures, no manual calculation needed. Signature algorithm:
- Filter out
signandsign_typefields - Filter out
nullandundefinedvalues - Sort by key name
- Concatenate into string:
key1=value1&key2=value2 - Append API Key:
key1=value1&key2=value2&apikey - MD5 encrypt and convert to lowercase
Complete Examples
See example files in the examples/ directory:
basic-usage.js- Basic usage example (Alipay)wechat-payment.js- WeChat Pay exampleorder-polling.js- Order polling example
License
MIT
Support
For questions or suggestions, please contact technical support.
Explore related projects
Loading…