n8n-nodes-pagseguro 0.1.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/dist/credentials/PagSeguroApi.credentials.d.ts +8 -0
- package/dist/credentials/PagSeguroApi.credentials.js +39 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +20 -0
- package/dist/nodes/PagSeguro/PagSeguro.node.d.ts +6 -0
- package/dist/nodes/PagSeguro/PagSeguro.node.js +783 -0
- package/dist/nodes/PagSeguro/PagSeguroTrigger.node.d.ts +13 -0
- package/dist/nodes/PagSeguro/PagSeguroTrigger.node.js +175 -0
- package/dist/nodes/PagSeguro/pagseguro.svg +6 -0
- package/nodes/PagSeguro/pagseguro.svg +6 -0
- package/package.json +48 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ICredentialType, INodeProperties } from 'n8n-workflow';
|
|
2
|
+
export declare class PagSeguroApi implements ICredentialType {
|
|
3
|
+
name: string;
|
|
4
|
+
displayName: string;
|
|
5
|
+
documentationUrl: string;
|
|
6
|
+
properties: INodeProperties[];
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=PagSeguroApi.credentials.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PagSeguroApi = void 0;
|
|
4
|
+
class PagSeguroApi {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.name = 'pagSeguroApi';
|
|
7
|
+
this.displayName = 'PagBank (PagSeguro) API';
|
|
8
|
+
this.documentationUrl = 'https://dev.pagbank.uol.com.br/reference/';
|
|
9
|
+
this.properties = [
|
|
10
|
+
{
|
|
11
|
+
displayName: 'API Token',
|
|
12
|
+
name: 'apiToken',
|
|
13
|
+
type: 'string',
|
|
14
|
+
typeOptions: { password: true },
|
|
15
|
+
default: '',
|
|
16
|
+
description: 'Bearer token da sua conta PagBank. Obtenha em: Minha Conta > Configurações > Credenciais',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
displayName: 'Environment',
|
|
20
|
+
name: 'environment',
|
|
21
|
+
type: 'options',
|
|
22
|
+
options: [
|
|
23
|
+
{
|
|
24
|
+
name: 'Production',
|
|
25
|
+
value: 'production',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: 'Sandbox',
|
|
29
|
+
value: 'sandbox',
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
default: 'production',
|
|
33
|
+
description: 'Ambiente de execução da API',
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.PagSeguroApi = PagSeguroApi;
|
|
39
|
+
//# sourceMappingURL=PagSeguroApi.credentials.js.map
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./nodes/PagSeguro/PagSeguro.node"), exports);
|
|
18
|
+
__exportStar(require("./nodes/PagSeguro/PagSeguroTrigger.node"), exports);
|
|
19
|
+
__exportStar(require("./credentials/PagSeguroApi.credentials"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
2
|
+
export declare class PagSeguro implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=PagSeguro.node.d.ts.map
|
|
@@ -0,0 +1,783 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PagSeguro = void 0;
|
|
4
|
+
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
const BASE_URLS = {
|
|
6
|
+
production: 'https://api.pagseguro.com',
|
|
7
|
+
sandbox: 'https://sandbox.api.pagseguro.com',
|
|
8
|
+
};
|
|
9
|
+
class PagSeguro {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.description = {
|
|
12
|
+
displayName: 'PagBank (PagSeguro)',
|
|
13
|
+
name: 'pagSeguro',
|
|
14
|
+
icon: 'file:pagseguro.svg',
|
|
15
|
+
group: ['transform'],
|
|
16
|
+
version: 1,
|
|
17
|
+
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
18
|
+
description: 'Integração com PagBank (PagSeguro) — a maior fintech do Brasil',
|
|
19
|
+
defaults: {
|
|
20
|
+
name: 'PagBank',
|
|
21
|
+
},
|
|
22
|
+
inputs: ['main'],
|
|
23
|
+
outputs: ['main'],
|
|
24
|
+
credentials: [
|
|
25
|
+
{
|
|
26
|
+
name: 'pagSeguroApi',
|
|
27
|
+
required: true,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
properties: [
|
|
31
|
+
// ─── Resource ─────────────────────────────────────────────────
|
|
32
|
+
{
|
|
33
|
+
displayName: 'Resource',
|
|
34
|
+
name: 'resource',
|
|
35
|
+
type: 'options',
|
|
36
|
+
noDataExpression: true,
|
|
37
|
+
options: [
|
|
38
|
+
{
|
|
39
|
+
name: 'Charge',
|
|
40
|
+
value: 'charge',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'Order',
|
|
44
|
+
value: 'order',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: 'PIX',
|
|
48
|
+
value: 'pix',
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
default: 'order',
|
|
52
|
+
},
|
|
53
|
+
// ─── Operations: Order ─────────────────────────────────────────
|
|
54
|
+
{
|
|
55
|
+
displayName: 'Operation',
|
|
56
|
+
name: 'operation',
|
|
57
|
+
type: 'options',
|
|
58
|
+
noDataExpression: true,
|
|
59
|
+
displayOptions: {
|
|
60
|
+
show: {
|
|
61
|
+
resource: ['order'],
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
options: [
|
|
65
|
+
{
|
|
66
|
+
name: 'Create',
|
|
67
|
+
value: 'create',
|
|
68
|
+
action: 'Create an order',
|
|
69
|
+
description: 'Cria um novo pedido no PagBank',
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: 'Get',
|
|
73
|
+
value: 'get',
|
|
74
|
+
action: 'Get an order',
|
|
75
|
+
description: 'Busca um pedido pelo ID',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: 'List',
|
|
79
|
+
value: 'list',
|
|
80
|
+
action: 'List orders',
|
|
81
|
+
description: 'Lista pedidos com filtros opcionais',
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
default: 'create',
|
|
85
|
+
},
|
|
86
|
+
// ─── Operations: Charge ────────────────────────────────────────
|
|
87
|
+
{
|
|
88
|
+
displayName: 'Operation',
|
|
89
|
+
name: 'operation',
|
|
90
|
+
type: 'options',
|
|
91
|
+
noDataExpression: true,
|
|
92
|
+
displayOptions: {
|
|
93
|
+
show: {
|
|
94
|
+
resource: ['charge'],
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
options: [
|
|
98
|
+
{
|
|
99
|
+
name: 'Cancel',
|
|
100
|
+
value: 'cancel',
|
|
101
|
+
action: 'Cancel a charge',
|
|
102
|
+
description: 'Cancela uma cobrança',
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: 'Create',
|
|
106
|
+
value: 'create',
|
|
107
|
+
action: 'Create a charge',
|
|
108
|
+
description: 'Cria uma nova cobrança avulsa',
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: 'Get',
|
|
112
|
+
value: 'get',
|
|
113
|
+
action: 'Get a charge',
|
|
114
|
+
description: 'Busca uma cobrança pelo ID',
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
default: 'create',
|
|
118
|
+
},
|
|
119
|
+
// ─── Operations: PIX ───────────────────────────────────────────
|
|
120
|
+
{
|
|
121
|
+
displayName: 'Operation',
|
|
122
|
+
name: 'operation',
|
|
123
|
+
type: 'options',
|
|
124
|
+
noDataExpression: true,
|
|
125
|
+
displayOptions: {
|
|
126
|
+
show: {
|
|
127
|
+
resource: ['pix'],
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
options: [
|
|
131
|
+
{
|
|
132
|
+
name: 'Create PIX Charge',
|
|
133
|
+
value: 'createCharge',
|
|
134
|
+
action: 'Create a PIX charge',
|
|
135
|
+
description: 'Cria uma cobrança PIX (QR Code)',
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: 'Get PIX Key Info',
|
|
139
|
+
value: 'getKeyInfo',
|
|
140
|
+
action: 'Get PIX key info',
|
|
141
|
+
description: 'Consulta informações de uma chave PIX',
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
default: 'createCharge',
|
|
145
|
+
},
|
|
146
|
+
// ═══════════════════════════════════════════════════════════════
|
|
147
|
+
// ORDER — CREATE
|
|
148
|
+
// ═══════════════════════════════════════════════════════════════
|
|
149
|
+
{
|
|
150
|
+
displayName: 'Customer Name',
|
|
151
|
+
name: 'customerName',
|
|
152
|
+
type: 'string',
|
|
153
|
+
required: true,
|
|
154
|
+
displayOptions: {
|
|
155
|
+
show: {
|
|
156
|
+
resource: ['order'],
|
|
157
|
+
operation: ['create'],
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
default: '',
|
|
161
|
+
description: 'Nome completo do comprador',
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
displayName: 'Customer Email',
|
|
165
|
+
name: 'customerEmail',
|
|
166
|
+
type: 'string',
|
|
167
|
+
placeholder: 'cliente@email.com',
|
|
168
|
+
required: true,
|
|
169
|
+
displayOptions: {
|
|
170
|
+
show: {
|
|
171
|
+
resource: ['order'],
|
|
172
|
+
operation: ['create'],
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
default: '',
|
|
176
|
+
description: 'E-mail do comprador',
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
displayName: 'Customer Tax ID (CPF/CNPJ)',
|
|
180
|
+
name: 'customerTaxId',
|
|
181
|
+
type: 'string',
|
|
182
|
+
required: true,
|
|
183
|
+
displayOptions: {
|
|
184
|
+
show: {
|
|
185
|
+
resource: ['order'],
|
|
186
|
+
operation: ['create'],
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
default: '',
|
|
190
|
+
description: 'CPF (11 dígitos) ou CNPJ (14 dígitos) do comprador, sem pontuação',
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
displayName: 'Items',
|
|
194
|
+
name: 'items',
|
|
195
|
+
type: 'fixedCollection',
|
|
196
|
+
typeOptions: {
|
|
197
|
+
multipleValues: true,
|
|
198
|
+
},
|
|
199
|
+
displayOptions: {
|
|
200
|
+
show: {
|
|
201
|
+
resource: ['order'],
|
|
202
|
+
operation: ['create'],
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
default: {},
|
|
206
|
+
placeholder: 'Add Item',
|
|
207
|
+
options: [
|
|
208
|
+
{
|
|
209
|
+
displayName: 'Item',
|
|
210
|
+
name: 'item',
|
|
211
|
+
values: [
|
|
212
|
+
{
|
|
213
|
+
displayName: 'Name',
|
|
214
|
+
name: 'name',
|
|
215
|
+
type: 'string',
|
|
216
|
+
default: '',
|
|
217
|
+
description: 'Nome do produto/serviço',
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
displayName: 'Quantity',
|
|
221
|
+
name: 'quantity',
|
|
222
|
+
type: 'number',
|
|
223
|
+
default: 1,
|
|
224
|
+
description: 'Quantidade',
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
displayName: 'Unit Amount (centavos)',
|
|
228
|
+
name: 'unit_amount',
|
|
229
|
+
type: 'number',
|
|
230
|
+
default: 0,
|
|
231
|
+
description: 'Valor unitário em centavos (ex: R$ 10,00 = 1000)',
|
|
232
|
+
},
|
|
233
|
+
],
|
|
234
|
+
},
|
|
235
|
+
],
|
|
236
|
+
description: 'Itens do pedido',
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
displayName: 'Payment Method',
|
|
240
|
+
name: 'paymentMethod',
|
|
241
|
+
type: 'options',
|
|
242
|
+
displayOptions: {
|
|
243
|
+
show: {
|
|
244
|
+
resource: ['order'],
|
|
245
|
+
operation: ['create'],
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
options: [
|
|
249
|
+
{
|
|
250
|
+
name: 'PIX',
|
|
251
|
+
value: 'PIX',
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
name: 'Credit Card',
|
|
255
|
+
value: 'CREDIT_CARD',
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
name: 'Boleto',
|
|
259
|
+
value: 'BOLETO',
|
|
260
|
+
},
|
|
261
|
+
],
|
|
262
|
+
default: 'PIX',
|
|
263
|
+
description: 'Método de pagamento do pedido',
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
displayName: 'Reference ID',
|
|
267
|
+
name: 'referenceId',
|
|
268
|
+
type: 'string',
|
|
269
|
+
displayOptions: {
|
|
270
|
+
show: {
|
|
271
|
+
resource: ['order'],
|
|
272
|
+
operation: ['create'],
|
|
273
|
+
},
|
|
274
|
+
},
|
|
275
|
+
default: '',
|
|
276
|
+
description: 'ID de referência interno (seu sistema). Opcional.',
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
displayName: 'Notification URL',
|
|
280
|
+
name: 'notificationUrl',
|
|
281
|
+
type: 'string',
|
|
282
|
+
displayOptions: {
|
|
283
|
+
show: {
|
|
284
|
+
resource: ['order'],
|
|
285
|
+
operation: ['create'],
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
default: '',
|
|
289
|
+
description: 'URL para receber notificações de pagamento (webhook). Opcional.',
|
|
290
|
+
},
|
|
291
|
+
// ═══════════════════════════════════════════════════════════════
|
|
292
|
+
// ORDER — GET / CHARGE — GET / CHARGE — CANCEL
|
|
293
|
+
// ═══════════════════════════════════════════════════════════════
|
|
294
|
+
{
|
|
295
|
+
displayName: 'Order ID',
|
|
296
|
+
name: 'orderId',
|
|
297
|
+
type: 'string',
|
|
298
|
+
required: true,
|
|
299
|
+
displayOptions: {
|
|
300
|
+
show: {
|
|
301
|
+
resource: ['order'],
|
|
302
|
+
operation: ['get'],
|
|
303
|
+
},
|
|
304
|
+
},
|
|
305
|
+
default: '',
|
|
306
|
+
description: 'ID do pedido no PagBank',
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
displayName: 'Charge ID',
|
|
310
|
+
name: 'chargeId',
|
|
311
|
+
type: 'string',
|
|
312
|
+
required: true,
|
|
313
|
+
displayOptions: {
|
|
314
|
+
show: {
|
|
315
|
+
resource: ['charge'],
|
|
316
|
+
operation: ['get', 'cancel'],
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
default: '',
|
|
320
|
+
description: 'ID da cobrança no PagBank',
|
|
321
|
+
},
|
|
322
|
+
// ═══════════════════════════════════════════════════════════════
|
|
323
|
+
// ORDER — LIST
|
|
324
|
+
// ═══════════════════════════════════════════════════════════════
|
|
325
|
+
{
|
|
326
|
+
displayName: 'Filters',
|
|
327
|
+
name: 'listFilters',
|
|
328
|
+
type: 'collection',
|
|
329
|
+
placeholder: 'Add Filter',
|
|
330
|
+
displayOptions: {
|
|
331
|
+
show: {
|
|
332
|
+
resource: ['order'],
|
|
333
|
+
operation: ['list'],
|
|
334
|
+
},
|
|
335
|
+
},
|
|
336
|
+
default: {},
|
|
337
|
+
options: [
|
|
338
|
+
{
|
|
339
|
+
displayName: 'Created At Start',
|
|
340
|
+
name: 'created_at.gte',
|
|
341
|
+
type: 'string',
|
|
342
|
+
default: '',
|
|
343
|
+
placeholder: '2024-01-01T00:00:00-03:00',
|
|
344
|
+
description: 'Data/hora de início (ISO 8601)',
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
displayName: 'Created At End',
|
|
348
|
+
name: 'created_at.lte',
|
|
349
|
+
type: 'string',
|
|
350
|
+
default: '',
|
|
351
|
+
placeholder: '2024-12-31T23:59:59-03:00',
|
|
352
|
+
description: 'Data/hora de fim (ISO 8601)',
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
displayName: 'Reference ID',
|
|
356
|
+
name: 'reference_id',
|
|
357
|
+
type: 'string',
|
|
358
|
+
default: '',
|
|
359
|
+
description: 'Filtrar por reference_id do seu sistema',
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
displayName: 'Page Limit',
|
|
363
|
+
name: 'limit',
|
|
364
|
+
type: 'number',
|
|
365
|
+
default: 20,
|
|
366
|
+
description: 'Número de resultados por página (max 100)',
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
displayName: 'Offset',
|
|
370
|
+
name: 'offset',
|
|
371
|
+
type: 'number',
|
|
372
|
+
default: 0,
|
|
373
|
+
description: 'Deslocamento para paginação',
|
|
374
|
+
},
|
|
375
|
+
],
|
|
376
|
+
},
|
|
377
|
+
// ═══════════════════════════════════════════════════════════════
|
|
378
|
+
// CHARGE — CREATE
|
|
379
|
+
// ═══════════════════════════════════════════════════════════════
|
|
380
|
+
{
|
|
381
|
+
displayName: 'Amount (centavos)',
|
|
382
|
+
name: 'chargeAmount',
|
|
383
|
+
type: 'number',
|
|
384
|
+
required: true,
|
|
385
|
+
displayOptions: {
|
|
386
|
+
show: {
|
|
387
|
+
resource: ['charge'],
|
|
388
|
+
operation: ['create'],
|
|
389
|
+
},
|
|
390
|
+
},
|
|
391
|
+
default: 0,
|
|
392
|
+
description: 'Valor da cobrança em centavos (ex: R$ 10,00 = 1000)',
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
displayName: 'Description',
|
|
396
|
+
name: 'chargeDescription',
|
|
397
|
+
type: 'string',
|
|
398
|
+
displayOptions: {
|
|
399
|
+
show: {
|
|
400
|
+
resource: ['charge'],
|
|
401
|
+
operation: ['create'],
|
|
402
|
+
},
|
|
403
|
+
},
|
|
404
|
+
default: '',
|
|
405
|
+
description: 'Descrição da cobrança',
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
displayName: 'Charge Payment Method',
|
|
409
|
+
name: 'chargePaymentMethod',
|
|
410
|
+
type: 'options',
|
|
411
|
+
displayOptions: {
|
|
412
|
+
show: {
|
|
413
|
+
resource: ['charge'],
|
|
414
|
+
operation: ['create'],
|
|
415
|
+
},
|
|
416
|
+
},
|
|
417
|
+
options: [
|
|
418
|
+
{
|
|
419
|
+
name: 'PIX',
|
|
420
|
+
value: 'PIX',
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
name: 'Boleto',
|
|
424
|
+
value: 'BOLETO',
|
|
425
|
+
},
|
|
426
|
+
],
|
|
427
|
+
default: 'PIX',
|
|
428
|
+
description: 'Método de pagamento da cobrança avulsa',
|
|
429
|
+
},
|
|
430
|
+
{
|
|
431
|
+
displayName: 'Charge Reference ID',
|
|
432
|
+
name: 'chargeReferenceId',
|
|
433
|
+
type: 'string',
|
|
434
|
+
displayOptions: {
|
|
435
|
+
show: {
|
|
436
|
+
resource: ['charge'],
|
|
437
|
+
operation: ['create'],
|
|
438
|
+
},
|
|
439
|
+
},
|
|
440
|
+
default: '',
|
|
441
|
+
description: 'ID de referência interno. Opcional.',
|
|
442
|
+
},
|
|
443
|
+
{
|
|
444
|
+
displayName: 'Charge Notification URL',
|
|
445
|
+
name: 'chargeNotificationUrl',
|
|
446
|
+
type: 'string',
|
|
447
|
+
displayOptions: {
|
|
448
|
+
show: {
|
|
449
|
+
resource: ['charge'],
|
|
450
|
+
operation: ['create'],
|
|
451
|
+
},
|
|
452
|
+
},
|
|
453
|
+
default: '',
|
|
454
|
+
description: 'URL para receber notificações desta cobrança. Opcional.',
|
|
455
|
+
},
|
|
456
|
+
// ═══════════════════════════════════════════════════════════════
|
|
457
|
+
// PIX — CREATE CHARGE
|
|
458
|
+
// ═══════════════════════════════════════════════════════════════
|
|
459
|
+
{
|
|
460
|
+
displayName: 'PIX Amount (centavos)',
|
|
461
|
+
name: 'pixAmount',
|
|
462
|
+
type: 'number',
|
|
463
|
+
required: true,
|
|
464
|
+
displayOptions: {
|
|
465
|
+
show: {
|
|
466
|
+
resource: ['pix'],
|
|
467
|
+
operation: ['createCharge'],
|
|
468
|
+
},
|
|
469
|
+
},
|
|
470
|
+
default: 0,
|
|
471
|
+
description: 'Valor da cobrança PIX em centavos (ex: R$ 10,00 = 1000)',
|
|
472
|
+
},
|
|
473
|
+
{
|
|
474
|
+
displayName: 'PIX Description',
|
|
475
|
+
name: 'pixDescription',
|
|
476
|
+
type: 'string',
|
|
477
|
+
displayOptions: {
|
|
478
|
+
show: {
|
|
479
|
+
resource: ['pix'],
|
|
480
|
+
operation: ['createCharge'],
|
|
481
|
+
},
|
|
482
|
+
},
|
|
483
|
+
default: '',
|
|
484
|
+
description: 'Descrição da cobrança PIX (aparece no app do pagador)',
|
|
485
|
+
},
|
|
486
|
+
{
|
|
487
|
+
displayName: 'PIX Expiration (segundos)',
|
|
488
|
+
name: 'pixExpiration',
|
|
489
|
+
type: 'number',
|
|
490
|
+
displayOptions: {
|
|
491
|
+
show: {
|
|
492
|
+
resource: ['pix'],
|
|
493
|
+
operation: ['createCharge'],
|
|
494
|
+
},
|
|
495
|
+
},
|
|
496
|
+
default: 3600,
|
|
497
|
+
description: 'Tempo de expiração do QR Code em segundos (padrão: 3600 = 1 hora)',
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
displayName: 'PIX Reference ID',
|
|
501
|
+
name: 'pixReferenceId',
|
|
502
|
+
type: 'string',
|
|
503
|
+
displayOptions: {
|
|
504
|
+
show: {
|
|
505
|
+
resource: ['pix'],
|
|
506
|
+
operation: ['createCharge'],
|
|
507
|
+
},
|
|
508
|
+
},
|
|
509
|
+
default: '',
|
|
510
|
+
description: 'ID de referência interno. Opcional.',
|
|
511
|
+
},
|
|
512
|
+
// ═══════════════════════════════════════════════════════════════
|
|
513
|
+
// PIX — GET KEY INFO
|
|
514
|
+
// ═══════════════════════════════════════════════════════════════
|
|
515
|
+
{
|
|
516
|
+
displayName: 'PIX Key',
|
|
517
|
+
name: 'pixKey',
|
|
518
|
+
type: 'string',
|
|
519
|
+
required: true,
|
|
520
|
+
displayOptions: {
|
|
521
|
+
show: {
|
|
522
|
+
resource: ['pix'],
|
|
523
|
+
operation: ['getKeyInfo'],
|
|
524
|
+
},
|
|
525
|
+
},
|
|
526
|
+
default: '',
|
|
527
|
+
description: 'Chave PIX (CPF, CNPJ, e-mail, telefone ou chave aleatória)',
|
|
528
|
+
},
|
|
529
|
+
],
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
async execute() {
|
|
533
|
+
const items = this.getInputData();
|
|
534
|
+
const returnData = [];
|
|
535
|
+
const credentials = await this.getCredentials('pagSeguroApi');
|
|
536
|
+
const environment = credentials.environment || 'production';
|
|
537
|
+
const baseUrl = BASE_URLS[environment];
|
|
538
|
+
const token = credentials.apiToken;
|
|
539
|
+
const resource = this.getNodeParameter('resource', 0);
|
|
540
|
+
const operation = this.getNodeParameter('operation', 0);
|
|
541
|
+
for (let i = 0; i < items.length; i++) {
|
|
542
|
+
try {
|
|
543
|
+
let responseData = {};
|
|
544
|
+
const headers = {
|
|
545
|
+
Authorization: `Bearer ${token}`,
|
|
546
|
+
'Content-Type': 'application/json',
|
|
547
|
+
Accept: 'application/json',
|
|
548
|
+
};
|
|
549
|
+
// ─── ORDER ────────────────────────────────────────────────
|
|
550
|
+
if (resource === 'order') {
|
|
551
|
+
if (operation === 'create') {
|
|
552
|
+
const customerName = this.getNodeParameter('customerName', i);
|
|
553
|
+
const customerEmail = this.getNodeParameter('customerEmail', i);
|
|
554
|
+
const customerTaxId = this.getNodeParameter('customerTaxId', i);
|
|
555
|
+
const paymentMethod = this.getNodeParameter('paymentMethod', i);
|
|
556
|
+
const referenceId = this.getNodeParameter('referenceId', i);
|
|
557
|
+
const notificationUrl = this.getNodeParameter('notificationUrl', i);
|
|
558
|
+
const itemsCollection = this.getNodeParameter('items', i);
|
|
559
|
+
const rawItems = itemsCollection.item || [];
|
|
560
|
+
const items_payload = rawItems.map((it) => ({
|
|
561
|
+
name: it.name,
|
|
562
|
+
quantity: it.quantity,
|
|
563
|
+
unit_amount: it.unit_amount,
|
|
564
|
+
}));
|
|
565
|
+
const body = {
|
|
566
|
+
customer: {
|
|
567
|
+
name: customerName,
|
|
568
|
+
email: customerEmail,
|
|
569
|
+
tax_id: customerTaxId,
|
|
570
|
+
},
|
|
571
|
+
items: items_payload,
|
|
572
|
+
charges: [
|
|
573
|
+
{
|
|
574
|
+
amount: {
|
|
575
|
+
value: items_payload.reduce((acc, it) => acc + it.unit_amount * it.quantity, 0),
|
|
576
|
+
currency: 'BRL',
|
|
577
|
+
},
|
|
578
|
+
payment_method: {
|
|
579
|
+
type: paymentMethod,
|
|
580
|
+
...(paymentMethod === 'PIX'
|
|
581
|
+
? { pix: { expiration_date: getPixExpiration(3600) } }
|
|
582
|
+
: {}),
|
|
583
|
+
},
|
|
584
|
+
...(notificationUrl ? { notification_urls: [notificationUrl] } : {}),
|
|
585
|
+
},
|
|
586
|
+
],
|
|
587
|
+
...(referenceId ? { reference_id: referenceId } : {}),
|
|
588
|
+
...(notificationUrl ? { notification_urls: [notificationUrl] } : {}),
|
|
589
|
+
};
|
|
590
|
+
responseData = await this.helpers.request({
|
|
591
|
+
method: 'POST',
|
|
592
|
+
url: `${baseUrl}/orders`,
|
|
593
|
+
headers,
|
|
594
|
+
body: JSON.stringify(body),
|
|
595
|
+
});
|
|
596
|
+
if (typeof responseData === 'string') {
|
|
597
|
+
responseData = JSON.parse(responseData);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
else if (operation === 'get') {
|
|
601
|
+
const orderId = this.getNodeParameter('orderId', i);
|
|
602
|
+
responseData = await this.helpers.request({
|
|
603
|
+
method: 'GET',
|
|
604
|
+
url: `${baseUrl}/orders/${orderId}`,
|
|
605
|
+
headers,
|
|
606
|
+
});
|
|
607
|
+
if (typeof responseData === 'string') {
|
|
608
|
+
responseData = JSON.parse(responseData);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
else if (operation === 'list') {
|
|
612
|
+
const filters = this.getNodeParameter('listFilters', i);
|
|
613
|
+
const qs = {};
|
|
614
|
+
if (filters['created_at.gte'])
|
|
615
|
+
qs['created_at.gte'] = filters['created_at.gte'];
|
|
616
|
+
if (filters['created_at.lte'])
|
|
617
|
+
qs['created_at.lte'] = filters['created_at.lte'];
|
|
618
|
+
if (filters.reference_id)
|
|
619
|
+
qs.reference_id = filters.reference_id;
|
|
620
|
+
if (filters.limit)
|
|
621
|
+
qs.limit = filters.limit;
|
|
622
|
+
if (filters.offset)
|
|
623
|
+
qs.offset = filters.offset;
|
|
624
|
+
const queryString = Object.keys(qs)
|
|
625
|
+
.map((k) => `${encodeURIComponent(k)}=${encodeURIComponent(String(qs[k]))}`)
|
|
626
|
+
.join('&');
|
|
627
|
+
responseData = await this.helpers.request({
|
|
628
|
+
method: 'GET',
|
|
629
|
+
url: `${baseUrl}/orders${queryString ? '?' + queryString : ''}`,
|
|
630
|
+
headers,
|
|
631
|
+
});
|
|
632
|
+
if (typeof responseData === 'string') {
|
|
633
|
+
responseData = JSON.parse(responseData);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
// ─── CHARGE ───────────────────────────────────────────────
|
|
638
|
+
else if (resource === 'charge') {
|
|
639
|
+
if (operation === 'create') {
|
|
640
|
+
const amount = this.getNodeParameter('chargeAmount', i);
|
|
641
|
+
const description = this.getNodeParameter('chargeDescription', i);
|
|
642
|
+
const paymentMethod = this.getNodeParameter('chargePaymentMethod', i);
|
|
643
|
+
const referenceId = this.getNodeParameter('chargeReferenceId', i);
|
|
644
|
+
const notificationUrl = this.getNodeParameter('chargeNotificationUrl', i);
|
|
645
|
+
const body = {
|
|
646
|
+
reference_id: referenceId || undefined,
|
|
647
|
+
description: description || undefined,
|
|
648
|
+
amount: {
|
|
649
|
+
value: amount,
|
|
650
|
+
currency: 'BRL',
|
|
651
|
+
},
|
|
652
|
+
payment_method: {
|
|
653
|
+
type: paymentMethod,
|
|
654
|
+
...(paymentMethod === 'PIX'
|
|
655
|
+
? { pix: { expiration_date: getPixExpiration(3600) } }
|
|
656
|
+
: {}),
|
|
657
|
+
...(paymentMethod === 'BOLETO'
|
|
658
|
+
? {
|
|
659
|
+
boleto: {
|
|
660
|
+
due_date: getBoletoDate(3),
|
|
661
|
+
instruction_lines: {
|
|
662
|
+
line_1: description || 'Pagamento via PagBank',
|
|
663
|
+
},
|
|
664
|
+
},
|
|
665
|
+
}
|
|
666
|
+
: {}),
|
|
667
|
+
},
|
|
668
|
+
...(notificationUrl ? { notification_urls: [notificationUrl] } : {}),
|
|
669
|
+
};
|
|
670
|
+
// Remove undefined keys
|
|
671
|
+
const cleanBody = JSON.parse(JSON.stringify(body));
|
|
672
|
+
responseData = await this.helpers.request({
|
|
673
|
+
method: 'POST',
|
|
674
|
+
url: `${baseUrl}/charges`,
|
|
675
|
+
headers,
|
|
676
|
+
body: JSON.stringify(cleanBody),
|
|
677
|
+
});
|
|
678
|
+
if (typeof responseData === 'string') {
|
|
679
|
+
responseData = JSON.parse(responseData);
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
else if (operation === 'get') {
|
|
683
|
+
const chargeId = this.getNodeParameter('chargeId', i);
|
|
684
|
+
responseData = await this.helpers.request({
|
|
685
|
+
method: 'GET',
|
|
686
|
+
url: `${baseUrl}/charges/${chargeId}`,
|
|
687
|
+
headers,
|
|
688
|
+
});
|
|
689
|
+
if (typeof responseData === 'string') {
|
|
690
|
+
responseData = JSON.parse(responseData);
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
else if (operation === 'cancel') {
|
|
694
|
+
const chargeId = this.getNodeParameter('chargeId', i);
|
|
695
|
+
responseData = await this.helpers.request({
|
|
696
|
+
method: 'POST',
|
|
697
|
+
url: `${baseUrl}/charges/${chargeId}/cancel`,
|
|
698
|
+
headers,
|
|
699
|
+
body: JSON.stringify({}),
|
|
700
|
+
});
|
|
701
|
+
if (typeof responseData === 'string') {
|
|
702
|
+
responseData = JSON.parse(responseData);
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
// ─── PIX ──────────────────────────────────────────────────
|
|
707
|
+
else if (resource === 'pix') {
|
|
708
|
+
if (operation === 'createCharge') {
|
|
709
|
+
const amount = this.getNodeParameter('pixAmount', i);
|
|
710
|
+
const description = this.getNodeParameter('pixDescription', i);
|
|
711
|
+
const expiration = this.getNodeParameter('pixExpiration', i);
|
|
712
|
+
const referenceId = this.getNodeParameter('pixReferenceId', i);
|
|
713
|
+
const body = {
|
|
714
|
+
...(referenceId ? { reference_id: referenceId } : {}),
|
|
715
|
+
...(description ? { description } : {}),
|
|
716
|
+
amount: {
|
|
717
|
+
value: amount,
|
|
718
|
+
currency: 'BRL',
|
|
719
|
+
},
|
|
720
|
+
payment_method: {
|
|
721
|
+
type: 'PIX',
|
|
722
|
+
pix: {
|
|
723
|
+
expiration_date: getPixExpiration(expiration),
|
|
724
|
+
},
|
|
725
|
+
},
|
|
726
|
+
};
|
|
727
|
+
responseData = await this.helpers.request({
|
|
728
|
+
method: 'POST',
|
|
729
|
+
url: `${baseUrl}/charges`,
|
|
730
|
+
headers,
|
|
731
|
+
body: JSON.stringify(body),
|
|
732
|
+
});
|
|
733
|
+
if (typeof responseData === 'string') {
|
|
734
|
+
responseData = JSON.parse(responseData);
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
else if (operation === 'getKeyInfo') {
|
|
738
|
+
const pixKey = this.getNodeParameter('pixKey', i);
|
|
739
|
+
responseData = await this.helpers.request({
|
|
740
|
+
method: 'GET',
|
|
741
|
+
url: `${baseUrl}/pix/keys/${encodeURIComponent(pixKey)}`,
|
|
742
|
+
headers,
|
|
743
|
+
});
|
|
744
|
+
if (typeof responseData === 'string') {
|
|
745
|
+
responseData = JSON.parse(responseData);
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
returnData.push({
|
|
750
|
+
json: responseData,
|
|
751
|
+
pairedItem: { item: i },
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
catch (error) {
|
|
755
|
+
if (this.continueOnFail()) {
|
|
756
|
+
returnData.push({
|
|
757
|
+
json: {
|
|
758
|
+
error: error.message,
|
|
759
|
+
},
|
|
760
|
+
pairedItem: { item: i },
|
|
761
|
+
});
|
|
762
|
+
continue;
|
|
763
|
+
}
|
|
764
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), error, {
|
|
765
|
+
itemIndex: i,
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
return [returnData];
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
exports.PagSeguro = PagSeguro;
|
|
773
|
+
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
|
774
|
+
function getPixExpiration(seconds) {
|
|
775
|
+
const d = new Date(Date.now() + seconds * 1000);
|
|
776
|
+
return d.toISOString().replace('Z', '-03:00').slice(0, 19) + '-03:00';
|
|
777
|
+
}
|
|
778
|
+
function getBoletoDate(daysFromNow) {
|
|
779
|
+
const d = new Date();
|
|
780
|
+
d.setDate(d.getDate() + daysFromNow);
|
|
781
|
+
return d.toISOString().slice(0, 10); // YYYY-MM-DD
|
|
782
|
+
}
|
|
783
|
+
//# sourceMappingURL=PagSeguro.node.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IHookFunctions, IWebhookFunctions, INodeType, INodeTypeDescription, IWebhookResponseData } from 'n8n-workflow';
|
|
2
|
+
export declare class PagSeguroTrigger implements INodeType {
|
|
3
|
+
description: INodeTypeDescription;
|
|
4
|
+
webhookMethods: {
|
|
5
|
+
default: {
|
|
6
|
+
checkExists(this: IHookFunctions): Promise<boolean>;
|
|
7
|
+
create(this: IHookFunctions): Promise<boolean>;
|
|
8
|
+
delete(this: IHookFunctions): Promise<boolean>;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
webhook(this: IWebhookFunctions): Promise<IWebhookResponseData>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=PagSeguroTrigger.node.d.ts.map
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PagSeguroTrigger = void 0;
|
|
4
|
+
class PagSeguroTrigger {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.description = {
|
|
7
|
+
displayName: 'PagBank (PagSeguro) Trigger',
|
|
8
|
+
name: 'pagSeguroTrigger',
|
|
9
|
+
icon: 'file:pagseguro.svg',
|
|
10
|
+
group: ['trigger'],
|
|
11
|
+
version: 1,
|
|
12
|
+
description: 'Recebe notificações de pagamento do PagBank via webhook (orders, charges, PIX)',
|
|
13
|
+
defaults: {
|
|
14
|
+
name: 'PagBank Trigger',
|
|
15
|
+
},
|
|
16
|
+
inputs: [],
|
|
17
|
+
outputs: ['main'],
|
|
18
|
+
credentials: [
|
|
19
|
+
{
|
|
20
|
+
name: 'pagSeguroApi',
|
|
21
|
+
required: false,
|
|
22
|
+
displayOptions: {
|
|
23
|
+
show: {
|
|
24
|
+
authentication: ['apiKey'],
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
webhooks: [
|
|
30
|
+
{
|
|
31
|
+
name: 'default',
|
|
32
|
+
httpMethod: 'POST',
|
|
33
|
+
responseMode: 'onReceived',
|
|
34
|
+
path: 'webhook',
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
properties: [
|
|
38
|
+
{
|
|
39
|
+
displayName: 'Authentication',
|
|
40
|
+
name: 'authentication',
|
|
41
|
+
type: 'options',
|
|
42
|
+
options: [
|
|
43
|
+
{
|
|
44
|
+
name: 'None (accept all POST requests)',
|
|
45
|
+
value: 'none',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'Validate PagBank Signature Header',
|
|
49
|
+
value: 'apiKey',
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
default: 'none',
|
|
53
|
+
description: 'Como validar as requisições recebidas do PagBank. "None" aceita qualquer POST — use apenas em ambiente controlado.',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
displayName: 'Event Types',
|
|
57
|
+
name: 'eventTypes',
|
|
58
|
+
type: 'multiOptions',
|
|
59
|
+
options: [
|
|
60
|
+
{
|
|
61
|
+
name: 'All Events',
|
|
62
|
+
value: '*',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: 'Charge — Authorized',
|
|
66
|
+
value: 'CHARGE_AUTHORIZED',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'Charge — Canceled',
|
|
70
|
+
value: 'CHARGE_CANCELED',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: 'Charge — Paid',
|
|
74
|
+
value: 'CHARGE_PAID',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: 'Order — Authorized',
|
|
78
|
+
value: 'ORDER_AUTHORIZED',
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: 'Order — Canceled',
|
|
82
|
+
value: 'ORDER_CANCELED',
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: 'Order — Paid',
|
|
86
|
+
value: 'ORDER_PAID',
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: 'PIX — Received',
|
|
90
|
+
value: 'TRANSACTION_RECEIVED',
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
default: ['*'],
|
|
94
|
+
description: 'Tipos de evento que serão processados. Selecione "*" para processar todos.',
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
displayName: 'Webhook Instructions',
|
|
98
|
+
name: 'webhookInstructions',
|
|
99
|
+
type: 'notice',
|
|
100
|
+
default: 'Configure a URL do webhook acima no painel do PagBank em: Minha Conta → Configurações → Webhooks. O PagBank enviará um POST para esta URL a cada evento de pagamento.',
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
};
|
|
104
|
+
this.webhookMethods = {
|
|
105
|
+
default: {
|
|
106
|
+
async checkExists() {
|
|
107
|
+
// PagBank não tem API para listar webhooks registrados por URL
|
|
108
|
+
// O usuário configura manualmente no painel
|
|
109
|
+
return false;
|
|
110
|
+
},
|
|
111
|
+
async create() {
|
|
112
|
+
// Registro manual — instrução exibida no node
|
|
113
|
+
return true;
|
|
114
|
+
},
|
|
115
|
+
async delete() {
|
|
116
|
+
// Remoção manual no painel do PagBank
|
|
117
|
+
return true;
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
async webhook() {
|
|
123
|
+
const req = this.getRequestObject();
|
|
124
|
+
const body = this.getBodyData();
|
|
125
|
+
// Filtrar por tipo de evento (se configurado)
|
|
126
|
+
const eventTypes = this.getNodeParameter('eventTypes');
|
|
127
|
+
const authentication = this.getNodeParameter('authentication');
|
|
128
|
+
// Validação de assinatura (quando habilitado)
|
|
129
|
+
if (authentication === 'apiKey') {
|
|
130
|
+
const credentials = await this.getCredentials('pagSeguroApi');
|
|
131
|
+
const expectedToken = credentials.apiToken;
|
|
132
|
+
const receivedHeader = req.headers['authorization'] || req.headers['x-pagseguro-signature'] || '';
|
|
133
|
+
const receivedToken = receivedHeader.replace('Bearer ', '').trim();
|
|
134
|
+
if (!receivedToken || receivedToken !== expectedToken) {
|
|
135
|
+
return {
|
|
136
|
+
webhookResponse: {
|
|
137
|
+
status: 401,
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
// Filtrar eventos
|
|
143
|
+
const eventType = (body.type || body.event_type || '');
|
|
144
|
+
if (!eventTypes.includes('*') && eventType && !eventTypes.includes(eventType)) {
|
|
145
|
+
// Evento ignorado — responde 200 mas não dispara o workflow
|
|
146
|
+
return {
|
|
147
|
+
webhookResponse: {
|
|
148
|
+
status: 200,
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
// Retornar o payload completo do PagBank
|
|
153
|
+
return {
|
|
154
|
+
workflowData: [
|
|
155
|
+
[
|
|
156
|
+
{
|
|
157
|
+
json: {
|
|
158
|
+
...body,
|
|
159
|
+
_meta: {
|
|
160
|
+
event_type: eventType || 'UNKNOWN',
|
|
161
|
+
received_at: new Date().toISOString(),
|
|
162
|
+
headers: {
|
|
163
|
+
'content-type': req.headers['content-type'],
|
|
164
|
+
'x-pagseguro-signature': req.headers['x-pagseguro-signature'],
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
],
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
exports.PagSeguroTrigger = PagSeguroTrigger;
|
|
175
|
+
//# sourceMappingURL=PagSeguroTrigger.node.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60">
|
|
2
|
+
<rect width="60" height="60" rx="12" fill="#009C3B"/>
|
|
3
|
+
<text x="50%" y="54%" dominant-baseline="middle" text-anchor="middle"
|
|
4
|
+
font-family="Arial, sans-serif" font-weight="bold" font-size="11"
|
|
5
|
+
fill="#FFDF00">PagBank</text>
|
|
6
|
+
</svg>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 60 60">
|
|
2
|
+
<rect width="60" height="60" rx="12" fill="#009C3B"/>
|
|
3
|
+
<text x="50%" y="54%" dominant-baseline="middle" text-anchor="middle"
|
|
4
|
+
font-family="Arial, sans-serif" font-weight="bold" font-size="11"
|
|
5
|
+
fill="#FFDF00">PagBank</text>
|
|
6
|
+
</svg>
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "n8n-nodes-pagseguro",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "n8n community node for PagBank (PagSeguro) — Brazilian payment platform. Supports Orders, Charges, PIX and Webhooks.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"n8n-community-node-package",
|
|
7
|
+
"pagseguro",
|
|
8
|
+
"pagbank",
|
|
9
|
+
"payment",
|
|
10
|
+
"brazil",
|
|
11
|
+
"pix",
|
|
12
|
+
"boleto",
|
|
13
|
+
"fintech"
|
|
14
|
+
],
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"main": "index.js",
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc && node scripts/copy-assets.js",
|
|
19
|
+
"dev": "tsc --watch",
|
|
20
|
+
"lint": "eslint nodes credentials --ext .ts",
|
|
21
|
+
"prepublishOnly": "npm run build"
|
|
22
|
+
},
|
|
23
|
+
"n8n": {
|
|
24
|
+
"n8nNodesApiVersion": 1,
|
|
25
|
+
"credentials": [
|
|
26
|
+
"dist/credentials/PagSeguroApi.credentials.js"
|
|
27
|
+
],
|
|
28
|
+
"nodes": [
|
|
29
|
+
"dist/nodes/PagSeguro/PagSeguro.node.js",
|
|
30
|
+
"dist/nodes/PagSeguro/PagSeguroTrigger.node.js"
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"typescript": "^5.0.0",
|
|
35
|
+
"@types/node": "^20.0.0"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"n8n-workflow": "*"
|
|
39
|
+
},
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "https://github.com/rd4marketing/n8n-nodes-pagseguro"
|
|
43
|
+
},
|
|
44
|
+
"author": {
|
|
45
|
+
"name": "RD4 Marketing",
|
|
46
|
+
"email": "rodrigoferreiraanuncios@gmail.com"
|
|
47
|
+
}
|
|
48
|
+
}
|