@yosle/tropipayjs 0.1.21 → 0.1.23

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 (39) hide show
  1. package/.nvmrc +1 -1
  2. package/.vscode/launch.json +18 -0
  3. package/LICENSE +9 -9
  4. package/README.md +152 -152
  5. package/api/TropipayAPI.d.ts +18 -5
  6. package/depositAccount/depositAccounts.d.ts +1 -1
  7. package/docs/readme.md +3 -3
  8. package/globals.d.ts +75 -75
  9. package/hooks/TropipayHooks.d.ts +2 -2
  10. package/index.d.ts +50 -12
  11. package/index.js +99 -8
  12. package/interfaces/countries/index.d.ts +1 -1
  13. package/interfaces/index.d.ts +14 -9
  14. package/jest.config.js +5 -0
  15. package/mediationPaymentCard/MediationPaymentCard.d.ts +17 -0
  16. package/package.json +49 -46
  17. package/paymentcard/PaymentCard.d.ts +17 -1
  18. package/paymentcard/paymentcard.spec.d.ts +1 -1
  19. package/rollup.config.js +24 -24
  20. package/src/api/TropipayAPI.ts +370 -323
  21. package/src/config/TropipayConfig.ts +2 -2
  22. package/src/constants/TropipayConstants.ts +2 -2
  23. package/src/depositAccount/depositAccounts.ts +139 -139
  24. package/src/hooks/TropipayHooks.ts +154 -154
  25. package/src/index.ts +28 -27
  26. package/src/interfaces/depositaccounts/index.ts +70 -70
  27. package/src/interfaces/index.js +1 -1
  28. package/src/interfaces/index.ts +201 -195
  29. package/src/interfaces/mediation/index.ts +22 -22
  30. package/src/interfaces/paymentlink/index.d.ts +36 -36
  31. package/src/interfaces/paymentlink/index.js +2 -2
  32. package/src/interfaces/paymentlink/index.ts +91 -91
  33. package/src/mediationPaymentCard/MediationPaymentCard.ts +42 -0
  34. package/src/mocks/tropipay.ts +0 -0
  35. package/src/paymentcard/PaymentCard.ts +123 -84
  36. package/src/paymentcard/paymentcard.spec.ts +79 -10
  37. package/src/utils/TropipayUtils.ts +126 -126
  38. package/src/utils/errors.ts +92 -101
  39. package/tsconfig.json +96 -95
