@100pay-hq/100pay.js 1.2.4 → 1.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -46,11 +46,17 @@ var PaymentVerificationError = class extends Error {
46
46
  }
47
47
  };
48
48
  var Pay100 = class {
49
+ /**
50
+ * Initialize the Pay100 SDK
51
+ * @param config - Configuration object containing API keys and optional base URL
52
+ */
49
53
  constructor({ publicKey, secretKey, baseUrl = BASE_URL }) {
50
54
  /**
51
- * Verify a transaction
52
- * @param transactionId Transaction ID to verify
53
- * @returns Promise resolving to verification result
55
+ * Verifies the status and details of a payment transaction
56
+ *
57
+ * @param transactionId - Unique identifier of the transaction to verify
58
+ * @returns Promise resolving to verification result with transaction data
59
+ * @throws PaymentVerificationError on network issues or invalid responses
54
60
  */
55
61
  this.verify = async (transactionId) => {
56
62
  try {
@@ -101,8 +107,18 @@ var Pay100 = class {
101
107
  );
102
108
  }
103
109
  };
104
- // subaccount methods
110
+ /**
111
+ * Namespace for subaccount management operations
112
+ * Provides methods to create and manage subaccounts
113
+ */
105
114
  this.subaccounts = {
115
+ /**
116
+ * Creates a new subaccount within the platform
117
+ *
118
+ * @param data - Subaccount configuration including owner details and supported currencies
119
+ * @returns Promise resolving to the created subaccount details
120
+ * @throws Error if the request fails or returns invalid data
121
+ */
106
122
  create: async (data) => {
107
123
  return this.request(
108
124
  "POST",
@@ -111,14 +127,41 @@ var Pay100 = class {
111
127
  );
112
128
  }
113
129
  };
130
+ /**
131
+ * Namespace for currency conversion operations
132
+ * Provides methods to calculate exchange rates and fees
133
+ */
134
+ this.conversion = {
135
+ /**
136
+ * Calculates a preview of currency conversion with rates and fees
137
+ *
138
+ * @param data - Conversion details including amount, source and target currencies
139
+ * @returns Promise resolving to detailed conversion calculation
140
+ * @throws Error if the request fails or returns invalid data
141
+ */
142
+ preview: async (data) => {
143
+ return this.request(
144
+ "POST",
145
+ "/api/v1/user/preview-convert-asset",
146
+ {
147
+ amount: data.amount,
148
+ to_symbol: data.toSymbol,
149
+ from_symbol: data.fromSymbol,
150
+ appId: data.appId
151
+ }
152
+ );
153
+ }
154
+ };
114
155
  this.publicKey = publicKey;
115
156
  this.secretKey = secretKey;
116
157
  this.baseUrl = baseUrl;
117
158
  }
118
159
  /**
119
- * Creates a request signature for secure server-to-server communication
120
- * @param payload Request payload to sign
121
- * @returns Object containing timestamp and signature
160
+ * Creates a cryptographic signature for secure server-to-server communication
161
+ *
162
+ * @param payload - Request payload that needs to be signed
163
+ * @returns Object containing current timestamp and HMAC SHA-256 signature
164
+ * @throws Error if secret key is missing or invalid
122
165
  */
123
166
  createSignature(payload) {
124
167
  const timestamp = Date.now().toString();
@@ -136,10 +179,10 @@ var Pay100 = class {
136
179
  return { timestamp, signature };
137
180
  }
138
181
  /**
139
- * Create common headers for API requests
140
- * @param additionalHeaders Additional headers to include
141
- * @param payload Payload to sign (if signature is needed)
142
- * @returns Headers object
182
+ * Constructs HTTP headers for API requests with optional authentication
183
+ *
184
+ * @param payload - Request payload used to generate security signature
185
+ * @returns Object containing all necessary HTTP headers
143
186
  */
144
187
  getHeaders(payload = {}) {
145
188
  if (this.secretKey) {
@@ -158,11 +201,13 @@ var Pay100 = class {
158
201
  };
159
202
  }
160
203
  /**
161
- * Generic method to make authenticated API calls
162
- * @param method HTTP method
163
- * @param endpoint API endpoint
164
- * @param data Request payload
165
- * @returns Promise resolving to API response
204
+ * Generic method to make authenticated API requests to any endpoint
205
+ *
206
+ * @param method - HTTP method to use (GET, POST, PUT, DELETE)
207
+ * @param endpoint - API endpoint path (will be appended to base URL)
208
+ * @param data - Request payload or query parameters
209
+ * @returns Promise resolving to the typed API response
210
+ * @throws Error with detailed message on request failure
166
211
  */
167
212
  async request(method, endpoint, data = {}) {
168
213
  try {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import axios, { AxiosError, AxiosResponse } from \"axios\";\nimport * as crypto from \"crypto\";\nimport {\n CreateSubAccountData,\n CreateSubAccountResponse,\n} from \"./types/subAccount\";\n\n// Interface for constructor parameters\ninterface IPay100Config {\n publicKey: string;\n secretKey?: string;\n baseUrl?: string;\n}\n\n// Interface for transaction data from API\ninterface ITransactionData {\n [key: string]: unknown; // For flexibility, since we don't know the exact structure\n}\n\n// Interface for raw API response\ninterface IRawApiResponse {\n status?: string;\n message?: string;\n data?: unknown;\n [key: string]: unknown;\n}\n\n// Interface for API success response\ninterface IVerifyResponse {\n status: \"success\" | \"error\";\n data: ITransactionData | Record<string, never>;\n message?: string;\n}\n\nconst BASE_URL = process.env.BASE_URL || \"https://api.100pay.co\";\n\n// Error type for payment verification\nexport class PaymentVerificationError extends Error {\n status: string;\n data: Record<string, never>;\n\n constructor(message: string) {\n super(message);\n this.name = \"PaymentVerificationError\";\n this.status = \"error\";\n this.data = {};\n }\n}\n\nexport class Pay100 {\n // optional\n private publicKey: string;\n private secretKey?: string;\n private baseUrl: string;\n\n constructor({ publicKey, secretKey, baseUrl = BASE_URL }: IPay100Config) {\n this.publicKey = publicKey;\n this.secretKey = secretKey;\n this.baseUrl = baseUrl;\n }\n\n /**\n * Creates a request signature for secure server-to-server communication\n * @param payload Request payload to sign\n * @returns Object containing timestamp and signature\n */\n private createSignature(payload: Record<string, unknown>): {\n timestamp: string;\n signature: string;\n } {\n const timestamp = Date.now().toString();\n\n // Extract the token part from the secret key if it's in the format\n // STATUS;TYPE;TOKEN (e.g., \"LIVE;SK;eyJhbGciOiJIUzI1...\")\n let signingSecret = this?.secretKey;\n\n if (this?.secretKey?.includes(\";\")) {\n const secretKeyParts = this.secretKey.split(\";\");\n if (secretKeyParts.length === 3) {\n // Use just the token part as the signing secret\n // This matches what the server expects in the verifySignature middleware\n signingSecret = secretKeyParts[2];\n }\n }\n\n if (!signingSecret) {\n throw new Error(\"Secret key is required for signing\");\n }\n\n // Create signature using HMAC SHA-256\n const signature = crypto\n .createHmac(\"sha256\", signingSecret)\n .update(timestamp + JSON.stringify(payload))\n .digest(\"hex\");\n\n return { timestamp, signature };\n }\n\n /**\n * Create common headers for API requests\n * @param additionalHeaders Additional headers to include\n * @param payload Payload to sign (if signature is needed)\n * @returns Headers object\n */\n private getHeaders(\n payload: Record<string, unknown> = {}\n ): Record<string, string> {\n // Generate signature based on payload\n\n if (this.secretKey) {\n const { timestamp, signature } = this.createSignature(payload);\n return {\n \"api-key\": this.publicKey,\n \"x-secret-key\": this.secretKey,\n \"x-timestamp\": timestamp,\n \"x-signature\": signature,\n \"Content-Type\": \"application/json\",\n };\n }\n return {\n \"api-key\": this.publicKey,\n \"Content-Type\": \"application/json\",\n };\n }\n\n /**\n * Verify a transaction\n * @param transactionId Transaction ID to verify\n * @returns Promise resolving to verification result\n */\n verify = async (transactionId: string): Promise<IVerifyResponse> => {\n try {\n const payload = { transactionId };\n\n const response: AxiosResponse<IRawApiResponse> = await axios({\n method: \"POST\",\n url: `${this.baseUrl}/api/v1/pay/crypto/payment/${transactionId}`,\n headers: this.getHeaders(payload),\n data: payload,\n });\n\n // Handle empty response\n if (!response.data) {\n return {\n status: \"error\",\n data: {},\n message:\n \"Something went wrong, be sure you supplied a valid payment id.\",\n };\n }\n\n // Handle string responses which indicate errors\n if (typeof response.data === \"string\") {\n if (response.data === \"Access Denied, Invalid KEY supplied\") {\n return {\n status: \"error\",\n data: {},\n message: \"Access Denied, Invalid KEY supplied\",\n };\n }\n\n if (response.data === \"invalid payment id supplied\") {\n return {\n status: \"error\",\n data: {},\n };\n }\n }\n\n // Validate and transform response data to ensure type safety\n const responseData = response.data;\n\n // Ensure the response data is an object that can be safely cast to ITransactionData\n const transactionData: ITransactionData =\n responseData && typeof responseData === \"object\"\n ? (responseData as ITransactionData)\n : {};\n\n // Return successful response with properly typed data\n return {\n status: \"success\",\n data: transactionData,\n };\n } catch (error) {\n // Handle Axios errors\n if (axios.isAxiosError(error)) {\n const axiosError = error as AxiosError;\n throw new PaymentVerificationError(\n axiosError.message ||\n \"Something went wrong, be sure you supplied a valid payment id.\"\n );\n }\n\n // Handle other errors\n throw new PaymentVerificationError(\n error instanceof Error ? error.message : \"An unknown error occurred\"\n );\n }\n };\n\n // subaccount methods\n subaccounts = {\n create: async (\n data: CreateSubAccountData\n ): Promise<CreateSubAccountResponse> => {\n return this.request<CreateSubAccountResponse>(\n \"POST\",\n \"/api/v1/assets/subaccount/create\",\n data\n );\n },\n };\n\n /**\n * Generic method to make authenticated API calls\n * @param method HTTP method\n * @param endpoint API endpoint\n * @param data Request payload\n * @returns Promise resolving to API response\n */\n async request<T>(\n method: \"GET\" | \"POST\" | \"PUT\" | \"DELETE\",\n endpoint: string,\n data: Record<string, unknown> = {}\n ): Promise<T> {\n try {\n const url = `${this.baseUrl}${endpoint}`;\n const headers = this.getHeaders(data);\n\n const response = await axios({\n method,\n url,\n headers,\n data: method !== \"GET\" ? data : undefined,\n params: method === \"GET\" ? data : undefined,\n });\n\n return response.data as T;\n } catch (error) {\n if (axios.isAxiosError(error)) {\n const axiosError = error as AxiosError;\n const errorMessage =\n axiosError.response?.data &&\n typeof axiosError.response.data === \"object\" &&\n \"message\" in axiosError.response.data\n ? String(axiosError.response.data.message)\n : axiosError.message;\n\n throw new Error(`API Request Failed: ${errorMessage}`);\n }\n\n throw error;\n }\n }\n}\n\nexport * from \"./types\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAiD;AACjD,aAAwB;AAiCxB,IAAM,WAAW,QAAQ,IAAI,YAAY;AAGlC,IAAM,2BAAN,cAAuC,MAAM;AAAA,EAIlD,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,OAAO,CAAC;AAAA,EACf;AACF;AAEO,IAAM,SAAN,MAAa;AAAA,EAMlB,YAAY,EAAE,WAAW,WAAW,UAAU,SAAS,GAAkB;AA2EzE;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAS,OAAO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,SAAS;AAAA,IAClB,SAAS,OAAO;AACd,UAAI,aAAAA,QAAM,aAAa,KAAK,GAAG;AAC7B,cAAM,aAAa;AACnB,cAAM,eACJ,WAAW,UAAU,QACrB,OAAO,WAAW,SAAS,SAAS,YACpC,aAAa,WAAW,SAAS,OAC7B,OAAO,WAAW,SAAS,KAAK,OAAO,IACvC,WAAW;AAEjB,cAAM,IAAI,MAAM,uBAAuB,YAAY,EAAE;AAAA,MACvD;AAEA,YAAM;AAAA,IACR;AAAA,EACF;AACF;","names":["axios"]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// src/index.ts\n\nimport axios, { AxiosError, AxiosResponse } from \"axios\";\nimport * as crypto from \"crypto\";\nimport {\n CreateSubAccountData,\n CreateSubAccountResponse,\n} from \"./types/subAccount\";\nimport { CurrencyConversionPayload, CurrencyConversionResult } from \"./types\";\n\n/**\n * Configuration interface for initializing the Pay100 SDK\n * @property publicKey - API public key required for all API calls\n * @property secretKey - Secret key used for server-side authentication and request signing\n * @property baseUrl - Optional API base URL, defaults to production endpoint\n */\ninterface IPay100Config {\n publicKey: string;\n secretKey?: string;\n baseUrl?: string;\n}\n\n/**\n * Interface representing transaction data returned from payment verification\n * Flexible structure to accommodate various transaction types and properties\n */\ninterface ITransactionData {\n [key: string]: unknown;\n}\n\n/**\n * Interface for raw API responses before processing\n * Provides a flexible structure while capturing common response elements\n */\ninterface IRawApiResponse {\n status?: string;\n message?: string;\n data?: unknown;\n [key: string]: unknown;\n}\n\n/**\n * Standardized response interface for transaction verification\n * @property status - Result status ('success' or 'error')\n * @property data - Transaction details when successful, empty object on failure\n * @property message - Optional response message, typically present on errors\n */\ninterface IVerifyResponse {\n status: \"success\" | \"error\";\n data: ITransactionData | Record<string, never>;\n message?: string;\n}\n\n// Default API endpoint if not otherwise specified\nconst BASE_URL = process.env.BASE_URL || \"https://api.100pay.co\";\n\n/**\n * Custom error class for payment verification failures\n * Provides consistent error structure for better error handling\n */\nexport class PaymentVerificationError extends Error {\n status: string;\n data: Record<string, never>;\n\n constructor(message: string) {\n super(message);\n this.name = \"PaymentVerificationError\";\n this.status = \"error\";\n this.data = {};\n }\n}\n\n/**\n * Main SDK class for interacting with the 100Pay payment platform\n * Provides methods for transaction verification, subaccount management,\n * and currency conversion\n */\nexport class Pay100 {\n private publicKey: string;\n private secretKey?: string;\n private baseUrl: string;\n\n /**\n * Initialize the Pay100 SDK\n * @param config - Configuration object containing API keys and optional base URL\n */\n constructor({ publicKey, secretKey, baseUrl = BASE_URL }: IPay100Config) {\n this.publicKey = publicKey;\n this.secretKey = secretKey;\n this.baseUrl = baseUrl;\n }\n\n /**\n * Creates a cryptographic signature for secure server-to-server communication\n *\n * @param payload - Request payload that needs to be signed\n * @returns Object containing current timestamp and HMAC SHA-256 signature\n * @throws Error if secret key is missing or invalid\n */\n private createSignature(payload: Record<string, unknown>): {\n timestamp: string;\n signature: string;\n } {\n const timestamp = Date.now().toString();\n\n // Extract the token part from the secret key if it's in the format\n // STATUS;TYPE;TOKEN (e.g., \"LIVE;SK;eyJhbGciOiJIUzI1...\")\n let signingSecret = this?.secretKey;\n\n if (this?.secretKey?.includes(\";\")) {\n const secretKeyParts = this.secretKey.split(\";\");\n if (secretKeyParts.length === 3) {\n // Use just the token part as the signing secret\n signingSecret = secretKeyParts[2];\n }\n }\n\n if (!signingSecret) {\n throw new Error(\"Secret key is required for signing\");\n }\n\n // Create signature using HMAC SHA-256\n const signature = crypto\n .createHmac(\"sha256\", signingSecret)\n .update(timestamp + JSON.stringify(payload))\n .digest(\"hex\");\n\n return { timestamp, signature };\n }\n\n /**\n * Constructs HTTP headers for API requests with optional authentication\n *\n * @param payload - Request payload used to generate security signature\n * @returns Object containing all necessary HTTP headers\n */\n private getHeaders(\n payload: Record<string, unknown> = {}\n ): Record<string, string> {\n // Generate authentication headers if secret key is available (server-side mode)\n if (this.secretKey) {\n const { timestamp, signature } = this.createSignature(payload);\n return {\n \"api-key\": this.publicKey,\n \"x-secret-key\": this.secretKey,\n \"x-timestamp\": timestamp,\n \"x-signature\": signature,\n \"Content-Type\": \"application/json\",\n };\n }\n\n // Basic headers for public API usage (client-side mode)\n return {\n \"api-key\": this.publicKey,\n \"Content-Type\": \"application/json\",\n };\n }\n\n /**\n * Verifies the status and details of a payment transaction\n *\n * @param transactionId - Unique identifier of the transaction to verify\n * @returns Promise resolving to verification result with transaction data\n * @throws PaymentVerificationError on network issues or invalid responses\n */\n verify = async (transactionId: string): Promise<IVerifyResponse> => {\n try {\n const payload = { transactionId };\n\n const response: AxiosResponse<IRawApiResponse> = await axios({\n method: \"POST\",\n url: `${this.baseUrl}/api/v1/pay/crypto/payment/${transactionId}`,\n headers: this.getHeaders(payload),\n data: payload,\n });\n\n // Handle empty response\n if (!response.data) {\n return {\n status: \"error\",\n data: {},\n message:\n \"Something went wrong, be sure you supplied a valid payment id.\",\n };\n }\n\n // Handle string responses which indicate errors\n if (typeof response.data === \"string\") {\n if (response.data === \"Access Denied, Invalid KEY supplied\") {\n return {\n status: \"error\",\n data: {},\n message: \"Access Denied, Invalid KEY supplied\",\n };\n }\n\n if (response.data === \"invalid payment id supplied\") {\n return {\n status: \"error\",\n data: {},\n };\n }\n }\n\n // Validate and transform response data to ensure type safety\n const responseData = response.data;\n\n // Ensure the response data is an object that can be safely cast to ITransactionData\n const transactionData: ITransactionData =\n responseData && typeof responseData === \"object\"\n ? (responseData as ITransactionData)\n : {};\n\n // Return successful response with properly typed data\n return {\n status: \"success\",\n data: transactionData,\n };\n } catch (error) {\n // Handle Axios errors with detailed message\n if (axios.isAxiosError(error)) {\n const axiosError = error as AxiosError;\n throw new PaymentVerificationError(\n axiosError.message ||\n \"Something went wrong, be sure you supplied a valid payment id.\"\n );\n }\n\n // Handle other errors with appropriate message\n throw new PaymentVerificationError(\n error instanceof Error ? error.message : \"An unknown error occurred\"\n );\n }\n };\n\n /**\n * Namespace for subaccount management operations\n * Provides methods to create and manage subaccounts\n */\n subaccounts = {\n /**\n * Creates a new subaccount within the platform\n *\n * @param data - Subaccount configuration including owner details and supported currencies\n * @returns Promise resolving to the created subaccount details\n * @throws Error if the request fails or returns invalid data\n */\n create: async (\n data: CreateSubAccountData\n ): Promise<CreateSubAccountResponse> => {\n return this.request<CreateSubAccountResponse>(\n \"POST\",\n \"/api/v1/assets/subaccount/create\",\n data\n );\n },\n };\n\n /**\n * Namespace for currency conversion operations\n * Provides methods to calculate exchange rates and fees\n */\n conversion = {\n /**\n * Calculates a preview of currency conversion with rates and fees\n *\n * @param data - Conversion details including amount, source and target currencies\n * @returns Promise resolving to detailed conversion calculation\n * @throws Error if the request fails or returns invalid data\n */\n preview: async (\n data: CurrencyConversionPayload\n ): Promise<CurrencyConversionResult> => {\n return this.request<CurrencyConversionResult>(\n \"POST\",\n \"/api/v1/user/preview-convert-asset\",\n {\n amount: data.amount,\n to_symbol: data.toSymbol,\n from_symbol: data.fromSymbol,\n appId: data.appId,\n }\n );\n },\n };\n\n /**\n * Generic method to make authenticated API requests to any endpoint\n *\n * @param method - HTTP method to use (GET, POST, PUT, DELETE)\n * @param endpoint - API endpoint path (will be appended to base URL)\n * @param data - Request payload or query parameters\n * @returns Promise resolving to the typed API response\n * @throws Error with detailed message on request failure\n */\n async request<T>(\n method: \"GET\" | \"POST\" | \"PUT\" | \"DELETE\",\n endpoint: string,\n data: Record<string, unknown> = {}\n ): Promise<T> {\n try {\n const url = `${this.baseUrl}${endpoint}`;\n const headers = this.getHeaders(data);\n\n const response = await axios({\n method,\n url,\n headers,\n data: method !== \"GET\" ? data : undefined,\n params: method === \"GET\" ? data : undefined,\n });\n\n return response.data as T;\n } catch (error) {\n if (axios.isAxiosError(error)) {\n const axiosError = error as AxiosError;\n const errorMessage =\n axiosError.response?.data &&\n typeof axiosError.response.data === \"object\" &&\n \"message\" in axiosError.response.data\n ? String(axiosError.response.data.message)\n : axiosError.message;\n\n throw new Error(`API Request Failed: ${errorMessage}`);\n }\n\n throw error;\n }\n }\n}\n\nexport * from \"./types\";\n"],"mappings":";;;;;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
  };
64
64
 
65
+ type CurrencyConversionPayload = {
66
+ amount: number;
67
+ fromSymbol: string;
68
+ toSymbol: string;
69
+ appId?: string;
70
+ };
71
+ type CurrencyConversionResult = {
72
+ convertedAmount: number;
73
+ totalAmount: number;
74
+ feeInUSD: number;
75
+ feeInToCurrency: number;
76
+ feeInfromSymbol: number;
77
+ conversionFeeInUSD: number;
78
+ conversionFeeInToCurrency: number;
79
+ conversionFeeInfromSymbol: number;
80
+ fromRate: number;
81
+ toRate: number;
82
+ intermediateUSDAmount: number;
83
+ };
84
+
85
+ /**
86
+ * Configuration interface for initializing the Pay100 SDK
87
+ * @property publicKey - API public key required for all API calls
88
+ * @property secretKey - Secret key used for server-side authentication and request signing
89
+ * @property baseUrl - Optional API base URL, defaults to production endpoint
90
+ */
65
91
  interface IPay100Config {
66
92
  publicKey: string;
67
93
  secretKey?: string;
68
94
  baseUrl?: string;
69
95
  }
96
+ /**
97
+ * Interface representing transaction data returned from payment verification
98
+ * Flexible structure to accommodate various transaction types and properties
99
+ */
70
100
  interface ITransactionData {
71
101
  [key: string]: unknown;
72
102
  }
103
+ /**
104
+ * Standardized response interface for transaction verification
105
+ * @property status - Result status ('success' or 'error')
106
+ * @property data - Transaction details when successful, empty object on failure
107
+ * @property message - Optional response message, typically present on errors
108
+ */
73
109
  interface IVerifyResponse {
74
110
  status: "success" | "error";
75
111
  data: ITransactionData | Record<string, never>;
76
112
  message?: string;
77
113
  }
114
+ /**
115
+ * Custom error class for payment verification failures
116
+ * Provides consistent error structure for better error handling
117
+ */
78
118
  declare class PaymentVerificationError extends Error {
79
119
  status: string;
80
120
  data: Record<string, never>;
81
121
  constructor(message: string);
82
122
  }
123
+ /**
124
+ * Main SDK class for interacting with the 100Pay payment platform
125
+ * Provides methods for transaction verification, subaccount management,
126
+ * and currency conversion
127
+ */
83
128
  declare class Pay100 {
84
129
  private publicKey;
85
130
  private secretKey?;
86
131
  private baseUrl;
132
+ /**
133
+ * Initialize the Pay100 SDK
134
+ * @param config - Configuration object containing API keys and optional base URL
135
+ */
87
136
  constructor({ publicKey, secretKey, baseUrl }: IPay100Config);
88
137
  /**
89
- * Creates a request signature for secure server-to-server communication
90
- * @param payload Request payload to sign
91
- * @returns Object containing timestamp and signature
138
+ * Creates a cryptographic signature for secure server-to-server communication
139
+ *
140
+ * @param payload - Request payload that needs to be signed
141
+ * @returns Object containing current timestamp and HMAC SHA-256 signature
142
+ * @throws Error if secret key is missing or invalid
92
143
  */
93
144
  private createSignature;
94
145
  /**
95
- * Create common headers for API requests
96
- * @param additionalHeaders Additional headers to include
97
- * @param payload Payload to sign (if signature is needed)
98
- * @returns Headers object
146
+ * Constructs HTTP headers for API requests with optional authentication
147
+ *
148
+ * @param payload - Request payload used to generate security signature
149
+ * @returns Object containing all necessary HTTP headers
99
150
  */
100
151
  private getHeaders;
101
152
  /**
102
- * Verify a transaction
103
- * @param transactionId Transaction ID to verify
104
- * @returns Promise resolving to verification result
153
+ * Verifies the status and details of a payment transaction
154
+ *
155
+ * @param transactionId - Unique identifier of the transaction to verify
156
+ * @returns Promise resolving to verification result with transaction data
157
+ * @throws PaymentVerificationError on network issues or invalid responses
105
158
  */
106
159
  verify: (transactionId: string) => Promise<IVerifyResponse>;
160
+ /**
161
+ * Namespace for subaccount management operations
162
+ * Provides methods to create and manage subaccounts
163
+ */
107
164
  subaccounts: {
165
+ /**
166
+ * Creates a new subaccount within the platform
167
+ *
168
+ * @param data - Subaccount configuration including owner details and supported currencies
169
+ * @returns Promise resolving to the created subaccount details
170
+ * @throws Error if the request fails or returns invalid data
171
+ */
108
172
  create: (data: CreateSubAccountData) => Promise<CreateSubAccountResponse>;
109
173
  };
110
174
  /**
111
- * Generic method to make authenticated API calls
112
- * @param method HTTP method
113
- * @param endpoint API endpoint
114
- * @param data Request payload
115
- * @returns Promise resolving to API response
175
+ * Namespace for currency conversion operations
176
+ * Provides methods to calculate exchange rates and fees
177
+ */
178
+ conversion: {
179
+ /**
180
+ * Calculates a preview of currency conversion with rates and fees
181
+ *
182
+ * @param data - Conversion details including amount, source and target currencies
183
+ * @returns Promise resolving to detailed conversion calculation
184
+ * @throws Error if the request fails or returns invalid data
185
+ */
186
+ preview: (data: CurrencyConversionPayload) => Promise<CurrencyConversionResult>;
187
+ };
188
+ /**
189
+ * Generic method to make authenticated API requests to any endpoint
190
+ *
191
+ * @param method - HTTP method to use (GET, POST, PUT, DELETE)
192
+ * @param endpoint - API endpoint path (will be appended to base URL)
193
+ * @param data - Request payload or query parameters
194
+ * @returns Promise resolving to the typed API response
195
+ * @throws Error with detailed message on request failure
116
196
  */
117
197
  request<T>(method: "GET" | "POST" | "PUT" | "DELETE", endpoint: string, data?: Record<string, unknown>): Promise<T>;
118
198
  }
119
199
 
120
- export { type Account, type AccountDetails, type CreateSubAccountData, type CreateSubAccountResponse, type Crypto, type Key, Pay100, PaymentVerificationError };
200
+ export { type Account, type AccountDetails, type CreateSubAccountData, type CreateSubAccountResponse, type Crypto, type CurrencyConversionPayload, type CurrencyConversionResult, type Key, Pay100, PaymentVerificationError };
package/dist/index.d.ts CHANGED
@@ -62,59 +62,139 @@ type Crypto = {
62
62
  mac: string;
63
63
  };
64
64
 
65
+ type CurrencyConversionPayload = {
66
+ amount: number;
67
+ fromSymbol: string;
68
+ toSymbol: string;
69
+ appId?: string;
70
+ };
71
+ type CurrencyConversionResult = {
72
+ convertedAmount: number;
73
+ totalAmount: number;
74
+ feeInUSD: number;
75
+ feeInToCurrency: number;
76
+ feeInfromSymbol: number;
77
+ conversionFeeInUSD: number;
78
+ conversionFeeInToCurrency: number;
79
+ conversionFeeInfromSymbol: number;
80
+ fromRate: number;
81
+ toRate: number;
82
+ intermediateUSDAmount: number;
83
+ };
84
+
85
+ /**
86
+ * Configuration interface for initializing the Pay100 SDK
87
+ * @property publicKey - API public key required for all API calls
88
+ * @property secretKey - Secret key used for server-side authentication and request signing
89
+ * @property baseUrl - Optional API base URL, defaults to production endpoint
90
+ */
65
91
  interface IPay100Config {
66
92
  publicKey: string;
67
93
  secretKey?: string;
68
94
  baseUrl?: string;
69
95
  }
96
+ /**
97
+ * Interface representing transaction data returned from payment verification
98
+ * Flexible structure to accommodate various transaction types and properties
99
+ */
70
100
  interface ITransactionData {
71
101
  [key: string]: unknown;
72
102
  }
103
+ /**
104
+ * Standardized response interface for transaction verification
105
+ * @property status - Result status ('success' or 'error')
106
+ * @property data - Transaction details when successful, empty object on failure
107
+ * @property message - Optional response message, typically present on errors
108
+ */
73
109
  interface IVerifyResponse {
74
110
  status: "success" | "error";
75
111
  data: ITransactionData | Record<string, never>;
76
112
  message?: string;
77
113
  }
114
+ /**
115
+ * Custom error class for payment verification failures
116
+ * Provides consistent error structure for better error handling
117
+ */
78
118
  declare class PaymentVerificationError extends Error {
79
119
  status: string;
80
120
  data: Record<string, never>;
81
121
  constructor(message: string);
82
122
  }
123
+ /**
124
+ * Main SDK class for interacting with the 100Pay payment platform
125
+ * Provides methods for transaction verification, subaccount management,
126
+ * and currency conversion
127
+ */
83
128
  declare class Pay100 {
84
129
  private publicKey;
85
130
  private secretKey?;
86
131
  private baseUrl;
132
+ /**
133
+ * Initialize the Pay100 SDK
134
+ * @param config - Configuration object containing API keys and optional base URL
135
+ */
87
136
  constructor({ publicKey, secretKey, baseUrl }: IPay100Config);
88
137
  /**
89
- * Creates a request signature for secure server-to-server communication
90
- * @param payload Request payload to sign
91
- * @returns Object containing timestamp and signature
138
+ * Creates a cryptographic signature for secure server-to-server communication
139
+ *
140
+ * @param payload - Request payload that needs to be signed
141
+ * @returns Object containing current timestamp and HMAC SHA-256 signature
142
+ * @throws Error if secret key is missing or invalid
92
143
  */
93
144
  private createSignature;
94
145
  /**
95
- * Create common headers for API requests
96
- * @param additionalHeaders Additional headers to include
97
- * @param payload Payload to sign (if signature is needed)
98
- * @returns Headers object
146
+ * Constructs HTTP headers for API requests with optional authentication
147
+ *
148
+ * @param payload - Request payload used to generate security signature
149
+ * @returns Object containing all necessary HTTP headers
99
150
  */
100
151
  private getHeaders;
101
152
  /**
102
- * Verify a transaction
103
- * @param transactionId Transaction ID to verify
104
- * @returns Promise resolving to verification result
153
+ * Verifies the status and details of a payment transaction
154
+ *
155
+ * @param transactionId - Unique identifier of the transaction to verify
156
+ * @returns Promise resolving to verification result with transaction data
157
+ * @throws PaymentVerificationError on network issues or invalid responses
105
158
  */
106
159
  verify: (transactionId: string) => Promise<IVerifyResponse>;
160
+ /**
161
+ * Namespace for subaccount management operations
162
+ * Provides methods to create and manage subaccounts
163
+ */
107
164
  subaccounts: {
165
+ /**
166
+ * Creates a new subaccount within the platform
167
+ *
168
+ * @param data - Subaccount configuration including owner details and supported currencies
169
+ * @returns Promise resolving to the created subaccount details
170
+ * @throws Error if the request fails or returns invalid data
171
+ */
108
172
  create: (data: CreateSubAccountData) => Promise<CreateSubAccountResponse>;
109
173
  };
110
174
  /**
111
- * Generic method to make authenticated API calls
112
- * @param method HTTP method
113
- * @param endpoint API endpoint
114
- * @param data Request payload
115
- * @returns Promise resolving to API response
175
+ * Namespace for currency conversion operations
176
+ * Provides methods to calculate exchange rates and fees
177
+ */
178
+ conversion: {
179
+ /**
180
+ * Calculates a preview of currency conversion with rates and fees
181
+ *
182
+ * @param data - Conversion details including amount, source and target currencies
183
+ * @returns Promise resolving to detailed conversion calculation
184
+ * @throws Error if the request fails or returns invalid data
185
+ */
186
+ preview: (data: CurrencyConversionPayload) => Promise<CurrencyConversionResult>;
187
+ };
188
+ /**
189
+ * Generic method to make authenticated API requests to any endpoint
190
+ *
191
+ * @param method - HTTP method to use (GET, POST, PUT, DELETE)
192
+ * @param endpoint - API endpoint path (will be appended to base URL)
193
+ * @param data - Request payload or query parameters
194
+ * @returns Promise resolving to the typed API response
195
+ * @throws Error with detailed message on request failure
116
196
  */
117
197
  request<T>(method: "GET" | "POST" | "PUT" | "DELETE", endpoint: string, data?: Record<string, unknown>): Promise<T>;
118
198
  }
119
199
 
120
- export { type Account, type AccountDetails, type CreateSubAccountData, type CreateSubAccountResponse, type Crypto, type Key, Pay100, PaymentVerificationError };
200
+ export { type Account, type AccountDetails, type CreateSubAccountData, type CreateSubAccountResponse, type Crypto, type CurrencyConversionPayload, type CurrencyConversionResult, type Key, Pay100, PaymentVerificationError };
package/dist/index.js CHANGED
@@ -11,11 +11,17 @@ var PaymentVerificationError = class extends Error {
11
11
  }
12
12
  };
13
13
  var Pay100 = class {
14
+ /**
15
+ * Initialize the Pay100 SDK
16
+ * @param config - Configuration object containing API keys and optional base URL
17
+ */
14
18
  constructor({ publicKey, secretKey, baseUrl = BASE_URL }) {
15
19
  /**
16
- * Verify a transaction
17
- * @param transactionId Transaction ID to verify
18
- * @returns Promise resolving to verification result
20
+ * Verifies the status and details of a payment transaction
21
+ *
22
+ * @param transactionId - Unique identifier of the transaction to verify
23
+ * @returns Promise resolving to verification result with transaction data
24
+ * @throws PaymentVerificationError on network issues or invalid responses
19
25
  */
20
26
  this.verify = async (transactionId) => {
21
27
  try {
@@ -66,8 +72,18 @@ var Pay100 = class {
66
72
  );
67
73
  }
68
74
  };
69
- // subaccount methods
75
+ /**
76
+ * Namespace for subaccount management operations
77
+ * Provides methods to create and manage subaccounts
78
+ */
70
79
  this.subaccounts = {
80
+ /**
81
+ * Creates a new subaccount within the platform
82
+ *
83
+ * @param data - Subaccount configuration including owner details and supported currencies
84
+ * @returns Promise resolving to the created subaccount details
85
+ * @throws Error if the request fails or returns invalid data
86
+ */
71
87
  create: async (data) => {
72
88
  return this.request(
73
89
  "POST",
@@ -76,14 +92,41 @@ var Pay100 = class {
76
92
  );
77
93
  }
78
94
  };
95
+ /**
96
+ * Namespace for currency conversion operations
97
+ * Provides methods to calculate exchange rates and fees
98
+ */
99
+ this.conversion = {
100
+ /**
101
+ * Calculates a preview of currency conversion with rates and fees
102
+ *
103
+ * @param data - Conversion details including amount, source and target currencies
104
+ * @returns Promise resolving to detailed conversion calculation
105
+ * @throws Error if the request fails or returns invalid data
106
+ */
107
+ preview: async (data) => {
108
+ return this.request(
109
+ "POST",
110
+ "/api/v1/user/preview-convert-asset",
111
+ {
112
+ amount: data.amount,
113
+ to_symbol: data.toSymbol,
114
+ from_symbol: data.fromSymbol,
115
+ appId: data.appId
116
+ }
117
+ );
118
+ }
119
+ };
79
120
  this.publicKey = publicKey;
80
121
  this.secretKey = secretKey;
81
122
  this.baseUrl = baseUrl;
82
123
  }
83
124
  /**
84
- * Creates a request signature for secure server-to-server communication
85
- * @param payload Request payload to sign
86
- * @returns Object containing timestamp and signature
125
+ * Creates a cryptographic signature for secure server-to-server communication
126
+ *
127
+ * @param payload - Request payload that needs to be signed
128
+ * @returns Object containing current timestamp and HMAC SHA-256 signature
129
+ * @throws Error if secret key is missing or invalid
87
130
  */
88
131
  createSignature(payload) {
89
132
  const timestamp = Date.now().toString();
@@ -101,10 +144,10 @@ var Pay100 = class {
101
144
  return { timestamp, signature };
102
145
  }
103
146
  /**
104
- * Create common headers for API requests
105
- * @param additionalHeaders Additional headers to include
106
- * @param payload Payload to sign (if signature is needed)
107
- * @returns Headers object
147
+ * Constructs HTTP headers for API requests with optional authentication
148
+ *
149
+ * @param payload - Request payload used to generate security signature
150
+ * @returns Object containing all necessary HTTP headers
108
151
  */
109
152
  getHeaders(payload = {}) {
110
153
  if (this.secretKey) {
@@ -123,11 +166,13 @@ var Pay100 = class {
123
166
  };
124
167
  }
125
168
  /**
126
- * Generic method to make authenticated API calls
127
- * @param method HTTP method
128
- * @param endpoint API endpoint
129
- * @param data Request payload
130
- * @returns Promise resolving to API response
169
+ * Generic method to make authenticated API requests to any endpoint
170
+ *
171
+ * @param method - HTTP method to use (GET, POST, PUT, DELETE)
172
+ * @param endpoint - API endpoint path (will be appended to base URL)
173
+ * @param data - Request payload or query parameters
174
+ * @returns Promise resolving to the typed API response
175
+ * @throws Error with detailed message on request failure
131
176
  */
132
177
  async request(method, endpoint, data = {}) {
133
178
  try {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import axios, { AxiosError, AxiosResponse } from \"axios\";\nimport * as crypto from \"crypto\";\nimport {\n CreateSubAccountData,\n CreateSubAccountResponse,\n} from \"./types/subAccount\";\n\n// Interface for constructor parameters\ninterface IPay100Config {\n publicKey: string;\n secretKey?: string;\n baseUrl?: string;\n}\n\n// Interface for transaction data from API\ninterface ITransactionData {\n [key: string]: unknown; // For flexibility, since we don't know the exact structure\n}\n\n// Interface for raw API response\ninterface IRawApiResponse {\n status?: string;\n message?: string;\n data?: unknown;\n [key: string]: unknown;\n}\n\n// Interface for API success response\ninterface IVerifyResponse {\n status: \"success\" | \"error\";\n data: ITransactionData | Record<string, never>;\n message?: string;\n}\n\nconst BASE_URL = process.env.BASE_URL || \"https://api.100pay.co\";\n\n// Error type for payment verification\nexport class PaymentVerificationError extends Error {\n status: string;\n data: Record<string, never>;\n\n constructor(message: string) {\n super(message);\n this.name = \"PaymentVerificationError\";\n this.status = \"error\";\n this.data = {};\n }\n}\n\nexport class Pay100 {\n // optional\n private publicKey: string;\n private secretKey?: string;\n private baseUrl: string;\n\n constructor({ publicKey, secretKey, baseUrl = BASE_URL }: IPay100Config) {\n this.publicKey = publicKey;\n this.secretKey = secretKey;\n this.baseUrl = baseUrl;\n }\n\n /**\n * Creates a request signature for secure server-to-server communication\n * @param payload Request payload to sign\n * @returns Object containing timestamp and signature\n */\n private createSignature(payload: Record<string, unknown>): {\n timestamp: string;\n signature: string;\n } {\n const timestamp = Date.now().toString();\n\n // Extract the token part from the secret key if it's in the format\n // STATUS;TYPE;TOKEN (e.g., \"LIVE;SK;eyJhbGciOiJIUzI1...\")\n let signingSecret = this?.secretKey;\n\n if (this?.secretKey?.includes(\";\")) {\n const secretKeyParts = this.secretKey.split(\";\");\n if (secretKeyParts.length === 3) {\n // Use just the token part as the signing secret\n // This matches what the server expects in the verifySignature middleware\n signingSecret = secretKeyParts[2];\n }\n }\n\n if (!signingSecret) {\n throw new Error(\"Secret key is required for signing\");\n }\n\n // Create signature using HMAC SHA-256\n const signature = crypto\n .createHmac(\"sha256\", signingSecret)\n .update(timestamp + JSON.stringify(payload))\n .digest(\"hex\");\n\n return { timestamp, signature };\n }\n\n /**\n * Create common headers for API requests\n * @param additionalHeaders Additional headers to include\n * @param payload Payload to sign (if signature is needed)\n * @returns Headers object\n */\n private getHeaders(\n payload: Record<string, unknown> = {}\n ): Record<string, string> {\n // Generate signature based on payload\n\n if (this.secretKey) {\n const { timestamp, signature } = this.createSignature(payload);\n return {\n \"api-key\": this.publicKey,\n \"x-secret-key\": this.secretKey,\n \"x-timestamp\": timestamp,\n \"x-signature\": signature,\n \"Content-Type\": \"application/json\",\n };\n }\n return {\n \"api-key\": this.publicKey,\n \"Content-Type\": \"application/json\",\n };\n }\n\n /**\n * Verify a transaction\n * @param transactionId Transaction ID to verify\n * @returns Promise resolving to verification result\n */\n verify = async (transactionId: string): Promise<IVerifyResponse> => {\n try {\n const payload = { transactionId };\n\n const response: AxiosResponse<IRawApiResponse> = await axios({\n method: \"POST\",\n url: `${this.baseUrl}/api/v1/pay/crypto/payment/${transactionId}`,\n headers: this.getHeaders(payload),\n data: payload,\n });\n\n // Handle empty response\n if (!response.data) {\n return {\n status: \"error\",\n data: {},\n message:\n \"Something went wrong, be sure you supplied a valid payment id.\",\n };\n }\n\n // Handle string responses which indicate errors\n if (typeof response.data === \"string\") {\n if (response.data === \"Access Denied, Invalid KEY supplied\") {\n return {\n status: \"error\",\n data: {},\n message: \"Access Denied, Invalid KEY supplied\",\n };\n }\n\n if (response.data === \"invalid payment id supplied\") {\n return {\n status: \"error\",\n data: {},\n };\n }\n }\n\n // Validate and transform response data to ensure type safety\n const responseData = response.data;\n\n // Ensure the response data is an object that can be safely cast to ITransactionData\n const transactionData: ITransactionData =\n responseData && typeof responseData === \"object\"\n ? (responseData as ITransactionData)\n : {};\n\n // Return successful response with properly typed data\n return {\n status: \"success\",\n data: transactionData,\n };\n } catch (error) {\n // Handle Axios errors\n if (axios.isAxiosError(error)) {\n const axiosError = error as AxiosError;\n throw new PaymentVerificationError(\n axiosError.message ||\n \"Something went wrong, be sure you supplied a valid payment id.\"\n );\n }\n\n // Handle other errors\n throw new PaymentVerificationError(\n error instanceof Error ? error.message : \"An unknown error occurred\"\n );\n }\n };\n\n // subaccount methods\n subaccounts = {\n create: async (\n data: CreateSubAccountData\n ): Promise<CreateSubAccountResponse> => {\n return this.request<CreateSubAccountResponse>(\n \"POST\",\n \"/api/v1/assets/subaccount/create\",\n data\n );\n },\n };\n\n /**\n * Generic method to make authenticated API calls\n * @param method HTTP method\n * @param endpoint API endpoint\n * @param data Request payload\n * @returns Promise resolving to API response\n */\n async request<T>(\n method: \"GET\" | \"POST\" | \"PUT\" | \"DELETE\",\n endpoint: string,\n data: Record<string, unknown> = {}\n ): Promise<T> {\n try {\n const url = `${this.baseUrl}${endpoint}`;\n const headers = this.getHeaders(data);\n\n const response = await axios({\n method,\n url,\n headers,\n data: method !== \"GET\" ? data : undefined,\n params: method === \"GET\" ? data : undefined,\n });\n\n return response.data as T;\n } catch (error) {\n if (axios.isAxiosError(error)) {\n const axiosError = error as AxiosError;\n const errorMessage =\n axiosError.response?.data &&\n typeof axiosError.response.data === \"object\" &&\n \"message\" in axiosError.response.data\n ? String(axiosError.response.data.message)\n : axiosError.message;\n\n throw new Error(`API Request Failed: ${errorMessage}`);\n }\n\n throw error;\n }\n }\n}\n\nexport * from \"./types\";\n"],"mappings":";AAAA,OAAO,WAA0C;AACjD,YAAY,YAAY;AAiCxB,IAAM,WAAW,QAAQ,IAAI,YAAY;AAGlC,IAAM,2BAAN,cAAuC,MAAM;AAAA,EAIlD,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,OAAO,CAAC;AAAA,EACf;AACF;AAEO,IAAM,SAAN,MAAa;AAAA,EAMlB,YAAY,EAAE,WAAW,WAAW,UAAU,SAAS,GAAkB;AA2EzE;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAS,OAAO,kBAAoD;AAClE,UAAI;AACF,cAAM,UAAU,E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AAG;AAC7B,cAAM,aAAa;AACnB,cAAM,eACJ,WAAW,UAAU,QACrB,OAAO,WAAW,SAAS,SAAS,YACpC,aAAa,WAAW,SAAS,OAC7B,OAAO,WAAW,SAAS,KAAK,OAAO,IACvC,WAAW;AAEjB,cAAM,IAAI,MAAM,uBAAuB,YAAY,EAAE;AAAA,MACvD;AAEA,YAAM;AAAA,IACR;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// src/index.ts\n\nimport axios, { AxiosError, AxiosResponse } from \"axios\";\nimport * as crypto from \"crypto\";\nimport {\n CreateSubAccountData,\n CreateSubAccountResponse,\n} from \"./types/subAccount\";\nimport { CurrencyConversionPayload, CurrencyConversionResult } from \"./types\";\n\n/**\n * Configuration interface for initializing the Pay100 SDK\n * @property publicKey - API public key required for all API calls\n * @property secretKey - Secret key used for server-side authentication and request signing\n * @property baseUrl - Optional API base URL, defaults to production endpoint\n */\ninterface IPay100Config {\n publicKey: string;\n secretKey?: string;\n baseUrl?: string;\n}\n\n/**\n * Interface representing transaction data returned from payment verification\n * Flexible structure to accommodate various transaction types and properties\n */\ninterface ITransactionData {\n [key: string]: unknown;\n}\n\n/**\n * Interface for raw API responses before processing\n * Provides a flexible structure while capturing common response elements\n */\ninterface IRawApiResponse {\n status?: string;\n message?: string;\n data?: unknown;\n [key: string]: unknown;\n}\n\n/**\n * Standardized response interface for transaction verification\n * @property status - Result status ('success' or 'error')\n * @property data - Transaction details when successful, empty object on failure\n * @property message - Optional response message, typically present on errors\n */\ninterface IVerifyResponse {\n status: \"success\" | \"error\";\n data: ITransactionData | Record<string, never>;\n message?: string;\n}\n\n// Default API endpoint if not otherwise specified\nconst BASE_URL = process.env.BASE_URL || \"https://api.100pay.co\";\n\n/**\n * Custom error class for payment verification failures\n * Provides consistent error structure for better error handling\n */\nexport class PaymentVerificationError extends Error {\n status: string;\n data: Record<string, never>;\n\n constructor(message: string) {\n super(message);\n this.name = \"PaymentVerificationError\";\n this.status = \"error\";\n this.data = {};\n }\n}\n\n/**\n * Main SDK class for interacting with the 100Pay payment platform\n * Provides methods for transaction verification, subaccount management,\n * and currency conversion\n */\nexport class Pay100 {\n private publicKey: string;\n private secretKey?: string;\n private baseUrl: string;\n\n /**\n * Initialize the Pay100 SDK\n * @param config - Configuration object containing API keys and optional base URL\n */\n constructor({ publicKey, secretKey, baseUrl = BASE_URL }: IPay100Config) {\n this.publicKey = publicKey;\n this.secretKey = secretKey;\n this.baseUrl = baseUrl;\n }\n\n /**\n * Creates a cryptographic signature for secure server-to-server communication\n *\n * @param payload - Request payload that needs to be signed\n * @returns Object containing current timestamp and HMAC SHA-256 signature\n * @throws Error if secret key is missing or invalid\n */\n private createSignature(payload: Record<string, unknown>): {\n timestamp: string;\n signature: string;\n } {\n const timestamp = Date.now().toString();\n\n // Extract the token part from the secret key if it's in the format\n // STATUS;TYPE;TOKEN (e.g., \"LIVE;SK;eyJhbGciOiJIUzI1...\")\n let signingSecret = this?.secretKey;\n\n if (this?.secretKey?.includes(\";\")) {\n const secretKeyParts = this.secretKey.split(\";\");\n if (secretKeyParts.length === 3) {\n // Use just the token part as the signing secret\n signingSecret = secretKeyParts[2];\n }\n }\n\n if (!signingSecret) {\n throw new Error(\"Secret key is required for signing\");\n }\n\n // Create signature using HMAC SHA-256\n const signature = crypto\n .createHmac(\"sha256\", signingSecret)\n .update(timestamp + JSON.stringify(payload))\n .digest(\"hex\");\n\n return { timestamp, signature };\n }\n\n /**\n * Constructs HTTP headers for API requests with optional authentication\n *\n * @param payload - Request payload used to generate security signature\n * @returns Object containing all necessary HTTP headers\n */\n private getHeaders(\n payload: Record<string, unknown> = {}\n ): Record<string, string> {\n // Generate authentication headers if secret key is available (server-side mode)\n if (this.secretKey) {\n const { timestamp, signature } = this.createSignature(payload);\n return {\n \"api-key\": this.publicKey,\n \"x-secret-key\": this.secretKey,\n \"x-timestamp\": timestamp,\n \"x-signature\": signature,\n \"Content-Type\": \"application/json\",\n };\n }\n\n // Basic headers for public API usage (client-side mode)\n return {\n \"api-key\": this.publicKey,\n \"Content-Type\": \"application/json\",\n };\n }\n\n /**\n * Verifies the status and details of a payment transaction\n *\n * @param transactionId - Unique identifier of the transaction to verify\n * @returns Promise resolving to verification result with transaction data\n * @throws PaymentVerificationError on network issues or invalid responses\n */\n verify = async (transactionId: string): Promise<IVerifyResponse> => {\n try {\n const payload = { transactionId };\n\n const response: AxiosResponse<IRawApiResponse> = await axios({\n method: \"POST\",\n url: `${this.baseUrl}/api/v1/pay/crypto/payment/${transactionId}`,\n headers: this.getHeaders(payload),\n data: payload,\n });\n\n // Handle empty response\n if (!response.data) {\n return {\n status: \"error\",\n data: {},\n message:\n \"Something went wrong, be sure you supplied a valid payment id.\",\n };\n }\n\n // Handle string responses which indicate errors\n if (typeof response.data === \"string\") {\n if (response.data === \"Access Denied, Invalid KEY supplied\") {\n return {\n status: \"error\",\n data: {},\n message: \"Access Denied, Invalid KEY supplied\",\n };\n }\n\n if (response.data === \"invalid payment id supplied\") {\n return {\n status: \"error\",\n data: {},\n };\n }\n }\n\n // Validate and transform response data to ensure type safety\n const responseData = response.data;\n\n // Ensure the response data is an object that can be safely cast to ITransactionData\n const transactionData: ITransactionData =\n responseData && typeof responseData === \"object\"\n ? (responseData as ITransactionData)\n : {};\n\n // Return successful response with properly typed data\n return {\n status: \"success\",\n data: transactionData,\n };\n } catch (error) {\n // Handle Axios errors with detailed message\n if (axios.isAxiosError(error)) {\n const axiosError = error as AxiosError;\n throw new PaymentVerificationError(\n axiosError.message ||\n \"Something went wrong, be sure you supplied a valid payment id.\"\n );\n }\n\n // Handle other errors with appropriate message\n throw new PaymentVerificationError(\n error instanceof Error ? error.message : \"An unknown error occurred\"\n );\n }\n };\n\n /**\n * Namespace for subaccount management operations\n * Provides methods to create and manage subaccounts\n */\n subaccounts = {\n /**\n * Creates a new subaccount within the platform\n *\n * @param data - Subaccount configuration including owner details and supported currencies\n * @returns Promise resolving to the created subaccount details\n * @throws Error if the request fails or returns invalid data\n */\n create: async (\n data: CreateSubAccountData\n ): Promise<CreateSubAccountResponse> => {\n return this.request<CreateSubAccountResponse>(\n \"POST\",\n \"/api/v1/assets/subaccount/create\",\n data\n );\n },\n };\n\n /**\n * Namespace for currency conversion operations\n * Provides methods to calculate exchange rates and fees\n */\n conversion = {\n /**\n * Calculates a preview of currency conversion with rates and fees\n *\n * @param data - Conversion details including amount, source and target currencies\n * @returns Promise resolving to detailed conversion calculation\n * @throws Error if the request fails or returns invalid data\n */\n preview: async (\n data: CurrencyConversionPayload\n ): Promise<CurrencyConversionResult> => {\n return this.request<CurrencyConversionResult>(\n \"POST\",\n \"/api/v1/user/preview-convert-asset\",\n {\n amount: data.amount,\n to_symbol: data.toSymbol,\n from_symbol: data.fromSymbol,\n appId: data.appId,\n }\n );\n },\n };\n\n /**\n * Generic method to make authenticated API requests to any endpoint\n *\n * @param method - HTTP method to use (GET, POST, PUT, DELETE)\n * @param endpoint - API endpoint path (will be appended to base URL)\n * @param data - Request payload or query parameters\n * @returns Promise resolving to the typed API response\n * @throws Error with detailed message on request failure\n */\n async request<T>(\n method: \"GET\" | \"POST\" | \"PUT\" | \"DELETE\",\n endpoint: string,\n data: Record<string, unknown> = {}\n ): Promise<T> {\n try {\n const url = `${this.baseUrl}${endpoint}`;\n const headers = this.getHeaders(data);\n\n const response = await axios({\n method,\n url,\n headers,\n data: method !== \"GET\" ? data : undefined,\n params: method === \"GET\" ? data : undefined,\n });\n\n return response.data as T;\n } catch (error) {\n if (axios.isAxiosError(error)) {\n const axiosError = error as AxiosError;\n const errorMessage =\n axiosError.response?.data &&\n typeof axiosError.response.data === \"object\" &&\n \"message\" in axiosError.response.data\n ? String(axiosError.response.data.message)\n : axiosError.message;\n\n throw new Error(`API Request Failed: ${errorMessage}`);\n }\n\n throw error;\n }\n }\n}\n\nexport * from \"./types\";\n"],"mappings":";AAEA,OAAO,WAA0C;AACjD,YAAY,YAAY;AAmDxB,IAAM,WAAW,QAAQ,IAAI,YAAY;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ACZ;AAExB,QAAI,KAAK,WAAW;AAClB,YAAM,EAAE,WAAW,UAAU,IAAI,KAAK,gBAAgB,OAAO;AAC7D,aAAO;AAAA,QACL,WAAW,KAAK;AAAA,QAChB,gBAAgB,KAAK;AAAA,QACrB,eAAe;AAAA,QACf,eAAe;AAAA,QACf,gBAAgB;AAAA,MAClB;AAAA,IACF;AAGA,WAAO;AAAA,MACL,WAAW,KAAK;AAAA,MAChB,gBAAgB;AAAA,IAClB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA2IA,MAAM,QACJ,QACA,UACA,OAAgC,CAAC,GACrB;AACZ,QAAI;AACF,YAAM,MAAM,GAAG,KAAK,OAAO,GAAG,QAAQ;AACtC,YAAM,UAAU,KAAK,WAAW,IAAI;AAEpC,YAAM,WAAW,MAAM,MAAM;AAAA,QAC3B;AAAA,QACA;AAAA,QACA;AAAA,QACA,MAAM,WAAW,QAAQ,OAAO;AAAA,QAChC,QAAQ,WAAW,QAAQ,OAAO;AAAA,MACpC,CAAC;AAED,aAAO,SAAS;AAAA,IAClB,SAAS,OAAO;AACd,UAAI,MAAM,aAAa,KAAK,GAAG;AAC7B,cAAM,aAAa;AACnB,cAAM,eACJ,WAAW,UAAU,QACrB,OAAO,WAAW,SAAS,SAAS,YACpC,aAAa,WAAW,SAAS,OAC7B,OAAO,WAAW,SAAS,KAAK,OAAO,IACvC,WAAW;AAEjB,cAAM,IAAI,MAAM,uBAAuB,YAAY,EAAE;AAAA,MACvD;AAEA,YAAM;AAAA,IACR;AAAA,EACF;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@100pay-hq/100pay.js",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "description": "100Pay.js is the official Nodejs API wrapper SDK that lets you easily verify crypto payments, run bulk payout, transfer assets and many more.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",