{
  "name": "SpecGrid — AEAT VeriFactu SHA-256 + SEPA EPC Payment QR Generator",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "specgrid-invoice-hook",
        "responseMode": "lastNode",
        "options": {}
      },
      "id": "webhook-invoice-in",
      "name": "1. Invoice Webhook Trigger",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [220, 300]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://eu.specgrid-api.workers.dev/api/v1/verifactu/fingerprint",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer SPECGRID-REPLACE-WITH-YOUR-POLAR-KEY"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ issuerNif: $json.body.issuerNif, seriesNumber: $json.body.seriesNumber, issueDate: $json.body.issueDate, invoiceType: $json.body.invoiceType || 'F1', taxAmount: $json.body.taxAmount, totalAmount: $json.body.totalAmount, previousHash: $json.body.previousHash || '', generationTimestamp: $json.body.generationTimestamp || new Date().toISOString().replace(/\\.\\d{3}Z$/, '+01:00'), verifactuMode: true, environment: 'production' }) }}",
        "options": {}
      },
      "id": "specgrid-verifactu",
      "name": "2. SpecGrid VeriFactu SHA-256 & QR",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [500, 220]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://eu.specgrid-api.workers.dev/api/v1/sepa/epc-qr",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "Bearer SPECGRID-REPLACE-WITH-YOUR-POLAR-KEY"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ beneficiaryName: $('1. Invoice Webhook Trigger').item.json.body.beneficiaryName, iban: $('1. Invoice Webhook Trigger').item.json.body.iban, amountEur: $('1. Invoice Webhook Trigger').item.json.body.totalAmount, remittanceText: 'Invoice ' + $('1. Invoice Webhook Trigger').item.json.body.seriesNumber }) }}",
        "options": {}
      },
      "id": "specgrid-sepa-qr",
      "name": "3. SpecGrid SEPA EPC069-12 QR",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [500, 420]
    },
    {
      "parameters": {
        "mode": "combine",
        "combineBy": "combineByPosition",
        "options": {}
      },
      "id": "merge-compliance-pack",
      "name": "4. Merge VeriFactu + SEPA QR",
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3,
      "position": [780, 310]
    }
  ],
  "connections": {
    "1. Invoice Webhook Trigger": {
      "main": [
        [
          { "node": "2. SpecGrid VeriFactu SHA-256 & QR", "type": "main", "index": 0 },
          { "node": "3. SpecGrid SEPA EPC069-12 QR", "type": "main", "index": 0 }
        ]
      ]
    },
    "2. SpecGrid VeriFactu SHA-256 & QR": {
      "main": [[{ "node": "4. Merge VeriFactu + SEPA QR", "type": "main", "index": 0 }]]
    },
    "3. SpecGrid SEPA EPC069-12 QR": {
      "main": [[{ "node": "4. Merge VeriFactu + SEPA QR", "type": "main", "index": 1 }]]
    }
  },
  "active": false,
  "settings": { "executionOrder": "v1" }
}
