n8n-nodes-mercadopago-pix-assinatura 1.0.6 → 1.0.7

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.
@@ -5,712 +5,712 @@ const helpers_1 = require("./helpers");
5
5
  class PixPayment {
6
6
  constructor() {
7
7
  this.description = {
8
- displayName: 'Mercado Pago PIX e Assinaturas',
9
- name: 'pixPayment',
10
- icon: 'file:mercadopago.svg',
11
- group: ['transform'],
8
+ displayName: "Mercado Pago PIX e Assinaturas",
9
+ name: "pixPayment",
10
+ icon: "file:mercadopago.svg",
11
+ group: ["transform"],
12
12
  version: 1,
13
13
  subtitle: '={{$parameter["resource"] + ": " + $parameter["operation"]}}',
14
- description: 'Processamento de pagamentos PIX, assinaturas e webhooks via Mercado Pago',
14
+ description: "Processamento de pagamentos PIX, assinaturas e webhooks via Mercado Pago",
15
15
  defaults: {
16
- name: 'Mercado Pago',
16
+ name: "Mercado Pago",
17
17
  },
18
- inputs: ['main'],
19
- outputs: ['main'],
18
+ inputs: ["main"],
19
+ outputs: ["main"],
20
20
  credentials: [
21
21
  {
22
- name: 'pixPaymentApi',
22
+ name: "pixPaymentApi",
23
23
  required: true,
24
24
  },
25
25
  ],
26
26
  properties: [
27
27
  {
28
- displayName: 'Resource',
29
- name: 'resource',
30
- type: 'options',
28
+ displayName: "Resource",
29
+ name: "resource",
30
+ type: "options",
31
31
  noDataExpression: true,
32
32
  options: [
33
33
  {
34
- name: 'PIX',
35
- value: 'pix',
34
+ name: "PIX",
35
+ value: "pix",
36
36
  },
37
37
  {
38
- name: 'Plano',
39
- value: 'plans',
38
+ name: "Plano",
39
+ value: "plans",
40
40
  },
41
41
  {
42
- name: 'Assinatura',
43
- value: 'subscriptions',
42
+ name: "Assinatura",
43
+ value: "subscriptions",
44
44
  },
45
45
  {
46
- name: 'Pagamento Recorrente',
47
- value: 'recurringPayments',
46
+ name: "Pagamento Recorrente",
47
+ value: "recurringPayments",
48
48
  },
49
49
  {
50
- name: 'Webhook',
51
- value: 'webhooks',
50
+ name: "Webhook",
51
+ value: "webhooks",
52
52
  },
53
53
  ],
54
- default: 'pix',
54
+ default: "pix",
55
55
  },
56
56
  // PIX Operations
57
57
  {
58
- displayName: 'Operation',
59
- name: 'operation',
60
- type: 'options',
58
+ displayName: "Operation",
59
+ name: "operation",
60
+ type: "options",
61
61
  noDataExpression: true,
62
62
  displayOptions: {
63
63
  show: {
64
- resource: ['pix'],
64
+ resource: ["pix"],
65
65
  },
66
66
  },
67
67
  options: [
68
68
  {
69
- name: 'Criar',
70
- value: 'create',
71
- description: 'Criar um pagamento PIX',
72
- action: 'Criar pagamento PIX',
69
+ name: "Criar",
70
+ value: "create",
71
+ description: "Criar um pagamento PIX",
72
+ action: "Criar pagamento PIX",
73
73
  },
74
74
  {
75
- name: 'Consultar',
76
- value: 'get',
77
- description: 'Consultar um pagamento PIX',
78
- action: 'Consultar pagamento PIX',
75
+ name: "Consultar",
76
+ value: "get",
77
+ description: "Consultar um pagamento PIX",
78
+ action: "Consultar pagamento PIX",
79
79
  },
80
80
  {
81
- name: 'Reembolsar',
82
- value: 'refund',
83
- description: 'Reembolsar um pagamento PIX',
84
- action: 'Reembolsar pagamento PIX',
81
+ name: "Reembolsar",
82
+ value: "refund",
83
+ description: "Reembolsar um pagamento PIX",
84
+ action: "Reembolsar pagamento PIX",
85
85
  },
86
86
  ],
87
- default: 'create',
87
+ default: "create",
88
88
  },
89
89
  // PIX Create Fields
90
90
  {
91
- displayName: 'Valor',
92
- name: 'amount',
93
- type: 'number',
91
+ displayName: "Valor",
92
+ name: "amount",
93
+ type: "number",
94
94
  required: true,
95
95
  displayOptions: {
96
96
  show: {
97
- resource: ['pix'],
98
- operation: ['create'],
97
+ resource: ["pix"],
98
+ operation: ["create"],
99
99
  },
100
100
  },
101
101
  default: 0,
102
- description: 'Valor do pagamento em reais (ex: 10.50)',
102
+ description: "Valor do pagamento em reais (ex: 10.50)",
103
103
  },
104
104
  {
105
- displayName: 'Descrição',
106
- name: 'description',
107
- type: 'string',
105
+ displayName: "Descrição",
106
+ name: "description",
107
+ type: "string",
108
108
  required: true,
109
109
  displayOptions: {
110
110
  show: {
111
- resource: ['pix'],
112
- operation: ['create'],
111
+ resource: ["pix"],
112
+ operation: ["create"],
113
113
  },
114
114
  },
115
- default: '',
116
- description: 'Descrição do pagamento',
115
+ default: "",
116
+ description: "Descrição do pagamento",
117
117
  },
118
118
  {
119
- displayName: 'E-mail do Pagador',
120
- name: 'payerEmail',
121
- type: 'string',
119
+ displayName: "E-mail do Pagador",
120
+ name: "payerEmail",
121
+ type: "string",
122
122
  required: true,
123
123
  displayOptions: {
124
124
  show: {
125
- resource: ['pix'],
126
- operation: ['create'],
125
+ resource: ["pix"],
126
+ operation: ["create"],
127
127
  },
128
128
  },
129
- default: '',
130
- description: 'E-mail do pagador',
129
+ default: "",
130
+ description: "E-mail do pagador",
131
131
  },
132
132
  {
133
- displayName: 'CPF/CNPJ do Pagador',
134
- name: 'payerDocument',
135
- type: 'string',
133
+ displayName: "CPF/CNPJ do Pagador",
134
+ name: "payerDocument",
135
+ type: "string",
136
136
  displayOptions: {
137
137
  show: {
138
- resource: ['pix'],
139
- operation: ['create'],
138
+ resource: ["pix"],
139
+ operation: ["create"],
140
140
  },
141
141
  },
142
- default: '',
143
- description: 'CPF ou CNPJ do pagador (apenas números)',
142
+ default: "",
143
+ description: "CPF ou CNPJ do pagador (apenas números)",
144
144
  },
145
145
  {
146
- displayName: 'Nome do Pagador',
147
- name: 'payerName',
148
- type: 'string',
146
+ displayName: "Nome do Pagador",
147
+ name: "payerName",
148
+ type: "string",
149
149
  displayOptions: {
150
150
  show: {
151
- resource: ['pix'],
152
- operation: ['create'],
151
+ resource: ["pix"],
152
+ operation: ["create"],
153
153
  },
154
154
  },
155
- default: '',
156
- description: 'Nome completo do pagador',
155
+ default: "",
156
+ description: "Nome completo do pagador",
157
157
  },
158
158
  {
159
- displayName: 'Data de Expiração',
160
- name: 'expirationDate',
161
- type: 'dateTime',
159
+ displayName: "Data de Expiração",
160
+ name: "expirationDate",
161
+ type: "dateTime",
162
162
  displayOptions: {
163
163
  show: {
164
- resource: ['pix'],
165
- operation: ['create'],
164
+ resource: ["pix"],
165
+ operation: ["create"],
166
166
  },
167
167
  },
168
- default: '',
169
- description: 'Data e hora de expiração do QR Code PIX',
168
+ default: "",
169
+ description: "Data e hora de expiração do QR Code PIX",
170
170
  },
171
171
  {
172
- displayName: 'Referência Externa',
173
- name: 'externalReference',
174
- type: 'string',
172
+ displayName: "Referência Externa",
173
+ name: "externalReference",
174
+ type: "string",
175
175
  displayOptions: {
176
176
  show: {
177
- resource: ['pix'],
178
- operation: ['create'],
177
+ resource: ["pix"],
178
+ operation: ["create"],
179
179
  },
180
180
  },
181
- default: '',
182
- description: 'Referência externa para identificar o pagamento',
181
+ default: "",
182
+ description: "Referência externa para identificar o pagamento",
183
183
  },
184
184
  {
185
- displayName: 'Chave de Idempotência',
186
- name: 'idempotencyKey',
187
- type: 'string',
185
+ displayName: "Chave de Idempotência",
186
+ name: "idempotencyKey",
187
+ type: "string",
188
188
  displayOptions: {
189
189
  show: {
190
- resource: ['pix'],
191
- operation: ['create'],
190
+ resource: ["pix"],
191
+ operation: ["create"],
192
192
  },
193
193
  },
194
- default: '',
195
- description: 'Chave única para garantir idempotência da requisição',
194
+ default: "",
195
+ description: "Chave única para garantir idempotência da requisição",
196
196
  },
197
197
  // PIX Get Fields
198
198
  {
199
- displayName: 'ID do Pagamento',
200
- name: 'paymentId',
201
- type: 'string',
199
+ displayName: "ID do Pagamento",
200
+ name: "paymentId",
201
+ type: "string",
202
202
  required: true,
203
203
  displayOptions: {
204
204
  show: {
205
- resource: ['pix'],
206
- operation: ['get'],
205
+ resource: ["pix"],
206
+ operation: ["get"],
207
207
  },
208
208
  },
209
- default: '',
210
- description: 'ID do pagamento a ser consultado',
209
+ default: "",
210
+ description: "ID do pagamento a ser consultado",
211
211
  },
212
212
  // PIX Refund Fields
213
213
  {
214
- displayName: 'ID do Pagamento',
215
- name: 'paymentId',
216
- type: 'string',
214
+ displayName: "ID do Pagamento",
215
+ name: "paymentId",
216
+ type: "string",
217
217
  required: true,
218
218
  displayOptions: {
219
219
  show: {
220
- resource: ['pix'],
221
- operation: ['refund'],
220
+ resource: ["pix"],
221
+ operation: ["refund"],
222
222
  },
223
223
  },
224
- default: '',
225
- description: 'ID do pagamento a ser reembolsado',
224
+ default: "",
225
+ description: "ID do pagamento a ser reembolsado",
226
226
  },
227
227
  {
228
- displayName: 'Valor do Reembolso',
229
- name: 'refundAmount',
230
- type: 'number',
228
+ displayName: "Valor do Reembolso",
229
+ name: "refundAmount",
230
+ type: "number",
231
231
  displayOptions: {
232
232
  show: {
233
- resource: ['pix'],
234
- operation: ['refund'],
233
+ resource: ["pix"],
234
+ operation: ["refund"],
235
235
  },
236
236
  },
237
237
  default: 0,
238
- description: 'Valor do reembolso em reais (deixe vazio para reembolso total)',
238
+ description: "Valor do reembolso em reais (deixe vazio para reembolso total)",
239
239
  },
240
240
  // Plan Operations
241
241
  {
242
- displayName: 'Operation',
243
- name: 'operation',
244
- type: 'options',
242
+ displayName: "Operation",
243
+ name: "operation",
244
+ type: "options",
245
245
  noDataExpression: true,
246
246
  displayOptions: {
247
247
  show: {
248
- resource: ['plans'],
248
+ resource: ["plans"],
249
249
  },
250
250
  },
251
251
  options: [
252
252
  {
253
- name: 'Criar',
254
- value: 'create',
255
- description: 'Criar um plano de assinatura',
256
- action: 'Criar plano',
253
+ name: "Criar",
254
+ value: "create",
255
+ description: "Criar um plano de assinatura",
256
+ action: "Criar plano",
257
257
  },
258
258
  {
259
- name: 'Consultar',
260
- value: 'get',
261
- description: 'Consultar um plano',
262
- action: 'Consultar plano',
259
+ name: "Consultar",
260
+ value: "get",
261
+ description: "Consultar um plano",
262
+ action: "Consultar plano",
263
263
  },
264
264
  {
265
- name: 'Listar',
266
- value: 'list',
267
- description: 'Listar planos',
268
- action: 'Listar planos',
265
+ name: "Listar",
266
+ value: "list",
267
+ description: "Listar planos",
268
+ action: "Listar planos",
269
269
  },
270
270
  {
271
- name: 'Atualizar',
272
- value: 'update',
273
- description: 'Atualizar um plano',
274
- action: 'Atualizar plano',
271
+ name: "Atualizar",
272
+ value: "update",
273
+ description: "Atualizar um plano",
274
+ action: "Atualizar plano",
275
275
  },
276
276
  ],
277
- default: 'create',
277
+ default: "create",
278
278
  },
279
279
  // Plan Create Fields
280
280
  {
281
- displayName: 'Nome do Plano',
282
- name: 'reason',
283
- type: 'string',
281
+ displayName: "Nome do Plano",
282
+ name: "reason",
283
+ type: "string",
284
284
  required: true,
285
285
  displayOptions: {
286
286
  show: {
287
- resource: ['plans'],
288
- operation: ['create'],
287
+ resource: ["plans"],
288
+ operation: ["create"],
289
289
  },
290
290
  },
291
- default: '',
292
- description: 'Nome/descrição do plano',
291
+ default: "",
292
+ description: "Nome/descrição do plano",
293
293
  },
294
294
  {
295
- displayName: 'Valor',
296
- name: 'amount',
297
- type: 'number',
295
+ displayName: "Valor",
296
+ name: "amount",
297
+ type: "number",
298
298
  required: true,
299
299
  displayOptions: {
300
300
  show: {
301
- resource: ['plans'],
302
- operation: ['create'],
301
+ resource: ["plans"],
302
+ operation: ["create"],
303
303
  },
304
304
  },
305
305
  default: 0,
306
- description: 'Valor do plano em reais (ex: 99.99)',
306
+ description: "Valor do plano em reais (ex: 99.99)",
307
307
  },
308
308
  {
309
- displayName: 'Frequência',
310
- name: 'frequency',
311
- type: 'number',
309
+ displayName: "Frequência",
310
+ name: "frequency",
311
+ type: "number",
312
312
  required: true,
313
313
  displayOptions: {
314
314
  show: {
315
- resource: ['plans'],
316
- operation: ['create'],
315
+ resource: ["plans"],
316
+ operation: ["create"],
317
317
  },
318
318
  },
319
319
  default: 1,
320
- description: 'Frequência de cobrança (ex: 1 para mensal)',
320
+ description: "Frequência de cobrança (ex: 1 para mensal)",
321
321
  },
322
322
  {
323
- displayName: 'Tipo de Frequência',
324
- name: 'frequencyType',
325
- type: 'options',
323
+ displayName: "Tipo de Frequência",
324
+ name: "frequencyType",
325
+ type: "options",
326
326
  required: true,
327
327
  displayOptions: {
328
328
  show: {
329
- resource: ['plans'],
330
- operation: ['create'],
329
+ resource: ["plans"],
330
+ operation: ["create"],
331
331
  },
332
332
  },
333
333
  options: [
334
334
  {
335
- name: 'Dias',
336
- value: 'days',
335
+ name: "Dias",
336
+ value: "days",
337
337
  },
338
338
  {
339
- name: 'Meses',
340
- value: 'months',
339
+ name: "Meses",
340
+ value: "months",
341
341
  },
342
342
  ],
343
- default: 'months',
344
- description: 'Tipo de frequência (dias ou meses)',
343
+ default: "months",
344
+ description: "Tipo de frequência (dias ou meses)",
345
345
  },
346
346
  // Plan Get/Update Fields
347
347
  {
348
- displayName: 'ID do Plano',
349
- name: 'planId',
350
- type: 'string',
348
+ displayName: "ID do Plano",
349
+ name: "planId",
350
+ type: "string",
351
351
  required: true,
352
352
  displayOptions: {
353
353
  show: {
354
- resource: ['plans'],
355
- operation: ['get', 'update'],
354
+ resource: ["plans"],
355
+ operation: ["get", "update"],
356
356
  },
357
357
  },
358
- default: '',
359
- description: 'ID do plano',
358
+ default: "",
359
+ description: "ID do plano",
360
360
  },
361
361
  // Plan Update Fields
362
362
  {
363
- displayName: 'Nome do Plano',
364
- name: 'reason',
365
- type: 'string',
363
+ displayName: "Nome do Plano",
364
+ name: "reason",
365
+ type: "string",
366
366
  displayOptions: {
367
367
  show: {
368
- resource: ['plans'],
369
- operation: ['update'],
368
+ resource: ["plans"],
369
+ operation: ["update"],
370
370
  },
371
371
  },
372
- default: '',
373
- description: 'Novo nome/descrição do plano',
372
+ default: "",
373
+ description: "Novo nome/descrição do plano",
374
374
  },
375
375
  {
376
- displayName: 'Valor',
377
- name: 'amount',
378
- type: 'number',
376
+ displayName: "Valor",
377
+ name: "amount",
378
+ type: "number",
379
379
  displayOptions: {
380
380
  show: {
381
- resource: ['plans'],
382
- operation: ['update'],
381
+ resource: ["plans"],
382
+ operation: ["update"],
383
383
  },
384
384
  },
385
385
  default: 0,
386
- description: 'Novo valor do plano em reais',
386
+ description: "Novo valor do plano em reais",
387
387
  },
388
388
  // Subscription Operations
389
389
  {
390
- displayName: 'Operation',
391
- name: 'operation',
392
- type: 'options',
390
+ displayName: "Operation",
391
+ name: "operation",
392
+ type: "options",
393
393
  noDataExpression: true,
394
394
  displayOptions: {
395
395
  show: {
396
- resource: ['subscriptions'],
396
+ resource: ["subscriptions"],
397
397
  },
398
398
  },
399
399
  options: [
400
400
  {
401
- name: 'Criar',
402
- value: 'create',
403
- description: 'Criar uma assinatura',
404
- action: 'Criar assinatura',
401
+ name: "Criar",
402
+ value: "create",
403
+ description: "Criar uma assinatura",
404
+ action: "Criar assinatura",
405
405
  },
406
406
  {
407
- name: 'Pausar',
408
- value: 'pause',
409
- description: 'Pausar uma assinatura',
410
- action: 'Pausar assinatura',
407
+ name: "Pausar",
408
+ value: "pause",
409
+ description: "Pausar uma assinatura",
410
+ action: "Pausar assinatura",
411
411
  },
412
412
  {
413
- name: 'Retomar',
414
- value: 'resume',
415
- description: 'Retomar uma assinatura pausada',
416
- action: 'Retomar assinatura',
413
+ name: "Retomar",
414
+ value: "resume",
415
+ description: "Retomar uma assinatura pausada",
416
+ action: "Retomar assinatura",
417
417
  },
418
418
  {
419
- name: 'Cancelar',
420
- value: 'cancel',
421
- description: 'Cancelar uma assinatura',
422
- action: 'Cancelar assinatura',
419
+ name: "Cancelar",
420
+ value: "cancel",
421
+ description: "Cancelar uma assinatura",
422
+ action: "Cancelar assinatura",
423
423
  },
424
424
  {
425
- name: 'Consultar',
426
- value: 'get',
427
- description: 'Consultar uma assinatura',
428
- action: 'Consultar assinatura',
425
+ name: "Consultar",
426
+ value: "get",
427
+ description: "Consultar uma assinatura",
428
+ action: "Consultar assinatura",
429
429
  },
430
430
  {
431
- name: 'Listar',
432
- value: 'list',
433
- description: 'Listar assinaturas',
434
- action: 'Listar assinaturas',
431
+ name: "Listar",
432
+ value: "list",
433
+ description: "Listar assinaturas",
434
+ action: "Listar assinaturas",
435
435
  },
436
436
  ],
437
- default: 'create',
437
+ default: "create",
438
438
  },
439
439
  // Subscription Create Fields
440
440
  {
441
- displayName: 'ID do Plano',
442
- name: 'planId',
443
- type: 'string',
441
+ displayName: "ID do Plano",
442
+ name: "planId",
443
+ type: "string",
444
444
  required: true,
445
445
  displayOptions: {
446
446
  show: {
447
- resource: ['subscriptions'],
448
- operation: ['create'],
447
+ resource: ["subscriptions"],
448
+ operation: ["create"],
449
449
  },
450
450
  },
451
- default: '',
452
- description: 'ID do plano de assinatura',
451
+ default: "",
452
+ description: "ID do plano de assinatura",
453
453
  },
454
454
  {
455
- displayName: 'E-mail do Pagador',
456
- name: 'payerEmail',
457
- type: 'string',
455
+ displayName: "E-mail do Pagador",
456
+ name: "payerEmail",
457
+ type: "string",
458
458
  required: true,
459
459
  displayOptions: {
460
460
  show: {
461
- resource: ['subscriptions'],
462
- operation: ['create'],
461
+ resource: ["subscriptions"],
462
+ operation: ["create"],
463
463
  },
464
464
  },
465
- default: '',
466
- description: 'E-mail do pagador',
465
+ default: "",
466
+ description: "E-mail do pagador",
467
467
  },
468
468
  {
469
- displayName: 'CPF/CNPJ do Pagador',
470
- name: 'payerDocument',
471
- type: 'string',
469
+ displayName: "CPF/CNPJ do Pagador",
470
+ name: "payerDocument",
471
+ type: "string",
472
472
  displayOptions: {
473
473
  show: {
474
- resource: ['subscriptions'],
475
- operation: ['create'],
474
+ resource: ["subscriptions"],
475
+ operation: ["create"],
476
476
  },
477
477
  },
478
- default: '',
479
- description: 'CPF ou CNPJ do pagador',
478
+ default: "",
479
+ description: "CPF ou CNPJ do pagador",
480
480
  },
481
481
  {
482
- displayName: 'Data de Início',
483
- name: 'startDate',
484
- type: 'dateTime',
482
+ displayName: "Data de Início",
483
+ name: "startDate",
484
+ type: "dateTime",
485
485
  displayOptions: {
486
486
  show: {
487
- resource: ['subscriptions'],
488
- operation: ['create'],
487
+ resource: ["subscriptions"],
488
+ operation: ["create"],
489
489
  },
490
490
  },
491
- default: '',
492
- description: 'Data de início da assinatura',
491
+ default: "",
492
+ description: "Data de início da assinatura",
493
493
  },
494
494
  {
495
- displayName: 'Período de Trial (dias)',
496
- name: 'trialPeriodDays',
497
- type: 'number',
495
+ displayName: "Período de Trial (dias)",
496
+ name: "trialPeriodDays",
497
+ type: "number",
498
498
  displayOptions: {
499
499
  show: {
500
- resource: ['subscriptions'],
501
- operation: ['create'],
500
+ resource: ["subscriptions"],
501
+ operation: ["create"],
502
502
  },
503
503
  },
504
504
  default: 0,
505
- description: 'Número de dias de período de trial',
505
+ description: "Número de dias de período de trial",
506
506
  },
507
507
  // Subscription Get/Cancel/Pause/Resume Fields
508
508
  {
509
- displayName: 'ID da Assinatura',
510
- name: 'subscriptionId',
511
- type: 'string',
509
+ displayName: "ID da Assinatura",
510
+ name: "subscriptionId",
511
+ type: "string",
512
512
  required: true,
513
513
  displayOptions: {
514
514
  show: {
515
- resource: ['subscriptions'],
516
- operation: ['get', 'cancel', 'pause', 'resume'],
515
+ resource: ["subscriptions"],
516
+ operation: ["get", "cancel", "pause", "resume"],
517
517
  },
518
518
  },
519
- default: '',
520
- description: 'ID da assinatura',
519
+ default: "",
520
+ description: "ID da assinatura",
521
521
  },
522
522
  // Recurring Payment Operations
523
523
  {
524
- displayName: 'Operation',
525
- name: 'operation',
526
- type: 'options',
524
+ displayName: "Operation",
525
+ name: "operation",
526
+ type: "options",
527
527
  noDataExpression: true,
528
528
  displayOptions: {
529
529
  show: {
530
- resource: ['recurringPayments'],
530
+ resource: ["recurringPayments"],
531
531
  },
532
532
  },
533
533
  options: [
534
534
  {
535
- name: 'Criar',
536
- value: 'create',
537
- description: 'Criar um pagamento recorrente',
538
- action: 'Criar pagamento recorrente',
535
+ name: "Criar",
536
+ value: "create",
537
+ description: "Criar um pagamento recorrente",
538
+ action: "Criar pagamento recorrente",
539
539
  },
540
540
  {
541
- name: 'Listar',
542
- value: 'list',
543
- description: 'Listar pagamentos recorrentes',
544
- action: 'Listar pagamentos recorrentes',
541
+ name: "Listar",
542
+ value: "list",
543
+ description: "Listar pagamentos recorrentes",
544
+ action: "Listar pagamentos recorrentes",
545
545
  },
546
546
  {
547
- name: 'Cancelar',
548
- value: 'cancel',
549
- description: 'Cancelar um pagamento recorrente',
550
- action: 'Cancelar pagamento recorrente',
547
+ name: "Cancelar",
548
+ value: "cancel",
549
+ description: "Cancelar um pagamento recorrente",
550
+ action: "Cancelar pagamento recorrente",
551
551
  },
552
552
  {
553
- name: 'Consultar',
554
- value: 'get',
555
- description: 'Consultar um pagamento recorrente',
556
- action: 'Consultar pagamento recorrente',
553
+ name: "Consultar",
554
+ value: "get",
555
+ description: "Consultar um pagamento recorrente",
556
+ action: "Consultar pagamento recorrente",
557
557
  },
558
558
  ],
559
- default: 'create',
559
+ default: "create",
560
560
  },
561
561
  // Recurring Payment Fields
562
562
  {
563
- displayName: 'ID do Plano',
564
- name: 'planId',
565
- type: 'string',
563
+ displayName: "ID do Plano",
564
+ name: "planId",
565
+ type: "string",
566
566
  required: true,
567
567
  displayOptions: {
568
568
  show: {
569
- resource: ['recurringPayments'],
570
- operation: ['create'],
569
+ resource: ["recurringPayments"],
570
+ operation: ["create"],
571
571
  },
572
572
  },
573
- default: '',
574
- description: 'ID do plano de pagamento recorrente',
573
+ default: "",
574
+ description: "ID do plano de pagamento recorrente",
575
575
  },
576
576
  {
577
- displayName: 'ID do Cliente',
578
- name: 'customerId',
579
- type: 'string',
577
+ displayName: "ID do Cliente",
578
+ name: "customerId",
579
+ type: "string",
580
580
  displayOptions: {
581
581
  show: {
582
- resource: ['recurringPayments'],
583
- operation: ['create', 'list', 'get'],
582
+ resource: ["recurringPayments"],
583
+ operation: ["create", "list", "get"],
584
584
  },
585
585
  },
586
- default: '',
587
- description: 'ID do cliente (filtro opcional)',
586
+ default: "",
587
+ description: "ID do cliente (filtro opcional)",
588
588
  },
589
589
  {
590
- displayName: 'ID do Pagamento Recorrente',
591
- name: 'recurringPaymentId',
592
- type: 'string',
590
+ displayName: "ID do Pagamento Recorrente",
591
+ name: "recurringPaymentId",
592
+ type: "string",
593
593
  required: true,
594
594
  displayOptions: {
595
595
  show: {
596
- resource: ['recurringPayments'],
597
- operation: ['get', 'cancel'],
596
+ resource: ["recurringPayments"],
597
+ operation: ["get", "cancel"],
598
598
  },
599
599
  },
600
- default: '',
601
- description: 'ID do pagamento recorrente',
600
+ default: "",
601
+ description: "ID do pagamento recorrente",
602
602
  },
603
603
  // Webhook Operations
604
604
  {
605
- displayName: 'Operation',
606
- name: 'operation',
607
- type: 'options',
605
+ displayName: "Operation",
606
+ name: "operation",
607
+ type: "options",
608
608
  noDataExpression: true,
609
609
  displayOptions: {
610
610
  show: {
611
- resource: ['webhooks'],
611
+ resource: ["webhooks"],
612
612
  },
613
613
  },
614
614
  options: [
615
615
  {
616
- name: 'Registrar',
617
- value: 'register',
618
- description: 'Registrar um novo webhook',
619
- action: 'Registrar webhook',
616
+ name: "Registrar",
617
+ value: "register",
618
+ description: "Registrar um novo webhook",
619
+ action: "Registrar webhook",
620
620
  },
621
621
  {
622
- name: 'Listar',
623
- value: 'list',
624
- description: 'Listar webhooks',
625
- action: 'Listar webhooks',
622
+ name: "Listar",
623
+ value: "list",
624
+ description: "Listar webhooks",
625
+ action: "Listar webhooks",
626
626
  },
627
627
  {
628
- name: 'Excluir',
629
- value: 'delete',
630
- description: 'Excluir um webhook',
631
- action: 'Excluir webhook',
628
+ name: "Excluir",
629
+ value: "delete",
630
+ description: "Excluir um webhook",
631
+ action: "Excluir webhook",
632
632
  },
633
633
  {
634
- name: 'Consultar',
635
- value: 'get',
636
- description: 'Consultar um webhook',
637
- action: 'Consultar webhook',
634
+ name: "Consultar",
635
+ value: "get",
636
+ description: "Consultar um webhook",
637
+ action: "Consultar webhook",
638
638
  },
639
639
  ],
640
- default: 'register',
640
+ default: "register",
641
641
  },
642
642
  // Webhook Fields
643
643
  {
644
- displayName: 'URL',
645
- name: 'url',
646
- type: 'string',
644
+ displayName: "URL",
645
+ name: "url",
646
+ type: "string",
647
647
  required: true,
648
648
  displayOptions: {
649
649
  show: {
650
- resource: ['webhooks'],
651
- operation: ['register'],
650
+ resource: ["webhooks"],
651
+ operation: ["register"],
652
652
  },
653
653
  },
654
- default: '',
655
- description: 'URL que receberá as notificações do webhook',
654
+ default: "",
655
+ description: "URL que receberá as notificações do webhook",
656
656
  },
657
657
  {
658
- displayName: 'Eventos',
659
- name: 'events',
660
- type: 'multiOptions',
658
+ displayName: "Eventos",
659
+ name: "events",
660
+ type: "multiOptions",
661
661
  displayOptions: {
662
662
  show: {
663
- resource: ['webhooks'],
664
- operation: ['register'],
663
+ resource: ["webhooks"],
664
+ operation: ["register"],
665
665
  },
666
666
  },
667
667
  options: [
668
668
  {
669
- name: 'payment.created',
670
- value: 'payment',
669
+ name: "payment.created",
670
+ value: "payment",
671
671
  },
672
672
  {
673
- name: 'payment.updated',
674
- value: 'payment',
673
+ name: "payment.updated",
674
+ value: "payment",
675
675
  },
676
676
  {
677
- name: 'subscription.created',
678
- value: 'subscription',
677
+ name: "subscription.created",
678
+ value: "subscription",
679
679
  },
680
680
  {
681
- name: 'subscription.updated',
682
- value: 'subscription',
681
+ name: "subscription.updated",
682
+ value: "subscription",
683
683
  },
684
684
  ],
685
- default: ['payment'],
686
- description: 'Eventos para os quais o webhook será notificado',
685
+ default: ["payment"],
686
+ description: "Eventos para os quais o webhook será notificado",
687
687
  },
688
688
  {
689
- displayName: 'Descrição',
690
- name: 'description',
691
- type: 'string',
689
+ displayName: "Descrição",
690
+ name: "description",
691
+ type: "string",
692
692
  displayOptions: {
693
693
  show: {
694
- resource: ['webhooks'],
695
- operation: ['register'],
694
+ resource: ["webhooks"],
695
+ operation: ["register"],
696
696
  },
697
697
  },
698
- default: '',
699
- description: 'Descrição do webhook',
698
+ default: "",
699
+ description: "Descrição do webhook",
700
700
  },
701
701
  {
702
- displayName: 'ID do Webhook',
703
- name: 'webhookId',
704
- type: 'string',
702
+ displayName: "ID do Webhook",
703
+ name: "webhookId",
704
+ type: "string",
705
705
  required: true,
706
706
  displayOptions: {
707
707
  show: {
708
- resource: ['webhooks'],
709
- operation: ['get', 'delete'],
708
+ resource: ["webhooks"],
709
+ operation: ["get", "delete"],
710
710
  },
711
711
  },
712
- default: '',
713
- description: 'ID do webhook',
712
+ default: "",
713
+ description: "ID do webhook",
714
714
  },
715
715
  ],
716
716
  };
@@ -718,18 +718,18 @@ class PixPayment {
718
718
  async execute() {
719
719
  const items = this.getInputData();
720
720
  const returnData = [];
721
- const credentials = (await this.getCredentials('pixPaymentApi'));
721
+ const credentials = (await this.getCredentials("pixPaymentApi"));
722
722
  const baseUrl = (0, helpers_1.getBaseUrl)(credentials.environment);
723
723
  for (let i = 0; i < items.length; i++) {
724
724
  try {
725
725
  let resource;
726
726
  let operation;
727
727
  try {
728
- resource = this.getNodeParameter('resource', i);
729
- operation = this.getNodeParameter('operation', i);
728
+ resource = this.getNodeParameter("resource", i);
729
+ operation = this.getNodeParameter("operation", i);
730
730
  }
731
731
  catch (error) {
732
- if (error?.message?.includes('Could not get parameter')) {
732
+ if (error?.message?.includes("Could not get parameter")) {
733
733
  throw new Error(`Erro ao obter parâmetros do node. Verifique se os campos "Resource" e "Operation" estão preenchidos corretamente. ` +
734
734
  `Detalhes: ${error.message}`);
735
735
  }
@@ -737,19 +737,19 @@ class PixPayment {
737
737
  }
738
738
  let responseData;
739
739
  switch (resource) {
740
- case 'pix':
740
+ case "pix":
741
741
  responseData = await PixPayment.handlePixOperation(this, operation, i, baseUrl, credentials);
742
742
  break;
743
- case 'plans':
743
+ case "plans":
744
744
  responseData = await PixPayment.handlePlanOperation(this, operation, i, baseUrl, credentials);
745
745
  break;
746
- case 'subscriptions':
746
+ case "subscriptions":
747
747
  responseData = await PixPayment.handleSubscriptionOperation(this, operation, i, baseUrl, credentials);
748
748
  break;
749
- case 'recurringPayments':
749
+ case "recurringPayments":
750
750
  responseData = await PixPayment.handleRecurringPaymentOperation(this, operation, i, baseUrl, credentials);
751
751
  break;
752
- case 'webhooks':
752
+ case "webhooks":
753
753
  responseData = await PixPayment.handleWebhookOperation(this, operation, i, baseUrl, credentials);
754
754
  break;
755
755
  default:
@@ -779,36 +779,37 @@ class PixPayment {
779
779
  }
780
780
  static async handlePixOperation(executeFunctions, operation, itemIndex, baseUrl, credentials) {
781
781
  switch (operation) {
782
- case 'create':
782
+ case "create":
783
783
  return await PixPayment.createPixPayment(executeFunctions, itemIndex, baseUrl, credentials);
784
- case 'get':
784
+ case "get":
785
785
  return await PixPayment.getPixPayment(executeFunctions, itemIndex, baseUrl, credentials);
786
- case 'refund':
786
+ case "refund":
787
787
  return await PixPayment.refundPixPayment(executeFunctions, itemIndex, baseUrl, credentials);
788
788
  default:
789
789
  throw new Error(`Operação PIX "${operation}" não é suportada`);
790
790
  }
791
791
  }
792
792
  static async createPixPayment(executeFunctions, itemIndex, baseUrl, credentials) {
793
- const amount = executeFunctions.getNodeParameter('amount', itemIndex);
794
- const description = executeFunctions.getNodeParameter('description', itemIndex);
795
- const payerEmail = executeFunctions.getNodeParameter('payerEmail', itemIndex);
796
- const payerDocument = executeFunctions.getNodeParameter('payerDocument', itemIndex);
797
- const payerName = executeFunctions.getNodeParameter('payerName', itemIndex);
798
- const expirationDate = executeFunctions.getNodeParameter('expirationDate', itemIndex);
799
- const externalReference = executeFunctions.getNodeParameter('externalReference', itemIndex);
800
- const idempotencyKey = executeFunctions.getNodeParameter('idempotencyKey', itemIndex);
793
+ const amount = executeFunctions.getNodeParameter("amount", itemIndex);
794
+ const description = executeFunctions.getNodeParameter("description", itemIndex);
795
+ const payerEmail = executeFunctions.getNodeParameter("payerEmail", itemIndex);
796
+ // Usar getNodeParameterSafe para campos opcionais
797
+ const payerDocument = (0, helpers_1.getNodeParameterSafe)(executeFunctions.getNodeParameter.bind(executeFunctions), "payerDocument", itemIndex, "");
798
+ const payerName = (0, helpers_1.getNodeParameterSafe)(executeFunctions.getNodeParameter.bind(executeFunctions), "payerName", itemIndex, "");
799
+ const expirationDate = (0, helpers_1.getNodeParameterSafe)(executeFunctions.getNodeParameter.bind(executeFunctions), "expirationDate", itemIndex, "");
800
+ const externalReference = (0, helpers_1.getNodeParameterSafe)(executeFunctions.getNodeParameter.bind(executeFunctions), "externalReference", itemIndex, "");
801
+ const idempotencyKey = (0, helpers_1.getNodeParameterSafe)(executeFunctions.getNodeParameter.bind(executeFunctions), "idempotencyKey", itemIndex, "");
801
802
  // Validações
802
803
  if (!(0, helpers_1.validateEmail)(payerEmail)) {
803
- throw new Error('E-mail do pagador inválido');
804
+ throw new Error("E-mail do pagador inválido");
804
805
  }
805
806
  if (amount <= 0) {
806
- throw new Error('Valor do pagamento deve ser maior que zero');
807
+ throw new Error("Valor do pagamento deve ser maior que zero");
807
808
  }
808
809
  const body = {
809
810
  transaction_amount: (0, helpers_1.normalizeAmount)(amount),
810
811
  description,
811
- payment_method_id: 'pix',
812
+ payment_method_id: "pix",
812
813
  payer: {
813
814
  email: payerEmail,
814
815
  },
@@ -816,7 +817,7 @@ class PixPayment {
816
817
  if (payerDocument) {
817
818
  const docType = (0, helpers_1.getDocumentType)(payerDocument);
818
819
  if (!docType) {
819
- throw new Error('CPF/CNPJ inválido. Deve conter 11 ou 14 dígitos numéricos');
820
+ throw new Error("CPF/CNPJ inválido. Deve conter 11 ou 14 dígitos numéricos");
820
821
  }
821
822
  body.payer.identification = {
822
823
  type: docType,
@@ -824,9 +825,9 @@ class PixPayment {
824
825
  };
825
826
  }
826
827
  if (payerName) {
827
- const nameParts = payerName.trim().split(' ');
828
- body.payer.first_name = nameParts[0] || '';
829
- body.payer.last_name = nameParts.slice(1).join(' ') || '';
828
+ const nameParts = payerName.trim().split(" ");
829
+ body.payer.first_name = nameParts[0] || "";
830
+ body.payer.last_name = nameParts.slice(1).join(" ") || "";
830
831
  }
831
832
  if (expirationDate) {
832
833
  body.date_of_expiration = new Date(expirationDate).toISOString();
@@ -836,13 +837,13 @@ class PixPayment {
836
837
  }
837
838
  const headers = {
838
839
  Authorization: `Bearer ${credentials.accessToken}`,
839
- 'Content-Type': 'application/json',
840
+ "Content-Type": "application/json",
840
841
  };
841
- if (idempotencyKey && idempotencyKey.trim() !== '') {
842
- headers['X-Idempotency-Key'] = idempotencyKey;
842
+ if (idempotencyKey && idempotencyKey.trim() !== "") {
843
+ headers["X-Idempotency-Key"] = idempotencyKey;
843
844
  }
844
- const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, 'pixPaymentApi', {
845
- method: 'POST',
845
+ const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, "pixPaymentApi", {
846
+ method: "POST",
846
847
  url: `${baseUrl}/v1/payments`,
847
848
  body,
848
849
  headers,
@@ -851,12 +852,12 @@ class PixPayment {
851
852
  return response;
852
853
  }
853
854
  static async getPixPayment(executeFunctions, itemIndex, baseUrl, credentials) {
854
- const paymentId = executeFunctions.getNodeParameter('paymentId', itemIndex);
855
+ const paymentId = executeFunctions.getNodeParameter("paymentId", itemIndex);
855
856
  if (!paymentId) {
856
- throw new Error('ID do pagamento é obrigatório');
857
+ throw new Error("ID do pagamento é obrigatório");
857
858
  }
858
- const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, 'pixPaymentApi', {
859
- method: 'GET',
859
+ const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, "pixPaymentApi", {
860
+ method: "GET",
860
861
  url: `${baseUrl}/v1/payments/${paymentId}`,
861
862
  headers: {
862
863
  Authorization: `Bearer ${credentials.accessToken}`,
@@ -866,22 +867,23 @@ class PixPayment {
866
867
  return response;
867
868
  }
868
869
  static async refundPixPayment(executeFunctions, itemIndex, baseUrl, credentials) {
869
- const paymentId = executeFunctions.getNodeParameter('paymentId', itemIndex);
870
- const refundAmount = executeFunctions.getNodeParameter('refundAmount', itemIndex);
870
+ const paymentId = executeFunctions.getNodeParameter("paymentId", itemIndex);
871
+ // Usar getNodeParameterSafe para campo opcional
872
+ const refundAmount = (0, helpers_1.getNodeParameterSafe)(executeFunctions.getNodeParameter.bind(executeFunctions), "refundAmount", itemIndex, 0);
871
873
  if (!paymentId) {
872
- throw new Error('ID do pagamento é obrigatório');
874
+ throw new Error("ID do pagamento é obrigatório");
873
875
  }
874
876
  const body = {};
875
877
  if (refundAmount && refundAmount > 0) {
876
878
  body.amount = (0, helpers_1.normalizeAmount)(refundAmount);
877
879
  }
878
- const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, 'pixPaymentApi', {
879
- method: 'POST',
880
+ const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, "pixPaymentApi", {
881
+ method: "POST",
880
882
  url: `${baseUrl}/v1/payments/${paymentId}/refunds`,
881
883
  body: Object.keys(body).length > 0 ? body : undefined,
882
884
  headers: {
883
885
  Authorization: `Bearer ${credentials.accessToken}`,
884
- 'Content-Type': 'application/json',
886
+ "Content-Type": "application/json",
885
887
  },
886
888
  json: true,
887
889
  });
@@ -889,36 +891,36 @@ class PixPayment {
889
891
  }
890
892
  static async handlePlanOperation(executeFunctions, operation, itemIndex, baseUrl, credentials) {
891
893
  switch (operation) {
892
- case 'create':
894
+ case "create":
893
895
  return await PixPayment.createPlan(executeFunctions, itemIndex, baseUrl, credentials);
894
- case 'get':
896
+ case "get":
895
897
  return await PixPayment.getPlan(executeFunctions, itemIndex, baseUrl, credentials);
896
- case 'list':
898
+ case "list":
897
899
  return await PixPayment.listPlans(executeFunctions, itemIndex, baseUrl, credentials);
898
- case 'update':
900
+ case "update":
899
901
  return await PixPayment.updatePlan(executeFunctions, itemIndex, baseUrl, credentials);
900
902
  default:
901
903
  throw new Error(`Operação de plano "${operation}" não é suportada`);
902
904
  }
903
905
  }
904
906
  static async createPlan(executeFunctions, itemIndex, baseUrl, credentials) {
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');
907
+ const reason = (0, helpers_1.getNodeParameterSafe)(executeFunctions.getNodeParameter.bind(executeFunctions), "reason", itemIndex, "");
908
+ const amountRaw = (0, helpers_1.getNodeParameterSafe)(executeFunctions.getNodeParameter.bind(executeFunctions), "amount", itemIndex, 0);
909
+ const frequencyRaw = (0, helpers_1.getNodeParameterSafe)(executeFunctions.getNodeParameter.bind(executeFunctions), "frequency", itemIndex, 1);
910
+ const frequencyType = (0, helpers_1.getNodeParameterSafe)(executeFunctions.getNodeParameter.bind(executeFunctions), "frequencyType", itemIndex, "months");
909
911
  // Normaliza valores numéricos (converte vírgula para ponto)
910
912
  const amount = (0, helpers_1.normalizeNumericValue)(amountRaw);
911
913
  const frequency = (0, helpers_1.normalizeNumericValue)(frequencyRaw);
912
- if (!reason || reason.trim() === '') {
913
- throw new Error('Nome do plano é obrigatório');
914
+ if (!reason || reason.trim() === "") {
915
+ throw new Error("Nome do plano é obrigatório");
914
916
  }
915
917
  if (amount <= 0) {
916
- throw new Error('Valor do plano deve ser maior que zero');
918
+ throw new Error("Valor do plano deve ser maior que zero");
917
919
  }
918
920
  if (frequency <= 0) {
919
- throw new Error('Frequência deve ser maior que zero');
921
+ throw new Error("Frequência deve ser maior que zero");
920
922
  }
921
- if (frequencyType !== 'days' && frequencyType !== 'months') {
923
+ if (frequencyType !== "days" && frequencyType !== "months") {
922
924
  throw new Error('Tipo de frequência deve ser "days" ou "months"');
923
925
  }
924
926
  const body = {
@@ -927,34 +929,32 @@ class PixPayment {
927
929
  frequency,
928
930
  frequency_type: frequencyType,
929
931
  transaction_amount: (0, helpers_1.normalizeAmount)(amount),
930
- currency_id: 'BRL',
932
+ currency_id: "BRL",
931
933
  },
932
934
  payment_methods_allowed: {
933
- payment_types: [
934
- { id: 'credit_card' },
935
- ],
935
+ payment_types: [{ id: "credit_card" }],
936
936
  },
937
- back_url: 'https://www.mercadopago.com.br',
937
+ back_url: "https://www.mercadopago.com.br",
938
938
  };
939
- const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, 'pixPaymentApi', {
940
- method: 'POST',
939
+ const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, "pixPaymentApi", {
940
+ method: "POST",
941
941
  url: `${baseUrl}/preapproval_plan`,
942
942
  body,
943
943
  headers: {
944
944
  Authorization: `Bearer ${credentials.accessToken}`,
945
- 'Content-Type': 'application/json',
945
+ "Content-Type": "application/json",
946
946
  },
947
947
  json: true,
948
948
  });
949
949
  return response;
950
950
  }
951
951
  static async getPlan(executeFunctions, itemIndex, baseUrl, credentials) {
952
- const planId = executeFunctions.getNodeParameter('planId', itemIndex);
953
- if (!planId || planId.trim() === '') {
954
- throw new Error('ID do plano é obrigatório');
952
+ const planId = executeFunctions.getNodeParameter("planId", itemIndex);
953
+ if (!planId || planId.trim() === "") {
954
+ throw new Error("ID do plano é obrigatório");
955
955
  }
956
- const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, 'pixPaymentApi', {
957
- method: 'GET',
956
+ const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, "pixPaymentApi", {
957
+ method: "GET",
958
958
  url: `${baseUrl}/preapproval_plan/${planId}`,
959
959
  headers: {
960
960
  Authorization: `Bearer ${credentials.accessToken}`,
@@ -964,8 +964,8 @@ class PixPayment {
964
964
  return response;
965
965
  }
966
966
  static async listPlans(executeFunctions, _itemIndex, baseUrl, credentials) {
967
- const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, 'pixPaymentApi', {
968
- method: 'GET',
967
+ const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, "pixPaymentApi", {
968
+ method: "GET",
969
969
  url: `${baseUrl}/preapproval_plan/search`,
970
970
  headers: {
971
971
  Authorization: `Bearer ${credentials.accessToken}`,
@@ -975,16 +975,16 @@ class PixPayment {
975
975
  return response;
976
976
  }
977
977
  static async updatePlan(executeFunctions, itemIndex, baseUrl, credentials) {
978
- const planId = (0, helpers_1.getNodeParameterSafe)(executeFunctions.getNodeParameter.bind(executeFunctions), 'planId', itemIndex, '');
979
- const reason = (0, helpers_1.getNodeParameterSafe)(executeFunctions.getNodeParameter.bind(executeFunctions), 'reason', itemIndex, '');
980
- const amountRaw = (0, helpers_1.getNodeParameterSafe)(executeFunctions.getNodeParameter.bind(executeFunctions), 'amount', itemIndex, 0);
981
- if (!planId || planId.trim() === '') {
982
- throw new Error('ID do plano é obrigatório');
978
+ const planId = (0, helpers_1.getNodeParameterSafe)(executeFunctions.getNodeParameter.bind(executeFunctions), "planId", itemIndex, "");
979
+ const reason = (0, helpers_1.getNodeParameterSafe)(executeFunctions.getNodeParameter.bind(executeFunctions), "reason", itemIndex, "");
980
+ const amountRaw = (0, helpers_1.getNodeParameterSafe)(executeFunctions.getNodeParameter.bind(executeFunctions), "amount", itemIndex, 0);
981
+ if (!planId || planId.trim() === "") {
982
+ throw new Error("ID do plano é obrigatório");
983
983
  }
984
984
  // Normaliza valor numérico (converte vírgula para ponto)
985
985
  const amount = (0, helpers_1.normalizeNumericValue)(amountRaw);
986
986
  const body = {};
987
- if (reason && reason.trim() !== '') {
987
+ if (reason && reason.trim() !== "") {
988
988
  body.reason = reason;
989
989
  }
990
990
  if (amount && amount > 0) {
@@ -993,15 +993,15 @@ class PixPayment {
993
993
  };
994
994
  }
995
995
  if (Object.keys(body).length === 0) {
996
- throw new Error('É necessário fornecer pelo menos um campo para atualizar (nome ou valor)');
996
+ throw new Error("É necessário fornecer pelo menos um campo para atualizar (nome ou valor)");
997
997
  }
998
- const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, 'pixPaymentApi', {
999
- method: 'PUT',
998
+ const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, "pixPaymentApi", {
999
+ method: "PUT",
1000
1000
  url: `${baseUrl}/preapproval_plan/${planId}`,
1001
1001
  body,
1002
1002
  headers: {
1003
1003
  Authorization: `Bearer ${credentials.accessToken}`,
1004
- 'Content-Type': 'application/json',
1004
+ "Content-Type": "application/json",
1005
1005
  },
1006
1006
  json: true,
1007
1007
  });
@@ -1009,39 +1009,40 @@ class PixPayment {
1009
1009
  }
1010
1010
  static async handleSubscriptionOperation(executeFunctions, operation, itemIndex, baseUrl, credentials) {
1011
1011
  switch (operation) {
1012
- case 'create':
1012
+ case "create":
1013
1013
  return await PixPayment.createSubscription(executeFunctions, itemIndex, baseUrl, credentials);
1014
- case 'get':
1014
+ case "get":
1015
1015
  return await PixPayment.getSubscription(executeFunctions, itemIndex, baseUrl, credentials);
1016
- case 'pause':
1016
+ case "pause":
1017
1017
  return await PixPayment.pauseSubscription(executeFunctions, itemIndex, baseUrl, credentials);
1018
- case 'resume':
1018
+ case "resume":
1019
1019
  return await PixPayment.resumeSubscription(executeFunctions, itemIndex, baseUrl, credentials);
1020
- case 'cancel':
1020
+ case "cancel":
1021
1021
  return await PixPayment.cancelSubscription(executeFunctions, itemIndex, baseUrl, credentials);
1022
- case 'list':
1022
+ case "list":
1023
1023
  return await PixPayment.listSubscriptions(executeFunctions, itemIndex, baseUrl, credentials);
1024
1024
  default:
1025
1025
  throw new Error(`Operação de assinatura "${operation}" não é suportada`);
1026
1026
  }
1027
1027
  }
1028
1028
  static async createSubscription(executeFunctions, itemIndex, baseUrl, credentials) {
1029
- const planId = executeFunctions.getNodeParameter('planId', itemIndex);
1030
- const payerEmail = executeFunctions.getNodeParameter('payerEmail', itemIndex);
1031
- const payerDocument = executeFunctions.getNodeParameter('payerDocument', itemIndex);
1032
- const startDate = executeFunctions.getNodeParameter('startDate', itemIndex);
1033
- const trialPeriodDays = executeFunctions.getNodeParameter('trialPeriodDays', itemIndex);
1029
+ const planId = executeFunctions.getNodeParameter("planId", itemIndex);
1030
+ const payerEmail = executeFunctions.getNodeParameter("payerEmail", itemIndex);
1031
+ // Usar getNodeParameterSafe para campos opcionais
1032
+ const payerDocument = (0, helpers_1.getNodeParameterSafe)(executeFunctions.getNodeParameter.bind(executeFunctions), "payerDocument", itemIndex, "");
1033
+ const startDate = (0, helpers_1.getNodeParameterSafe)(executeFunctions.getNodeParameter.bind(executeFunctions), "startDate", itemIndex, "");
1034
+ const trialPeriodDays = (0, helpers_1.getNodeParameterSafe)(executeFunctions.getNodeParameter.bind(executeFunctions), "trialPeriodDays", itemIndex, 0);
1034
1035
  if (!(0, helpers_1.validateEmail)(payerEmail)) {
1035
- throw new Error('E-mail do pagador inválido');
1036
+ throw new Error("E-mail do pagador inválido");
1036
1037
  }
1037
1038
  const body = {
1038
1039
  preapproval_plan_id: planId,
1039
1040
  payer_email: payerEmail,
1040
1041
  };
1041
- if (payerDocument) {
1042
+ if (payerDocument && payerDocument.trim() !== "") {
1042
1043
  const docType = (0, helpers_1.getDocumentType)(payerDocument);
1043
1044
  if (!docType) {
1044
- throw new Error('CPF/CNPJ inválido');
1045
+ throw new Error("CPF/CNPJ inválido");
1045
1046
  }
1046
1047
  body.payer = {
1047
1048
  identification: {
@@ -1050,28 +1051,28 @@ class PixPayment {
1050
1051
  },
1051
1052
  };
1052
1053
  }
1053
- if (startDate) {
1054
+ if (startDate && startDate.trim() !== "") {
1054
1055
  body.start_date = new Date(startDate).toISOString();
1055
1056
  }
1056
1057
  if (trialPeriodDays && trialPeriodDays > 0) {
1057
1058
  body.trial_period_days = trialPeriodDays;
1058
1059
  }
1059
- const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, 'pixPaymentApi', {
1060
- method: 'POST',
1060
+ const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, "pixPaymentApi", {
1061
+ method: "POST",
1061
1062
  url: `${baseUrl}/preapproval`,
1062
1063
  body,
1063
1064
  headers: {
1064
1065
  Authorization: `Bearer ${credentials.accessToken}`,
1065
- 'Content-Type': 'application/json',
1066
+ "Content-Type": "application/json",
1066
1067
  },
1067
1068
  json: true,
1068
1069
  });
1069
1070
  return response;
1070
1071
  }
1071
1072
  static async getSubscription(executeFunctions, itemIndex, baseUrl, credentials) {
1072
- const subscriptionId = executeFunctions.getNodeParameter('subscriptionId', itemIndex);
1073
- const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, 'pixPaymentApi', {
1074
- method: 'GET',
1073
+ const subscriptionId = executeFunctions.getNodeParameter("subscriptionId", itemIndex);
1074
+ const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, "pixPaymentApi", {
1075
+ method: "GET",
1075
1076
  url: `${baseUrl}/preapproval/${subscriptionId}`,
1076
1077
  headers: {
1077
1078
  Authorization: `Bearer ${credentials.accessToken}`,
@@ -1081,56 +1082,56 @@ class PixPayment {
1081
1082
  return response;
1082
1083
  }
1083
1084
  static async pauseSubscription(executeFunctions, itemIndex, baseUrl, credentials) {
1084
- const subscriptionId = executeFunctions.getNodeParameter('subscriptionId', itemIndex);
1085
- const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, 'pixPaymentApi', {
1086
- method: 'PUT',
1085
+ const subscriptionId = executeFunctions.getNodeParameter("subscriptionId", itemIndex);
1086
+ const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, "pixPaymentApi", {
1087
+ method: "PUT",
1087
1088
  url: `${baseUrl}/preapproval/${subscriptionId}`,
1088
1089
  body: {
1089
- status: 'paused',
1090
+ status: "paused",
1090
1091
  },
1091
1092
  headers: {
1092
1093
  Authorization: `Bearer ${credentials.accessToken}`,
1093
- 'Content-Type': 'application/json',
1094
+ "Content-Type": "application/json",
1094
1095
  },
1095
1096
  json: true,
1096
1097
  });
1097
1098
  return response;
1098
1099
  }
1099
1100
  static async resumeSubscription(executeFunctions, itemIndex, baseUrl, credentials) {
1100
- const subscriptionId = executeFunctions.getNodeParameter('subscriptionId', itemIndex);
1101
- const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, 'pixPaymentApi', {
1102
- method: 'PUT',
1101
+ const subscriptionId = executeFunctions.getNodeParameter("subscriptionId", itemIndex);
1102
+ const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, "pixPaymentApi", {
1103
+ method: "PUT",
1103
1104
  url: `${baseUrl}/preapproval/${subscriptionId}`,
1104
1105
  body: {
1105
- status: 'authorized',
1106
+ status: "authorized",
1106
1107
  },
1107
1108
  headers: {
1108
1109
  Authorization: `Bearer ${credentials.accessToken}`,
1109
- 'Content-Type': 'application/json',
1110
+ "Content-Type": "application/json",
1110
1111
  },
1111
1112
  json: true,
1112
1113
  });
1113
1114
  return response;
1114
1115
  }
1115
1116
  static async cancelSubscription(executeFunctions, itemIndex, baseUrl, credentials) {
1116
- const subscriptionId = executeFunctions.getNodeParameter('subscriptionId', itemIndex);
1117
- const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, 'pixPaymentApi', {
1118
- method: 'PUT',
1117
+ const subscriptionId = executeFunctions.getNodeParameter("subscriptionId", itemIndex);
1118
+ const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, "pixPaymentApi", {
1119
+ method: "PUT",
1119
1120
  url: `${baseUrl}/preapproval/${subscriptionId}`,
1120
1121
  body: {
1121
- status: 'cancelled',
1122
+ status: "cancelled",
1122
1123
  },
1123
1124
  headers: {
1124
1125
  Authorization: `Bearer ${credentials.accessToken}`,
1125
- 'Content-Type': 'application/json',
1126
+ "Content-Type": "application/json",
1126
1127
  },
1127
1128
  json: true,
1128
1129
  });
1129
1130
  return response;
1130
1131
  }
1131
1132
  static async listSubscriptions(executeFunctions, _itemIndex, baseUrl, credentials) {
1132
- const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, 'pixPaymentApi', {
1133
- method: 'GET',
1133
+ const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, "pixPaymentApi", {
1134
+ method: "GET",
1134
1135
  url: `${baseUrl}/preapproval/search`,
1135
1136
  headers: {
1136
1137
  Authorization: `Bearer ${credentials.accessToken}`,
@@ -1141,24 +1142,24 @@ class PixPayment {
1141
1142
  }
1142
1143
  static async handleRecurringPaymentOperation(executeFunctions, operation, itemIndex, baseUrl, credentials) {
1143
1144
  switch (operation) {
1144
- case 'create':
1145
+ case "create":
1145
1146
  return await PixPayment.createRecurringPayment(executeFunctions, itemIndex, baseUrl, credentials);
1146
- case 'get':
1147
+ case "get":
1147
1148
  return await PixPayment.getRecurringPayment(executeFunctions, itemIndex, baseUrl, credentials);
1148
- case 'list':
1149
+ case "list":
1149
1150
  return await PixPayment.listRecurringPayments(executeFunctions, itemIndex, baseUrl, credentials);
1150
- case 'cancel':
1151
+ case "cancel":
1151
1152
  return await PixPayment.cancelRecurringPayment(executeFunctions, itemIndex, baseUrl, credentials);
1152
1153
  default:
1153
1154
  throw new Error(`Operação de pagamento recorrente "${operation}" não é suportada`);
1154
1155
  }
1155
1156
  }
1156
1157
  static async createRecurringPayment(executeFunctions, itemIndex, baseUrl, credentials) {
1157
- const planId = executeFunctions.getNodeParameter('planId', itemIndex);
1158
+ const planId = executeFunctions.getNodeParameter("planId", itemIndex);
1158
1159
  // Para pagamentos recorrentes, geralmente criamos via assinatura
1159
1160
  // Esta é uma implementação simplificada
1160
- const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, 'pixPaymentApi', {
1161
- method: 'GET',
1161
+ const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, "pixPaymentApi", {
1162
+ method: "GET",
1162
1163
  url: `${baseUrl}/preapproval/${planId}`,
1163
1164
  headers: {
1164
1165
  Authorization: `Bearer ${credentials.accessToken}`,
@@ -1168,9 +1169,9 @@ class PixPayment {
1168
1169
  return response;
1169
1170
  }
1170
1171
  static async getRecurringPayment(executeFunctions, itemIndex, baseUrl, credentials) {
1171
- const recurringPaymentId = executeFunctions.getNodeParameter('recurringPaymentId', itemIndex);
1172
- const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, 'pixPaymentApi', {
1173
- method: 'GET',
1172
+ const recurringPaymentId = executeFunctions.getNodeParameter("recurringPaymentId", itemIndex);
1173
+ const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, "pixPaymentApi", {
1174
+ method: "GET",
1174
1175
  url: `${baseUrl}/preapproval/${recurringPaymentId}`,
1175
1176
  headers: {
1176
1177
  Authorization: `Bearer ${credentials.accessToken}`,
@@ -1180,13 +1181,14 @@ class PixPayment {
1180
1181
  return response;
1181
1182
  }
1182
1183
  static async listRecurringPayments(executeFunctions, itemIndex, baseUrl, credentials) {
1183
- const customerId = executeFunctions.getNodeParameter('customerId', itemIndex);
1184
+ // Usar getNodeParameterSafe para campo opcional
1185
+ const customerId = (0, helpers_1.getNodeParameterSafe)(executeFunctions.getNodeParameter.bind(executeFunctions), "customerId", itemIndex, "");
1184
1186
  let url = `${baseUrl}/preapproval/search`;
1185
1187
  if (customerId) {
1186
1188
  url += `?payer_id=${customerId}`;
1187
1189
  }
1188
- const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, 'pixPaymentApi', {
1189
- method: 'GET',
1190
+ const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, "pixPaymentApi", {
1191
+ method: "GET",
1190
1192
  url,
1191
1193
  headers: {
1192
1194
  Authorization: `Bearer ${credentials.accessToken}`,
@@ -1196,16 +1198,16 @@ class PixPayment {
1196
1198
  return response;
1197
1199
  }
1198
1200
  static async cancelRecurringPayment(executeFunctions, itemIndex, baseUrl, credentials) {
1199
- const recurringPaymentId = executeFunctions.getNodeParameter('recurringPaymentId', itemIndex);
1200
- const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, 'pixPaymentApi', {
1201
- method: 'PUT',
1201
+ const recurringPaymentId = executeFunctions.getNodeParameter("recurringPaymentId", itemIndex);
1202
+ const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, "pixPaymentApi", {
1203
+ method: "PUT",
1202
1204
  url: `${baseUrl}/preapproval/${recurringPaymentId}`,
1203
1205
  body: {
1204
- status: 'cancelled',
1206
+ status: "cancelled",
1205
1207
  },
1206
1208
  headers: {
1207
1209
  Authorization: `Bearer ${credentials.accessToken}`,
1208
- 'Content-Type': 'application/json',
1210
+ "Content-Type": "application/json",
1209
1211
  },
1210
1212
  json: true,
1211
1213
  });
@@ -1213,48 +1215,49 @@ class PixPayment {
1213
1215
  }
1214
1216
  static async handleWebhookOperation(executeFunctions, operation, itemIndex, baseUrl, credentials) {
1215
1217
  switch (operation) {
1216
- case 'register':
1218
+ case "register":
1217
1219
  return await PixPayment.registerWebhook(executeFunctions, itemIndex, baseUrl, credentials);
1218
- case 'get':
1220
+ case "get":
1219
1221
  return await PixPayment.getWebhook(executeFunctions, itemIndex, baseUrl, credentials);
1220
- case 'list':
1222
+ case "list":
1221
1223
  return await PixPayment.listWebhooks(executeFunctions, itemIndex, baseUrl, credentials);
1222
- case 'delete':
1224
+ case "delete":
1223
1225
  return await PixPayment.deleteWebhook(executeFunctions, itemIndex, baseUrl, credentials);
1224
1226
  default:
1225
1227
  throw new Error(`Operação de webhook "${operation}" não é suportada`);
1226
1228
  }
1227
1229
  }
1228
1230
  static async registerWebhook(executeFunctions, itemIndex, baseUrl, credentials) {
1229
- const url = executeFunctions.getNodeParameter('url', itemIndex);
1230
- const events = executeFunctions.getNodeParameter('events', itemIndex);
1231
- const description = executeFunctions.getNodeParameter('description', itemIndex);
1232
- if (!url || !url.startsWith('http')) {
1233
- throw new Error('URL do webhook deve ser uma URL válida (http:// ou https://)');
1231
+ const url = executeFunctions.getNodeParameter("url", itemIndex);
1232
+ // Usar getNodeParameterSafe para campos opcionais
1233
+ const events = (0, helpers_1.getNodeParameterSafe)(executeFunctions.getNodeParameter.bind(executeFunctions), "events", itemIndex, []);
1234
+ const description = (0, helpers_1.getNodeParameterSafe)(executeFunctions.getNodeParameter.bind(executeFunctions), "description", itemIndex, "");
1235
+ if (!url || !url.startsWith("http")) {
1236
+ throw new Error("URL do webhook deve ser uma URL válida (http:// ou https://)");
1234
1237
  }
1235
1238
  const body = {
1236
1239
  url,
1237
- events: events.length > 0 ? events : ['payment'],
1240
+ events: events.length > 0 ? events : ["payment"],
1238
1241
  };
1239
1242
  if (description) {
1240
1243
  body.description = description;
1241
1244
  }
1242
- const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, 'pixPaymentApi', {
1243
- method: 'POST',
1245
+ const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, "pixPaymentApi", {
1246
+ method: "POST",
1244
1247
  url: `${baseUrl}/v1/webhooks`,
1245
1248
  body,
1246
1249
  headers: {
1247
1250
  Authorization: `Bearer ${credentials.accessToken}`,
1248
- 'Content-Type': 'application/json',
1251
+ "Content-Type": "application/json",
1249
1252
  },
1250
1253
  json: true,
1251
1254
  });
1252
1255
  return response;
1253
1256
  }
1254
1257
  static async getWebhook(executeFunctions, itemIndex, baseUrl, credentials) {
1255
- const webhookId = executeFunctions.getNodeParameter('webhookId', itemIndex);
1256
- const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, 'pixPaymentApi', {
1257
- method: 'GET',
1258
+ const webhookId = executeFunctions.getNodeParameter("webhookId", itemIndex);
1259
+ const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, "pixPaymentApi", {
1260
+ method: "GET",
1258
1261
  url: `${baseUrl}/v1/webhooks/${webhookId}`,
1259
1262
  headers: {
1260
1263
  Authorization: `Bearer ${credentials.accessToken}`,
@@ -1264,8 +1267,8 @@ class PixPayment {
1264
1267
  return response;
1265
1268
  }
1266
1269
  static async listWebhooks(executeFunctions, _itemIndex, baseUrl, credentials) {
1267
- const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, 'pixPaymentApi', {
1268
- method: 'GET',
1270
+ const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, "pixPaymentApi", {
1271
+ method: "GET",
1269
1272
  url: `${baseUrl}/v1/webhooks`,
1270
1273
  headers: {
1271
1274
  Authorization: `Bearer ${credentials.accessToken}`,
@@ -1275,9 +1278,9 @@ class PixPayment {
1275
1278
  return response;
1276
1279
  }
1277
1280
  static async deleteWebhook(executeFunctions, itemIndex, baseUrl, credentials) {
1278
- const webhookId = executeFunctions.getNodeParameter('webhookId', itemIndex);
1279
- const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, 'pixPaymentApi', {
1280
- method: 'DELETE',
1281
+ const webhookId = executeFunctions.getNodeParameter("webhookId", itemIndex);
1282
+ const response = await executeFunctions.helpers.requestWithAuthentication.call(executeFunctions, "pixPaymentApi", {
1283
+ method: "DELETE",
1281
1284
  url: `${baseUrl}/v1/webhooks/${webhookId}`,
1282
1285
  headers: {
1283
1286
  Authorization: `Bearer ${credentials.accessToken}`,
@@ -1288,39 +1291,45 @@ class PixPayment {
1288
1291
  }
1289
1292
  static normalizeResponse(data, resource) {
1290
1293
  const normalized = {
1291
- id: data.id || '',
1292
- status: data.status || '',
1294
+ id: data.id || "",
1295
+ status: data.status || "",
1293
1296
  createdAt: data.date_created || data.created_at || new Date().toISOString(),
1294
1297
  raw: data,
1295
1298
  };
1296
1299
  // Normalização específica por recurso
1297
1300
  switch (resource) {
1298
- case 'pix':
1299
- normalized.amount = data.transaction_amount ? data.transaction_amount / 100 : undefined;
1300
- normalized.currency = data.currency_id || 'BRL';
1301
- normalized.qrCode = data.point_of_interaction?.transaction_data?.qr_code;
1302
- normalized.qrCodeBase64 = data.point_of_interaction?.transaction_data?.qr_code_base64;
1301
+ case "pix":
1302
+ normalized.amount = data.transaction_amount
1303
+ ? data.transaction_amount / 100
1304
+ : undefined;
1305
+ normalized.currency = data.currency_id || "BRL";
1306
+ normalized.qrCode =
1307
+ data.point_of_interaction?.transaction_data?.qr_code;
1308
+ normalized.qrCodeBase64 =
1309
+ data.point_of_interaction?.transaction_data?.qr_code_base64;
1303
1310
  normalized.description = data.description;
1304
1311
  normalized.payerEmail = data.payer?.email;
1305
1312
  break;
1306
- case 'plans':
1313
+ case "plans":
1307
1314
  normalized.planId = data.id;
1308
- normalized.amount = data.auto_recurring?.transaction_amount ? data.auto_recurring.transaction_amount / 100 : undefined;
1315
+ normalized.amount = data.auto_recurring?.transaction_amount
1316
+ ? data.auto_recurring.transaction_amount / 100
1317
+ : undefined;
1309
1318
  normalized.description = data.reason;
1310
1319
  break;
1311
- case 'subscriptions':
1320
+ case "subscriptions":
1312
1321
  normalized.planId = data.preapproval_plan_id;
1313
1322
  normalized.payerEmail = data.payer_email;
1314
1323
  normalized.startDate = data.start_date;
1315
1324
  normalized.endDate = data.end_date;
1316
1325
  normalized.statusDetail = data.status_detail;
1317
1326
  break;
1318
- case 'recurringPayments':
1327
+ case "recurringPayments":
1319
1328
  normalized.planId = data.preapproval_plan_id;
1320
1329
  normalized.payerEmail = data.payer_email;
1321
1330
  normalized.nextBillingDate = data.next_billing_date;
1322
1331
  break;
1323
- case 'webhooks':
1332
+ case "webhooks":
1324
1333
  normalized.url = data.url;
1325
1334
  normalized.events = data.events || [];
1326
1335
  normalized.description = data.description;