@smartsoft001/trans-shell-nestjs 2.117.0 → 2.118.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 (2) hide show
  1. package/index.js +38 -21
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -2372,6 +2372,7 @@ var RevolutConfig = class {
2372
2372
  test;
2373
2373
  token;
2374
2374
  };
2375
+ var REVOLUT_API_VERSION = "2024-09-01";
2375
2376
  var REVOLUT_CONFIG_PROVIDER = "REVOLUT_CONFIG_PROVIDER";
2376
2377
 
2377
2378
  // packages/shared/revolut/src/lib/revolut.service.ts
@@ -2386,34 +2387,36 @@ var RevolutService = class {
2386
2387
  const config = await this.getConfig(obj.data);
2387
2388
  const data = {
2388
2389
  amount: obj.amount,
2390
+ currency: "PLN",
2389
2391
  description: obj.name,
2390
- capture_mode: "AUTOMATIC",
2391
- merchant_order_ext_ref: obj.id,
2392
- customer_email: obj.email,
2393
- currency: "PLN"
2392
+ capture_mode: "automatic",
2393
+ merchant_order_ext_ref: obj.id
2394
2394
  };
2395
- const response = await this.httpService.post(this.getBaseUrl(config) + "/api/1.0/orders", data, {
2396
- headers: {
2397
- "Content-Type": "application/json",
2398
- Authorization: "Bearer " + config.token
2399
- },
2395
+ const hasCustomer = !!obj.email || !!obj.firstName || !!obj.lastName || !!obj.contactPhone;
2396
+ if (hasCustomer) {
2397
+ const fullName = [obj.firstName, obj.lastName].filter(Boolean).join(" ");
2398
+ data.customer = {
2399
+ email: obj.email,
2400
+ full_name: fullName || void 0,
2401
+ phone: obj.contactPhone
2402
+ };
2403
+ }
2404
+ const response = await this.httpService.post(this.getBaseUrl(config) + "/api/orders", data, {
2405
+ headers: this.getHeaders(config),
2400
2406
  maxRedirects: 0
2401
2407
  }).toPromise();
2402
2408
  return {
2403
2409
  responseData: response.data,
2404
- orderId: response.data["public_id"]
2410
+ orderId: response.data.token
2405
2411
  };
2406
2412
  }
2407
2413
  async getStatus(trans) {
2408
2414
  const config = await this.getConfig(trans.data);
2409
2415
  const historyItem = trans.history.find((h) => h.status === "started");
2410
2416
  const response = await this.httpService.get(
2411
- this.getBaseUrl(config) + "/api/1.0/orders/" + historyItem.data.responseData.id,
2417
+ this.getBaseUrl(config) + "/api/orders/" + historyItem.data.responseData.id,
2412
2418
  {
2413
- headers: {
2414
- "Content-Type": "application/json",
2415
- Authorization: "Bearer " + config.token
2416
- },
2419
+ headers: this.getHeaders(config),
2417
2420
  maxRedirects: 0
2418
2421
  }
2419
2422
  ).toPromise();
@@ -2428,7 +2431,15 @@ var RevolutService = class {
2428
2431
  getBaseUrl(config) {
2429
2432
  if (config.test)
2430
2433
  return "https://sandbox-merchant.revolut.com";
2431
- return "https://merchant.revolut.com/api";
2434
+ return "https://merchant.revolut.com";
2435
+ }
2436
+ getHeaders(config) {
2437
+ return {
2438
+ "Content-Type": "application/json",
2439
+ Accept: "application/json",
2440
+ Authorization: "Bearer " + config.token,
2441
+ "Revolut-Api-Version": REVOLUT_API_VERSION
2442
+ };
2432
2443
  }
2433
2444
  async getConfig(data) {
2434
2445
  try {
@@ -2444,14 +2455,18 @@ var RevolutService = class {
2444
2455
  }
2445
2456
  getStatusFromExternal(status) {
2446
2457
  switch (status) {
2447
- case "PROCESSING":
2458
+ case "pending":
2459
+ return "pending";
2460
+ case "processing":
2461
+ return "pending";
2462
+ case "authorised":
2463
+ return "completed";
2464
+ case "completed":
2448
2465
  return "completed";
2449
- case "CANCELLED":
2466
+ case "cancelled":
2450
2467
  return "canceled";
2451
- case "FAILED":
2468
+ case "failed":
2452
2469
  return "canceled";
2453
- case "PENDING":
2454
- return "pending";
2455
2470
  default:
2456
2471
  return status;
2457
2472
  }
@@ -3037,6 +3052,7 @@ var TransShellNestjsModule = class {
3037
3052
  ] : []
3038
3053
  ],
3039
3054
  imports: [
3055
+ HttpModule,
3040
3056
  CrudShellNestjsModule.forRoot({
3041
3057
  ...config,
3042
3058
  db: {
@@ -3088,6 +3104,7 @@ var TransShellNestjsCoreModule = class {
3088
3104
  ] : []
3089
3105
  ],
3090
3106
  imports: [
3107
+ HttpModule,
3091
3108
  CrudShellNestjsModule.forRoot({
3092
3109
  ...config,
3093
3110
  db: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartsoft001/trans-shell-nestjs",
3
- "version": "2.117.0",
3
+ "version": "2.118.0",
4
4
  "description": "This library was generated with [Nx](https://nx.dev).",
5
5
  "repository": {
6
6
  "type": "git",