@riocrypto/common-server 1.0.1384 → 1.0.1392

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.
@@ -23,7 +23,7 @@ class InvopopClient {
23
23
  this.baseUrl = "https://api.invopop.com";
24
24
  }
25
25
  createJob(order, user) {
26
- var _a, _b;
26
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
27
27
  return __awaiter(this, void 0, void 0, function* () {
28
28
  const uuid = (0, uuid_1.v1)();
29
29
  const operationDate = new Date(order.createdAt);
@@ -60,22 +60,24 @@ class InvopopClient {
60
60
  ],
61
61
  },
62
62
  customer: {
63
- name: user.mexicoFiscalName
64
- ? user.mexicoFiscalName.toLocaleUpperCase()
63
+ name: ((_a = user.invoicing) === null || _a === void 0 ? void 0 : _a.MX.fiscalName)
64
+ ? (_b = user.invoicing) === null || _b === void 0 ? void 0 : _b.MX.fiscalName.toLocaleUpperCase()
65
65
  : (0, common_1.getUserName)(user),
66
66
  tax_id: {
67
67
  country: "MX",
68
- zone: user.rfc ? user.postalCode : "66260",
69
- code: user.rfc || "XAXX010101000",
68
+ zone: ((_c = user.invoicing) === null || _c === void 0 ? void 0 : _c.MX.shouldInvoice)
69
+ ? user.address.postalCode
70
+ : "66260",
71
+ code: ((_e = (_d = user.KYC) === null || _d === void 0 ? void 0 : _d.MX) === null || _e === void 0 ? void 0 : _e.taxId) || "XAXX010101000",
70
72
  },
71
73
  identities: [
72
74
  {
73
75
  key: "mx-cfdi-fiscal-regime",
74
- code: ((_a = user.mexicoFiscalRegimenCode) === null || _a === void 0 ? void 0 : _a.toString()) || "616",
76
+ code: ((_g = (_f = user.invoicing) === null || _f === void 0 ? void 0 : _f.MX.fiscalRegimenCode) === null || _g === void 0 ? void 0 : _g.toString()) || "616",
75
77
  },
76
78
  {
77
79
  key: "mx-cfdi-use",
78
- code: user.rfc ? "G03" : "S01",
80
+ code: ((_h = user.invoicing) === null || _h === void 0 ? void 0 : _h.MX.shouldInvoice) ? "G03" : "S01",
79
81
  },
80
82
  ],
81
83
  },
@@ -86,7 +88,7 @@ class InvopopClient {
86
88
  item: {
87
89
  name: "Facilitación de Compra-Venta de Activos Virtuales",
88
90
  identities: [{ key: "mx-cfdi-prod-serv", code: "80151500" }],
89
- price: (_b = order.actualFees.platformFeeFiat) === null || _b === void 0 ? void 0 : _b.toFixed(2),
91
+ price: (_j = order.actualFees.platformFeeFiat) === null || _j === void 0 ? void 0 : _j.toFixed(2),
90
92
  },
91
93
  taxes: [
92
94
  {
@@ -35,12 +35,13 @@ class KapstarClient {
35
35
  });
36
36
  }
37
37
  createInvoice(amount, orderId, user) {
38
+ var _a, _b;
38
39
  return __awaiter(this, void 0, void 0, function* () {
39
40
  const kapstarResponse = yield this.axiosInstance.post("/transaction-service/v1/external/invoice", {
40
41
  amount,
41
42
  name: (0, common_1.getUserName)(user),
42
43
  tags: [orderId],
43
- tax_id: user.cpf,
44
+ tax_id: (_b = (_a = user.KYC) === null || _a === void 0 ? void 0 : _a.BR) === null || _b === void 0 ? void 0 : _b.taxId,
44
45
  });
45
46
  return kapstarResponse.data;
46
47
  });
@@ -43,7 +43,7 @@ class KillbClient {
43
43
  }
44
44
  createUser(user) {
45
45
  return __awaiter(this, void 0, void 0, function* () {
46
- const dateOfBirth = this.formatDateToYYYYMMDD(new Date(user.birthday));
46
+ const dateOfBirth = this.formatDateToYYYYMMDD(new Date(user.individualData.birthday));
47
47
  const { data } = yield axios_1.default.post(`${this.baseUrl}/api/v1/auth/login`, {
48
48
  email: this.username,
49
49
  paassword: this.password,
@@ -20,15 +20,15 @@ const getUserTransactionLimits = (mongoose, id) => __awaiter(void 0, void 0, voi
20
20
  throw new common_1.NotFoundError("User");
21
21
  }
22
22
  const { volume } = yield (0, calculate_aggregate_volume_and_revenue_1.calculateAggregateVolumeAndRevenue)(mongoose, 30, user, true);
23
- const { riskTier } = user;
23
+ const { risk } = user;
24
24
  let limit = 0;
25
- if (riskTier === common_1.RiskTier.High) {
25
+ if (risk === common_1.RiskTier.High) {
26
26
  limit = 3000;
27
27
  }
28
- else if (riskTier === common_1.RiskTier.Medium) {
28
+ else if (risk === common_1.RiskTier.Medium) {
29
29
  limit = 75000;
30
30
  }
31
- else if (riskTier === common_1.RiskTier.Low) {
31
+ else if (risk === common_1.RiskTier.Low) {
32
32
  if (user.hasPassedEDD) {
33
33
  limit = 100000000;
34
34
  }
package/build/index.d.ts CHANGED
@@ -43,7 +43,6 @@ export * from "./models/market-data";
43
43
  export * from "./models/telegram-session";
44
44
  export * from "./clients/bitstamp-client";
45
45
  export * from "./clients/ccxt-client";
46
- export * from "./clients/kushki-client";
47
46
  export * from "./clients/slack-client";
48
47
  export * from "./clients/gueno-client";
49
48
  export * from "./clients/fireblocks-client";
package/build/index.js CHANGED
@@ -59,7 +59,6 @@ __exportStar(require("./models/market-data"), exports);
59
59
  __exportStar(require("./models/telegram-session"), exports);
60
60
  __exportStar(require("./clients/bitstamp-client"), exports);
61
61
  __exportStar(require("./clients/ccxt-client"), exports);
62
- __exportStar(require("./clients/kushki-client"), exports);
63
62
  __exportStar(require("./clients/slack-client"), exports);
64
63
  __exportStar(require("./clients/gueno-client"), exports);
65
64
  __exportStar(require("./clients/fireblocks-client"), exports);
@@ -22,7 +22,7 @@ const secret_manager_client_1 = require("../clients/secret-manager-client");
22
22
  const admin_1 = require("../models/admin");
23
23
  const admin_auth_1 = require("../models/admin-auth");
24
24
  const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(void 0, void 0, void 0, function* () {
25
- var _a, _b, _c, _d;
25
+ var _a, _b, _c, _d, _e, _f, _g, _h;
26
26
  if (authorizationTypes.includes(common_1.AuthorizationType.Cluster)) {
27
27
  let apiKey = req.header("x-cluster-api-key");
28
28
  const CLUSTER_API_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("CLUSTER_API_KEY");
@@ -126,7 +126,8 @@ const authorize = (req, res, next, mongoose, authorizationTypes) => __awaiter(vo
126
126
  req.user = user;
127
127
  }
128
128
  else {
129
- if (user.kycStatus === common_1.KYCStatus.Approved) {
129
+ if (((_f = (_e = user.KYC) === null || _e === void 0 ? void 0 : _e.MX) === null || _f === void 0 ? void 0 : _f.status) === common_1.KYCStatus.Approved ||
130
+ ((_h = (_g = user.KYC) === null || _g === void 0 ? void 0 : _g.PE) === null || _h === void 0 ? void 0 : _h.status) === common_1.KYCStatus.Approved) {
130
131
  req.user = user;
131
132
  }
132
133
  }
@@ -3,6 +3,29 @@ import { Mongoose, Model, Document } from "mongoose";
3
3
  interface UserAttrs {
4
4
  createdAt: Date;
5
5
  authIds?: string[];
6
+ individualData?: {
7
+ firstName: string;
8
+ middleName?: string;
9
+ lastName: string;
10
+ secondLastName?: string;
11
+ birthday: Date;
12
+ countryOfOrigin: CountryOfOrigin;
13
+ };
14
+ businessData?: {
15
+ businessName: string;
16
+ legalRepresentative?: {
17
+ name: string;
18
+ status?: string;
19
+ email?: string;
20
+ };
21
+ UBO?: {
22
+ id?: string;
23
+ name: string;
24
+ status?: string;
25
+ email?: string;
26
+ };
27
+ };
28
+ risk: RiskTier;
6
29
  type: UserType;
7
30
  phoneNumber: string;
8
31
  email: string;
@@ -13,7 +36,6 @@ interface UserAttrs {
13
36
  postalCode: string;
14
37
  country: CountryOfOrigin;
15
38
  kycStatus: KYCStatus;
16
- riskTier: RiskTier;
17
39
  hasPassedEDD: boolean;
18
40
  firstName?: string;
19
41
  middleName?: string;
@@ -68,6 +90,81 @@ interface UserAttrs {
68
90
  mexicoFiscalName?: string;
69
91
  taxId?: string;
70
92
  usKYCStatus?: "none" | "pending" | "failed" | "approved";
93
+ KYC?: {
94
+ MX?: {
95
+ status?: KYCStatus;
96
+ personalId?: string;
97
+ taxId?: string;
98
+ files?: {
99
+ certificateOfIncorporation?: string;
100
+ kycReport?: string;
101
+ taxTranscript?: string;
102
+ proofOfAddress?: string;
103
+ businessRegistration?: string;
104
+ taxIdentificationCertificate?: string;
105
+ legalRepresentativeIdPowerOfAttorney?: string;
106
+ personalIdentificationCertificate?: string;
107
+ extraFiles?: string[];
108
+ };
109
+ };
110
+ PE?: {
111
+ status?: KYCStatus;
112
+ personalId?: string;
113
+ taxId?: string;
114
+ files?: {
115
+ certificateOfIncorporation?: string;
116
+ kycReport?: string;
117
+ taxTranscript?: string;
118
+ proofOfAddress?: string;
119
+ businessRegistration?: string;
120
+ taxIdentificationCertificate?: string;
121
+ legalRepresentativeIdPowerOfAttorney?: string;
122
+ personalIdentificationCertificate?: string;
123
+ extraFiles?: string[];
124
+ };
125
+ };
126
+ US?: {
127
+ status?: KYCStatus;
128
+ personalId?: string;
129
+ taxId?: string;
130
+ files?: {
131
+ certificateOfIncorporation?: string;
132
+ kycReport?: string;
133
+ extraFiles?: string[];
134
+ };
135
+ };
136
+ BR?: {
137
+ status: KYCStatus;
138
+ personalId?: string;
139
+ taxId?: string;
140
+ files?: {
141
+ certificateOfIncorporation?: string;
142
+ kycReport?: string;
143
+ taxTranscript?: string;
144
+ proofOfAddress?: string;
145
+ businessRegistration?: string;
146
+ taxIdentificationCertificate?: string;
147
+ legalRepresentativeIdPowerOfAttorney?: string;
148
+ personalIdentificationCertificate?: string;
149
+ extraFiles?: string[];
150
+ };
151
+ };
152
+ };
153
+ address: {
154
+ street1: string;
155
+ street2?: string;
156
+ city: string;
157
+ state: string;
158
+ postalCode: string;
159
+ country: CountryOfOrigin;
160
+ };
161
+ invoicing?: {
162
+ MX: {
163
+ shouldInvoice: boolean;
164
+ fiscalName?: string;
165
+ fiscalRegimenCode?: number;
166
+ };
167
+ };
71
168
  }
72
169
  interface UserModel extends Model<UserDoc> {
73
170
  build(attrs: UserAttrs): UserDoc;
@@ -76,6 +173,29 @@ interface UserDoc extends Document {
76
173
  _id: string;
77
174
  createdAt: Date;
78
175
  authIds?: string[];
176
+ individualData?: {
177
+ firstName: string;
178
+ middleName?: string;
179
+ lastName: string;
180
+ secondLastName?: string;
181
+ birthday: Date;
182
+ countryOfOrigin: CountryOfOrigin;
183
+ };
184
+ businessData?: {
185
+ businessName: string;
186
+ legalRepresentative?: {
187
+ name: string;
188
+ email?: string;
189
+ status?: string;
190
+ };
191
+ UBO?: {
192
+ id?: string;
193
+ name: string;
194
+ email?: string;
195
+ status?: string;
196
+ };
197
+ };
198
+ risk: RiskTier;
79
199
  type: UserType;
80
200
  phoneNumber: string;
81
201
  email: string;
@@ -86,27 +206,25 @@ interface UserDoc extends Document {
86
206
  postalCode: string;
87
207
  country: CountryOfOrigin;
88
208
  kycStatus: KYCStatus;
89
- riskTier: RiskTier;
90
209
  hasPassedEDD: boolean;
91
210
  firstName?: string;
92
211
  middleName?: string;
93
212
  lastName?: string;
94
213
  secondLastName?: string;
95
- cosignerGroupId?: string;
96
214
  companyName?: string;
215
+ birthday?: Date;
216
+ cosignerGroupId?: string;
97
217
  legalRepresentative?: string;
98
218
  cpf?: string;
219
+ CPF?: string;
220
+ language?: Language;
221
+ attributes?: UserAttribute[];
222
+ brokerId?: string;
99
223
  curp?: string;
100
224
  ruc?: string;
101
- CPF?: string;
102
225
  CURP?: string;
103
226
  RUC?: string;
104
227
  economicActivity?: string;
105
- birthday?: Date;
106
- language?: Language;
107
- countriesToInvoice?: Country[];
108
- attributes?: UserAttribute[];
109
- brokerId?: string;
110
228
  platformFeeRanges?: {
111
229
  MX?: {
112
230
  buy?: PlatformFeeRange[];
@@ -137,10 +255,86 @@ interface UserDoc extends Document {
137
255
  notificationUrl?: string;
138
256
  rfc?: string;
139
257
  RFC?: string;
258
+ countriesToInvoice?: Country[];
140
259
  mexicoFiscalRegimenCode?: number;
141
260
  mexicoFiscalName?: string;
142
261
  taxId?: string;
143
262
  usKYCStatus?: "none" | "pending" | "failed" | "approved";
263
+ KYC?: {
264
+ MX?: {
265
+ status?: KYCStatus;
266
+ personalId?: string;
267
+ taxId?: string;
268
+ files?: {
269
+ certificateOfIncorporation?: string;
270
+ kycReport?: string;
271
+ taxTranscript?: string;
272
+ proofOfAddress?: string;
273
+ businessRegistration?: string;
274
+ taxIdentificationCertificate?: string;
275
+ legalRepresentativeIdPowerOfAttorney?: string;
276
+ personalIdentificationCertificate?: string;
277
+ extraFiles?: string[];
278
+ };
279
+ };
280
+ PE?: {
281
+ status?: KYCStatus;
282
+ personalId?: string;
283
+ taxId?: string;
284
+ files?: {
285
+ certificateOfIncorporation?: string;
286
+ kycReport?: string;
287
+ taxTranscript?: string;
288
+ proofOfAddress?: string;
289
+ businessRegistration?: string;
290
+ taxIdentificationCertificate?: string;
291
+ legalRepresentativeIdPowerOfAttorney?: string;
292
+ personalIdentificationCertificate?: string;
293
+ extraFiles?: string[];
294
+ };
295
+ };
296
+ US?: {
297
+ status?: KYCStatus;
298
+ personalId?: string;
299
+ taxId?: string;
300
+ files?: {
301
+ certificateOfIncorporation?: string;
302
+ kycReport?: string;
303
+ extraFiles?: string[];
304
+ };
305
+ };
306
+ BR?: {
307
+ status?: KYCStatus;
308
+ personalId?: string;
309
+ taxId?: string;
310
+ files?: {
311
+ certificateOfIncorporation?: string;
312
+ kycReport?: string;
313
+ taxTranscript?: string;
314
+ proofOfAddress?: string;
315
+ businessRegistration?: string;
316
+ taxIdentificationCertificate?: string;
317
+ legalRepresentativeIdPowerOfAttorney?: string;
318
+ personalIdentificationCertificate?: string;
319
+ extraFiles?: string[];
320
+ };
321
+ };
322
+ };
323
+ address: {
324
+ street1: string;
325
+ street2?: string;
326
+ city: string;
327
+ state: string;
328
+ postalCode: string;
329
+ country: CountryOfOrigin;
330
+ };
331
+ invoicing?: {
332
+ MX: {
333
+ shouldInvoice: boolean;
334
+ fiscalName?: string;
335
+ fiscalRegimenCode?: number;
336
+ };
337
+ };
144
338
  }
145
339
  declare const buildUser: (mongoose: Mongoose) => UserModel;
146
340
  export { buildUser, UserDoc };
@@ -70,7 +70,7 @@ const buildUser = (mongoose) => {
70
70
  type: String,
71
71
  required: true,
72
72
  },
73
- riskTier: {
73
+ risk: {
74
74
  type: String,
75
75
  required: true,
76
76
  },
@@ -308,6 +308,250 @@ const buildUser = (mongoose) => {
308
308
  type: String,
309
309
  },
310
310
  ],
311
+ address: {
312
+ street1: {
313
+ type: String,
314
+ required: true,
315
+ },
316
+ street2: {
317
+ type: String,
318
+ },
319
+ city: {
320
+ type: String,
321
+ required: true,
322
+ },
323
+ state: {
324
+ type: String,
325
+ required: true,
326
+ },
327
+ postalCode: {
328
+ type: String,
329
+ required: true,
330
+ },
331
+ country: {
332
+ type: String,
333
+ required: true,
334
+ },
335
+ },
336
+ KYC: {
337
+ MX: {
338
+ status: {
339
+ type: String,
340
+ required: true,
341
+ },
342
+ personalId: {
343
+ type: String,
344
+ },
345
+ taxId: {
346
+ type: String,
347
+ },
348
+ files: {
349
+ certificateOfIncorporation: {
350
+ type: String,
351
+ },
352
+ kycReport: {
353
+ type: String,
354
+ },
355
+ taxTranscript: {
356
+ type: String,
357
+ },
358
+ proofOfAddress: {
359
+ type: String,
360
+ },
361
+ businessRegistration: {
362
+ type: String,
363
+ },
364
+ taxIdentificationCertificate: {
365
+ type: String,
366
+ },
367
+ legalRepresentativeIdPowerOfAttorney: {
368
+ type: String,
369
+ },
370
+ personalIdentificationCertificate: {
371
+ type: String,
372
+ },
373
+ extraFiles: [
374
+ {
375
+ type: String,
376
+ },
377
+ ],
378
+ },
379
+ },
380
+ PE: {
381
+ status: {
382
+ type: String,
383
+ required: true,
384
+ },
385
+ personalId: {
386
+ type: String,
387
+ },
388
+ taxId: {
389
+ type: String,
390
+ },
391
+ files: {
392
+ certificateOfIncorporation: {
393
+ type: String,
394
+ },
395
+ kycReport: {
396
+ type: String,
397
+ },
398
+ taxTranscript: {
399
+ type: String,
400
+ },
401
+ proofOfAddress: {
402
+ type: String,
403
+ },
404
+ businessRegistration: {
405
+ type: String,
406
+ },
407
+ taxIdentificationCertificate: {
408
+ type: String,
409
+ },
410
+ legalRepresentativeIdPowerOfAttorney: {
411
+ type: String,
412
+ },
413
+ personalIdentificationCertificate: {
414
+ type: String,
415
+ },
416
+ extraFiles: [
417
+ {
418
+ type: String,
419
+ },
420
+ ],
421
+ },
422
+ },
423
+ US: {
424
+ status: {
425
+ type: String,
426
+ required: true,
427
+ },
428
+ personalId: {
429
+ type: String,
430
+ },
431
+ taxId: {
432
+ type: String,
433
+ },
434
+ files: {
435
+ certificateOfIncorporation: {
436
+ type: String,
437
+ },
438
+ kycReport: {
439
+ type: String,
440
+ },
441
+ extraFiles: [
442
+ {
443
+ type: String,
444
+ },
445
+ ],
446
+ },
447
+ },
448
+ BR: {
449
+ status: {
450
+ type: String,
451
+ required: true,
452
+ },
453
+ personalId: {
454
+ type: String,
455
+ },
456
+ taxId: {
457
+ type: String,
458
+ },
459
+ files: {
460
+ certificateOfIncorporation: {
461
+ type: String,
462
+ },
463
+ kycReport: {
464
+ type: String,
465
+ },
466
+ taxTranscript: {
467
+ type: String,
468
+ },
469
+ proofOfAddress: {
470
+ type: String,
471
+ },
472
+ businessRegistration: {
473
+ type: String,
474
+ },
475
+ taxIdentificationCertificate: {
476
+ type: String,
477
+ },
478
+ legalRepresentativeIdPowerOfAttorney: {
479
+ type: String,
480
+ },
481
+ personalIdentificationCertificate: {
482
+ type: String,
483
+ },
484
+ extraFiles: [
485
+ {
486
+ type: String,
487
+ },
488
+ ],
489
+ },
490
+ },
491
+ },
492
+ invoicing: {
493
+ MX: {
494
+ shouldInvoice: {
495
+ type: Boolean,
496
+ },
497
+ fiscalName: {
498
+ type: String,
499
+ },
500
+ fiscalRegimenCode: {
501
+ type: Number,
502
+ },
503
+ },
504
+ },
505
+ businessData: {
506
+ businessName: {
507
+ type: String,
508
+ },
509
+ legalRepresentative: {
510
+ name: {
511
+ type: String,
512
+ },
513
+ email: {
514
+ type: String,
515
+ },
516
+ status: {
517
+ type: String,
518
+ },
519
+ },
520
+ UBO: {
521
+ name: {
522
+ type: String,
523
+ },
524
+ email: {
525
+ type: String,
526
+ },
527
+ id: {
528
+ type: String,
529
+ },
530
+ status: {
531
+ type: String,
532
+ },
533
+ },
534
+ },
535
+ individualData: {
536
+ firstName: {
537
+ type: String,
538
+ },
539
+ middleName: {
540
+ type: String,
541
+ },
542
+ lastName: {
543
+ type: String,
544
+ },
545
+ secondLastName: {
546
+ type: String,
547
+ },
548
+ birthday: {
549
+ type: Date,
550
+ },
551
+ countryOfOrigin: {
552
+ type: String,
553
+ },
554
+ },
311
555
  notificationUrl: {
312
556
  type: String,
313
557
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.1384",
3
+ "version": "1.0.1392",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -27,7 +27,7 @@
27
27
  "@everapi/currencyapi-js": "^1.0.6",
28
28
  "@google-cloud/storage": "^6.9.5",
29
29
  "@google-cloud/vision": "^4.0.2",
30
- "@riocrypto/common": "^1.0.1206",
30
+ "@riocrypto/common": "^1.0.1213",
31
31
  "@types/express": "^4.17.13",
32
32
  "axios": "^0.27.2",
33
33
  "ccxt": "^3.0.30",
@@ -1,12 +0,0 @@
1
- import { Order, User } from "@riocrypto/common";
2
- declare class KushkiClient {
3
- private privateMerchantId;
4
- private environment;
5
- private baseUrl;
6
- constructor(privateMerchantId: string, environment: "sandbox" | "production");
7
- createPaymentLink(order: Order, user: User, token: string): Promise<any>;
8
- createBankPaymentToken(order: Order, user: User): Promise<any>;
9
- createBankPayment(order: Order, user: User, token: string): Promise<any>;
10
- }
11
- export declare const buildKushkiClient: () => Promise<KushkiClient>;
12
- export {};
@@ -1,159 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.buildKushkiClient = void 0;
16
- const common_1 = require("@riocrypto/common");
17
- const axios_1 = __importDefault(require("axios"));
18
- const secret_manager_client_1 = require("./secret-manager-client");
19
- class KushkiClient {
20
- constructor(privateMerchantId, environment) {
21
- this.privateMerchantId = privateMerchantId;
22
- this.environment = environment;
23
- this.baseUrl = `https://api${this.environment === "production" ? "." : "-uat."}kushkipagos.com`;
24
- }
25
- createPaymentLink(order, user, token) {
26
- return __awaiter(this, void 0, void 0, function* () {
27
- const body = {
28
- token,
29
- amount: {
30
- currency: order.fiat,
31
- subtotalIva: 0,
32
- subtotalIva0: order.amountFiat,
33
- iva: 0,
34
- ice: 0,
35
- },
36
- contactDetails: {
37
- firstName: user.firstName,
38
- lastName: user.lastName,
39
- email: user.email,
40
- documentType: "CC",
41
- phoneNumber: user.phoneNumber,
42
- },
43
- orderDetails: {
44
- siteDomain: "riocrypto.com",
45
- shippingDetails: {
46
- name: `${user.firstName} ${user.lastName}`,
47
- phone: user.phoneNumber,
48
- address1: user.street1,
49
- address2: user.street2,
50
- city: user.city,
51
- region: user.state,
52
- country: user.country,
53
- zipcode: user.postalCode,
54
- },
55
- billingDetails: {
56
- name: `${user.firstName} ${user.lastName}`,
57
- phone: user.phoneNumber,
58
- address1: user.street1,
59
- address2: user.street2,
60
- city: user.city,
61
- region: user.state,
62
- country: user.country,
63
- zipcode: user.postalCode,
64
- },
65
- product: {
66
- id: order.id,
67
- title: order.crypto,
68
- price: order.amountFiat,
69
- sku: order.id,
70
- quantity: 1,
71
- },
72
- },
73
- };
74
- const response = yield (0, axios_1.default)({
75
- method: "post",
76
- url: `${this.baseUrl}/card/v1/charges`,
77
- headers: {
78
- "Content-Type": "application/json",
79
- "Private-Merchant-Id": this.privateMerchantId,
80
- "Accept-Encoding": "gzip,deflate,compress",
81
- },
82
- data: body,
83
- });
84
- const data = response.data;
85
- return data;
86
- });
87
- }
88
- createBankPaymentToken(order, user) {
89
- return __awaiter(this, void 0, void 0, function* () {
90
- const body = {
91
- amount: {
92
- subtotalIva: 0,
93
- subtotalIva0: order.amountFiat,
94
- iva: 0,
95
- },
96
- callbackUrl: "https://riocrypto.com",
97
- userType: user.type === common_1.UserType.Business ? 1 : 0,
98
- documentType: "CC",
99
- documentNumber: "123456789",
100
- paymentDescription: `Compra de ${order.crypto} en riocrypto.com`,
101
- email: user.email,
102
- currency: order.fiat,
103
- };
104
- const response = yield (0, axios_1.default)({
105
- method: "post",
106
- url: `${this.baseUrl}/transfer/v1/tokens`,
107
- headers: {
108
- "Content-Type": "application/json",
109
- "Private-Merchant-Id": this.privateMerchantId,
110
- "Accept-Encoding": "gzip,deflate,compress",
111
- },
112
- data: body,
113
- });
114
- const data = response.data;
115
- return data;
116
- });
117
- }
118
- createBankPayment(order, user, token) {
119
- return __awaiter(this, void 0, void 0, function* () {
120
- const body = {
121
- token,
122
- amount: {
123
- subtotalIva: 0,
124
- subtotalIva0: order.amountFiat,
125
- iva: 0,
126
- },
127
- contactDetails: {
128
- fullName: user.type === common_1.UserType.Business
129
- ? user.companyName
130
- : `${user.firstName} ${user.lastName}`,
131
- email: user.email,
132
- documentType: "CC",
133
- phoneNumber: user.phoneNumber,
134
- },
135
- };
136
- const response = yield (0, axios_1.default)({
137
- method: "post",
138
- url: `${this.baseUrl}/transfer/v1/init`,
139
- headers: {
140
- "Content-Type": "application/json",
141
- "Private-Merchant-Id": this.privateMerchantId,
142
- "Accept-Encoding": "gzip,deflate,compress",
143
- },
144
- data: body,
145
- });
146
- const data = response.data;
147
- return data;
148
- });
149
- }
150
- }
151
- const buildKushkiClient = () => __awaiter(void 0, void 0, void 0, function* () {
152
- const KUSHKI_PRIVATE_MERCHANT_ID = yield secret_manager_client_1.secretManagerClient.getSecretValue("KUSHKI_PRIVATE_MERCHANT_ID");
153
- if (!KUSHKI_PRIVATE_MERCHANT_ID) {
154
- throw new Error("Unable to get KUSHKI_PRIVATE_MERCHANT_ID");
155
- }
156
- const kushkiClient = new KushkiClient(KUSHKI_PRIVATE_MERCHANT_ID, process.env.KUSHKI_ENV);
157
- return kushkiClient;
158
- });
159
- exports.buildKushkiClient = buildKushkiClient;
@@ -1,21 +0,0 @@
1
- import { User } from "@riocrypto/common";
2
- declare class STPClient {
3
- private apiKey;
4
- private env;
5
- private baseUrl;
6
- constructor(apiKey: string, env: "production" | "sandbox");
7
- createCryptoListIndividualUser(user: User): Promise<{
8
- id: number;
9
- descripcion: string;
10
- }>;
11
- createCryptoListBusinessUser(user: User): Promise<{
12
- id: number;
13
- descripcion: string;
14
- }>;
15
- getCyptoListUsers(user: User): Promise<{
16
- id: number;
17
- descripcion: string;
18
- }>;
19
- }
20
- export declare const buildSTPClient: () => Promise<STPClient>;
21
- export {};
@@ -1,97 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.buildSTPClient = void 0;
16
- const secret_manager_client_1 = require("./secret-manager-client");
17
- const axios_1 = __importDefault(require("axios"));
18
- const common_1 = require("@riocrypto/common");
19
- class STPClient {
20
- constructor(apiKey, env) {
21
- this.apiKey = apiKey;
22
- this.env = env;
23
- this.baseUrl =
24
- env === "production"
25
- ? "https://stpmex.com:7024"
26
- : "https://demo.stpmex.com:7024";
27
- }
28
- createCryptoListIndividualUser(user) {
29
- return __awaiter(this, void 0, void 0, function* () {
30
- const { data } = yield axios_1.default.put(`${this.baseUrl}/speiws/rest/cuentaModule/fisicaCrypto`, {
31
- nombre: user.firstName.toLocaleUpperCase(),
32
- apellidoPaterno: user.lastName.toLocaleUpperCase(),
33
- apellidoMaterno: user.lastName.toLocaleUpperCase(),
34
- cuenta: "",
35
- empresa: "Rampa Blockchain SAPI",
36
- }, {
37
- headers: {
38
- Authorization: `Bearer ${this.apiKey}`,
39
- },
40
- });
41
- if (data.id !== 0) {
42
- throw new Error(data.descripcion);
43
- }
44
- return data;
45
- });
46
- }
47
- createCryptoListBusinessUser(user) {
48
- return __awaiter(this, void 0, void 0, function* () {
49
- const { data } = yield axios_1.default.put(`${this.baseUrl}/speiws/rest/cuentaModule/moralCrypto`, {
50
- nombre: user.companyName.toLocaleUpperCase(),
51
- cuenta: "",
52
- empresa: "Rampa Blockchain SAPI",
53
- fechaConstitucion: "2020-01-01",
54
- }, {
55
- headers: {
56
- Authorization: `Bearer ${this.apiKey}`,
57
- },
58
- });
59
- if (data.id !== 0) {
60
- throw new Error(data.descripcion);
61
- }
62
- return data;
63
- });
64
- }
65
- getCyptoListUsers(user) {
66
- return __awaiter(this, void 0, void 0, function* () {
67
- const { data } = yield axios_1.default.put(`${this.baseUrl}/speiws/rest/cuentaModule/moralCrypto`, {
68
- nombre: user.companyName.toLocaleUpperCase(),
69
- cuenta: "",
70
- empresa: "Rampa Blockchain SAPI",
71
- fechaConstitucion: "2020-01-01",
72
- }, {
73
- headers: {
74
- Authorization: `Bearer ${this.apiKey}`,
75
- },
76
- });
77
- if (data.id !== 0) {
78
- throw new Error(data.descripcion);
79
- }
80
- return data;
81
- });
82
- }
83
- }
84
- const buildSTPClient = () => __awaiter(void 0, void 0, void 0, function* () {
85
- // Retrieve secrets asynchronously
86
- const STP_API_KEY = yield secret_manager_client_1.secretManagerClient.getSecretValue("STP_API_KEY");
87
- if (!STP_API_KEY) {
88
- throw new common_1.SecretManagerError();
89
- }
90
- const env = process.env.RIO_ENV === common_1.RioEnv.Production ||
91
- process.env.RIO_ENV === common_1.RioEnv.Staging ||
92
- process.env.RIO_ENV === common_1.RioEnv.Development
93
- ? "production"
94
- : "sandbox";
95
- return new STPClient(STP_API_KEY, env);
96
- });
97
- exports.buildSTPClient = buildSTPClient;