@tradepoints/api
v0.1.0
Published
Official TradePoints TypeScript SDK for merchant API integrations
Maintainers
Readme
@tradepoints/api
Official TypeScript SDK for integrating TradePoints merchant APIs into Node.js applications.
Requirements
- Node.js 20 or later
- TradePoints merchant credentials
Installation
npm install @tradepoints/apiGetting started
import {
TradePoints,
TradePointsEnvironment,
PointsMode,
} from "@tradepoints/api";
const tradepoints = new TradePoints({
merchantId: process.env.TRADEPOINTS_MERCHANT_ID!,
merchantSecret: process.env.TRADEPOINTS_MERCHANT_SECRET!,
environment: TradePointsEnvironment.PRODUCTION,
});Award points
const result = await tradepoints.addPoints({
transactionId: "ORDER-1001",
amount: 100,
mode: PointsMode.BILL,
cardNo: "1234567890123456",
});
console.log(result.pointsRewarded);Register a member
const member = await tradepoints.registerMember({
email: "[email protected]",
firstName: "John",
lastName: "Smith",
});
console.log(member.cardNo);Validate a card
const result = await tradepoints.validateCard("1234567890123456");
console.log(result.isExists);Check points balance
const result = await tradepoints.getPointsBalance("1234567890123456");
console.log(result.pointsBalance);Refund points
const result = await tradepoints.refundPoints({
transactionId: "ORDER-1001",
});
console.log(result.pointsRefunded);Error handling
import { TradePointsApiError } from "@tradepoints/api";
try {
await tradepoints.validateCard("invalid-card");
} catch (error) {
if (error instanceof TradePointsApiError) {
console.error(error.statusCode, error.message);
} else {
throw error;
}
}Security
Merchant credentials must only be used in trusted server-side environments. Never expose merchant secrets in browser applications.
License
UNLICENSED — All rights reserved.
Documentation
Visit TradePoints Documentation for integration guides and API references.
