@infrab4a/connect 5.7.5 → 5.7.7

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
@@ -17,6 +17,7 @@ var tsMd5 = require('ts-md5');
17
17
  var gqlQueryBuilder = require('gql-query-builder');
18
18
  var firestore = require('firebase/firestore');
19
19
  var storage = require('firebase/storage');
20
+ var currency = require('currency.js');
20
21
 
21
22
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
22
23
 
@@ -40,6 +41,7 @@ function _interopNamespace(e) {
40
41
 
41
42
  var serializeJavascript__namespace = /*#__PURE__*/_interopNamespace(serializeJavascript);
42
43
  var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
44
+ var currency__namespace = /*#__PURE__*/_interopNamespace(currency);
43
45
 
44
46
  exports.AntifraudProviders = void 0;
45
47
  (function (AntifraudProviders) {
@@ -11130,9 +11132,9 @@ class PagarmeV5BaseAxiosAdapter {
11130
11132
  }
11131
11133
  async refund(order, amount) {
11132
11134
  try {
11133
- console.warn('[PAGARME REFUND] Starting refund process for order', order.id, order.payment, 'with amount', amount);
11134
- const amountToSend = +amount.toFixed(2) * 100;
11135
- console.warn('[PAGARME REFUND] Amount to send in cents', amountToSend);
11135
+ console.warn('[PAGARME REFUND] Starting refund process for order', order.id, order.payment.payment_method, order.payment.amount, 'to refund with amount', amount);
11136
+ const amountInCents = currency__namespace(amount).multiply(100).value;
11137
+ console.warn('[PAGARME REFUND] Amount to send in cents', amountInCents);
11136
11138
  const { data } = await axios__default["default"]({
11137
11139
  method: 'DELETE',
11138
11140
  url: `${this.credentials.URL}/charges/${order.payment.charger_id}`,
@@ -11141,7 +11143,7 @@ class PagarmeV5BaseAxiosAdapter {
11141
11143
  'Content-Type': 'application/json',
11142
11144
  },
11143
11145
  data: {
11144
- amount: amountToSend,
11146
+ amount: amountInCents,
11145
11147
  },
11146
11148
  });
11147
11149
  console.warn('[RESPONSE PAGARME REFUND]', JSON.stringify(data));
package/index.esm.js CHANGED
@@ -16,6 +16,7 @@ import { Md5 } from 'ts-md5';
16
16
  import { mutation, query } from 'gql-query-builder';
17
17
  import { deleteField, arrayUnion, arrayRemove, Timestamp, doc, getDoc, updateDoc, setDoc, deleteDoc, collection, limit, getDocs, query as query$1, where, orderBy, startAfter, addDoc } from 'firebase/firestore';
18
18
  import { ref, uploadBytes } from 'firebase/storage';
19
+ import * as currency from 'currency.js';
19
20
 
20
21
  var AntifraudProviders;
21
22
  (function (AntifraudProviders) {
@@ -11106,9 +11107,9 @@ class PagarmeV5BaseAxiosAdapter {
11106
11107
  }
11107
11108
  async refund(order, amount) {
11108
11109
  try {
11109
- console.warn('[PAGARME REFUND] Starting refund process for order', order.id, order.payment, 'with amount', amount);
11110
- const amountToSend = +amount.toFixed(2) * 100;
11111
- console.warn('[PAGARME REFUND] Amount to send in cents', amountToSend);
11110
+ console.warn('[PAGARME REFUND] Starting refund process for order', order.id, order.payment.payment_method, order.payment.amount, 'to refund with amount', amount);
11111
+ const amountInCents = currency(amount).multiply(100).value;
11112
+ console.warn('[PAGARME REFUND] Amount to send in cents', amountInCents);
11112
11113
  const { data } = await axios({
11113
11114
  method: 'DELETE',
11114
11115
  url: `${this.credentials.URL}/charges/${order.payment.charger_id}`,
@@ -11117,7 +11118,7 @@ class PagarmeV5BaseAxiosAdapter {
11117
11118
  'Content-Type': 'application/json',
11118
11119
  },
11119
11120
  data: {
11120
- amount: amountToSend,
11121
+ amount: amountInCents,
11121
11122
  },
11122
11123
  });
11123
11124
  console.warn('[RESPONSE PAGARME REFUND]', JSON.stringify(data));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "5.7.5",
3
+ "version": "5.7.7",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -11,6 +11,7 @@
11
11
  "dependencies": {
12
12
  "axios": "^0.27.2",
13
13
  "class-transformer": "^0.5.1",
14
+ "currency.js": "2.0.4",
14
15
  "date-fns": "2.28.0",
15
16
  "date-fns-tz": "2.0.1",
16
17
  "debug": "^4.3.4",