@@ -1,323 +1,370 @@
1
- /**
2
- * Tropipayjs is a Typescript/Javascript library for the Tropipay API.
3
- *
4
- * @author Yosleivy Baez Acosta
5
- *
6
- */
7
-
8
- import axios, { Axios } from "axios";
9
- import {
10
- TropipayConfig,
11
- AccountBalance,
12
- Country,
13
- PaymentLinkPayload,
14
- PaymentLink,
15
- mediationPaymentCardConfig,
16
- LoginResponse,
17
- AccountDeposits,
18
- } from "../interfaces";
19
- type ServerMode = "Development" | "Production";
20
- import { TropipayHooks } from "../hooks/TropipayHooks";
21
- import { PaymentCard } from "../paymentcard/PaymentCard";
22
- import { DepositAccounts } from "../depositAccount/depositAccounts";
23
- import { TropipayJSException, handleExceptions } from "../utils/errors";
24
- export class Tropipay {
25
- readonly clientId: string;
26
- readonly clientSecret: string;
27
- readonly scopes: String[];
28
- public request: Axios;
29
- public static accessToken: string | null;
30
- public static refreshToken: string | null;
31
- public serverMode: ServerMode;
32
- public hooks: TropipayHooks;
33
- public paymentCards: PaymentCard;
34
- public depositAccounts: DepositAccounts;
35
-
36
- /**
37
- * Initializes a new instance of the Tropipay class.
38
- *
39
- * @param {TropipayConfig} config - The configuration object.
40
- */
41
-
42
- constructor(config: TropipayConfig) {
43
- // use all scopes if none is passed
44
- if (!config?.scopes) {
45
- this.scopes = [
46
- "ALLOW_GET_PROFILE_DATA",
47
- "ALLOW_PAYMENT_IN",
48
- "ALLOW_EXTERNAL_CHARGE",
49
- "KYC3_FULL_ALLOW",
50
- "ALLOW_PAYMENT_OUT",
51
- "ALLOW_MARKET_PURCHASES",
52
- "ALLOW_GET_BALANCE",
53
- "ALLOW_GET_MOVEMENT_LIST",
54
- "ALLOW_GET_CREDENTIAL",
55
- ];
56
- } else {
57
- this.scopes = config.scopes;
58
- }
59
-
60
- if (!config.clientId || !config.clientSecret) {
61
- throw new TropipayJSException(
62
- `You must pass clientId and clientSecret in Tropipay constructor`,
63
- 400,
64
- null
65
- );
66
- }
67
-
68
- this.clientId = config.clientId;
69
- this.clientSecret = config.clientSecret;
70
- this.serverMode = config.serverMode || "Development";
71
- this.request = axios.create({
72
- baseURL:
73
- this.serverMode === "Production"
74
- ? "https://www.tropipay.com"
75
- : "https://tropipay-dev.herokuapp.com",
76
- headers: {
77
- "Content-Type": "application/json",
78
- Accept: "application/json",
79
- Authorization: `Bearer ${Tropipay.accessToken}`,
80
- },
81
- });
82
- this.hooks = new TropipayHooks(this);
83
- this.paymentCards = new PaymentCard(this);
84
- this.depositAccounts = new DepositAccounts(this);
85
- }
86
-
87
- public async login() {
88
- try {
89
- if (Tropipay.refreshToken) {
90
- const { data } = await this.request.post<LoginResponse>(
91
- "/api/v2/access/token",
92
- {
93
- client_id: this.clientId,
94
- client_secret: this.clientSecret,
95
- grant_type: "refresh_token",
96
- refresh_token: Tropipay.refreshToken,
97
- },
98
- {
99
- headers: {
100
- "Content-Type": "application/json",
101
- Accept: "application/json",
102
- },
103
- }
104
- );
105
- return data;
106
- }
107
-
108
- // normal credetials login
109
- const { data } = await this.request.post<LoginResponse>(
110
- "/api/v2/access/token",
111
- {
112
- client_id: this.clientId,
113
- client_secret: this.clientSecret,
114
- grant_type: "client_credentials",
115
- scope: this.scopes.join(" "), // "ALLOW_GET_PROFILE_DATA ALLOW_PAYMENT_IN ALLOW_EXTERNAL_CHARGE KYC3_FULL_ALLOW ALLOW_PAYMENT_OUT ALLOW_MARKET_PURCHASES ALLOW_GET_BALANCE ALLOW_GET_MOVEMENT_LIST ALLOW_GET_CREDENTIAL",
116
- },
117
- {
118
- headers: {
119
- "Content-Type": "application/json",
120
- Accept: "application/json",
121
- },
122
- }
123
- );
124
-
125
- Tropipay.accessToken = data.access_token;
126
- Tropipay.refreshToken = data.refresh_token;
127
- return data;
128
- } catch (error) {
129
- Tropipay.accessToken = null;
130
- Tropipay.refreshToken = null;
131
- throw handleExceptions(error as any);
132
- }
133
- }
134
-
135
- /**
136
- * Get the list of all supported countries by Tropipay.
137
- * @returns Array of Countries Data
138
- * @see https://tpp.stoplight.io/docs/tropipay-api-doc/bfac21259e2ff-getting-users-countries-list
139
- */
140
- async countries(): Promise<Country[]> {
141
- try {
142
- const countries = await this.request.get("/api/v2/countries");
143
- return countries.data;
144
- } catch (error) {
145
- throw handleExceptions(error as any);
146
- }
147
- }
148
- /**
149
- * Get user balance
150
- * @returns balance Object { balance: number, pendingIn: number, pendingOut: number }
151
- */
152
- async getBalance(): Promise<AccountBalance> {
153
- if (!Tropipay.accessToken) {
154
- await this.login();
155
- }
156
- try {
157
- const balance = await this.request.get("/api/v2/users/balance", {
158
- headers: {
159
- "Content-Type": "application/json",
160
- Authorization: `Bearer ${Tropipay.accessToken}`,
161
- Accept: "application/json",
162
- },
163
- });
164
- return balance.data;
165
- } catch (error) {
166
- throw handleExceptions(error as any);
167
- }
168
- }
169
-
170
- /**
171
- * Get the list of all detination countries supported by Tropipay.
172
- * Obtaining the list of valid countries to send funds to. Useful
173
- * when adding new beneficiaries to some user.
174
- *
175
- * @returns Array of Country Objects
176
- * @see https://tpp.stoplight.io/docs/tropipay-api-doc/3cfe5504f0524-getting-list-of-beneficiary-countries
177
- */
178
- async destinations(): Promise<Country[]> {
179
- try {
180
- const countries = await this.request.get(
181
- "/api/v2/countries/destinations"
182
- );
183
- return countries.data;
184
- } catch (error) {
185
- throw new Error(`Could not retrieve the destination countries list`);
186
- }
187
- }
188
-
189
- /**
190
- * Get list of all the favorites payment links.
191
- * @returns Array of account Object or throws an error
192
- */
193
- async favorites() {
194
- if (!Tropipay.accessToken) {
195
- await this.login();
196
- }
197
- try {
198
- const favoritesList = await this.request.get(
199
- "/api/v2/paymentcards/favorites",
200
- {
201
- headers: {
202
- "Content-Type": "application/json",
203
- Authorization: `Bearer ${Tropipay.accessToken}`,
204
- Accept: "application/json",
205
- },
206
- }
207
- );
208
- return favoritesList?.data?.rows;
209
- } catch (error) {
210
- throw handleExceptions(error as any);
211
- }
212
- }
213
-
214
- /**
215
- * List all account movements. You can optionaly specify
216
- * offset and limit params for pagination.
217
- * @returns
218
- */
219
- async movements(offset = 0, limit = 10) {
220
- if (!Tropipay.accessToken) await this.login();
221
-
222
- try {
223
- const movements = await this.request.get("/api/v2/movements", {
224
- params: { limit: limit, offset: offset },
225
- headers: {
226
- "Content-Type": "application/json",
227
- Accept: "application/json",
228
- Authorization: `Bearer ${Tropipay.accessToken}`,
229
- },
230
- });
231
- return movements.data;
232
- } catch (error) {
233
- throw handleExceptions(error as any);
234
- }
235
- }
236
-
237
- /**
238
- * Return profile data for current Tropipay account.
239
- * @returns account object
240
- */
241
- async profile() {
242
- if (!Tropipay.accessToken) await this.login();
243
- try {
244
- const profile = await this.request.get("/api/users/profile");
245
- return profile.data;
246
- } catch (error) {
247
- throw handleExceptions(error as any);
248
- }
249
- }
250
-
251
- /**
252
- * Obtain current Tropipay conversion rate. For example USD to EUR
253
- * targetCurrency must be 'EUR'
254
- * @param originCurrency Target currency code supported by Tropipay.
255
- * @param targetCurrency Must be 'EUR'? (not documented by Tropipay)
256
- * @returns Conversion rate (number)
257
- * @see https://tpp.stoplight.io/docs/tropipay-api-doc/85163f6f28b23-get-rate
258
- */
259
- async rates(
260
- originCurrency: string,
261
- targetCurrency: string = "EUR"
262
- ): Promise<number | Error> {
263
- if (!Tropipay.accessToken) {
264
- await this.login();
265
- }
266
- try {
267
- const rates = await this.request.post(
268
- "/api/v2/movements/get_rate",
269
- {
270
- currencyFrom: originCurrency,
271
- currencyTo: targetCurrency,
272
- },
273
- {
274
- headers: {
275
- "Content-Type": "application/json",
276
- Accept: "application/json",
277
- Authorization: `Bearer ${Tropipay.accessToken}`,
278
- },
279
- }
280
- );
281
- return rates.data.rate;
282
- } catch (error) {
283
- throw handleExceptions(error as any);
284
- }
285
- }
286
-
287
- /**
288
- * (ONLY in Bussiness Accounts)
289
- * An escrow payment link. This allows a payment to be made to persons
290
- * belonging or not to the TropiPay platform with the particularity
291
- * that the payment will be held in custody or retained until it is
292
- * released with the approval of the payer.
293
- * @see https://tpp.stoplight.io/docs/tropipay-api-doc/12a128ff971e4-creating-a-mediation-payment-card
294
- * @param config Payload with the payment details
295
- */
296
- async createMediationPaymentCard(
297
- config: mediationPaymentCardConfig
298
- ): Promise<PaymentLink> {
299
- if (!Tropipay.accessToken) await this.login();
300
- try {
301
- const mediation = await this.request.post(
302
- "/api/v2/paymentcards/mediation",
303
- config,
304
- {
305
- headers: {
306
- "Content-Type": "application/json",
307
- Authorization: `Bearer ${Tropipay.accessToken}`,
308
- Accept: "application/json",
309
- },
310
- }
311
- );
312
- return mediation.data as PaymentLink;
313
- } catch (error) {
314
- throw handleExceptions(error as any);
315
- }
316
- }
317
- }
318
-
319
- export class ClientSideUtils {
320
- constructor(tropipayInstance: Tropipay) {
321
- throw Error(`Not implemented yet`);
322
- }
323
- }
1
+ /**
2
+ * Tropipayjs is a Typescript/Javascript library for the Tropipay API.
3
+ *
4
+ * @author Yosleivy Baez Acosta
5
+ *
6
+ */
7
+
8
+ import axios, { Axios, AxiosError, AxiosRequestConfig } from "axios";
9
+ import {
10
+ TropipayConfig,
11
+ AccountBalance,
12
+ Country,
13
+ PaymentLinkPayload,
14
+ PaymentLink,
15
+ MediationPaymentCardConfig,
16
+ LoginResponse,
17
+ AccountDeposits,
18
+ } from "../interfaces";
19
+ type ServerMode = "Development" | "Production";
20
+ import TropipayHooks from "../hooks/TropipayHooks";
21
+ import PaymentCard from "../paymentcard/PaymentCard";
22
+ import MediationPaymentCard from "../mediationPaymentCard/MediationPaymentCard";
23
+ import DepositAccounts from "../depositAccount/depositAccounts";
24
+ import { TropipayJSException, handleExceptions } from "../utils/errors";
25
+ export class Tropipay {
26
+ readonly clientId: string;
27
+ readonly clientSecret: string;
28
+ readonly scopes: String[];
29
+ public request: Axios;
30
+ public static accessToken: string | null;
31
+ public static refreshToken: string | null;
32
+ public static expiresIn: number | null;
33
+ public serverMode: ServerMode;
34
+ public hooks: TropipayHooks;
35
+ public paymentCards: PaymentCard;
36
+ public depositAccounts: DepositAccounts;
37
+ public mediationPaymentCard: MediationPaymentCard;
38
+
39
+ /**
40
+ * Initializes a new instance of the Tropipay class.
41
+ *
42
+ * @param {TropipayConfig} config - The configuration object.
43
+ */
44
+
45
+ constructor(config: TropipayConfig) {
46
+ // use all scopes if none is passed
47
+ if (!config?.scopes) {
48
+ this.scopes = [
49
+ "ALLOW_GET_PROFILE_DATA",
50
+ "ALLOW_PAYMENT_IN",
51
+ "ALLOW_EXTERNAL_CHARGE",
52
+ "KYC3_FULL_ALLOW",
53
+ "ALLOW_PAYMENT_OUT",
54
+ "ALLOW_MARKET_PURCHASES",
55
+ "ALLOW_GET_BALANCE",
56
+ "ALLOW_GET_MOVEMENT_LIST",
57
+ "ALLOW_GET_CREDENTIAL",
58
+ ];
59
+ } else {
60
+ this.scopes = config.scopes;
61
+ }
62
+
63
+ if (!config.clientId || !config.clientSecret) {
64
+ throw new TropipayJSException(
65
+ `You must pass clientId and clientSecret in Tropipay constructor`,
66
+ 400,
67
+ null
68
+ );
69
+ }
70
+
71
+ this.clientId = config.clientId;
72
+ this.clientSecret = config.clientSecret;
73
+ this.serverMode = config.serverMode || "Development";
74
+
75
+ const tpp_env = this.serverMode === "Production"
76
+ ? "https://www.tropipay.com"
77
+ : "https://tropipay-dev.herokuapp.com";
78
+ this.request = axios.create({
79
+ baseURL: config.customTropipayUrl || tpp_env,
80
+ headers: {
81
+ "Content-Type": "application/json",
82
+ Accept: "application/json",
83
+ Authorization: `Bearer ${Tropipay.accessToken}`,
84
+ },
85
+ });
86
+
87
+
88
+ // Add request interceptor for Token expired
89
+ this.request.interceptors.request.use(
90
+ async (config: any) => {
91
+ const currentTimestamp = Math.floor(Date.now() / 1000); // Current time in seconds
92
+
93
+ if (Tropipay.expiresIn && Tropipay.expiresIn < currentTimestamp) {
94
+ // Token has expired, attempt to refresh it
95
+ try {
96
+ await this.login();
97
+ } catch (error) {
98
+ // Handle token refresh error
99
+ Tropipay.accessToken = null;
100
+ Tropipay.refreshToken = null;
101
+ throw handleExceptions(error as any);
102
+ }
103
+ }
104
+
105
+ return config;
106
+ },
107
+ (error: AxiosError) => {
108
+ return Promise.reject(error);
109
+ }
110
+ );
111
+
112
+ this.hooks = new TropipayHooks(this);
113
+ this.paymentCards = new PaymentCard(this);
114
+ this.mediationPaymentCard = new MediationPaymentCard(this);
115
+
116
+ this.depositAccounts = new DepositAccounts(this);
117
+
118
+
119
+ }
120
+
121
+ public async login() {
122
+ try {
123
+ if (Tropipay.refreshToken) {
124
+ const { data } = await this.request.post<LoginResponse>(
125
+ "/api/v2/access/token",
126
+ {
127
+ client_id: this.clientId,
128
+ client_secret: this.clientSecret,
129
+ grant_type: "refresh_token",
130
+ refresh_token: Tropipay.refreshToken,
131
+ },
132
+ {
133
+ headers: {
134
+ "Content-Type": "application/json",
135
+ Accept: "application/json",
136
+ },
137
+ }
138
+ );
139
+ return data;
140
+ }
141
+
142
+ // normal credetials login
143
+ const { data } = await this.request.post<LoginResponse>(
144
+ "/api/v2/access/token",
145
+ {
146
+ client_id: this.clientId,
147
+ client_secret: this.clientSecret,
148
+ grant_type: "client_credentials",
149
+ scope: this.scopes.join(" "), // "ALLOW_GET_PROFILE_DATA ALLOW_PAYMENT_IN ALLOW_EXTERNAL_CHARGE KYC3_FULL_ALLOW ALLOW_PAYMENT_OUT ALLOW_MARKET_PURCHASES ALLOW_GET_BALANCE ALLOW_GET_MOVEMENT_LIST ALLOW_GET_CREDENTIAL",
150
+ },
151
+ {
152
+ headers: {
153
+ "Content-Type": "application/json",
154
+ Accept: "application/json",
155
+ },
156
+ }
157
+ );
158
+
159
+ Tropipay.accessToken = data.access_token;
160
+ Tropipay.refreshToken = data.refresh_token;
161
+ Tropipay.expiresIn = data.expires_in;
162
+ return data;
163
+ } catch (error) {
164
+ Tropipay.accessToken = null;
165
+ Tropipay.refreshToken = null;
166
+ Tropipay.expiresIn = null;
167
+ throw handleExceptions(error as any);
168
+ }
169
+ }
170
+
171
+ /**
172
+ * Get the list of all supported countries by Tropipay.
173
+ * @returns Array of Countries Data
174
+ * @see https://tpp.stoplight.io/docs/tropipay-api-doc/bfac21259e2ff-getting-users-countries-list
175
+ */
176
+ async countries(): Promise<Country[]> {
177
+ try {
178
+ const countries = await this.request.get("/api/v2/countries");
179
+ return countries.data;
180
+ } catch (error) {
181
+ throw handleExceptions(error as any);
182
+ }
183
+ }
184
+ /**
185
+ * Get user balance
186
+ * @returns balance Object { balance: number, pendingIn: number, pendingOut: number }
187
+ */
188
+ async getBalance(): Promise<AccountBalance> {
189
+ if (!Tropipay.accessToken) {
190
+ await this.login();
191
+ }
192
+ try {
193
+ const balance = await this.request.get("/api/v2/users/balance", {
194
+ headers: {
195
+ "Content-Type": "application/json",
196
+ Authorization: `Bearer ${Tropipay.accessToken}`,
197
+ Accept: "application/json",
198
+ },
199
+ });
200
+ return balance.data;
201
+ } catch (error) {
202
+ throw handleExceptions(error as any);
203
+ }
204
+ }
205
+
206
+ /**
207
+ * Get the list of all detination countries supported by Tropipay.
208
+ * Obtaining the list of valid countries to send funds to. Useful
209
+ * when adding new beneficiaries to some user.
210
+ *
211
+ * @returns Array of Country Objects
212
+ * @see https://tpp.stoplight.io/docs/tropipay-api-doc/3cfe5504f0524-getting-list-of-beneficiary-countries
213
+ */
214
+ async destinations(): Promise<Country[]> {
215
+ try {
216
+ const countries = await this.request.get(
217
+ "/api/v2/countries/destinations"
218
+ );
219
+ return countries.data;
220
+ } catch (error) {
221
+ throw new Error(`Could not retrieve the destination countries list`);
222
+ }
223
+ }
224
+
225
+ /**
226
+ * Get list of all the favorites payment links.
227
+ * @returns Array of account Object or throws an error
228
+ */
229
+ async favorites() {
230
+ if (!Tropipay.accessToken) {
231
+ await this.login();
232
+ }
233
+ try {
234
+ const favoritesList = await this.request.get(
235
+ "/api/v2/paymentcards/favorites",
236
+ {
237
+ headers: {
238
+ "Content-Type": "application/json",
239
+ Authorization: `Bearer ${Tropipay.accessToken}`,
240
+ Accept: "application/json",
241
+ },
242
+ }
243
+ );
244
+ return favoritesList?.data?.rows;
245
+ } catch (error) {
246
+ throw handleExceptions(error as any);
247
+ }
248
+ }
249
+
250
+ /**
251
+ * List all account movements. You can optionaly specify
252
+ * offset and limit params for pagination.
253
+ * @returns
254
+ */
255
+ async movements(offset = 0, limit = 10) {
256
+ if (!Tropipay.accessToken) await this.login();
257
+
258
+ try {
259
+ const movements = await this.request.get("/api/v2/movements", {
260
+ params: { limit: limit, offset: offset },
261
+ headers: {
262
+ "Content-Type": "application/json",
263
+ Accept: "application/json",
264
+ Authorization: `Bearer ${Tropipay.accessToken}`,
265
+ },
266
+ });
267
+ return movements.data;
268
+ } catch (error) {
269
+ throw handleExceptions(error as any);
270
+ }
271
+ }
272
+
273
+ /**
274
+ * Return profile data for current Tropipay account.
275
+ * @returns account object
276
+ */
277
+ async profile() {
278
+ if (!Tropipay.accessToken) await this.login();
279
+ try {
280
+ const profile = await this.request.get("/api/users/profile");
281
+ return profile.data;
282
+ } catch (error) {
283
+ throw handleExceptions(error as any);
284
+ }
285
+ }
286
+
287
+ /**
288
+ * Obtain current Tropipay conversion rate. For example USD to EUR
289
+ * targetCurrency must be 'EUR'
290
+ * @param originCurrency Target currency code supported by Tropipay.
291
+ * @param targetCurrency Must be 'EUR'? (not documented by Tropipay)
292
+ * @returns Conversion rate (number)
293
+ * @see https://tpp.stoplight.io/docs/tropipay-api-doc/85163f6f28b23-get-rate
294
+ */
295
+ async rates(
296
+ originCurrency: string,
297
+ targetCurrency: string = "EUR"
298
+ ): Promise<number | Error> {
299
+ if (!Tropipay.accessToken) {
300
+ await this.login();
301
+ }
302
+ try {
303
+ const rates = await this.request.post(
304
+ "/api/v2/movements/get_rate",
305
+ {
306
+ currencyFrom: originCurrency,
307
+ currencyTo: targetCurrency,
308
+ },
309
+ {
310
+ headers: {
311
+ "Content-Type": "application/json",
312
+ Accept: "application/json",
313
+ Authorization: `Bearer ${Tropipay.accessToken}`,
314
+ },
315
+ }
316
+ );
317
+ return rates.data.rate;
318
+ } catch (error) {
319
+ throw handleExceptions(error as any);
320
+ }
321
+ }
322
+
323
+ /**
324
+ * (ONLY in Bussiness Accounts)
325
+ * An escrow payment link. This allows a payment to be made to persons
326
+ * belonging or not to the TropiPay platform with the particularity
327
+ * that the payment will be held in custody or retained until it is
328
+ * released with the approval of the payer.
329
+ * @see https://tpp.stoplight.io/docs/tropipay-api-doc/12a128ff971e4-creating-a-mediation-payment-card
330
+ * @param config Payload with the payment details
331
+ */
332
+ async createMediationPaymentCard(
333
+ config: MediationPaymentCardConfig
334
+ ): Promise<PaymentLink> {
335
+ if (!Tropipay.accessToken) await this.login();
336
+ try {
337
+ const mediation = await this.request.post(
338
+ "/api/v2/paymentcards/mediation",
339
+ config,
340
+ {
341
+ headers: {
342
+ "Content-Type": "application/json",
343
+ Authorization: `Bearer ${Tropipay.accessToken}`,
344
+ Accept: "application/json",
345
+ },
346
+ }
347
+ );
348
+ return mediation.data as PaymentLink;
349
+ } catch (error) {
350
+ throw handleExceptions(error as any);
351
+ }
352
+ }
353
+ }
354
+
355
+ export class ClientSideUtils {
356
+ constructor(tropipayInstance: Tropipay) {
357
+ throw Error(`Not implemented yet`);
358
+ }
359
+ }
360
+
361
+ export const Scopes = {
362
+ ALLOW_PAYMENT_IN: "ALLOW_PAYMENT_IN",
363
+ ALLOW_EXTERNAL_CHARGE: "ALLOW_EXTERNAL_CHARGE",
364
+ KYC3_FULL_ALLOW: "KYC3_FULL_ALLOW",
365
+ ALLOW_PAYMENT_OUT: "ALLOW_PAYMENT_OUT",
366
+ ALLOW_MARKET_PURCHASES: "ALLOW_MARKET_PURCHASES",
367
+ ALLOW_GET_BALANCE: "ALLOW_GET_BALANCE",
368
+ ALLOW_GET_MOVEMENT_LIST: "ALLOW_GET_MOVEMENT_LIST",
369
+ ALLOW_GET_CREDENTIAL: "ALLOW_GET_CREDENTIAL",
370
+ };