@yosle/tropipayjs 0.1.22 → 0.1.24

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