@infrab4a/connect 5.3.6 → 5.3.9-beta.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.
package/index.cjs.js CHANGED
@@ -1815,7 +1815,7 @@ class AntifraudCardService {
1815
1815
  }
1816
1816
  getTodayDateRange() {
1817
1817
  const timeZone = 'America/Sao_Paulo';
1818
- const today = dateFnsTz.toZonedTime(new Date(), timeZone);
1818
+ const today = dateFnsTz.utcToZonedTime(new Date(), timeZone);
1819
1819
  const day = dateFns.startOfDay(today);
1820
1820
  const endOfDay = dateFns.endOfDay(today);
1821
1821
  return { day: dateFns.addHours(day, 3), endOfDay: dateFns.addHours(endOfDay, 3) };
@@ -8830,15 +8830,17 @@ class PagarMeV5RequestHelper {
8830
8830
  customer: this.buildCustomer(checkout),
8831
8831
  shipping: this.buildShipping(checkout),
8832
8832
  payments: this.buildPayment(checkout, method, card),
8833
+ ...this.buildAdditionalInfo(checkout),
8833
8834
  };
8834
8835
  }
8835
8836
  static buildItems(checkout) {
8837
+ const isSubscriber = checkout.user?.isSubscriber ?? false;
8836
8838
  return checkout.lineItems
8837
8839
  .filter((item) => !item.isGift)
8838
8840
  .map((item) => {
8839
8841
  return {
8840
8842
  amount: Math.floor(item.pricePaid * 100),
8841
- description: item.name,
8843
+ description: isSubscriber ? `${item.name} - ASSINANTE` : item.name,
8842
8844
  quantity: item.quantity,
8843
8845
  code: item.EAN,
8844
8846
  };
@@ -8935,6 +8937,14 @@ class PagarMeV5RequestHelper {
8935
8937
  },
8936
8938
  };
8937
8939
  }
8940
+ static buildAdditionalInfo(checkout) {
8941
+ const isSubscriber = checkout.user?.isSubscriber ?? false;
8942
+ if (isSubscriber)
8943
+ return {
8944
+ antifraude_enabled: false,
8945
+ };
8946
+ return {};
8947
+ }
8938
8948
  }
8939
8949
 
