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

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 +154 -25
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -117,9 +117,17 @@ Subaccounts allow you to create and manage separate accounts under your main acc
117
117
  ```typescript
118
118
  // Create a subaccount
119
119
  const subaccount = await client.subaccounts.create({
120
- name: "Partner Store",
121
- email: "partner@example.com",
122
- // Additional properties as needed
120
+ symbols: ["BTC", "ETH", "USDT"],
121
+ networks: ["ETHEREUM", "BSC"],
122
+ owner: {
123
+ name: "Partner Store",
124
+ email: "partner@example.com",
125
+ phone: "+1234567890"
126
+ },
127
+ metadata: {
128
+ storeId: "store-123",
129
+ region: "US"
130
+ }
123
131
  });
124
132
  ```
125
133
 
@@ -127,9 +135,14 @@ const subaccount = await client.subaccounts.create({
127
135
 
128
136
  ```typescript
129
137
  interface CreateSubAccountData {
130
- name: string;
131
- email: string;
132
- // Additional properties defined in types
138
+ symbols: string[]; // List of supported cryptocurrencies
139
+ networks: string[]; // List of supported blockchain networks
140
+ owner: {
141
+ name: string; // Owner's name
142
+ email: string; // Owner's email
143
+ phone: string; // Owner's phone number
144
+ };
145
+ metadata: Record<string, unknown>; // Custom metadata for the subaccount
133
146
  }
134
147
  ```
135
148
 
@@ -137,11 +150,88 @@ interface CreateSubAccountData {
137
150
 
138
151
  ```typescript
139
152
  interface CreateSubAccountResponse {
140
- status: string;
141
153
  message: string;
142
- data: {
143
- // Subaccount properties
154
+ accounts: Account[];
155
+ }
156
+
157
+ interface Account {
158
+ balance: {
159
+ available: number | null;
160
+ locked: number | null;
161
+ };
162
+ accountType: string; // e.g. "subaccount"
163
+ walletType: string; // e.g. "crypto"
164
+ status: string; // e.g. "active"
165
+ _id: string;
166
+ name: string; // e.g. "Tether USDT"
167
+ symbol: string; // e.g. "USDT"
168
+ decimals: string; // e.g. "18"
169
+ account: AccountDetails;
170
+ contractAddress: string;
171
+ logo: string;
172
+ userId: string;
173
+ appId: string;
174
+ network: string;
175
+ ownerId: string;
176
+ parentWallet: string;
177
+ __v: number;
178
+ }
179
+
180
+ interface AccountDetails {
181
+ address: string;
182
+ key: Key;
183
+ network: string;
184
+ }
185
+
186
+ interface Key {
187
+ version: number;
188
+ id: string;
189
+ address: string;
190
+ crypto: Crypto;
191
+ }
192
+
193
+ interface Crypto {
194
+ ciphertext: string;
195
+ cipherparams: {
196
+ iv: string;
197
+ };
198
+ cipher: string;
199
+ kdf: string;
200
+ kdfparams: {
201
+ dklen: number;
202
+ salt: string;
203
+ n: number;
204
+ r: number;
205
+ p: number;
144
206
  };
207
+ mac: string;
208
+ }
209
+ ```
210
+
211
+ **Example:**
212
+
213
+ ```typescript
214
+ try {
215
+ const result = await client.subaccounts.create({
216
+ symbols: ["USDT", "BTC"],
217
+ networks: ["ETHEREUM"],
218
+ owner: {
219
+ name: "Merchant Store",
220
+ email: "merchant@example.com",
221
+ phone: "+1234567890"
222
+ },
223
+ metadata: {
224
+ businessType: "ecommerce"
225
+ }
226
+ });
227
+
228
+ console.log(`Created ${result.accounts.length} accounts for the subaccount`);
229
+ // Store wallet addresses for each account
230
+ result.accounts.forEach(account => {
231
+ console.log(`${account.symbol} wallet: ${account.account.address}`);
232
+ });
233
+ } catch (error) {
234
+ console.error(`Failed to create subaccount: ${error.message}`);
145
235
  }
146
236
  ```
147
237
 
@@ -163,10 +253,10 @@ const conversion = await client.conversion.preview({
163
253
 
164
254
  ```typescript
165
255
  interface CurrencyConversionPayload {
166
- amount: number;
167
- fromSymbol: string;
168
- toSymbol: string;
169
- appId?: string;
256
+ amount: number; // Amount to convert
257
+ fromSymbol: string; // Source currency symbol
258
+ toSymbol: string; // Target currency symbol
259
+ appId?: string; // Optional application ID
170
260
  }
171
261
  ```
172
262
 
@@ -174,11 +264,36 @@ interface CurrencyConversionPayload {
174
264
 
175
265
  ```typescript
176
266
  interface CurrencyConversionResult {
177
- status: string;
178
- message: string;
179
- data: {
180
- // Conversion details including rates and fees
181
- };
267
+ convertedAmount: number; // Final amount after conversion
268
+ totalAmount: number; // Total amount including fees
269
+ feeInUSD: number; // Fee amount in USD
270
+ feeInToCurrency: number; // Fee amount in target currency
271
+ feeInfromSymbol: number; // Fee amount in source currency
272
+ conversionFeeInUSD: number; // Conversion fee in USD
273
+ conversionFeeInToCurrency: number; // Conversion fee in target currency
274
+ conversionFeeInfromSymbol: number; // Conversion fee in source currency
275
+ fromRate: number; // Exchange rate for source currency
276
+ toRate: number; // Exchange rate for target currency
277
+ intermediateUSDAmount: number; // Intermediate amount in USD
278
+ }
279
+ ```
280
+
281
+ **Example:**
282
+
283
+ ```typescript
284
+ try {
285
+ const preview = await client.conversion.preview({
286
+ amount: 0.5,
287
+ fromSymbol: "BTC",
288
+ toSymbol: "USDT"
289
+ });
290
+
291
+ console.log(`Converting 0.5 BTC to USDT:`);
292
+ console.log(`You will receive: ${preview.convertedAmount} USDT`);
293
+ console.log(`Exchange rate: 1 BTC = ${preview.toRate / preview.fromRate} USDT`);
294
+ console.log(`Total fees: ${preview.feeInUSD} USD (${preview.feeInfromSymbol} BTC)`);
295
+ } catch (error) {
296
+ console.error(`Conversion preview failed: ${error.message}`);
182
297
  }
183
298
  ```
184
299
 
@@ -242,7 +357,10 @@ import {
242
357
  Pay100,
243
358
  PaymentVerificationError,
244
359
  CreateSubAccountData,
245
- CurrencyConversionPayload
360
+ CurrencyConversionPayload,
361
+ CurrencyConversionResult,
362
+ Account,
363
+ AccountDetails
246
364
  } from '@100pay-hq/100pay.js';
247
365
  ```
248
366
 
@@ -258,12 +376,23 @@ import {
258
376
 
259
377
  ```typescript
260
378
  const subaccount = await client.subaccounts.create({
261
- name: "Partner Name",
262
- email: "partner@example.com"
379
+ symbols: ["BTC", "ETH", "USDT"],
380
+ networks: ["ETHEREUM"],
381
+ owner: {
382
+ name: "Partner Name",
383
+ email: "partner@example.com",
384
+ phone: "+1234567890"
385
+ },
386
+ metadata: {
387
+ partnerId: "partner-123"
388
+ }
263
389
  });
264
390
 
265
391
  // Save the subaccount information for future use
266
- console.log(`Created subaccount: ${subaccount.data.id}`);
392
+ console.log(`Created subaccount with ${subaccount.accounts.length} wallets`);
393
+ subaccount.accounts.forEach(account => {
394
+ console.log(`${account.symbol} wallet: ${account.account.address}`);
395
+ });
267
396
  ```
268
397
 
269
398
  ### Currency Conversion Preview
@@ -277,9 +406,9 @@ const preview = await client.conversion.preview({
277
406
  });
278
407
 
279
408
  // 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}`);
409
+ console.log(`You will receive approximately ${preview.convertedAmount} BTC`);
410
+ console.log(`Exchange rate: 1 USDT = ${preview.toRate / preview.fromRate} BTC`);
411
+ console.log(`Fee: ${preview.feeInfromSymbol} USDT (${preview.feeInUSD} USD)`);
283
412
  ```
284
413
 
285
414
  ## Resources
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@100pay-hq/100pay.js",
3
- "version": "1.2.6",
3
+ "version": "1.2.7",
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",