{
  "name": "Lancer: create client and payment request",
  "nodes": [
    {
      "parameters": {},
      "id": "8c2d0e7a-3b44-4b8e-8d0e-2a6c9b1f0001",
      "name": "Start (replace with your trigger)",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [0, 0]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            { "id": "s1", "name": "name", "value": "אקו בע\"מ", "type": "string" },
            { "id": "s2", "name": "email", "value": "billing@example.com", "type": "string" },
            { "id": "s3", "name": "contactName", "value": "דנה לוי", "type": "string" },
            { "id": "s4", "name": "title", "value": "מקדמה – אתר תדמית", "type": "string" },
            { "id": "s5", "name": "amountShekels", "value": 2500, "type": "number" }
          ]
        },
        "options": {}
      },
      "id": "8c2d0e7a-3b44-4b8e-8d0e-2a6c9b1f0002",
      "name": "Sample input",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [240, 0]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.lancer-erp.com/api/v1/clients",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ name: $json.name, email: $json.email, source: 'api', tags: ['n8n'], contacts: [{ name: $json.contactName, email: $json.email }] }) }}",
        "options": {}
      },
      "id": "8c2d0e7a-3b44-4b8e-8d0e-2a6c9b1f0003",
      "name": "Create client (clients:write)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [480, 0],
      "credentials": { "httpHeaderAuth": { "id": "", "name": "Lancer API key" } }
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.lancer-erp.com/api/v1/payment-requests",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ clientId: $json.id, title: $('Sample input').item.json.title, amountAgorot: Math.round($('Sample input').item.json.amountShekels * 100), createLink: true }) }}",
        "options": {}
      },
      "id": "8c2d0e7a-3b44-4b8e-8d0e-2a6c9b1f0004",
      "name": "Create payment request (payment_requests:write)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [720, 0],
      "credentials": { "httpHeaderAuth": { "id": "", "name": "Lancer API key" } }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            { "id": "o1", "name": "paymentRequestId", "value": "={{ $json.id }}", "type": "string" },
            { "id": "o2", "name": "payUrl", "value": "={{ $json.payUrl }}", "type": "string" }
          ]
        },
        "options": {}
      },
      "id": "8c2d0e7a-3b44-4b8e-8d0e-2a6c9b1f0005",
      "name": "Pay link (send it on)",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [960, 0]
    }
  ],
  "connections": {
    "Start (replace with your trigger)": { "main": [[{ "node": "Sample input", "type": "main", "index": 0 }]] },
    "Sample input": { "main": [[{ "node": "Create client (clients:write)", "type": "main", "index": 0 }]] },
    "Create client (clients:write)": { "main": [[{ "node": "Create payment request (payment_requests:write)", "type": "main", "index": 0 }]] },
    "Create payment request (payment_requests:write)": { "main": [[{ "node": "Pay link (send it on)", "type": "main", "index": 0 }]] }
  },
  "settings": { "executionOrder": "v1" },
  "pinData": {}
}
