@cloudcommerce/app-pagarme-v5 2.41.2 → 2.41.5
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
// eslint-disable-next-line default-param-last
|
|
2
|
+
export const addInstallments = (amount, installments = {}, gateway = {}, response) => {
|
|
2
3
|
const interestFreeMinAmount = installments.interest_free_min_amount || 5;
|
|
3
4
|
const maxInterestFree = installments.max_interest_free;
|
|
4
5
|
const minInstallment = installments.min_installment || 5;
|
|
@@ -44,3 +45,5 @@ export default (amount, response, installments = {}, gateway = {}) => {
|
|
|
44
45
|
}
|
|
45
46
|
return { response, gateway };
|
|
46
47
|
};
|
|
48
|
+
|
|
49
|
+
export default addInstallments;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getFirestore } from 'firebase-admin/firestore';
|
|
2
|
-
import config from '@cloudcommerce/firebase/lib/config';
|
|
3
2
|
import api from '@cloudcommerce/api';
|
|
4
|
-
import logger from 'firebase
|
|
3
|
+
import { logger } from '@cloudcommerce/firebase/lib/config';
|
|
4
|
+
import getAppData from '@cloudcommerce/firebase/lib/helpers/get-app-data';
|
|
5
5
|
import axios from './functions-lib/pagarme/create-axios.mjs';
|
|
6
6
|
import {
|
|
7
7
|
getOrderById,
|
|
@@ -14,27 +14,13 @@ import {
|
|
|
14
14
|
} from './functions-lib/api-utils.mjs';
|
|
15
15
|
import { parserChangeStatusToEcom } from './functions-lib/pagarme/parses-utils.mjs';
|
|
16
16
|
|
|
17
|
-
const getAppData = async () => {
|
|
18
|
-
return new Promise((resolve, reject) => {
|
|
19
|
-
api.get(
|
|
20
|
-
`applications?app_id=${config.get().apps.pagarMeV5.appId}&fields=hidden_data`,
|
|
21
|
-
)
|
|
22
|
-
.then(({ data: result }) => {
|
|
23
|
-
resolve(result[0]);
|
|
24
|
-
})
|
|
25
|
-
.catch((err) => {
|
|
26
|
-
reject(err);
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
|
|
31
17
|
const handleWehook = async (req, res) => {
|
|
32
18
|
const colletionFirebase = getFirestore().collection('pagarmeV5Subscriptions');
|
|
33
19
|
const { body } = req;
|
|
34
20
|
|
|
35
21
|
try {
|
|
36
22
|
const type = body.type;
|
|
37
|
-
const appData = await getAppData();
|
|
23
|
+
const appData = await getAppData('pagarMeV5');
|
|
38
24
|
|
|
39
25
|
if (!process.env.PAGARMEV5_API_TOKEN) {
|
|
40
26
|
const pagarmeApiToken = appData.pagarme_api_token;
|
|
@@ -42,7 +28,6 @@ const handleWehook = async (req, res) => {
|
|
|
42
28
|
process.env.PAGARMEV5_API_TOKEN = pagarmeApiToken;
|
|
43
29
|
} else {
|
|
44
30
|
logger.warn('Missing PAGARMEV5 API TOKEN');
|
|
45
|
-
|
|
46
31
|
return res.status(401)
|
|
47
32
|
.send({
|
|
48
33
|
error: 'NO_PAGARME_KEYS',
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcommerce/app-pagarme-v5",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.41.
|
|
4
|
+
"version": "2.41.5",
|
|
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": {
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
"axios": "^1.8.4",
|
|
32
32
|
"firebase-admin": "^13.2.0",
|
|
33
33
|
"firebase-functions": "^6.3.2",
|
|
34
|
-
"@cloudcommerce/api": "2.41.
|
|
35
|
-
"@cloudcommerce/firebase": "2.41.
|
|
34
|
+
"@cloudcommerce/api": "2.41.5",
|
|
35
|
+
"@cloudcommerce/firebase": "2.41.5"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@cloudcommerce/
|
|
39
|
-
"@cloudcommerce/
|
|
38
|
+
"@cloudcommerce/types": "2.41.5",
|
|
39
|
+
"@cloudcommerce/test-base": "2.41.5"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "bash scripts/build.sh",
|