Configuration
Configure the ZSI Pay Node.js SDK with your API credentials and optional client settings.
Initialize the SDK
Create a ZSIPay instance with your API credentials. Keep these credentials on your server and never expose them to browser-side code.
import { ZSIPay } from "zsi-pay";
const zsiPay = new ZSIPay({
apiKey: process.env.ZSI_PAY_API_KEY!,
apiSecret: process.env.ZSI_PAY_API_SECRET!,
webhookSecret: process.env.ZSI_PAY_WEBHOOK_SECRET!,
});Configuration options
The SDK client accepts the following configuration options.
| Option | Type | Required | Description |
|---|---|---|---|
apiKey | string | Required | Your ZSI Pay project API key. |
apiSecret | string | Required | Your ZSI Pay project API secret. |
webhookSecret | string | Optional | Secret used to verify webhook signatures. |
timeout | number | Optional | Optional request timeout configuration for SDK API requests. |
maxRetries | number | Optional | Optional maximum number of retries for retryable requests. |
API credentials
Your API key and API secret authenticate requests made through the SDK. You can generate these credentials from your ZSI Pay dashboard.
ZSI_PAY_API_KEY=your_api_key
ZSI_PAY_API_SECRET=your_api_secretKeep your API secret private
Never include your API secret in frontend JavaScript, mobile applications, public repositories, or client-side environment variables.
Webhook secret
If your application handles ZSI Pay webhooks, provide your webhook secret when initializing the SDK.
ZSI_PAY_WEBHOOK_SECRET=your_webhook_secretconst zsiPay = new ZSIPay({
apiKey: process.env.ZSI_PAY_API_KEY!,
apiSecret: process.env.ZSI_PAY_API_SECRET!,
webhookSecret: process.env.ZSI_PAY_WEBHOOK_SECRET!,
});The webhook secret is used when verifying incoming webhook requests. See the Webhooks guide for verification details.
Optional configuration
You can provide additional options when creating the client.
const zsiPay = new ZSIPay({
apiKey: process.env.ZSI_PAY_API_KEY!,
apiSecret: process.env.ZSI_PAY_API_SECRET!,
webhookSecret: process.env.ZSI_PAY_WEBHOOK_SECRET!,
timeout: 10000,
maxRetries: 3,
});Use these options only when you need to customize request behavior. The SDK defaults are suitable for most integrations.
Recommended environment setup
Store credentials in environment variables instead of hardcoding them in your application source code.
ZSI_PAY_API_KEY=your_api_key
ZSI_PAY_API_SECRET=your_api_secret
ZSI_PAY_WEBHOOK_SECRET=your_webhook_secretMake sure these variables are available only to your server-side application.
Complete example
import { ZSIPay } from "zsi-pay";
const zsiPay = new ZSIPay({
apiKey: process.env.ZSI_PAY_API_KEY!,
apiSecret: process.env.ZSI_PAY_API_SECRET!,
webhookSecret: process.env.ZSI_PAY_WEBHOOK_SECRET!,
timeout: 10000,
maxRetries: 3,
});
export default zsiPay;Security best practices
- • Keep API secrets on your server.
- • Never commit credentials to Git.
- • Use environment variables for sensitive configuration.
- • Never expose your API secret or webhook secret in frontend code.
- • Verify webhook signatures before processing webhook events.
