@yosle/tropipayjs 0.2.3 → 0.3.0

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 (47) hide show
  1. package/README.md +69 -9
  2. package/index.d.ts +358 -76
  3. package/index.js +421 -342
  4. package/index.js.map +1 -0
  5. package/package.json +10 -2
  6. package/.nvmrc +0 -1
  7. package/.vscode/launch.json +0 -18
  8. package/SECURITY.md +0 -43
  9. package/api/TropipayAPI.d.ts +0 -133
  10. package/config/TropipayConfig.d.ts +0 -2
  11. package/constants/TropipayConstants.d.ts +0 -2
  12. package/depositAccount/depositAccounts.d.ts +0 -36
  13. package/docs/readme.md +0 -3
  14. package/globals.d.ts +0 -75
  15. package/hooks/TropipayHooks.d.ts +0 -38
  16. package/interfaces/countries/index.d.ts +0 -1
  17. package/interfaces/depositaccounts/index.d.ts +0 -68
  18. package/interfaces/index.d.ts +0 -176
  19. package/interfaces/mediation/index.d.ts +0 -22
  20. package/interfaces/paymentlink/index.d.ts +0 -87
  21. package/jest.config.js +0 -5
  22. package/mediationPaymentCard/MediationPaymentCard.d.ts +0 -17
  23. package/paymentcard/PaymentCard.d.ts +0 -37
  24. package/paymentcard/paymentcard.spec.d.ts +0 -1
  25. package/rollup.config.js +0 -23
  26. package/src/api/TropipayAPI.ts +0 -459
  27. package/src/config/TropipayConfig.ts +0 -2
  28. package/src/constants/TropipayConstants.ts +0 -2
  29. package/src/depositAccount/depositAccounts.ts +0 -139
  30. package/src/hooks/TropipayHooks.ts +0 -154
  31. package/src/index.ts +0 -29
  32. package/src/interfaces/depositaccounts/index.ts +0 -70
  33. package/src/interfaces/index.js +0 -2
  34. package/src/interfaces/index.ts +0 -212
  35. package/src/interfaces/mediation/index.ts +0 -23
  36. package/src/interfaces/paymentlink/index.d.ts +0 -36
  37. package/src/interfaces/paymentlink/index.js +0 -3
  38. package/src/interfaces/paymentlink/index.ts +0 -91
  39. package/src/mediationPaymentCard/MediationPaymentCard.ts +0 -42
  40. package/src/mocks/tropipay.ts +0 -0
  41. package/src/paymentcard/PaymentCard.ts +0 -123
  42. package/src/paymentcard/paymentcard.spec.ts +0 -79
  43. package/src/utils/TropipayUtils.ts +0 -126
  44. package/src/utils/errors.ts +0 -92
  45. package/tsconfig.json +0 -96
  46. package/utils/TropipayUtils.d.ts +0 -45
  47. package/utils/errors.d.ts +0 -16
package/index.d.ts CHANGED
@@ -1,7 +1,12 @@
1
1
  import { Axios } from 'axios';
2
2
 
3
3
  type ServerMode$1 = "Development" | "Production";
4
- declare const MAX_IMAGE_SIZE_MB = 1;
4
+ declare const MAX_IMAGE_SIZE_MB = 2;
5
+ /**
6
+ * Base path for the Tropipay API. All SDK endpoints target API v3
7
+ * (v2 is deprecated).
8
+ */
9
+ declare const API_BASE = "/api/v3";
5
10
 
