n8n-nodes-mercadopago-pix-assinatura 1.0.3 → 1.0.4
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.
|
@@ -891,10 +891,13 @@ class PixPayment {
|
|
|
891
891
|
}
|
|
892
892
|
}
|
|
893
893
|
static async createPlan(executeFunctions, itemIndex, baseUrl, credentials) {
|
|
894
|
-
const reason = executeFunctions.getNodeParameter('reason', itemIndex);
|
|
895
|
-
const
|
|
896
|
-
const
|
|
897
|
-
const frequencyType = executeFunctions.getNodeParameter('frequencyType', itemIndex);
|
|
894
|
+
const reason = executeFunctions.getNodeParameter('reason', itemIndex, '');
|
|
895
|
+
const amountRaw = executeFunctions.getNodeParameter('amount', itemIndex, 0);
|
|
896
|
+
const frequencyRaw = executeFunctions.getNodeParameter('frequency', itemIndex, 1);
|
|
897
|
+
const frequencyType = executeFunctions.getNodeParameter('frequencyType', itemIndex, 'months');
|
|
898
|
+
// Normaliza valores numéricos (converte vírgula para ponto)
|
|
899
|
+
const amount = (0, helpers_1.normalizeNumericValue)(amountRaw);
|
|
900
|
+
const frequency = (0, helpers_1.normalizeNumericValue)(frequencyRaw);
|
|
898
901
|
if (!reason || reason.trim() === '') {
|
|
899
902
|
throw new Error('Nome do plano é obrigatório');
|
|
900
903
|
}
|
|
@@ -960,12 +963,14 @@ class PixPayment {
|
|
|
960
963
|
return response;
|
|
961
964
|
}
|
|
962
965
|
static async updatePlan(executeFunctions, itemIndex, baseUrl, credentials) {
|
|
963
|
-
const planId = executeFunctions.getNodeParameter('planId', itemIndex);
|
|
964
|
-
const reason = executeFunctions.getNodeParameter('reason', itemIndex);
|
|
965
|
-
const
|
|
966
|
+
const planId = executeFunctions.getNodeParameter('planId', itemIndex, '');
|
|
967
|
+
const reason = executeFunctions.getNodeParameter('reason', itemIndex, '');
|
|
968
|
+
const amountRaw = executeFunctions.getNodeParameter('amount', itemIndex, 0);
|
|
966
969
|
if (!planId || planId.trim() === '') {
|
|
967
970
|
throw new Error('ID do plano é obrigatório');
|
|
968
971
|
}
|
|
972
|
+
// Normaliza valor numérico (converte vírgula para ponto)
|
|
973
|
+
const amount = (0, helpers_1.normalizeNumericValue)(amountRaw);
|
|
969
974
|
const body = {};
|
|
970
975
|
if (reason && reason.trim() !== '') {
|
|
971
976
|
body.reason = reason;
|
|
@@ -36,3 +36,9 @@ export declare function getDocumentType(document: string): 'CPF' | 'CNPJ' | null
|
|
|
36
36
|
* Valida se o email tem formato válido
|
|
37
37
|
*/
|
|
38
38
|
export declare function validateEmail(email: string): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Normaliza valores numéricos convertendo vírgula para ponto decimal
|
|
41
|
+
* Aceita string ou number e retorna number
|
|
42
|
+
* Exemplo: "14,9" -> 14.9, "14.9" -> 14.9
|
|
43
|
+
*/
|
|
44
|
+
export declare function normalizeNumericValue(value: string | number | undefined | null): number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateEmail = exports.getDocumentType = exports.cleanDocument = exports.handleMercadoPagoError = exports.formatDate = exports.validateCNPJ = exports.validateCPF = exports.normalizeAmount = exports.getBaseUrl = void 0;
|
|
3
|
+
exports.normalizeNumericValue = exports.validateEmail = exports.getDocumentType = exports.cleanDocument = exports.handleMercadoPagoError = exports.formatDate = exports.validateCNPJ = exports.validateCPF = exports.normalizeAmount = exports.getBaseUrl = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Retorna a URL base da API do Mercado Pago conforme o ambiente
|
|
6
6
|
*/
|
|
@@ -105,3 +105,21 @@ function validateEmail(email) {
|
|
|
105
105
|
return emailRegex.test(email);
|
|
106
106
|
}
|
|
107
107
|
exports.validateEmail = validateEmail;
|
|
108
|
+
/**
|
|
109
|
+
* Normaliza valores numéricos convertendo vírgula para ponto decimal
|
|
110
|
+
* Aceita string ou number e retorna number
|
|
111
|
+
* Exemplo: "14,9" -> 14.9, "14.9" -> 14.9
|
|
112
|
+
*/
|
|
113
|
+
function normalizeNumericValue(value) {
|
|
114
|
+
if (value === undefined || value === null) {
|
|
115
|
+
return 0;
|
|
116
|
+
}
|
|
117
|
+
if (typeof value === 'number') {
|
|
118
|
+
return value;
|
|
119
|
+
}
|
|
120
|
+
// Converte string: substitui vírgula por ponto e remove espaços
|
|
121
|
+
const normalized = String(value).trim().replace(',', '.');
|
|
122
|
+
const parsed = parseFloat(normalized);
|
|
123
|
+
return isNaN(parsed) ? 0 : parsed;
|
|
124
|
+
}
|
|
125
|
+
exports.normalizeNumericValue = normalizeNumericValue;
|