n8n-nodes-mercadopago-pix-assinatura 1.0.0
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/README.md +291 -0
- package/dist/credentials/PixPaymentApi.credentials.d.ts +7 -0
- package/dist/credentials/PixPaymentApi.credentials.js +58 -0
- package/dist/nodes/PixPayment/PixPayment.node.d.ts +27 -0
- package/dist/nodes/PixPayment/PixPayment.node.js +1041 -0
- package/dist/nodes/PixPayment/helpers.d.ts +38 -0
- package/dist/nodes/PixPayment/helpers.js +107 -0
- package/dist/nodes/PixPayment/mercadopago.svg +1 -0
- package/dist/nodes/PixPayment/types.d.ts +118 -0
- package/dist/nodes/PixPayment/types.js +2 -0
- package/package.json +75 -0
package/README.md
ADDED
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
# n8n-nodes-mercadopago-pix-assinatura
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/n8n-nodes-mercadopago-pix-assinatura)
|
|
4
|
+
[](https://www.npmjs.com/package/n8n-nodes-mercadopago-pix-assinatura)
|
|
5
|
+
|
|
6
|
+
Node customizado do n8n para processamento de pagamentos via Mercado Pago, com suporte completo a:
|
|
7
|
+
|
|
8
|
+
- 💰 **Pagamentos PIX** (criação, consulta, reembolso)
|
|
9
|
+
- 🔄 **Assinaturas** (criar, pausar, retomar, cancelar, consultar, listar)
|
|
10
|
+
- 📅 **Pagamentos Recorrentes** (gerenciamento completo)
|
|
11
|
+
- 🔔 **Webhooks** (registro, listagem, exclusão, consulta)
|
|
12
|
+
|
|
13
|
+
## 📋 Requisitos
|
|
14
|
+
|
|
15
|
+
- n8n >= 2.0.3
|
|
16
|
+
- Node.js >= 18.17.0
|
|
17
|
+
- Credenciais do Mercado Pago (Access Token)
|
|
18
|
+
|
|
19
|
+
## 🚀 Instalação
|
|
20
|
+
|
|
21
|
+
### Instalação Local (Desenvolvimento)
|
|
22
|
+
|
|
23
|
+
1. Clone o repositório:
|
|
24
|
+
```bash
|
|
25
|
+
git clone https://github.com/eliveutonsouza/n8n-nodes-mercadopago-pix-assinatura.git
|
|
26
|
+
cd n8n-nodes-mercadopago-pix-assinatura
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
2. Instale as dependências:
|
|
30
|
+
```bash
|
|
31
|
+
npm install
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
3. Compile o projeto:
|
|
35
|
+
```bash
|
|
36
|
+
npm run build
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
4. Para desenvolvimento com watch mode:
|
|
40
|
+
```bash
|
|
41
|
+
npm run dev
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Instalação no n8n Self-Hosted (via NPM)
|
|
45
|
+
|
|
46
|
+
**Recomendado**: Instale via npm para facilitar atualizações.
|
|
47
|
+
|
|
48
|
+
1. No diretório do seu n8n self-hosted, instale o pacote:
|
|
49
|
+
```bash
|
|
50
|
+
npm install n8n-nodes-mercadopago-pix-assinatura
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
2. Reinicie o n8n:
|
|
54
|
+
```bash
|
|
55
|
+
# Se estiver usando Docker
|
|
56
|
+
docker restart n8n
|
|
57
|
+
|
|
58
|
+
# Se estiver usando npm diretamente
|
|
59
|
+
# Reinicie o processo do n8n
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
3. O node aparecerá na lista de nodes disponíveis no n8n
|
|
63
|
+
|
|
64
|
+
### Instalação Manual no n8n
|
|
65
|
+
|
|
66
|
+
1. Copie a pasta `dist` para o diretório de nodes customizados do n8n
|
|
67
|
+
2. Reinicie o n8n
|
|
68
|
+
3. O node aparecerá na lista de nodes disponíveis
|
|
69
|
+
|
|
70
|
+
## ⚙️ Configuração de Credenciais
|
|
71
|
+
|
|
72
|
+
1. Acesse o [Painel de Desenvolvedores do Mercado Pago](https://www.mercadopago.com.br/developers/panel/credentials)
|
|
73
|
+
2. Obtenha seu **Access Token** (produção ou sandbox)
|
|
74
|
+
3. No n8n, vá em **Credentials** → **Add Credential**
|
|
75
|
+
4. Selecione **Mercado Pago API**
|
|
76
|
+
5. Preencha:
|
|
77
|
+
- **Access Token**: Seu token de acesso
|
|
78
|
+
- **Client ID**: (Opcional)
|
|
79
|
+
- **Client Secret**: (Opcional)
|
|
80
|
+
- **Environment**: Sandbox ou Production
|
|
81
|
+
|
|
82
|
+
## 📖 Uso
|
|
83
|
+
|
|
84
|
+
### PIX - Criar Pagamento
|
|
85
|
+
|
|
86
|
+
Cria um novo pagamento PIX e retorna o QR Code para pagamento.
|
|
87
|
+
|
|
88
|
+
**Campos obrigatórios:**
|
|
89
|
+
- Valor (em reais, ex: 10.50)
|
|
90
|
+
- Descrição
|
|
91
|
+
- E-mail do Pagador
|
|
92
|
+
|
|
93
|
+
**Campos opcionais:**
|
|
94
|
+
- CPF/CNPJ do Pagador
|
|
95
|
+
- Nome do Pagador
|
|
96
|
+
- Data de Expiração
|
|
97
|
+
- Referência Externa
|
|
98
|
+
- Chave de Idempotência
|
|
99
|
+
|
|
100
|
+
**Resposta:**
|
|
101
|
+
```json
|
|
102
|
+
{
|
|
103
|
+
"id": "123456789",
|
|
104
|
+
"status": "pending",
|
|
105
|
+
"amount": 10.50,
|
|
106
|
+
"currency": "BRL",
|
|
107
|
+
"qrCode": "00020126...",
|
|
108
|
+
"qrCodeBase64": "data:image/png;base64,...",
|
|
109
|
+
"description": "Pagamento de teste",
|
|
110
|
+
"payerEmail": "cliente@example.com",
|
|
111
|
+
"createdAt": "2024-01-01T12:00:00.000Z",
|
|
112
|
+
"raw": { ... }
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### PIX - Consultar Pagamento
|
|
117
|
+
|
|
118
|
+
Consulta o status de um pagamento PIX existente.
|
|
119
|
+
|
|
120
|
+
**Campos obrigatórios:**
|
|
121
|
+
- ID do Pagamento
|
|
122
|
+
|
|
123
|
+
**Resposta:**
|
|
124
|
+
```json
|
|
125
|
+
{
|
|
126
|
+
"id": "123456789",
|
|
127
|
+
"status": "approved",
|
|
128
|
+
"amount": 10.50,
|
|
129
|
+
"currency": "BRL",
|
|
130
|
+
"createdAt": "2024-01-01T12:00:00.000Z",
|
|
131
|
+
"raw": { ... }
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### PIX - Reembolsar Pagamento
|
|
136
|
+
|
|
137
|
+
Reembolsa total ou parcialmente um pagamento PIX.
|
|
138
|
+
|
|
139
|
+
**Campos obrigatórios:**
|
|
140
|
+
- ID do Pagamento
|
|
141
|
+
|
|
142
|
+
**Campos opcionais:**
|
|
143
|
+
- Valor do Reembolso (deixe vazio para reembolso total)
|
|
144
|
+
|
|
145
|
+
### Assinaturas - Criar
|
|
146
|
+
|
|
147
|
+
Cria uma nova assinatura baseada em um plano existente.
|
|
148
|
+
|
|
149
|
+
**Campos obrigatórios:**
|
|
150
|
+
- ID do Plano
|
|
151
|
+
- E-mail do Pagador
|
|
152
|
+
|
|
153
|
+
**Campos opcionais:**
|
|
154
|
+
- CPF/CNPJ do Pagador
|
|
155
|
+
- Data de Início
|
|
156
|
+
- Período de Trial (dias)
|
|
157
|
+
|
|
158
|
+
### Assinaturas - Pausar/Retomar/Cancelar
|
|
159
|
+
|
|
160
|
+
Gerencia o status de uma assinatura existente.
|
|
161
|
+
|
|
162
|
+
**Campos obrigatórios:**
|
|
163
|
+
- ID da Assinatura
|
|
164
|
+
|
|
165
|
+
### Assinaturas - Consultar/Listar
|
|
166
|
+
|
|
167
|
+
Consulta uma assinatura específica ou lista todas as assinaturas.
|
|
168
|
+
|
|
169
|
+
### Pagamentos Recorrentes
|
|
170
|
+
|
|
171
|
+
Gerencia pagamentos recorrentes com histórico e próxima cobrança.
|
|
172
|
+
|
|
173
|
+
**Operações disponíveis:**
|
|
174
|
+
- Criar
|
|
175
|
+
- Listar
|
|
176
|
+
- Cancelar
|
|
177
|
+
- Consultar
|
|
178
|
+
|
|
179
|
+
### Webhooks - Registrar
|
|
180
|
+
|
|
181
|
+
Registra um novo webhook para receber notificações de eventos.
|
|
182
|
+
|
|
183
|
+
**Campos obrigatórios:**
|
|
184
|
+
- URL (deve ser acessível publicamente)
|
|
185
|
+
|
|
186
|
+
**Campos opcionais:**
|
|
187
|
+
- Eventos (payment, subscription)
|
|
188
|
+
- Descrição
|
|
189
|
+
|
|
190
|
+
**Eventos disponíveis:**
|
|
191
|
+
- `payment` - Notificações de pagamentos
|
|
192
|
+
- `subscription` - Notificações de assinaturas
|
|
193
|
+
|
|
194
|
+
### Webhooks - Listar/Consultar/Excluir
|
|
195
|
+
|
|
196
|
+
Gerencia webhooks registrados.
|
|
197
|
+
|
|
198
|
+
## 🔒 Segurança
|
|
199
|
+
|
|
200
|
+
- ✅ Tokens nunca são logados
|
|
201
|
+
- ✅ Suporte a idempotência via `X-Idempotency-Key`
|
|
202
|
+
- ✅ Validação de campos obrigatórios
|
|
203
|
+
- ✅ Validação de CPF/CNPJ e e-mails
|
|
204
|
+
- ✅ Suporte a ambientes sandbox e produção
|
|
205
|
+
|
|
206
|
+
## 🧪 Testes
|
|
207
|
+
|
|
208
|
+
Para testar localmente:
|
|
209
|
+
|
|
210
|
+
1. Configure credenciais sandbox do Mercado Pago
|
|
211
|
+
2. Execute o n8n em modo desenvolvimento:
|
|
212
|
+
```bash
|
|
213
|
+
npm run dev
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
3. Crie um workflow de teste no n8n
|
|
217
|
+
4. Teste cada operação com dados de exemplo
|
|
218
|
+
|
|
219
|
+
## 📝 Estrutura de Respostas
|
|
220
|
+
|
|
221
|
+
Todas as respostas seguem um formato padronizado:
|
|
222
|
+
|
|
223
|
+
```json
|
|
224
|
+
{
|
|
225
|
+
"id": "string",
|
|
226
|
+
"status": "string",
|
|
227
|
+
"amount": 0.00,
|
|
228
|
+
"currency": "BRL",
|
|
229
|
+
"createdAt": "ISO8601",
|
|
230
|
+
"raw": { /* Dados completos da API */ }
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
O campo `raw` contém a resposta completa da API do Mercado Pago para acesso a todos os dados disponíveis.
|
|
235
|
+
|
|
236
|
+
## 🐛 Troubleshooting
|
|
237
|
+
|
|
238
|
+
### Erro: "Credenciais não encontradas"
|
|
239
|
+
- Verifique se as credenciais foram configuradas corretamente no n8n
|
|
240
|
+
- Certifique-se de que o Access Token está válido
|
|
241
|
+
|
|
242
|
+
### Erro: "E-mail do pagador inválido"
|
|
243
|
+
- Verifique o formato do e-mail (deve conter @ e domínio válido)
|
|
244
|
+
|
|
245
|
+
### Erro: "CPF/CNPJ inválido"
|
|
246
|
+
- CPF deve conter 11 dígitos numéricos
|
|
247
|
+
- CNPJ deve conter 14 dígitos numéricos
|
|
248
|
+
- Caracteres especiais são removidos automaticamente
|
|
249
|
+
|
|
250
|
+
### Erro: "Valor do pagamento deve ser maior que zero"
|
|
251
|
+
- Verifique se o valor está correto
|
|
252
|
+
- Valores são convertidos automaticamente para centavos
|
|
253
|
+
|
|
254
|
+
### Webhook não recebe notificações
|
|
255
|
+
- Verifique se a URL é acessível publicamente
|
|
256
|
+
- Certifique-se de que o servidor está rodando e acessível
|
|
257
|
+
- Verifique os logs do Mercado Pago no painel de desenvolvedores
|
|
258
|
+
|
|
259
|
+
## 📚 Documentação Adicional
|
|
260
|
+
|
|
261
|
+
- [Documentação do Mercado Pago](https://www.mercadopago.com.br/developers/pt/docs)
|
|
262
|
+
- [API de Pagamentos](https://www.mercadopago.com.br/developers/pt/reference/payments/_payments/post)
|
|
263
|
+
- [API de Assinaturas](https://www.mercadopago.com.br/developers/pt/docs/your-integrations/subscriptions)
|
|
264
|
+
- [API de Webhooks](https://www.mercadopago.com.br/developers/pt/docs/your-integrations/notifications/webhooks)
|
|
265
|
+
|
|
266
|
+
## 🤝 Contribuindo
|
|
267
|
+
|
|
268
|
+
Contribuições são bem-vindas! Por favor:
|
|
269
|
+
|
|
270
|
+
1. Faça um fork do projeto
|
|
271
|
+
2. Crie uma branch para sua feature (`git checkout -b feature/AmazingFeature`)
|
|
272
|
+
3. Commit suas mudanças (`git commit -m 'Add some AmazingFeature'`)
|
|
273
|
+
4. Push para a branch (`git push origin feature/AmazingFeature`)
|
|
274
|
+
5. Abra um Pull Request
|
|
275
|
+
|
|
276
|
+
## 📄 Licença
|
|
277
|
+
|
|
278
|
+
Este projeto está licenciado sob a Licença MIT - veja o arquivo LICENSE para detalhes.
|
|
279
|
+
|
|
280
|
+
## 👤 Autor
|
|
281
|
+
|
|
282
|
+
Eliveuton Souza - eliveuton3m@hotmail.com
|
|
283
|
+
|
|
284
|
+
**GitHub**: [@eliveutonsouza](https://github.com/eliveutonsouza)
|
|
285
|
+
**NPM**: [n8n-nodes-mercadopago-pix-assinatura](https://www.npmjs.com/package/n8n-nodes-mercadopago-pix-assinatura)
|
|
286
|
+
|
|
287
|
+
## 🙏 Agradecimentos
|
|
288
|
+
|
|
289
|
+
- Equipe do n8n pela excelente plataforma
|
|
290
|
+
- Mercado Pago pela API robusta e documentação completa
|
|
291
|
+
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PixPaymentApi = void 0;
|
|
4
|
+
class PixPaymentApi {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.name = 'pixPaymentApi';
|
|
7
|
+
this.displayName = 'Mercado Pago API';
|
|
8
|
+
this.documentationUrl = 'https://www.mercadopago.com.br/developers/pt/docs';
|
|
9
|
+
this.properties = [
|
|
10
|
+
{
|
|
11
|
+
displayName: 'Access Token',
|
|
12
|
+
name: 'accessToken',
|
|
13
|
+
type: 'string',
|
|
14
|
+
typeOptions: {
|
|
15
|
+
password: true,
|
|
16
|
+
},
|
|
17
|
+
default: '',
|
|
18
|
+
required: true,
|
|
19
|
+
description: 'Token de acesso do Mercado Pago. Obtenha em: https://www.mercadopago.com.br/developers/panel/credentials',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
displayName: 'Client ID',
|
|
23
|
+
name: 'clientId',
|
|
24
|
+
type: 'string',
|
|
25
|
+
default: '',
|
|
26
|
+
description: 'ID do cliente (opcional, usado para algumas operações)',
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
displayName: 'Client Secret',
|
|
30
|
+
name: 'clientSecret',
|
|
31
|
+
type: 'string',
|
|
32
|
+
typeOptions: {
|
|
33
|
+
password: true,
|
|
34
|
+
},
|
|
35
|
+
default: '',
|
|
36
|
+
description: 'Secret do cliente (opcional, usado para algumas operações)',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
displayName: 'Environment',
|
|
40
|
+
name: 'environment',
|
|
41
|
+
type: 'options',
|
|
42
|
+
options: [
|
|
43
|
+
{
|
|
44
|
+
name: 'Sandbox',
|
|
45
|
+
value: 'sandbox',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'Production',
|
|
49
|
+
value: 'production',
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
default: 'sandbox',
|
|
53
|
+
description: 'Ambiente de execução',
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.PixPaymentApi = PixPaymentApi;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
|
+
export declare class PixPayment implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
5
|
+
private static handlePixOperation;
|
|
6
|
+
private static createPixPayment;
|
|
7
|
+
private static getPixPayment;
|
|
8
|
+
private static refundPixPayment;
|
|
9
|
+
private static handleSubscriptionOperation;
|
|
10
|
+
private static createSubscription;
|
|
11
|
+
private static getSubscription;
|
|
12
|
+
private static pauseSubscription;
|
|
13
|
+
private static resumeSubscription;
|
|
14
|
+
private static cancelSubscription;
|
|
15
|
+
private static listSubscriptions;
|
|
16
|
+
private static handleRecurringPaymentOperation;
|
|
17
|
+
private static createRecurringPayment;
|
|
18
|
+
private static getRecurringPayment;
|
|
19
|
+
private static listRecurringPayments;
|
|
20
|
+
private static cancelRecurringPayment;
|
|
21
|
+
private static handleWebhookOperation;
|
|
22
|
+
private static registerWebhook;
|
|
23
|
+
private static getWebhook;
|
|
24
|
+
private static listWebhooks;
|
|
25
|
+
private static deleteWebhook;
|
|
26
|
+
private static normalizeResponse;
|
|
27
|
+
}
|