6
11
  type AccountBalance = {
7
12
  balance: number;
@@ -26,25 +31,83 @@ interface UserHook {
26
31
  target: string;
27
32
  value: string;
28
33
  }
29
- interface UserHook {
30
- event: HookEventType;
31
- target: string;
32
- value: string;
33
- }
34
34
  interface UserHookSubscribed extends UserHook {
35
35
  createdAt: string;
36
36
  updatedAt: string;
37
37
  }
38
- interface UserHookSubscribed extends UserHook {
39
- createdAt: string;
40
- updatedAt: string;
38
+ /**
39
+ * Payment methods accepted by the Tropipay API for payment links
40
+ * (`paymentMethods` field of a paymentcard).
41
+ *
42
+ * - `TPP`: pay with Tropipay balance.
43
+ * - `EXT`: external credit/debit card.
44
+ * - `CRYPTO`: pay with cryptocurrency.
45
+ * - `WIRE_TRANSFER`: bank wire transfer.
46
+ * - `APPLE_PAY` / `GOOGLE_PAY`: wallet payments. The server adds them
47
+ * automatically when `EXT` is present, so they rarely need to be sent.
48
+ * - `TPP_GIFTCARD`: Tropipay gift card.
49
+ * - `TROPICARD`: Tropicard.
50
+ */
51
+ type PaymentMethod = "TPP" | "EXT" | "CRYPTO" | "WIRE_TRANSFER" | "APPLE_PAY" | "GOOGLE_PAY" | "TPP_GIFTCARD" | "TROPICARD";
52
+ /**
53
+ * Payment reasons accepted in the `reasonId` field.
54
+ */
55
+ declare enum Reasons {
56
+ HOUSING_ARRANGEMENT = 1,
57
+ FINANCIAL_AID = 2,
58
+ FAMILY_SUPPORT = 3,
59
+ TRAVEL_FUND = 4,
60
+ REAL_ESTATE_PURCHASE = 5,
61
+ FURNITURE_PURCHASE = 6,
62
+ EDUCATION = 7,
63
+ MEDICAL_EXPENSES = 8,
64
+ OTHER = 9,
65
+ DEBT_PAYMENT = 10,
66
+ TOURISM = 11,
67
+ SELF_SHIPPING = 12,
68
+ ACCOUNT_ACTIVATION = 13,
69
+ SPORTS_ACTIVITIES = 14,
70
+ DONATION = 15,
71
+ AFFILIATE_COMMISSION = 16,
72
+ SALARY = 17,
73
+ SAVINGS = 18,
74
+ RENT_AND_LEASING = 19,
75
+ SHARED_EXPENSES = 20,
76
+ SERVICE_PAYMENT = 21,
77
+ GIFT = 22,
78
+ CRYPTOCURRENCY_PURCHASE = 23,
79
+ OPERATING_EXPENSES = 24,
80
+ CURRENCY_EXCHANGE = 25,
81
+ ACCOMMODATION = 26,
82
+ EQUIPMENT_PURCHASE = 27,
83
+ CONSULTING = 28,
84
+ SOFTWARE_DEVELOPMENT = 29,
85
+ REFUND = 30,
86
+ PACKAGE_DELIVERY = 31,
87
+ PERSONAL_EXPENSES = 32,
88
+ INVESTMENT = 33,
89
+ BILL_PAYMENT = 34,
90
+ HOST_PAYMENT = 35,
91
+ TRANSPORTATION = 36,
92
+ LOAN = 37,
93
+ BONUS = 38,
94
+ HALLOWEEN_REMITTANCE = 39,
95
+ PLINK_REMITTANCE = 41,
96
+ R1_2023 = 78,
97
+ HAPPYWEEK = 79,
98
+ SENDING_YOU_A_KISS = 80
41
99
  }
100
+ /**
101
+ * Currencies accepted when creating a payment link (API v3).
102
+ */
103
+ type PaymentLinkCurrency = "USD" | "EUR" | "USDC" | "USDT";
42
104
  interface PaymentLinkPayload {
43
105
  reference: string;
44
106
  concept: string;
45
107
  favorite: boolean;
108
+ /** Amount in cents (minimum 100). */
46
109
  amount: number;
47
- currency: string;
110
+ currency: PaymentLinkCurrency;
48
111
  description: string;
49
112
  singleUse: boolean;
50
113
  reasonId: number;
@@ -67,9 +130,35 @@ interface PaymentLinkPayload {
67
130
  termsAndConditions: boolean;
68
131
  } | null;
69
132
  directPayment: boolean;
70
- paymentMethods?: string[];
133
+ /**
134
+ * Payment methods to offer on the payment page.
135
+ * If omitted the server defaults to `["EXT", "TPP", "WIRE_TRANSFER"]`.
136
+ * `APPLE_PAY`/`GOOGLE_PAY` are injected automatically when `EXT` is
137
+ * included. The server intersects this list with the methods enabled
138
+ * for the account, so a requested method (e.g. `CRYPTO`) only shows
139
+ * up if the account has it active.
140
+ */
141
+ paymentMethods?: PaymentMethod[];
71
142
  imageBase?: string;
72
143
  saveToken?: boolean;
144
+ /**
145
+ * Account that will receive the payment (multi-account support).
146
+ * Must belong to the authenticated user, otherwise the API responds
147
+ * with ACCOUNT_NOT_FOUND. Defaults to the user's default account.
148
+ */
149
+ accountId?: number;
150
+ /** Absolute expiration timestamp (ISO 8601). Alternative to expirationDays. */
151
+ expirationDate?: string;
152
+ /**
153
+ * 3D-Secure behavior: "default" lets Tropipay decide, "force" always
154
+ * requires 3DS, "bypass" skips it (needs the SKIP_3DS_VERIFICATION_MARKETPLACE
155
+ * setting enabled on the account, otherwise falls back to "default").
156
+ */
157
+ payment3DS?: "default" | "force" | "bypass";
158
+ strictPostalCodeCheck?: boolean;
159
+ strictAddressCheck?: boolean;
160
+ /** 1 = SIMPLE, 2 = MEDIATION, 3 = GIFTCARD, 4 = MARKETPLACE */
161
+ paymentcardType?: 1 | 2 | 3 | 4;
73
162
  }
74
163
  interface PaymentLink extends PaymentLinkPayload {
75
164
  expirationDate: string;
@@ -80,25 +169,6 @@ interface PaymentLink extends PaymentLinkPayload {
80
169
  shortUrl: string;
81
170
  paymentUrl: string;
82
171
  }
83
- interface MediationPaymentCardConfig {
84
- amount: number;
85
- currency: "EUR" | "USD";
86
- concept: string;
87
- description: string;
88
- reference: string;
89
- singleUse: boolean;
90
- lang: string;
91
- productUrl?: string;
92
- buyer: null | any;
93
- seller: {
94
- sellerId?: number;
95
- type?: number;
96
- email?: string;
97
- };
98
- feePercent?: number;
99
- feeFixed?: number;
100
- sendMail: boolean;
101
- }
102
172
  type LoginResponse = {
103
173
  access_token: string;
104
174
  refresh_token: string;
@@ -125,6 +195,74 @@ type Country = {
125
195
  isFavorite: boolean;
126
196
  position: any;
127
197
  };
198
+ /**
199
+ * A Tropipay account (a user can hold several, one per currency).
200
+ * Returned by `tpp.accounts.list()` — use `id` as the `accountId`
201
+ * when creating payment links or transfers.
202
+ */
203
+ type Account = {
204
+ id: number;
205
+ accountNumber: string;
206
+ currency: string;
207
+ balance: number;
208
+ pendingIn?: number;
209
+ pendingOut?: number;
210
+ state: number;
211
+ isDefault?: boolean;
212
+ type?: number;
213
+ createdAt?: string;
214
+ updatedAt?: string;
215
+ /** Payment method slugs enabled for this account. */
216
+ paymentMethods?: any[];
217
+ services?: any[];
218
+ paymentEntity?: any;
219
+ canRefund?: boolean;
220
+ };
221
+ /**
222
+ * Payload for an external payout (transfer to a beneficiary).
223
+ * Used by `tpp.transfers.payout()` (`simulate()` takes `PayoutSimulatePayload`).
224
+ */
225
+ interface PayoutPayload {
226
+ /** Amount in cents to be debited. */
227
+ amount: number;
228
+ currency: string;
229
+ /** Amount in cents the beneficiary receives (alternative to amount). */
230
+ destinationAmount?: number;
231
+ destinationCurrency: string;
232
+ /** Beneficiary (deposit account) id. */
233
+ depositaccountId: number;
234
+ reasonId: number;
235
+ /** Free-text reason. Required when reasonId is OTHER (9). */
236
+ reasonDes?: string;
237
+ /** Concept shown to the beneficiary (max 254 chars). */
238
+ conceptTransfer?: string;
239
+ /** 2FA delivery type used to validate the securityCode. */
240
+ twoFaType?: number;
241
+ /** 2FA code obtained via transfers.requestSecurityCode(). */
242
+ securityCode: string;
243
+ /** Source account id (multi-account). Defaults to the default account. */
244
+ accountId?: number;
245
+ }
246
+ /**
247
+ * Payload for `tpp.transfers.simulate()`. Note the shape differs from
248
+ * the payout payload: the simulation endpoint uses currencyToPay /
249
+ * currencyToGet and amountToPay / amountToGet, and requires accountId.
250
+ */
251
+ interface PayoutSimulatePayload {
252
+ /** Source account id (required). Get it from `accounts.list()`. */
253
+ accountId: number;
254
+ currencyToPay: "USD" | "EUR" | "USDC" | "USDT";
255
+ currencyToGet?: "USD" | "EUR" | "USDC" | "USDT";
256
+ /** Amount in cents to be debited (provide this or amountToGet). */
257
+ amountToPay?: number;
258
+ /** Amount in cents the beneficiary receives (provide this or amountToPay). */
259
+ amountToGet?: number;
260
+ /** Beneficiary (deposit account) id. */
261
+ depositaccountId?: number;
262
+ paymentMethod?: string;
263
+ serviceSlug?: string;
264
+ destinationAccount?: number;
265
+ }
128
266
  type Deposit = {
129
267
  id: number;
130
268
  accountNumber: string;
@@ -188,7 +326,7 @@ declare class TropipayHooks {
188
326
  * you must select from the list of available events, otherwise
189
327
  * it will not produce an error but it will not be executed.
190
328
  * For get full list of available events see endpoint
191
- * GET /api/v2/hook/events.
329
+ * GET /api/v3/user/hooks/events.
192
330
  * @param target String representing the type of event supported.
193
331
  * It is currently available: 'web' (allows to receive information in a url),
194
332
  * 'email' (allows to receive information in an email address).
@@ -221,9 +359,11 @@ declare class PaymentCard {
221
359
  constructor(tropipayInstance: Tropipay);
222
360
  /**
223
361
  * Create a paymentLink with the specified options.
362
+ * Supports multi-account via the optional `accountId` field of the
363
+ * payload (defaults to the user's default account).
224
364
  * @param payload PaymentLinkPayload Object.
225
365
  * @returns Promise<PaymentLink> or throws an Exception.
226
- * @see https://tpp.stoplight.io/docs/tropipay-api-doc/b3A6ODgyNTM3OQ-create-a-new-pay-link-charge
366
+ * @see https://doc.tropipay.com/docs/api-reference/payment-cards
227
367
  */
228
368
  create(payload: PaymentLinkPayload): Promise<PaymentLink>;
229
369
  /**
@@ -240,6 +380,17 @@ declare class PaymentCard {
240
380
  * @throws {Error} If an error occurs while retrieving the payment card.
241
381
  */
242
382
  get(id: string): Promise<any>;
383
+ /**
384
+ * Updates a payment card. Send the card id in `cardId` plus the
385
+ * fields to modify.
386
+ *
387
+ * @param payload Object with `cardId` and the fields to update.
388
+ * @return {Promise<any>} A Promise that resolves to the updated payment card data.
389
+ * @throws {Error} If an error occurs while updating the payment card.
390
+ */
391
+ update(payload: {
392
+ cardId: string;
393
+ } & Partial<PaymentLinkPayload>): Promise<any>;
243
394
  /**
244
395
  * Deletes a payment card with the specified ID. Its a LOGIC delete
245
396
  * so this will delete the paymentcard from paymentcard list and
@@ -251,27 +402,14 @@ declare class PaymentCard {
251
402
  delete(id: string): Promise<any>;
252
403
  }
253
404
 
254
- declare class MediationPaymentCard {
255
- private tropipay;
256
- constructor(tropipayInstance: Tropipay);
257
- /**
258
- * (ONLY FOR BUSINESS ACCOUNTS) Create a mediation paymentcard (an escrow payment link) with the specified options.
259
- * This allows a payment to be made to persons belonging or not to the TropiPay platform with the
260
- * particularity that the payment will be held in custody or retained until it is released with
261
- * the approval of the payer.
262
- * @param payload PaymentLinkPayload Object.
263
- * @returns Promise<PaymentLink> or throws an Exception.
264
- * @see https://tpp.stoplight.io/docs/tropipay-api-doc/12a128ff971e4-creating-a-mediation-payment-card
265
- */
266
- create(payload: MediationPaymentCardConfig): Promise<PaymentLink>;
267
- }
268
-
269
405
  interface DepositAccountConfig {
406
+ id?: number;
270
407
  searchValue?: string;
271
408
  alias: string;
272
409
  userRelationTypeId: number;
273
410
  beneficiaryType: BeneficiaryType;
274
411
  searchBy?: number;
412
+ /** Bank account number, card number or crypto wallet address (beneficiaryType 3). */
275
413
  accountNumber?: string;
276
414
  swift?: string;
277
415
  type: DepositAccountType;
@@ -288,11 +426,67 @@ interface DepositAccountConfig {
288
426
  paymentType?: string;
289
427
  documentTypeId?: number;
290
428
  documentExpirationDate: string;
429
+ /**
430
+ * Blockchain network of the wallet. Required when beneficiaryType is
431
+ * CRYPTO (3). The API matches it case-insensitively against its
432
+ * supported network list.
433
+ */
434
+ network?: CryptoNetwork;
435
+ currency?: string;
291
436
  }
292
437
  type INTERNAL = 1;
293
438
  type EXTERNAL = 2;
294
- type BeneficiaryType = INTERNAL | EXTERNAL;
295
- type DepositAccountType = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11;
439
+ type CRYPTO = 3;
440
+ /**
441
+ * 1 = INTERNAL (another Tropipay user), 2 = EXTERNAL (bank account/card),
442
+ * 3 = CRYPTO (crypto wallet).
443
+ */
444
+ type BeneficiaryType = INTERNAL | EXTERNAL | CRYPTO;
445
+ /**
446
+ * Crypto networks supported for wallet beneficiaries.
447
+ */
448
+ type CryptoNetwork = "SOLANA" | "ETHEREUM" | "POLYGON" | "BSC" | "BINANCE_SMART_CHAIN" | "BEP20" | "BINANCE_CHAIN" | "BEP2" | "ARBITRUM" | "OPTIMISM" | "AVALANCHE" | "BASE" | "TRON" | "BITCOIN" | "BTC" | "ETH";
449
+ declare const DepositAccountTypesList: {
450
+ /**
451
+ * Banco Metropolitano (Cuba) Bank Account
452
+ */
453
+ readonly BANMET_BANK_ACCOUNT: 0;
454
+ /**
455
+ * Banco Popular de Ahorro
456
+ */
457
+ readonly BPA_BANK_ACCOUNT: 1;
458
+ /**
459
+ * Banco de Credito y Comercio (Cuba) Bank Account
460
+ */
461
+ readonly BANDEC_BANK_ACCOUNT: 2;
462
+ /**
463
+ * Banco Metropilitano (Cuba) card
464
+ */
465
+ readonly BANMET_CARD: 3;
466
+ /**
467
+ * Banco Popular de Ahorro (Cuba) card
468
+ */
469
+ readonly BPA_CARD: 4;
470
+ /**
471
+ * Not available anymore
472
+ * @deprecated
473
+ */
474
+ readonly AIS_CUC_CARD: 5;
475
+ /**
476
+ * Not available
477
+ * @deprecated
478
+ */
479
+ readonly AIS_USD_CARD: 6;
480
+ /**
481
+ * For international bank accounts
482
+ */
483
+ readonly OTHER: 7;
484
+ /**
485
+ * Banco de Credito y comercio card
486
+ */
487
+ readonly BANDEC_CARD: 8;
488
+ };
489
+ type DepositAccountType = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11;
296
490
 
297
491
  declare class DepositAccounts {
298
492
  private tropipay;
@@ -304,6 +498,8 @@ declare class DepositAccounts {
304
498
  list(): Promise<any>;
305
499
  /**
306
500
  * Adds a new beneficiary to the user account.
501
+ * For crypto wallet beneficiaries use `beneficiaryType: 3`, put the
502
+ * wallet address in `accountNumber` and set the `network`.
307
503
  * @param payload
308
504
  * @returns
309
505
  */
@@ -317,16 +513,97 @@ declare class DepositAccounts {
317
513
  get(id: string): Promise<any>;
318
514
  /**
319
515
  * Updates certain beneficiary data.
320
- * @param depositAccountObj
516
+ * @param depositAccountObj Object with the beneficiary id and the fields to update.
321
517
  * @returns
322
518
  */
323
519
  update(depositAccountObj: Partial<DepositAccountConfig>): Promise<any>;
324
520
  /**
325
- * (UNTESTED) Deletes the beneficiary indicated by id
521
+ * Deletes the beneficiary indicated by id
326
522
  * @param id
327
523
  * @returns
328
524
  */
329
525
  delete(id: number): Promise<any>;
526
+ /**
527
+ * Validates a beneficiary account number (bank account, card or
528
+ * crypto wallet address) before creating it.
529
+ * @param payload Account number data to validate (e.g. { accountNumber, paymentType, network, currency })
530
+ * @returns
531
+ */
532
+ validateAccountNumber(payload: Record<string, unknown>): Promise<any>;
533
+ }
534
+
535
+ /**
536
+ * Multi-account support. A Tropipay user can hold several accounts
537
+ * (one per currency). Use `list()` to discover the `accountId` values
538
+ * accepted by `paymentCards.create()` and `transfers.payout()`.
539
+ */
540
+ declare class Accounts {
541
+ private tropipay;
542
+ constructor(tropipayInstance: Tropipay);
543
+ /**
544
+ * List all the accounts of the current user with their id,
545
+ * accountNumber, currency, balance and enabled payment methods.
546
+ * @param type Optional comma-separated account types filter.
547
+ * @returns Array of Account objects.
548
+ */
549
+ list(type?: string): Promise<Account[]>;
550
+ /**
551
+ * Get the balance of every account of the user.
552
+ * @returns Balances for all accounts.
553
+ */
554
+ allBalances(): Promise<any>;
555
+ /**
556
+ * Get the balance of one account by its account number
557
+ * (note: accountNumber, not account id — get it from `list()`).
558
+ * @param accountNumber The account number.
559
+ */
560
+ balance(accountNumber: string): Promise<any>;
561
+ /**
562
+ * List the movements of one account.
563
+ * @param accountId The account id (from `list()`).
564
+ * @param options Pagination: limit (max 50, default 20) and offset.
565
+ */
566
+ movements(accountId: number, options?: {
567
+ limit?: number;
568
+ offset?: number;
569
+ }): Promise<any>;
570
+ }
571
+
572
+ /**
573
+ * Money transfers (payouts) to beneficiaries. Requires 2FA and the
574
+ * ALLOW_EXTERNAL_TRANSFER permission on the Tropipay account.
575
+ *
576
+ * Typical flow:
577
+ * 1. `simulate(payload)` to preview amounts and fees.
578
+ * 2. `requestSecurityCode()` to receive the 2FA code (SMS/email).
579
+ * 3. `payout({ ...payload, securityCode })` to execute the transfer.
580
+ */
581
+ declare class Transfers {
582
+ private tropipay;
583
+ constructor(tropipayInstance: Tropipay);
584
+ /**
585
+ * Simulate a payout without executing it: returns the resulting
586
+ * amounts, rates and fees for the given payload.
587
+ * Note the payload shape differs from `payout()`: it uses
588
+ * `currencyToPay`/`currencyToGet`, `amountToPay`/`amountToGet` and
589
+ * requires `accountId`.
590
+ * @param payload Simulation data (no securityCode needed).
591
+ */
592
+ simulate(payload: PayoutSimulatePayload): Promise<any>;
593
+ /**
594
+ * Execute a payout (external transfer) to a beneficiary.
595
+ * Requires the 2FA `securityCode` in the payload (use
596
+ * `requestSecurityCode()` first; in Development mode "123456" works).
597
+ * Supports multi-account via the optional `accountId` field.
598
+ * @param payload Payout data including securityCode.
599
+ */
600
+ payout(payload: PayoutPayload): Promise<any>;
601
+ /**
602
+ * Request the 2FA security code needed to confirm a payout.
603
+ * The code is delivered by SMS or email depending on the user's
604
+ * 2FA settings.
605
+ */
606
+ requestSecurityCode(): Promise<any>;
330
607
  }
331
608
 
332
609
  /**
@@ -343,14 +620,15 @@ declare class Tropipay {
343
620
  readonly clientSecret: string;
344
621
  readonly scopes: String[];
345
622
  request: Axios;
346
- static accessToken: string | null;
347
- static refreshToken: string | null;
348
- static expiresIn: number | null;
623
+ accessToken: string | null;
624
+ refreshToken: string | null;
625
+ expiresIn: number | null;
349
626
  serverMode: ServerMode;
350
627
  hooks: TropipayHooks;
351
628
  paymentCards: PaymentCard;
352
629
  depositAccounts: DepositAccounts;
353
- mediationPaymentCard: MediationPaymentCard;
630
+ accounts: Accounts;
631
+ transfers: Transfers;
354
632
  /**
355
633
  * Initializes a new instance of the Tropipay class.
356
634
  *
@@ -361,11 +639,13 @@ declare class Tropipay {
361
639
  /**
362
640
  * Get the list of all supported countries by Tropipay.
363
641
  * @returns Array of Countries Data
364
- * @see https://tpp.stoplight.io/docs/tropipay-api-doc/bfac21259e2ff-getting-users-countries-list
642
+ * @see https://doc.tropipay.com/docs/api-reference/countries
365
643
  */
366
644
  countries(): Promise<Country[]>;
367
645
  /**
368
- * Get user balance
646
+ * Get balance of the user's default account.
647
+ * For per-account balances use `accounts.balance()` or
648
+ * `accounts.allBalances()`.
369
649
  * @returns balance Object { balance: number, pendingIn: number, pendingOut: number }
370
650
  */
371
651
  getBalance(): Promise<AccountBalance>;
@@ -375,7 +655,7 @@ declare class Tropipay {
375
655
  * when adding new beneficiaries to some user.
376
656
  *
377
657
  * @returns Array of Country Objects
378
- * @see https://tpp.stoplight.io/docs/tropipay-api-doc/3cfe5504f0524-getting-list-of-beneficiary-countries
658
+ * @see https://doc.tropipay.com/docs/api-reference/countries
379
659
  */
380
660
  destinations(): Promise<Country[]>;
381
661
  /**
@@ -385,7 +665,10 @@ declare class Tropipay {
385
665
  favorites(): Promise<any>;
386
666
  /**
387
667
  * List all account movements. You can optionaly specify
388
- * offset and limit params for pagination.
668
+ * offset and limit params for pagination (limit is capped
669
+ * to 50 by the API).
670
+ * For the movements of one specific account use
671
+ * `accounts.movements(accountId)`.
389
672
  * @returns
390
673
  */
391
674
  movements(offset?: number, limit?: number): Promise<any>;
@@ -400,20 +683,9 @@ declare class Tropipay {
400
683
  * @param originCurrency Target currency code supported by Tropipay.
401
684
  * @param targetCurrency Must be 'EUR'? (not documented by Tropipay)
402
685
  * @returns Conversion rate (number)
403
- * @see https://tpp.stoplight.io/docs/tropipay-api-doc/85163f6f28b23-get-rate
686
+ * @see https://doc.tropipay.com/docs/api-reference/movements
404
687
  */
405
688
  rates(originCurrency: string, targetCurrency?: string): Promise<number | Error>;
406
- /**
407
- * (ONLY in Bussiness Accounts)
408
- * An escrow payment link. This allows a payment to be made to persons
409
- * belonging or not to the TropiPay platform with the particularity
410
- * that the payment will be held in custody or retained until it is
411
- * released with the approval of the payer.
412
- * @deprecated This method is no longer supported and may be removed in a future release.
413
- * @see https://tpp.stoplight.io/docs/tropipay-api-doc/12a128ff971e4-creating-a-mediation-payment-card
414
- * @param config Payload with the payment details
415
- */
416
- createMediationPaymentCard(config: MediationPaymentCardConfig): Promise<PaymentLink>;
417
689
  /**
418
690
  * Refund a completed transaction.
419
691
  * Requires 2FA enabled and ALLOW_REFUND permission on the Tropipay account.
@@ -443,9 +715,6 @@ declare class Tropipay {
443
715
  */
444
716
  requestSecurityCode(type?: "sms" | "email"): Promise<any>;
445
717
  }
446
- declare class ClientSideUtils {
447
- constructor(tropipayInstance: Tropipay);
448
- }
449
718
 
450
719
  declare class ServerSideUtils {
451
720
  private tropipay;
@@ -464,11 +733,24 @@ declare class ServerSideUtils {
464
733
  } | Tropipay, originalCurrencyAmount: string, bankOrderCode: string, signature: string): boolean;
465
734
  /**
466
735
  * Checks if the provided base64 string represents a square image.
736
+ * Supports PNG and JPEG images (dimensions are read directly from
737
+ * the binary header, no DOM required).
467
738
  *
468
739
  * @param {string} base64String - The base64 string of the image
469
740
  * @return {Promise<boolean>} A Promise that resolves to a boolean indicating whether the image is square
470
741
  */
471
742
  static isBase64ImageSquare(base64String: string): Promise<boolean>;
743
+ /**
744
+ * Reads the width/height of a base64 encoded PNG or JPEG image
745
+ * from its binary header.
746
+ *
747
+ * @param {string} base64String - base64 image, with or without the data: prefix
748
+ * @return {{width: number, height: number}} the image dimensions
749
+ */
750
+ static getImageDimensions(base64String: string): {
751
+ width: number;
752
+ height: number;
753
+ };
472
754
  /**
473
755
  * Takes a local file path and returns a base64 representation of the file content.
474
756
  *
@@ -494,5 +776,5 @@ declare class ServerSideUtils {
494
776
 
495
777
  declare const SERVER_MODE: ServerMode$1;
496
778
 
497
- export { ClientSideUtils, MAX_IMAGE_SIZE_MB, SERVER_MODE, ServerSideUtils, Tropipay };
498
- export type { AccountBalance, AccountDeposits, Country, Deposit, HookEventType, HookTargetType, LoginError, LoginResponse, MediationPaymentCardConfig, PaymentLink, PaymentLinkPayload, RefundResponse, ServerMode$1 as ServerMode, TropipayConfig, TropipayCredentials, UserHook, UserHookSubscribed };
779
+ export { API_BASE, Accounts, DepositAccountTypesList, DepositAccounts, MAX_IMAGE_SIZE_MB, PaymentCard, Reasons, SERVER_MODE, ServerSideUtils, Transfers, Tropipay, TropipayHooks };
780
+ export type { Account, AccountBalance, AccountDeposits, BeneficiaryType, Country, CryptoNetwork, Deposit, DepositAccountConfig, DepositAccountType, HookEventType, HookTargetType, LoginError, LoginResponse, PaymentLink, PaymentLinkCurrency, PaymentLinkPayload, PaymentMethod, PayoutPayload, PayoutSimulatePayload, RefundResponse, ServerMode$1 as ServerMode, TropipayConfig, TropipayCredentials, UserHook, UserHookSubscribed };