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

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.
Files changed (2) hide show
  1. package/README.md +82 -18
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,12 +1,13 @@
1
1
  # 100Pay SDK
2
2
 
3
- A TypeScript library for integrating with the 100Pay payment platform, enabling developers to easily accept cryptocurrency payments.
3
+ A TypeScript library for integrating with the 100Pay payment platform, enabling developers to easily accept cryptocurrency payments and manage transactions.
4
4
 
5
5
  ## Features
6
6
 
7
7
  - ✅ Verify cryptocurrency payments
8
8
  - ✅ Create and manage subaccounts
9
- - ✅ Make cryptocurrency transfers
9
+ - ✅ Preview currency conversions
10
+ - ✅ Make authenticated API requests
10
11
  - ✅ Full TypeScript support with comprehensive typing
11
12
  - ✅ Secure server-to-server communication with request signing
12
13
 
@@ -30,7 +31,7 @@ import { Pay100 } from '@100pay-hq/100pay.js';
30
31
  // Initialize the 100Pay client
31
32
  const client = new Pay100({
32
33
  publicKey: 'your_public_key',
33
- secretKey: 'your_secret_key'
34
+ secretKey: 'your_secret_key' // Required for server-side operations
34
35
  });
35
36
 
36
37
  // Verify a transaction
@@ -60,7 +61,7 @@ async function verifyTransaction(transactionId) {
60
61
  const client = new Pay100({
61
62
  publicKey: string, // Your 100Pay public API key (required)
62
63
  secretKey?: string, // Your 100Pay secret API key (required for server-side operations)
63
- baseUrl?: string // Optional custom API base URL
64
+ baseUrl?: string // Optional custom API base URL (defaults to https://api.100pay.co)
64
65
  });
65
66
  ```
66
67
 
@@ -144,6 +145,43 @@ interface CreateSubAccountResponse {
144
145
  }
145
146
  ```
146
147
 
148
+ ### Currency Conversion
149
+
150
+ Preview currency conversion rates and fees:
151
+
152
+ ```typescript
153
+ // Preview a currency conversion
154
+ const conversion = await client.conversion.preview({
155
+ amount: 100,
156
+ fromSymbol: "BTC",
157
+ toSymbol: "USDT",
158
+ appId: "your_app_id" // Optional
159
+ });
160
+ ```
161
+
162
+ **Parameters:**
163
+
164
+ ```typescript
165
+ interface CurrencyConversionPayload {
166
+ amount: number;
167
+ fromSymbol: string;
168
+ toSymbol: string;
169
+ appId?: string;
170
+ }
171
+ ```
172
+
173
+ **Returns:**
174
+
175
+ ```typescript
176
+ interface CurrencyConversionResult {
177
+ status: string;
178
+ message: string;
179
+ data: {
180
+ // Conversion details including rates and fees
181
+ };
182
+ }
183
+ ```
184
+
147
185
  ### Generic API Requests
148
186
 
149
187
  The SDK provides a generic `request` method for making any API call to the 100Pay API:
@@ -156,6 +194,16 @@ const response = await client.request<ResponseType>(
156
194
  );
157
195
  ```
158
196
 
197
+ **Example:**
198
+
199
+ ```typescript
200
+ // Get user balance
201
+ const balance = await client.request<BalanceResponse>(
202
+ 'GET',
203
+ '/api/v1/user/balance'
204
+ );
205
+ ```
206
+
159
207
  ## Error Handling
160
208
 
161
209
  The SDK provides typed error handling:
@@ -177,14 +225,25 @@ try {
177
225
 
178
226
  ## Security and Authentication
179
227
 
180
- This SDK implements secure authentication with 100Pay using API keys and request signing for server-to-server communications. All requests that require authentication automatically include the necessary headers with timestamps and signatures.
228
+ This SDK implements secure authentication with 100Pay using API keys and request signing for server-to-server communications:
229
+
230
+ 1. Each request is signed with HMAC SHA-256 using your secret key
231
+ 2. Signatures include a timestamp to prevent replay attacks
232
+ 3. All requests include your public API key for identification
233
+
234
+ Client-side operations can use public key only, while server-side operations require both public and secret keys.
181
235
 
182
236
  ## TypeScript Support
183
237
 
184
238
  This package is built with TypeScript and includes full type definitions. The main types are exported for your convenience:
185
239
 
186
240
  ```typescript
187
- import { Pay100, PaymentVerificationError, CreateSubAccountData } from '@100pay-hq/100pay.js';
241
+ import {
242
+ Pay100,
243
+ PaymentVerificationError,
244
+ CreateSubAccountData,
245
+ CurrencyConversionPayload
246
+ } from '@100pay-hq/100pay.js';
188
247
  ```
189
248
 
190
249
  ## Common Use Cases
@@ -207,6 +266,22 @@ const subaccount = await client.subaccounts.create({
207
266
  console.log(`Created subaccount: ${subaccount.data.id}`);
208
267
  ```
209
268
 
269
+ ### Currency Conversion Preview
270
+
271
+ ```typescript
272
+ // Get conversion rates before executing a trade
273
+ const preview = await client.conversion.preview({
274
+ amount: 1000,
275
+ fromSymbol: "USDT",
276
+ toSymbol: "BTC"
277
+ });
278
+
279
+ // Show user the conversion details
280
+ console.log(`You will receive approximately ${preview.data.receivedAmount} ${preview.data.toSymbol}`);
281
+ console.log(`Exchange rate: 1 ${preview.data.fromSymbol} = ${preview.data.rate} ${preview.data.toSymbol}`);
282
+ console.log(`Fee: ${preview.data.fee} ${preview.data.fromSymbol}`);
283
+ ```
284
+
210
285
  ## Resources
211
286
 
212
287
  - [100Pay Platform](https://100pay.co)
@@ -237,17 +312,6 @@ npm run build
237
312
  - `npm run lint` - Lint the code
238
313
  - `npm run lint:fix` - Lint and fix code
239
314
 
240
- ## Migration from JavaScript Version
241
-
242
- The TypeScript version includes some improvements over the original JavaScript version:
243
-
244
- 1. Uses `axios` instead of the deprecated `request` library
245
- 2. Better error handling with typed errors
246
- 3. Stricter type checking for method parameters and return values
247
- 4. Object-based constructor for better flexibility
248
-
249
- If you're migrating from the JavaScript version, note that the constructor now requires an object parameter rather than individual arguments.
250
-
251
315
  ## License
252
316
 
253
- [MIT License](LICENSE.md).
317
+ [MIT License](LICENSE.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@100pay-hq/100pay.js",
3
- "version": "1.2.5",
3
+ "version": "1.2.6",
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",