@cloudcommerce/app-pagarme-v5 2.52.0 → 2.52.2

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.
@@ -248,13 +248,12 @@ const handleWehook = async (req, res) => {
248
248
  }
249
249
 
250
250
  if (charge.order) {
251
- // payment update (order in pagarme)
252
251
  const { order: orderPagarme, status } = charge;
253
252
  logger.info(`Pagar.me charge ${orderPagarme.id} ${status}`);
254
253
  const order = await getOrderIntermediatorTransactionId(orderPagarme.id);
255
254
  if (order) {
256
- if (order.financial_status?.current !== parserChangeStatusToEcom(status)) {
257
- // updadte status
255
+ const newEcomStatus = parserChangeStatusToEcom(status);
256
+ if (order.financial_status?.current !== newEcomStatus) {
258
257
  let isUpdateTransaction = false;
259
258
  let transactionBody;
260
259
  const transaction = order.transactions.find(
@@ -270,12 +269,13 @@ const handleWehook = async (req, res) => {
270
269
  } else if (transactionPagarme.transaction_type === 'boleto') {
271
270
  notificationCode += `${transactionPagarme.gateway_id || ''};`;
272
271
  } else if (transactionPagarme.transaction_type === 'pix') {
273
- let notes = transaction.notes;
274
- // pix_provider_tid"
275
- notes = notes.replaceAll('display:block', 'display:none'); // disable QR Code
276
- notes = `${notes} # PIX Aprovado`;
277
- transactionBody = { notes };
278
- isUpdateTransaction = true;
272
+ if (newEcomStatus === 'paid') {
273
+ let notes = transaction.notes;
274
+ notes = notes.replaceAll('display:block', 'display:none');
275
+ notes = `${notes} # PIX Aprovado`;
276
+ transactionBody = { notes };
277
+ isUpdateTransaction = true;
278
+ }
279
279
  }
280
280
  let statusDateTime;
281
281
  if (order.payments_history?.some(({ flags }) => flags?.includes('pagarme-expired'))) {
@@ -285,7 +285,7 @@ const handleWehook = async (req, res) => {
285
285
  }
286
286
  const bodyPaymentHistory = {
287
287
  date_time: statusDateTime,
288
- status: parserChangeStatusToEcom(status),
288
+ status: newEcomStatus,
289
289
  notification_code: notificationCode,
290
290
  flags: ['PagarMe'],
291
291
  };
@@ -297,7 +297,7 @@ const handleWehook = async (req, res) => {
297
297
  await updateTransaction(order._id, transactionBody, transaction._id)
298
298
  .catch(logger.error);
299
299
  }
300
- logger.info(`${order._id} update to ${parserChangeStatusToEcom(status)}`);
300
+ logger.info(`${order._id} update to ${newEcomStatus}`);
301
301
  return res.sendStatus(201);
302
302
  }
303
303
  return res.sendStatus(200);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/app-pagarme-v5",
3
3
  "type": "module",
4
- "version": "2.52.0",
4
+ "version": "2.52.2",
5
5
  "description": "e-com.plus Cloud Commerce app to integrate Pagar.me API v5 with recurring payments",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
@@ -30,13 +30,13 @@
30
30
  "@ecomplus/utils": "1.5.0-rc.6",
31
31
  "axios": "^1.12.2",
32
32
  "firebase-admin": "^13.5.0",
33
- "firebase-functions": "^6.4.0",
34
- "@cloudcommerce/api": "2.52.0",
35
- "@cloudcommerce/firebase": "2.52.0"
33
+ "firebase-functions": "^6.5.0",
34
+ "@cloudcommerce/firebase": "2.52.2",
35
+ "@cloudcommerce/api": "2.52.2"
36
36
  },
37
37
  "devDependencies": {
38
- "@cloudcommerce/types": "2.52.0",
39
- "@cloudcommerce/test-base": "2.52.0"
38
+ "@cloudcommerce/types": "2.52.2",
39
+ "@cloudcommerce/test-base": "2.52.2"
40
40
  },
41
41
  "scripts": {
42
42
  "build": "bash scripts/build.sh",