8940
8950
  class PagarMeV5ResponseHelper {
@@ -9719,14 +9729,6 @@ Object.defineProperty(exports, 'formatInTimeZone', {
9719
9729
  enumerable: true,
9720
9730
  get: function () { return dateFnsTz.formatInTimeZone; }
9721
9731
  });
9722
- Object.defineProperty(exports, 'fromZonedTime', {
9723
- enumerable: true,
9724
- get: function () { return dateFnsTz.fromZonedTime; }
9725
- });
9726
- Object.defineProperty(exports, 'toZonedTime', {
9727
- enumerable: true,
9728
- get: function () { return dateFnsTz.toZonedTime; }
9729
- });
9730
9732
  Object.defineProperty(exports, 'chunk', {
9731
9733
  enumerable: true,
9732
9734
  get: function () { return lodash.chunk; }
package/index.esm.js CHANGED
@@ -3,8 +3,8 @@ import { __decorate, __metadata } from 'tslib';
3
3
  import { plainToInstance, instanceToPlain, Type } from 'class-transformer';
4
4
  import { parseISO, startOfDay, endOfDay, addHours, subDays, format, addDays } from 'date-fns';
5
5
  export { add, addBusinessDays, addDays, addMonths, addYears, endOfDay, format, formatISO9075, parseISO, startOfDay, sub, subDays } from 'date-fns';
6
- import { toZonedTime } from 'date-fns-tz';
7
- export { formatInTimeZone, fromZonedTime, toZonedTime } from 'date-fns-tz';
6
+ import { utcToZonedTime } from 'date-fns-tz';
7
+ export { formatInTimeZone } from 'date-fns-tz';
8
8
  import { compact, get, isNil, isArray, first, last, flatten, isString, omit, each, unset, isObject, isEmpty, isDate, isBoolean, isInteger, isNumber, isNaN as isNaN$1, set, chunk, sortBy } from 'lodash';
9
9
  export { chunk, each, get, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, pick, set, sortBy, unset } from 'lodash';
10
10
  import { debug } from 'debug';
@@ -1791,7 +1791,7 @@ class AntifraudCardService {
1791
1791
  }
1792
1792
  getTodayDateRange() {
1793
1793
  const timeZone = 'America/Sao_Paulo';
1794
- const today = toZonedTime(new Date(), timeZone);
1794
+ const today = utcToZonedTime(new Date(), timeZone);
1795
1795
  const day = startOfDay(today);
1796
1796
  const endOfDay$1 = endOfDay(today);
1797
1797
  return { day: addHours(day, 3), endOfDay: addHours(endOfDay$1, 3) };
@@ -8806,15 +8806,17 @@ class PagarMeV5RequestHelper {
8806
8806
  customer: this.buildCustomer(checkout),
8807
8807
  shipping: this.buildShipping(checkout),
8808
8808
  payments: this.buildPayment(checkout, method, card),
8809
+ ...this.buildAdditionalInfo(checkout),
8809
8810
  };
8810
8811
  }
8811
8812
  static buildItems(checkout) {
8813
+ const isSubscriber = checkout.user?.isSubscriber ?? false;
8812
8814
  return checkout.lineItems
8813
8815
  .filter((item) => !item.isGift)
8814
8816
  .map((item) => {
8815
8817
  return {
8816
8818
  amount: Math.floor(item.pricePaid * 100),
8817
- description: item.name,
8819
+ description: isSubscriber ? `${item.name} - ASSINANTE` : item.name,
8818
8820
  quantity: item.quantity,
8819
8821
  code: item.EAN,
8820
8822
  };
@@ -8911,6 +8913,14 @@ class PagarMeV5RequestHelper {
8911
8913
  },
8912
8914
  };
8913
8915
  }
8916
+ static buildAdditionalInfo(checkout) {
8917
+ const isSubscriber = checkout.user?.isSubscriber ?? false;
8918
+ if (isSubscriber)
8919
+ return {
8920
+ antifraude_enabled: false,
8921
+ };
8922
+ return {};
8923
+ }
8914
8924
  }
8915
8925
 
8916
8926
  class PagarMeV5ResponseHelper {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "5.3.6",
3
+ "version": "5.3.9-beta.0",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -11,8 +11,8 @@
11
11
  "dependencies": {
12
12
  "axios": "^0.27.2",
13
13
  "class-transformer": "^0.5.1",
14
- "date-fns": "^2.28.0",
15
- "date-fns-tz": "^3.2.0",
14
+ "date-fns": "2.28.0",
15
+ "date-fns-tz": "2.0.1",
16
16
  "debug": "^4.3.4",
17
17
  "firebase": "^9.22.0",
18
18
  "gql-query-builder": "3.7.0",
@@ -14,4 +14,11 @@ export declare class Order extends Checkout {
14
14
  reshipmentOrderId?: string;
15
15
  isChange?: boolean;
16
16
  isReshipment?: boolean;
17
+ pedidov?: number;
18
+ metadata?: {
19
+ ip?: string;
20
+ userAgent?: string;
21
+ plataform?: string;
22
+ origin?: string;
23
+ };
17
24
  }
@@ -9,4 +9,5 @@ export declare class PagarMeV5RequestHelper {
9
9
  private static getPixOrder;
10
10
  private static getBoletoOrder;
11
11
  private static getCardOrder;
12
+ private static buildAdditionalInfo;
12
13
  }
@@ -3,6 +3,7 @@ export type PagarMeV5RequestPayload = {
3
3
  customer: PagarMeV5OrderCustomer;
4
4
  payments: PagarMeV5OrderPaymentInfo[];
5
5
  shipping?: PagarMeV5OrderShippingInfo;
6
+ antifraude_enabled?: boolean;
6
7
  };
7
8
  export type PagarMeV5OrderCustomer = {
8
9
  name: string;
@@ -1,5 +1,5 @@
1
1
  import { add, addBusinessDays, addDays, addMonths, addYears, Duration, endOfDay, format, formatISO9075, parseISO, startOfDay, sub, subDays } from 'date-fns';
2
- import { formatInTimeZone, fromZonedTime, toZonedTime } from 'date-fns-tz';
2
+ import { formatInTimeZone } from 'date-fns-tz';
3
3
  import { chunk, each, get, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, pick, set, sortBy, unset } from 'lodash';
4
4
  export type DateDuration = Duration;
5
5
  export * from './circular-dependencies';
@@ -14,4 +14,4 @@ export * from './obs-emitter';
14
14
  export * from './parse-datetime';
15
15
  export * from './serialize';
16
16
  export * from './types';
17
- export { add, addBusinessDays, addDays, addMonths, addYears, toZonedTime, formatInTimeZone, fromZonedTime, chunk, each, endOfDay, format, formatISO9075, get, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, parseISO, pick, set, sortBy, startOfDay, sub, subDays, unset, };
17
+ export { add, addBusinessDays, addDays, addMonths, addYears, formatInTimeZone, chunk, each, endOfDay, format, formatISO9075, get, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, parseISO, pick, set, sortBy, startOfDay, sub, subDays, unset, };