n8n-nodes-mercadopago-pix-assinatura 1.0.4 → 1.0.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.
|
@@ -722,8 +722,19 @@ class PixPayment {
|
|
|
722
722
|
const baseUrl = (0, helpers_1.getBaseUrl)(credentials.environment);
|
|
723
723
|
for (let i = 0; i < items.length; i++) {
|
|
724
724
|
try {
|
|
725
|
-
|
|
726
|
-
|
|
725
|
+
let resource;
|
|
726
|
+
let operation;
|
|
727
|
+
try {
|
|
728
|
+
resource = this.getNodeParameter('resource', i);
|
|
729
|
+
operation = this.getNodeParameter('operation', i);
|
|
730
|
+
}
|
|
731
|
+
catch (error) {
|
|
732
|
+
if (error?.message?.includes('Could not get parameter')) {
|
|
733
|
+
throw new Error(`Erro ao obter parâmetros do node. Verifique se os campos "Resource" e "Operation" estão preenchidos corretamente. ` +
|
|
734
|
+
`Detalhes: ${error.message}`);
|
|
735
|
+
}
|
|
736
|
+
throw error;
|
|
737
|
+
}
|
|
727
738
|
let responseData;
|
|
728
739
|
switch (resource) {
|
|
729
740
|
case 'pix':
|
|
@@ -891,10 +902,10 @@ class PixPayment {
|
|
|
891
902
|
}
|
|
892
903
|
}
|
|
893
904
|
static async createPlan(executeFunctions, itemIndex, baseUrl, credentials) {
|
|
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');
|
|
905
|
+
const reason = (0, helpers_1.getNodeParameterSafe)(executeFunctions.getNodeParameter.bind(executeFunctions), 'reason', itemIndex, '');
|
|
906
|
+
const amountRaw = (0, helpers_1.getNodeParameterSafe)(executeFunctions.getNodeParameter.bind(executeFunctions), 'amount', itemIndex, 0);
|
|
907
|
+
const frequencyRaw = (0, helpers_1.getNodeParameterSafe)(executeFunctions.getNodeParameter.bind(executeFunctions), 'frequency', itemIndex, 1);
|
|
908
|
+
const frequencyType = (0, helpers_1.getNodeParameterSafe)(executeFunctions.getNodeParameter.bind(executeFunctions), 'frequencyType', itemIndex, 'months');
|
|
898
909
|
// Normaliza valores numéricos (converte vírgula para ponto)
|
|
899
910
|
const amount = (0, helpers_1.normalizeNumericValue)(amountRaw);
|
|
900
911
|
const frequency = (0, helpers_1.normalizeNumericValue)(frequencyRaw);
|
|
@@ -963,9 +974,9 @@ class PixPayment {
|
|
|
963
974
|
return response;
|
|
964
975
|
}
|
|
965
976
|
static async updatePlan(executeFunctions, itemIndex, baseUrl, credentials) {
|
|
966
|
-
const planId = executeFunctions.getNodeParameter('planId', itemIndex, '');
|
|
967
|
-
const reason = executeFunctions.getNodeParameter('reason', itemIndex, '');
|
|
968
|
-
const amountRaw = executeFunctions.getNodeParameter('amount', itemIndex, 0);
|
|
977
|
+
const planId = (0, helpers_1.getNodeParameterSafe)(executeFunctions.getNodeParameter.bind(executeFunctions), 'planId', itemIndex, '');
|
|
978
|
+
const reason = (0, helpers_1.getNodeParameterSafe)(executeFunctions.getNodeParameter.bind(executeFunctions), 'reason', itemIndex, '');
|
|
979
|
+
const amountRaw = (0, helpers_1.getNodeParameterSafe)(executeFunctions.getNodeParameter.bind(executeFunctions), 'amount', itemIndex, 0);
|
|
969
980
|
if (!planId || planId.trim() === '') {
|
|
970
981
|
throw new Error('ID do plano é obrigatório');
|
|
971
982
|
}
|
|
@@ -42,3 +42,8 @@ export declare function validateEmail(email: string): boolean;
|
|
|
42
42
|
* Exemplo: "14,9" -> 14.9, "14.9" -> 14.9
|
|
43
43
|
*/
|
|
44
44
|
export declare function normalizeNumericValue(value: string | number | undefined | null): number;
|
|
45
|
+
/**
|
|
46
|
+
* Obtém parâmetro do node de forma segura, retornando valor padrão em caso de erro
|
|
47
|
+
* Útil para parâmetros que podem não estar visíveis devido a displayOptions
|
|
48
|
+
*/
|
|
49
|
+
export declare function getNodeParameterSafe<T>(getNodeParameter: (name: string, itemIndex: number, fallback?: T) => T, name: string, itemIndex: number, fallback: T): T;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizeNumericValue = exports.validateEmail = exports.getDocumentType = exports.cleanDocument = exports.handleMercadoPagoError = exports.formatDate = exports.validateCNPJ = exports.validateCPF = exports.normalizeAmount = exports.getBaseUrl = void 0;
|
|
3
|
+
exports.getNodeParameterSafe = 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
|
*/
|
|
@@ -123,3 +123,21 @@ function normalizeNumericValue(value) {
|
|
|
123
123
|
return isNaN(parsed) ? 0 : parsed;
|
|
124
124
|
}
|
|
125
125
|
exports.normalizeNumericValue = normalizeNumericValue;
|
|
126
|
+
/**
|
|
127
|
+
* Obtém parâmetro do node de forma segura, retornando valor padrão em caso de erro
|
|
128
|
+
* Útil para parâmetros que podem não estar visíveis devido a displayOptions
|
|
129
|
+
*/
|
|
130
|
+
function getNodeParameterSafe(getNodeParameter, name, itemIndex, fallback) {
|
|
131
|
+
try {
|
|
132
|
+
return getNodeParameter(name, itemIndex, fallback);
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
// Se o erro for "Could not get parameter", retorna o valor padrão
|
|
136
|
+
if (error?.message?.includes('Could not get parameter') || error?.message?.includes('parameter')) {
|
|
137
|
+
return fallback;
|
|
138
|
+
}
|
|
139
|
+
// Para outros erros, relança
|
|
140
|
+
throw error;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
exports.getNodeParameterSafe = getNodeParameterSafe;
|