n8n-nodes-mercadopago-pix-assinatura 1.0.1 → 1.0.3
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
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
Node customizado do n8n para processamento de pagamentos via Mercado Pago, com suporte completo a:
|
|
7
7
|
|
|
8
8
|
- 💰 **Pagamentos PIX** (criação, consulta, reembolso)
|
|
9
|
+
- 📋 **Planos** (criar, consultar, listar, atualizar)
|
|
9
10
|
- 🔄 **Assinaturas** (criar, pausar, retomar, cancelar, consultar, listar)
|
|
10
11
|
- 📅 **Pagamentos Recorrentes** (gerenciamento completo)
|
|
11
12
|
- 🔔 **Webhooks** (registro, listagem, exclusão, consulta)
|
|
@@ -21,22 +22,26 @@ Node customizado do n8n para processamento de pagamentos via Mercado Pago, com s
|
|
|
21
22
|
### Instalação Local (Desenvolvimento)
|
|
22
23
|
|
|
23
24
|
1. Clone o repositório:
|
|
25
|
+
|
|
24
26
|
```bash
|
|
25
27
|
git clone https://github.com/eliveutonsouza/n8n-nodes-mercadopago-pix-assinatura.git
|
|
26
28
|
cd n8n-nodes-mercadopago-pix-assinatura
|
|
27
29
|
```
|
|
28
30
|
|
|
29
31
|
2. Instale as dependências:
|
|
32
|
+
|
|
30
33
|
```bash
|
|
31
34
|
npm install
|
|
32
35
|
```
|
|
33
36
|
|
|
34
37
|
3. Compile o projeto:
|
|
38
|
+
|
|
35
39
|
```bash
|
|
36
40
|
npm run build
|
|
37
41
|
```
|
|
38
42
|
|
|
39
43
|
4. Para desenvolvimento com watch mode:
|
|
44
|
+
|
|
40
45
|
```bash
|
|
41
46
|
npm run dev
|
|
42
47
|
```
|
|
@@ -46,11 +51,13 @@ npm run dev
|
|
|
46
51
|
**Recomendado**: Instale via npm para facilitar atualizações.
|
|
47
52
|
|
|
48
53
|
1. No diretório do seu n8n self-hosted, instale o pacote:
|
|
54
|
+
|
|
49
55
|
```bash
|
|
50
56
|
npm install n8n-nodes-mercadopago-pix-assinatura
|
|
51
57
|
```
|
|
52
58
|
|
|
53
59
|
2. Reinicie o n8n:
|
|
60
|
+
|
|
54
61
|
```bash
|
|
55
62
|
# Se estiver usando Docker
|
|
56
63
|
docker restart n8n
|
|
@@ -88,11 +95,13 @@ docker restart n8n
|
|
|
88
95
|
Cria um novo pagamento PIX e retorna o QR Code para pagamento.
|
|
89
96
|
|
|
90
97
|
**Campos obrigatórios:**
|
|
98
|
+
|
|
91
99
|
- Valor (em reais, ex: 10.50)
|
|
92
100
|
- Descrição
|
|
93
101
|
- E-mail do Pagador
|
|
94
102
|
|
|
95
103
|
**Campos opcionais:**
|
|
104
|
+
|
|
96
105
|
- CPF/CNPJ do Pagador
|
|
97
106
|
- Nome do Pagador
|
|
98
107
|
- Data de Expiração
|
|
@@ -100,6 +109,7 @@ Cria um novo pagamento PIX e retorna o QR Code para pagamento.
|
|
|
100
109
|
- Chave de Idempotência
|
|
101
110
|
|
|
102
111
|
**Resposta:**
|
|
112
|
+
|
|
103
113
|
```json
|
|
104
114
|
{
|
|
105
115
|
"id": "123456789",
|
|
@@ -120,9 +130,11 @@ Cria um novo pagamento PIX e retorna o QR Code para pagamento.
|
|
|
120
130
|
Consulta o status de um pagamento PIX existente.
|
|
121
131
|
|
|
122
132
|
**Campos obrigatórios:**
|
|
133
|
+
|
|
123
134
|
- ID do Pagamento
|
|
124
135
|
|
|
125
136
|
**Resposta:**
|
|
137
|
+
|
|
126
138
|
```json
|
|
127
139
|
{
|
|
128
140
|
"id": "123456789",
|
|
@@ -139,9 +151,11 @@ Consulta o status de um pagamento PIX existente.
|
|
|
139
151
|
Reembolsa total ou parcialmente um pagamento PIX.
|
|
140
152
|
|
|
141
153
|
**Campos obrigatórios:**
|
|
154
|
+
|
|
142
155
|
- ID do Pagamento
|
|
143
156
|
|
|
144
157
|
**Campos opcionais:**
|
|
158
|
+
|
|
145
159
|
- Valor do Reembolso (deixe vazio para reembolso total)
|
|
146
160
|
|
|
147
161
|
### Assinaturas - Criar
|
|
@@ -149,10 +163,12 @@ Reembolsa total ou parcialmente um pagamento PIX.
|
|
|
149
163
|
Cria uma nova assinatura baseada em um plano existente.
|
|
150
164
|
|
|
151
165
|
**Campos obrigatórios:**
|
|
166
|
+
|
|
152
167
|
- ID do Plano
|
|
153
168
|
- E-mail do Pagador
|
|
154
169
|
|
|
155
170
|
**Campos opcionais:**
|
|
171
|
+
|
|
156
172
|
- CPF/CNPJ do Pagador
|
|
157
173
|
- Data de Início
|
|
158
174
|
- Período de Trial (dias)
|
|
@@ -162,6 +178,7 @@ Cria uma nova assinatura baseada em um plano existente.
|
|
|
162
178
|
Gerencia o status de uma assinatura existente.
|
|
163
179
|
|
|
164
180
|
**Campos obrigatórios:**
|
|
181
|
+
|
|
165
182
|
- ID da Assinatura
|
|
166
183
|
|
|
167
184
|
### Assinaturas - Consultar/Listar
|
|
@@ -173,6 +190,7 @@ Consulta uma assinatura específica ou lista todas as assinaturas.
|
|
|
173
190
|
Gerencia pagamentos recorrentes com histórico e próxima cobrança.
|
|
174
191
|
|
|
175
192
|
**Operações disponíveis:**
|
|
193
|
+
|
|
176
194
|
- Criar
|
|
177
195
|
- Listar
|
|
178
196
|
- Cancelar
|
|
@@ -183,13 +201,16 @@ Gerencia pagamentos recorrentes com histórico e próxima cobrança.
|
|
|
183
201
|
Registra um novo webhook para receber notificações de eventos.
|
|
184
202
|
|
|
185
203
|
**Campos obrigatórios:**
|
|
204
|
+
|
|
186
205
|
- URL (deve ser acessível publicamente)
|
|
187
206
|
|
|
188
207
|
**Campos opcionais:**
|
|
208
|
+
|
|
189
209
|
- Eventos (payment, subscription)
|
|
190
210
|
- Descrição
|
|
191
211
|
|
|
192
212
|
**Eventos disponíveis:**
|
|
213
|
+
|
|
193
214
|
- `payment` - Notificações de pagamentos
|
|
194
215
|
- `subscription` - Notificações de assinaturas
|
|
195
216
|
|
|
@@ -211,6 +232,7 @@ Para testar localmente:
|
|
|
211
232
|
|
|
212
233
|
1. Configure credenciais sandbox do Mercado Pago
|
|
213
234
|
2. Execute o n8n em modo desenvolvimento:
|
|
235
|
+
|
|
214
236
|
```bash
|
|
215
237
|
npm run dev
|
|
216
238
|
```
|
|
@@ -226,10 +248,12 @@ Todas as respostas seguem um formato padronizado:
|
|
|
226
248
|
{
|
|
227
249
|
"id": "string",
|
|
228
250
|
"status": "string",
|
|
229
|
-
"amount": 0.
|
|
251
|
+
"amount": 0.0,
|
|
230
252
|
"currency": "BRL",
|
|
231
253
|
"createdAt": "ISO8601",
|
|
232
|
-
"raw": {
|
|
254
|
+
"raw": {
|
|
255
|
+
/* Dados completos da API */
|
|
256
|
+
}
|
|
233
257
|
}
|
|
234
258
|
```
|
|
235
259
|
|
|
@@ -238,22 +262,27 @@ O campo `raw` contém a resposta completa da API do Mercado Pago para acesso a t
|
|
|
238
262
|
## 🐛 Troubleshooting
|
|
239
263
|
|
|
240
264
|
### Erro: "Credenciais não encontradas"
|
|
265
|
+
|
|
241
266
|
- Verifique se as credenciais foram configuradas corretamente no n8n
|
|
242
267
|
- Certifique-se de que o Access Token está válido
|
|
243
268
|
|
|
244
269
|
### Erro: "E-mail do pagador inválido"
|
|
270
|
+
|
|
245
271
|
- Verifique o formato do e-mail (deve conter @ e domínio válido)
|
|
246
272
|
|
|
247
273
|
### Erro: "CPF/CNPJ inválido"
|
|
274
|
+
|
|
248
275
|
- CPF deve conter 11 dígitos numéricos
|
|
249
276
|
- CNPJ deve conter 14 dígitos numéricos
|
|
250
277
|
- Caracteres especiais são removidos automaticamente
|
|
251
278
|
|
|
252
279
|
### Erro: "Valor do pagamento deve ser maior que zero"
|
|
280
|
+
|
|
253
281
|
- Verifique se o valor está correto
|
|
254
282
|
- Valores são convertidos automaticamente para centavos
|
|
255
283
|
|
|
256
284
|
### Webhook não recebe notificações
|
|
285
|
+
|
|
257
286
|
- Verifique se a URL é acessível publicamente
|
|
258
287
|
- Certifique-se de que o servidor está rodando e acessível
|
|
259
288
|
- Verifique os logs do Mercado Pago no painel de desenvolvedores
|
|
@@ -290,4 +319,3 @@ Eliveuton Souza - eliveuton3m@hotmail.com
|
|
|
290
319
|
|
|
291
320
|
- Equipe do n8n pela excelente plataforma
|
|
292
321
|
- Mercado Pago pela API robusta e documentação completa
|
|
293
|
-
|
|
@@ -6,6 +6,11 @@ export declare class PixPayment implements INodeType {
|
|
|
6
6
|
private static createPixPayment;
|
|
7
7
|
private static getPixPayment;
|
|
8
8
|
private static refundPixPayment;
|
|
9
|
+
private static handlePlanOperation;
|
|
10
|
+
private static createPlan;
|
|
11
|
+
private static getPlan;
|
|
12
|
+
private static listPlans;
|
|
13
|
+
private static updatePlan;
|
|
9
14
|
private static handleSubscriptionOperation;
|
|
10
15
|
private static createSubscription;
|
|
11
16
|
private static getSubscription;
|
|
@@ -34,6 +34,10 @@ class PixPayment {
|
|
|
34
34
|
name: 'PIX',
|
|
35
35
|
value: 'pix',
|
|
36
36
|
},
|
|
37
|
+
{
|
|
38
|
+
name: 'Plano',
|
|
39
|
+
value: 'plans',
|
|
40
|
+
},
|
|
37
41
|
{
|
|
38
42
|
name: 'Assinatura',
|
|
39
43
|
value: 'subscriptions',
|
|
@@ -233,6 +237,154 @@ class PixPayment {
|
|
|
233
237
|
default: 0,
|
|
234
238
|
description: 'Valor do reembolso em reais (deixe vazio para reembolso total)',
|
|
235
239
|
},
|
|
240
|
+
// Plan Operations
|
|
241
|
+
{
|
|
242
|
+
displayName: 'Operation',
|
|
243
|
+
name: 'operation',
|
|
244
|
+
type: 'options',
|
|
245
|
+
noDataExpression: true,
|
|
246
|
+
displayOptions: {
|
|
247
|
+
show: {
|
|
248
|
+
resource: ['plans'],
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
options: [
|
|
252
|
+
{
|
|
253
|
+
name: 'Criar',
|
|
254
|
+
value: 'create',
|
|
255
|
+
description: 'Criar um plano de assinatura',
|
|
256
|
+
action: 'Criar plano',
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
name: 'Consultar',
|
|
260
|
+
value: 'get',
|
|
261
|
+
description: 'Consultar um plano',
|
|
262
|
+
action: 'Consultar plano',
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
name: 'Listar',
|
|
266
|
+
value: 'list',
|
|
267
|
+
description: 'Listar planos',
|
|
268
|
+
action: 'Listar planos',
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
name: 'Atualizar',
|
|
272
|
+
value: 'update',
|
|
273
|
+
description: 'Atualizar um plano',
|
|
274
|
+
action: 'Atualizar plano',
|
|
275
|
+
},
|
|
276
|
+
],
|
|
277
|
+
default: 'create',
|
|
278
|
+
},
|
|
279
|
+
// Plan Create Fields
|
|
280
|
+
{
|
|
281
|
+
displayName: 'Nome do Plano',
|
|
282
|
+
name: 'reason',
|
|
283
|
+
type: 'string',
|
|
284
|
+
required: true,
|
|
285
|
+
displayOptions: {
|
|
286
|
+
show: {
|
|
287
|
+
resource: ['plans'],
|
|
288
|
+
operation: ['create'],
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
default: '',
|
|
292
|
+
description: 'Nome/descrição do plano',
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
displayName: 'Valor',
|
|
296
|
+
name: 'amount',
|
|
297
|
+
type: 'number',
|
|
298
|
+
required: true,
|
|
299
|
+
displayOptions: {
|
|
300
|
+
show: {
|
|
301
|
+
resource: ['plans'],
|
|
302
|
+
operation: ['create'],
|
|
303
|
+
},
|
|
304
|
+
},
|
|
305
|
+
default: 0,
|
|
306
|
+
description: 'Valor do plano em reais (ex: 99.99)',
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
displayName: 'Frequência',
|
|
310
|
+
name: 'frequency',
|
|
311
|
+
type: 'number',
|
|
312
|
+
required: true,
|
|
313
|
+
displayOptions: {
|
|
314
|
+
show: {
|
|
315
|
+
resource: ['plans'],
|
|
316
|
+
operation: ['create'],
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
default: 1,
|
|
320
|
+
description: 'Frequência de cobrança (ex: 1 para mensal)',
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
displayName: 'Tipo de Frequência',
|
|
324
|
+
name: 'frequencyType',
|
|
325
|
+
type: 'options',
|
|
326
|
+
required: true,
|
|
327
|
+
displayOptions: {
|
|
328
|
+
show: {
|
|
329
|
+
resource: ['plans'],
|
|
330
|
+
operation: ['create'],
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
options: [
|
|
334
|
+
{
|
|
335
|
+
name: 'Dias',
|
|
336
|
+
value: 'days',
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
name: 'Meses',
|
|
340
|
+
value: 'months',
|
|
341
|
+
},
|
|
342
|
+
],
|
|
343
|
+
default: 'months',
|
|
344
|
+
description: 'Tipo de frequência (dias ou meses)',
|
|
345
|
+
},
|
|
346
|
+
// Plan Get/Update Fields
|
|
347
|
+
{
|
|
348
|
+
displayName: 'ID do Plano',
|
|
349
|
+
name: 'planId',
|
|
350
|
+
type: 'string',
|
|
351
|
+
required: true,
|
|
352
|
+
displayOptions: {
|
|
353
|
+
show: {
|
|
354
|
+
resource: ['plans'],
|
|
355
|
+
operation: ['get', 'update'],
|
|
356
|
+
},
|
|
357
|
+
},
|
|
358
|
+
default: '',
|
|
359
|
+
description: 'ID do plano',
|
|
360
|
+
},
|
|
361
|
+
// Plan Update Fields
|
|
362
|
+
{
|
|
363
|
+
displayName: 'Nome do Plano',
|
|
364
|
+
name: 'reason',
|
|
365
|
+
type: 'string',
|
|
366
|
+
displayOptions: {
|
|
367
|
+
show: {
|
|
368
|
+
resource: ['plans'],
|
|
369
|
+
operation: ['update'],
|
|
370
|
+
},
|
|
371
|
+
},
|
|
372
|
+
default: '',
|
|
373
|
+
description: 'Novo nome/descrição do plano',
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
displayName: 'Valor',
|
|
377
|
+
name: 'amount',
|
|
378
|
+
type: 'number',
|
|
379
|
+
displayOptions: {
|
|
380
|
+
show: {
|
|
381
|
+
resource: ['plans'],
|
|
382
|
+
operation: ['update'],
|
|
383
|
+
},
|
|
384
|
+
},
|
|
385
|
+
default: 0,
|
|
386
|
+
description: 'Novo valor do plano em reais',
|
|
387
|
+
},
|
|
236
388
|
// Subscription Operations
|
|
237
389
|
{
|
|
238
390
|
displayName: 'Operation',
|
|
@@ -577,6 +729,9 @@ class PixPayment {
|
|
|
577
729
|
case 'pix':
|
|
578
730
|
responseData = await PixPayment.handlePixOperation(this, operation, i, baseUrl, credentials);
|
|
579
731
|
break;
|
|
732
|
+
case 'plans':
|
|
733
|
+
responseData = await PixPayment.handlePlanOperation(this, operation, i, baseUrl, credentials);
|
|
734
|
+
break;
|
|
580
735
|
case 'subscriptions':
|
|
581
736
|
responseData = await PixPayment.handleSubscriptionOperation(this, operation, i, baseUrl, credentials);
|
|
582
737
|
break;
|
|
@@ -721,6 +876,120 @@ class PixPayment {
|
|
|
721
876
|
});
|
|
722
877
|
return response;
|
|
723
878
|
}
|
|
879
|
+
static async handlePlanOperation(executeFunctions, operation, itemIndex, baseUrl, credentials) {
|
|
880
|
+
switch (operation) {
|
|
881
|
+
case 'create':
|
|
882
|
+
return await PixPayment.createPlan(executeFunctions, itemIndex, baseUrl, credentials);
|
|
883
|
+
case 'get':
|
|
884
|
+
return await PixPayment.getPlan(executeFunctions, itemIndex, baseUrl, credentials);
|
|
885
|
+
case 'list':
|
|
886
|
+
return await PixPayment.listPlans(executeFunctions, itemIndex, baseUrl, credentials);
|
|
887
|
+
case 'update':
|
|
888
|
+
return await PixPayment.updatePlan(executeFunctions, itemIndex, baseUrl, credentials);
|
|
889
|
+
default:
|
|
890
|
+
throw new Error(`Operação de plano "${operation}" não é suportada`);
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
static async createPlan(executeFunctions, itemIndex, baseUrl, credentials) {
|
|
894
|
+
const reason = executeFunctions.getNodeParameter('reason', itemIndex);
|
|
895
|
+
const amount = executeFunctions.getNodeParameter('amount', itemIndex);
|
|
896
|
+
const frequency = executeFunctions.getNodeParameter('frequency', itemIndex);
|
|
897
|
+
const frequencyType = executeFunctions.getNodeParameter('frequencyType', itemIndex);
|
|
898
|
+
if (!reason || reason.trim() === '') {
|
|
899
|
+
throw new Error('Nome do plano é obrigatório');
|
|
900
|
+
}
|
|
901
|
+
if (amount <= 0) {
|
|
902
|
+
throw new Error('Valor do plano deve ser maior que zero');
|
|
903
|
+
}
|
|
904
|
+
if (frequency <= 0) {
|
|
905
|
+
throw new Error('Frequência deve ser maior que zero');
|
|
906
|
+
}
|
|
907
|
+
if (frequencyType !== 'days' && frequencyType !== 'months') {
|
|
908
|
+
throw new Error('Tipo de frequência deve ser "days" ou "months"');
|
|
909
|
+
}
|
|
910
|
+
const body = {
|
|
911
|
+
reason,
|
|
912
|
+
auto_recurring: {
|
|
913
|
+
frequency,
|
|
914
|
+
frequency_type: frequencyType,
|
|
915
|
+
transaction_amount: (0, helpers_1.normalizeAmount)(amount),
|
|
916
|
+
currency_id: 'BRL',
|
|
917
|
+
},
|
|
918
|
+
payment_methods_allowed: {
|
|
919
|
+
payment_types: [
|
|
920
|
+
{ id: 'credit_card' },
|
|
921
|
+
],
|
|
922
|
+
},
|
|
923
|
+
};
|
|
924
|
+
const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, 'pixPaymentApi', {
|
|
925
|
+
method: 'POST',
|
|
926
|
+
url: `${baseUrl}/preapproval_plan`,
|
|
927
|
+
body,
|
|
928
|
+
headers: {
|
|
929
|
+
Authorization: `Bearer ${credentials.accessToken}`,
|
|
930
|
+
'Content-Type': 'application/json',
|
|
931
|
+
},
|
|
932
|
+
json: true,
|
|
933
|
+
});
|
|
934
|
+
return response;
|
|
935
|
+
}
|
|
936
|
+
static async getPlan(executeFunctions, itemIndex, baseUrl, credentials) {
|
|
937
|
+
const planId = executeFunctions.getNodeParameter('planId', itemIndex);
|
|
938
|
+
if (!planId || planId.trim() === '') {
|
|
939
|
+
throw new Error('ID do plano é obrigatório');
|
|
940
|
+
}
|
|
941
|
+
const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, 'pixPaymentApi', {
|
|
942
|
+
method: 'GET',
|
|
943
|
+
url: `${baseUrl}/preapproval_plan/${planId}`,
|
|
944
|
+
headers: {
|
|
945
|
+
Authorization: `Bearer ${credentials.accessToken}`,
|
|
946
|
+
},
|
|
947
|
+
json: true,
|
|
948
|
+
});
|
|
949
|
+
return response;
|
|
950
|
+
}
|
|
951
|
+
static async listPlans(executeFunctions, _itemIndex, baseUrl, credentials) {
|
|
952
|
+
const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, 'pixPaymentApi', {
|
|
953
|
+
method: 'GET',
|
|
954
|
+
url: `${baseUrl}/preapproval_plan/search`,
|
|
955
|
+
headers: {
|
|
956
|
+
Authorization: `Bearer ${credentials.accessToken}`,
|
|
957
|
+
},
|
|
958
|
+
json: true,
|
|
959
|
+
});
|
|
960
|
+
return response;
|
|
961
|
+
}
|
|
962
|
+
static async updatePlan(executeFunctions, itemIndex, baseUrl, credentials) {
|
|
963
|
+
const planId = executeFunctions.getNodeParameter('planId', itemIndex);
|
|
964
|
+
const reason = executeFunctions.getNodeParameter('reason', itemIndex);
|
|
965
|
+
const amount = executeFunctions.getNodeParameter('amount', itemIndex);
|
|
966
|
+
if (!planId || planId.trim() === '') {
|
|
967
|
+
throw new Error('ID do plano é obrigatório');
|
|
968
|
+
}
|
|
969
|
+
const body = {};
|
|
970
|
+
if (reason && reason.trim() !== '') {
|
|
971
|
+
body.reason = reason;
|
|
972
|
+
}
|
|
973
|
+
if (amount && amount > 0) {
|
|
974
|
+
body.auto_recurring = {
|
|
975
|
+
transaction_amount: (0, helpers_1.normalizeAmount)(amount),
|
|
976
|
+
};
|
|
977
|
+
}
|
|
978
|
+
if (Object.keys(body).length === 0) {
|
|
979
|
+
throw new Error('É necessário fornecer pelo menos um campo para atualizar (nome ou valor)');
|
|
980
|
+
}
|
|
981
|
+
const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, 'pixPaymentApi', {
|
|
982
|
+
method: 'PUT',
|
|
983
|
+
url: `${baseUrl}/preapproval_plan/${planId}`,
|
|
984
|
+
body,
|
|
985
|
+
headers: {
|
|
986
|
+
Authorization: `Bearer ${credentials.accessToken}`,
|
|
987
|
+
'Content-Type': 'application/json',
|
|
988
|
+
},
|
|
989
|
+
json: true,
|
|
990
|
+
});
|
|
991
|
+
return response;
|
|
992
|
+
}
|
|
724
993
|
static async handleSubscriptionOperation(executeFunctions, operation, itemIndex, baseUrl, credentials) {
|
|
725
994
|
switch (operation) {
|
|
726
995
|
case 'create':
|
|
@@ -1017,6 +1286,11 @@ class PixPayment {
|
|
|
1017
1286
|
normalized.description = data.description;
|
|
1018
1287
|
normalized.payerEmail = data.payer?.email;
|
|
1019
1288
|
break;
|
|
1289
|
+
case 'plans':
|
|
1290
|
+
normalized.planId = data.id;
|
|
1291
|
+
normalized.amount = data.auto_recurring?.transaction_amount ? data.auto_recurring.transaction_amount / 100 : undefined;
|
|
1292
|
+
normalized.description = data.reason;
|
|
1293
|
+
break;
|
|
1020
1294
|
case 'subscriptions':
|
|
1021
1295
|
normalized.planId = data.preapproval_plan_id;
|
|
1022
1296
|
normalized.payerEmail = data.payer_email;
|
|
@@ -58,6 +58,27 @@ export interface Subscription {
|
|
|
58
58
|
recurring_application_id?: number;
|
|
59
59
|
operation_type?: string;
|
|
60
60
|
}
|
|
61
|
+
export interface Plan {
|
|
62
|
+
id: string;
|
|
63
|
+
status: string;
|
|
64
|
+
reason: string;
|
|
65
|
+
auto_recurring: {
|
|
66
|
+
frequency: number;
|
|
67
|
+
frequency_type: string;
|
|
68
|
+
transaction_amount: number;
|
|
69
|
+
currency_id: string;
|
|
70
|
+
};
|
|
71
|
+
payment_methods_allowed?: {
|
|
72
|
+
payment_types?: Array<{
|
|
73
|
+
id: string;
|
|
74
|
+
}>;
|
|
75
|
+
payment_methods?: Array<{
|
|
76
|
+
id: string;
|
|
77
|
+
}>;
|
|
78
|
+
};
|
|
79
|
+
date_created?: string;
|
|
80
|
+
last_modified?: string;
|
|
81
|
+
}
|
|
61
82
|
export interface RecurringPayment {
|
|
62
83
|
id: string;
|
|
63
84
|
status: string;
|