UNPKG

nasspay

Version:

TypeScript/JavaScript SDK for integrating with the Nass Merchant Payment Gateway. Supports both Portal and Direct API integration methods with comprehensive type definitions.

34 lines (33 loc) 1.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.UAT_BASE_URL_DIRECT_API_TRANSACTION_PROCESSING = exports.UAT_BASE_URL_PORTAL = void 0; exports.handleAxiosError = handleAxiosError; // UAT Environment: https://uat-gateway.nass.iq:9746/ [cite: 7] exports.UAT_BASE_URL_PORTAL = "https://uat-gateway.nass.iq:9746/"; // Transaction Processing URL (tURL): https://3dsecure.nass.iq/cgi-bin/cgi_json [cite: 9] exports.UAT_BASE_URL_DIRECT_API_TRANSACTION_PROCESSING = "https://3dsecure.nass.iq/cgi-bin/cgi_json"; // Production URL will be provided by your account manager or the support team. [cite: 7] // export const PROD_BASE_URL_PORTAL = 'YOUR_PRODUCTION_PORTAL_URL'; // export const PROD_BASE_URL_DIRECT_API_TRANSACTION_PROCESSING = 'YOUR_PRODUCTION_DIRECT_API_URL'; /** * Handles Axios errors and extracts relevant error information. * @param error The AxiosError object. * @returns An Error object with a descriptive message. */ function handleAxiosError(error) { if (error.response) { // The request was made and the server responded with a status code // that falls out of the range of 2xx const { status, data } = error.response; const message = (data === null || data === void 0 ? void 0 : data.message) || error.response.statusText || "Unknown error"; return new Error(`Nass Payment Gateway Error (${status}): ${message}`); } else if (error.request) { // The request was made but no response was received return new Error("Nass Payment Gateway Error: No response received from server."); } else { // Something happened in setting up the request that triggered an Error return new Error(`Nass Payment Gateway Error: ${error.message}`); } }