{
  "info": {
    "_postman_id": "043bdfdf-272f-4a9b-8563-3493495d053f",
    "name": "billware API",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "_exporter_id": "13946438"
  },
  "item": [
    {
      "name": "Authentication",
      "item": [
        {
          "name": "test.connection",
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "exec": [
                  "const payload = JSON.stringify({});",
                  "pm.environment.set(\"requestBody\", payload);",
                  "",
                  "// Copy the credential from billware (\"App\" => \"API\" => \"Show Credentials\")",
                  "// Change them in Postman -> Collection -> billware API -> Variables",
                  "const apiAppId = pm.collectionVariables.get(\"apiAppId\");",
                  "const apiSecret = pm.collectionVariables.get(\"apiSecret\");",
                  "",
                  "// Use TextEncoder to encode the string",
                  "const encoder = new TextEncoder();",
                  "const keyData = encoder.encode(apiSecret);",
                  "const data = encoder.encode(payload);",
                  "",
                  "// Create HMAC with SHA-256",
                  "crypto.subtle.importKey(",
                  "    'raw',",
                  "    keyData,",
                  "    { name: 'HMAC', hash: 'SHA-256' },",
                  "    false,",
                  "    ['sign']",
                  ").then(key => {",
                  "    return crypto.subtle.sign('HMAC', key, data);",
                  "}).then(signature => {",
                  "    const hmacBase64 = btoa(String.fromCharCode(...new Uint8Array(signature)));",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Hmac',",
                  "        value: `${apiAppId}:${hmacBase64}`",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Method',",
                  "        value: 'test.connection'",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'Content-Type',",
                  "        value: 'application/json'",
                  "    });",
                  "});",
                  ""
                ],
                "type": "text/javascript",
                "packages": {}
              }
            },
            {
              "listen": "test",
              "script": {
                "exec": [
                  ""
                ],
                "type": "text/javascript",
                "packages": {}
              }
            }
          ],
          "protocolProfileBehavior": {
            "disableBodyPruning": true
          },
          "request": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{{requestBody}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}",
              "host": [
                "{{baseUrl}}"
              ]
            }
          },
          "response": []
        }
      ]
    },
    {
      "name": "Articles",
      "item": [
        {
          "name": "article.create",
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "exec": [
                  "const payload = JSON.stringify({",
                  "  article_title: \"Kaninchenstall XL\",",
                  "  article_subtitle: \"Mit extra Auslauf und wetterfestem Dach\",",
                  "  article_description: \"Ein hochwertiger, wetterfester Kaninchenstall aus Holz mit extra großem Auslaufbereich.\",",
                  "  article_nr: \"KAN-XL-2025\",",
                  "  article_sku: \"STALL-XL-001\",",
                  "  article_ean: \"4012345678901\",",
                  "  article_unit: \"unit_ppu\",             // Preis pro Stück",
                  "  article_type: \"billware\",             // laut Defaults",
                  "  article_price: 129.99,",
                  "  article_tax_rate: 19.0,",
                  "  article_purchase_price: 75.00",
                  "});",
                  "",
                  "pm.environment.set(\"requestBody\", payload);",
                  "",
                  "// Copy the credential from billware (\"App\" => \"API\" => \"Show Credentials\")",
                  "// Change them in Postman -> Collection -> billware API -> Variables",
                  "const apiAppId = pm.collectionVariables.get(\"apiAppId\");",
                  "const apiSecret = pm.collectionVariables.get(\"apiSecret\");",
                  "",
                  "// Use TextEncoder to encode the string",
                  "const encoder = new TextEncoder();",
                  "const keyData = encoder.encode(apiSecret);",
                  "const data = encoder.encode(payload);",
                  "",
                  "// Create HMAC with SHA-256",
                  "crypto.subtle.importKey(",
                  "    'raw',",
                  "    keyData,",
                  "    { name: 'HMAC', hash: 'SHA-256' },",
                  "    false,",
                  "    ['sign']",
                  ").then(key => {",
                  "    return crypto.subtle.sign('HMAC', key, data);",
                  "}).then(signature => {",
                  "    const hmacBase64 = btoa(String.fromCharCode(...new Uint8Array(signature)));",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Hmac',",
                  "        value: `${apiAppId}:${hmacBase64}`",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Method',",
                  "        value: 'article.create'",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'Content-Type',",
                  "        value: 'application/json'",
                  "    });",
                  "});",
                  ""
                ],
                "type": "text/javascript",
                "packages": {}
              }
            }
          ],
          "protocolProfileBehavior": {
            "disableBodyPruning": true
          },
          "request": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{{requestBody}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}",
              "host": [
                "{{baseUrl}}"
              ]
            }
          },
          "response": []
        },
        {
          "name": "article.read (by article_ident)",
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "exec": [
                  "const payload = JSON.stringify({",
                  "  article_ident: \"5kjynoies71pgqv4\", // see response from article.create",
                  "});",
                  "",
                  "pm.environment.set(\"requestBody\", payload);",
                  "",
                  "// Copy the credential from billware (\"App\" => \"API\" => \"Show Credentials\")",
                  "// Change them in Postman -> Collection -> billware API -> Variables",
                  "const apiAppId = pm.collectionVariables.get(\"apiAppId\");",
                  "const apiSecret = pm.collectionVariables.get(\"apiSecret\");",
                  "",
                  "// Use TextEncoder to encode the string",
                  "const encoder = new TextEncoder();",
                  "const keyData = encoder.encode(apiSecret);",
                  "const data = encoder.encode(payload);",
                  "",
                  "// Create HMAC with SHA-256",
                  "crypto.subtle.importKey(",
                  "    'raw',",
                  "    keyData,",
                  "    { name: 'HMAC', hash: 'SHA-256' },",
                  "    false,",
                  "    ['sign']",
                  ").then(key => {",
                  "    return crypto.subtle.sign('HMAC', key, data);",
                  "}).then(signature => {",
                  "    const hmacBase64 = btoa(String.fromCharCode(...new Uint8Array(signature)));",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Hmac',",
                  "        value: `${apiAppId}:${hmacBase64}`",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Method',",
                  "        value: 'article.read'",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'Content-Type',",
                  "        value: 'application/json'",
                  "    });",
                  "});",
                  ""
                ],
                "type": "text/javascript",
                "packages": {}
              }
            }
          ],
          "protocolProfileBehavior": {
            "disableBodyPruning": true
          },
          "request": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{{requestBody}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}",
              "host": [
                "{{baseUrl}}"
              ]
            }
          },
          "response": []
        },
        {
          "name": "article.read (by SKU / EAN)",
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "exec": [
                  "const payload = JSON.stringify({",
                  "  article_identifier: \"sku\",",
                  "  article_sku: \"STALL-XL-001\"",
                  "});",
                  "",
                  "pm.environment.set(\"requestBody\", payload);",
                  "",
                  "// Copy the credential from billware (\"App\" => \"API\" => \"Show Credentials\")",
                  "// Change them in Postman -> Collection -> billware API -> Variables",
                  "const apiAppId = pm.collectionVariables.get(\"apiAppId\");",
                  "const apiSecret = pm.collectionVariables.get(\"apiSecret\");",
                  "",
                  "// Use TextEncoder to encode the string",
                  "const encoder = new TextEncoder();",
                  "const keyData = encoder.encode(apiSecret);",
                  "const data = encoder.encode(payload);",
                  "",
                  "// Create HMAC with SHA-256",
                  "crypto.subtle.importKey(",
                  "    'raw',",
                  "    keyData,",
                  "    { name: 'HMAC', hash: 'SHA-256' },",
                  "    false,",
                  "    ['sign']",
                  ").then(key => {",
                  "    return crypto.subtle.sign('HMAC', key, data);",
                  "}).then(signature => {",
                  "    const hmacBase64 = btoa(String.fromCharCode(...new Uint8Array(signature)));",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Hmac',",
                  "        value: `${apiAppId}:${hmacBase64}`",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Method',",
                  "        value: 'article.read'",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'Content-Type',",
                  "        value: 'application/json'",
                  "    });",
                  "});",
                  ""
                ],
                "type": "text/javascript",
                "packages": {}
              }
            }
          ],
          "protocolProfileBehavior": {
            "disableBodyPruning": true
          },
          "request": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{{requestBody}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}",
              "host": [
                "{{baseUrl}}"
              ]
            }
          },
          "response": []
        },
        {
          "name": "article.update",
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "exec": [
                  "const payload = JSON.stringify({",
                  "  article_ident: \"5kjynoies71pgqv4\", // see response from article.create",
                  "  article_title: \"Hasenstall XXL\"",
                  "});",
                  "",
                  "pm.environment.set(\"requestBody\", payload);",
                  "",
                  "// Copy the credential from billware (\"App\" => \"API\" => \"Show Credentials\")",
                  "// Change them in Postman -> Collection -> billware API -> Variables",
                  "const apiAppId = pm.collectionVariables.get(\"apiAppId\");",
                  "const apiSecret = pm.collectionVariables.get(\"apiSecret\");",
                  "",
                  "// Use TextEncoder to encode the string",
                  "const encoder = new TextEncoder();",
                  "const keyData = encoder.encode(apiSecret);",
                  "const data = encoder.encode(payload);",
                  "",
                  "// Create HMAC with SHA-256",
                  "crypto.subtle.importKey(",
                  "    'raw',",
                  "    keyData,",
                  "    { name: 'HMAC', hash: 'SHA-256' },",
                  "    false,",
                  "    ['sign']",
                  ").then(key => {",
                  "    return crypto.subtle.sign('HMAC', key, data);",
                  "}).then(signature => {",
                  "    const hmacBase64 = btoa(String.fromCharCode(...new Uint8Array(signature)));",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Hmac',",
                  "        value: `${apiAppId}:${hmacBase64}`",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Method',",
                  "        value: 'article.update'",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'Content-Type',",
                  "        value: 'application/json'",
                  "    });",
                  "});",
                  ""
                ],
                "type": "text/javascript",
                "packages": {}
              }
            }
          ],
          "protocolProfileBehavior": {
            "disableBodyPruning": true
          },
          "request": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{{requestBody}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}",
              "host": [
                "{{baseUrl}}"
              ]
            }
          },
          "response": []
        },
        {
          "name": "article.delete",
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "exec": [
                  "const payload = JSON.stringify({",
                  "  article_ident: \"5kjynoies71pgqv4\", // see response from article.create",
                  "});",
                  "",
                  "pm.environment.set(\"requestBody\", payload);",
                  "",
                  "// Copy the credential from billware (\"App\" => \"API\" => \"Show Credentials\")",
                  "// Change them in Postman -> Collection -> billware API -> Variables",
                  "const apiAppId = pm.collectionVariables.get(\"apiAppId\");",
                  "const apiSecret = pm.collectionVariables.get(\"apiSecret\");",
                  "",
                  "// Use TextEncoder to encode the string",
                  "const encoder = new TextEncoder();",
                  "const keyData = encoder.encode(apiSecret);",
                  "const data = encoder.encode(payload);",
                  "",
                  "// Create HMAC with SHA-256",
                  "crypto.subtle.importKey(",
                  "    'raw',",
                  "    keyData,",
                  "    { name: 'HMAC', hash: 'SHA-256' },",
                  "    false,",
                  "    ['sign']",
                  ").then(key => {",
                  "    return crypto.subtle.sign('HMAC', key, data);",
                  "}).then(signature => {",
                  "    const hmacBase64 = btoa(String.fromCharCode(...new Uint8Array(signature)));",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Hmac',",
                  "        value: `${apiAppId}:${hmacBase64}`",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Method',",
                  "        value: 'article.delete'",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'Content-Type',",
                  "        value: 'application/json'",
                  "    });",
                  "});",
                  ""
                ],
                "type": "text/javascript",
                "packages": {}
              }
            }
          ],
          "protocolProfileBehavior": {
            "disableBodyPruning": true
          },
          "request": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{{requestBody}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}",
              "host": [
                "{{baseUrl}}"
              ]
            }
          },
          "response": []
        },
        {
          "name": "article.exists",
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "exec": [
                  "const payload = JSON.stringify({",
                  "  article_ident: \"5kjynoies71pgqv4\", // see response from article.create",
                  "});",
                  "",
                  "pm.environment.set(\"requestBody\", payload);",
                  "",
                  "// Copy the credential from billware (\"App\" => \"API\" => \"Show Credentials\")",
                  "// Change them in Postman -> Collection -> billware API -> Variables",
                  "const apiAppId = pm.collectionVariables.get(\"apiAppId\");",
                  "const apiSecret = pm.collectionVariables.get(\"apiSecret\");",
                  "",
                  "// Use TextEncoder to encode the string",
                  "const encoder = new TextEncoder();",
                  "const keyData = encoder.encode(apiSecret);",
                  "const data = encoder.encode(payload);",
                  "",
                  "// Create HMAC with SHA-256",
                  "crypto.subtle.importKey(",
                  "    'raw',",
                  "    keyData,",
                  "    { name: 'HMAC', hash: 'SHA-256' },",
                  "    false,",
                  "    ['sign']",
                  ").then(key => {",
                  "    return crypto.subtle.sign('HMAC', key, data);",
                  "}).then(signature => {",
                  "    const hmacBase64 = btoa(String.fromCharCode(...new Uint8Array(signature)));",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Hmac',",
                  "        value: `${apiAppId}:${hmacBase64}`",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Method',",
                  "        value: 'article.exists'",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'Content-Type',",
                  "        value: 'application/json'",
                  "    });",
                  "});",
                  ""
                ],
                "type": "text/javascript",
                "packages": {}
              }
            }
          ],
          "protocolProfileBehavior": {
            "disableBodyPruning": true
          },
          "request": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{{requestBody}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}",
              "host": [
                "{{baseUrl}}"
              ]
            }
          },
          "response": []
        }
      ]
    },
    {
      "name": "Customers",
      "item": [
        {
          "name": "customer.create",
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "exec": [
                  "const payload = JSON.stringify({",
                  "  customer_type: \"billware\",",
                  "  is_business_client: 0,",
                  "  bill_title: \"Mister\",",
                  "  bill_firstname: \"Max\",",
                  "  bill_lastname: \"Mustermann\",",
                  "  bill_street: \"Musterstraße 12\",",
                  "  bill_zipcode: \"12345\",",
                  "  bill_city: \"Musterstadt\",",
                  "  bill_country: \"DE\",",
                  "  bill_phone: \"+49 123 4567890\",",
                  "  bill_email: \"max.mustermann@example.com\",",
                  "",
                  "  divergent_delivery_address: 1,",
                  "  delivery_title: \"Mister\",",
                  "  delivery_firstname: \"Max\",",
                  "  delivery_lastname: \"Mustermann\",",
                  "  delivery_street: \"Lieferweg 5\",",
                  "  delivery_zipcode: \"54321\",",
                  "  delivery_city: \"Lieferstadt\",",
                  "  delivery_country: \"DE\",",
                  "  delivery_phone: \"+49 987 6543210\",",
                  "",
                  "  account_iban: \"DE89370400440532013000\",",
                  "  account_bic: \"COBADEFFXXX\",",
                  "  account_bank: \"Commerzbank\",",
                  "  account_paypal: \"max.paypal@example.com\",",
                  "  user_note: \"Kunde möchte Rechnung nur per E-Mail erhalten\"",
                  "});",
                  "",
                  "pm.environment.set(\"requestBody\", payload);",
                  "",
                  "// Copy the credential from billware (\"App\" => \"API\" => \"Show Credentials\")",
                  "// Change them in Postman -> Collection -> billware API -> Variables",
                  "const apiAppId = pm.collectionVariables.get(\"apiAppId\");",
                  "const apiSecret = pm.collectionVariables.get(\"apiSecret\");",
                  "",
                  "// Use TextEncoder to encode the string",
                  "const encoder = new TextEncoder();",
                  "const keyData = encoder.encode(apiSecret);",
                  "const data = encoder.encode(payload);",
                  "",
                  "// Create HMAC with SHA-256",
                  "crypto.subtle.importKey(",
                  "    'raw',",
                  "    keyData,",
                  "    { name: 'HMAC', hash: 'SHA-256' },",
                  "    false,",
                  "    ['sign']",
                  ").then(key => {",
                  "    return crypto.subtle.sign('HMAC', key, data);",
                  "}).then(signature => {",
                  "    const hmacBase64 = btoa(String.fromCharCode(...new Uint8Array(signature)));",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Hmac',",
                  "        value: `${apiAppId}:${hmacBase64}`",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Method',",
                  "        value: 'customer.create'",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'Content-Type',",
                  "        value: 'application/json'",
                  "    });",
                  "});",
                  ""
                ],
                "type": "text/javascript",
                "packages": {}
              }
            }
          ],
          "protocolProfileBehavior": {
            "disableBodyPruning": true
          },
          "request": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{{requestBody}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}",
              "host": [
                "{{baseUrl}}"
              ]
            }
          },
          "response": []
        },
        {
          "name": "customer.read",
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "exec": [
                  "const payload = JSON.stringify({",
                  "  customer_ident: \"46yq1898qmohrz57\", // see response from customer.create",
                  "});",
                  "",
                  "pm.environment.set(\"requestBody\", payload);",
                  "",
                  "// Copy the credential from billware (\"App\" => \"API\" => \"Show Credentials\")",
                  "// Change them in Postman -> Collection -> billware API -> Variables",
                  "const apiAppId = pm.collectionVariables.get(\"apiAppId\");",
                  "const apiSecret = pm.collectionVariables.get(\"apiSecret\");",
                  "",
                  "// Use TextEncoder to encode the string",
                  "const encoder = new TextEncoder();",
                  "const keyData = encoder.encode(apiSecret);",
                  "const data = encoder.encode(payload);",
                  "",
                  "// Create HMAC with SHA-256",
                  "crypto.subtle.importKey(",
                  "    'raw',",
                  "    keyData,",
                  "    { name: 'HMAC', hash: 'SHA-256' },",
                  "    false,",
                  "    ['sign']",
                  ").then(key => {",
                  "    return crypto.subtle.sign('HMAC', key, data);",
                  "}).then(signature => {",
                  "    const hmacBase64 = btoa(String.fromCharCode(...new Uint8Array(signature)));",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Hmac',",
                  "        value: `${apiAppId}:${hmacBase64}`",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Method',",
                  "        value: 'customer.read'",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'Content-Type',",
                  "        value: 'application/json'",
                  "    });",
                  "});",
                  ""
                ],
                "type": "text/javascript",
                "packages": {}
              }
            }
          ],
          "protocolProfileBehavior": {
            "disableBodyPruning": true
          },
          "request": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{{requestBody}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}",
              "host": [
                "{{baseUrl}}"
              ]
            }
          },
          "response": []
        },
        {
          "name": "customer.update",
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "exec": [
                  "const payload = JSON.stringify({",
                  "  customer_ident: \"46yq1898qmohrz57\", // see response from customer.create",
                  "  bill_firstname: \"Moritz\",",
                  "});",
                  "",
                  "pm.environment.set(\"requestBody\", payload);",
                  "",
                  "// Copy the credential from billware (\"App\" => \"API\" => \"Show Credentials\")",
                  "// Change them in Postman -> Collection -> billware API -> Variables",
                  "const apiAppId = pm.collectionVariables.get(\"apiAppId\");",
                  "const apiSecret = pm.collectionVariables.get(\"apiSecret\");",
                  "",
                  "// Use TextEncoder to encode the string",
                  "const encoder = new TextEncoder();",
                  "const keyData = encoder.encode(apiSecret);",
                  "const data = encoder.encode(payload);",
                  "",
                  "// Create HMAC with SHA-256",
                  "crypto.subtle.importKey(",
                  "    'raw',",
                  "    keyData,",
                  "    { name: 'HMAC', hash: 'SHA-256' },",
                  "    false,",
                  "    ['sign']",
                  ").then(key => {",
                  "    return crypto.subtle.sign('HMAC', key, data);",
                  "}).then(signature => {",
                  "    const hmacBase64 = btoa(String.fromCharCode(...new Uint8Array(signature)));",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Hmac',",
                  "        value: `${apiAppId}:${hmacBase64}`",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Method',",
                  "        value: 'customer.update'",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'Content-Type',",
                  "        value: 'application/json'",
                  "    });",
                  "});",
                  ""
                ],
                "type": "text/javascript",
                "packages": {}
              }
            }
          ],
          "protocolProfileBehavior": {
            "disableBodyPruning": true
          },
          "request": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{{requestBody}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}",
              "host": [
                "{{baseUrl}}"
              ]
            }
          },
          "response": []
        },
        {
          "name": "customer.delete",
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "exec": [
                  "const payload = JSON.stringify({",
                  "  customer_ident: \"46yq1898qmohrz57\", // see response from customer.create",
                  "});",
                  "",
                  "pm.environment.set(\"requestBody\", payload);",
                  "",
                  "// Copy the credential from billware (\"App\" => \"API\" => \"Show Credentials\")",
                  "// Change them in Postman -> Collection -> billware API -> Variables",
                  "const apiAppId = pm.collectionVariables.get(\"apiAppId\");",
                  "const apiSecret = pm.collectionVariables.get(\"apiSecret\");",
                  "",
                  "// Use TextEncoder to encode the string",
                  "const encoder = new TextEncoder();",
                  "const keyData = encoder.encode(apiSecret);",
                  "const data = encoder.encode(payload);",
                  "",
                  "// Create HMAC with SHA-256",
                  "crypto.subtle.importKey(",
                  "    'raw',",
                  "    keyData,",
                  "    { name: 'HMAC', hash: 'SHA-256' },",
                  "    false,",
                  "    ['sign']",
                  ").then(key => {",
                  "    return crypto.subtle.sign('HMAC', key, data);",
                  "}).then(signature => {",
                  "    const hmacBase64 = btoa(String.fromCharCode(...new Uint8Array(signature)));",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Hmac',",
                  "        value: `${apiAppId}:${hmacBase64}`",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Method',",
                  "        value: 'customer.delete'",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'Content-Type',",
                  "        value: 'application/json'",
                  "    });",
                  "});",
                  ""
                ],
                "type": "text/javascript",
                "packages": {}
              }
            }
          ],
          "protocolProfileBehavior": {
            "disableBodyPruning": true
          },
          "request": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{{requestBody}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}",
              "host": [
                "{{baseUrl}}"
              ]
            }
          },
          "response": []
        },
        {
          "name": "customer.exists",
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "exec": [
                  "const payload = JSON.stringify({",
                  "  customer_ident: \"46yq1898qmohrz57\", // see response from customer.create",
                  "});",
                  "",
                  "pm.environment.set(\"requestBody\", payload);",
                  "",
                  "// Copy the credential from billware (\"App\" => \"API\" => \"Show Credentials\")",
                  "// Change them in Postman -> Collection -> billware API -> Variables",
                  "const apiAppId = pm.collectionVariables.get(\"apiAppId\");",
                  "const apiSecret = pm.collectionVariables.get(\"apiSecret\");",
                  "",
                  "// Use TextEncoder to encode the string",
                  "const encoder = new TextEncoder();",
                  "const keyData = encoder.encode(apiSecret);",
                  "const data = encoder.encode(payload);",
                  "",
                  "// Create HMAC with SHA-256",
                  "crypto.subtle.importKey(",
                  "    'raw',",
                  "    keyData,",
                  "    { name: 'HMAC', hash: 'SHA-256' },",
                  "    false,",
                  "    ['sign']",
                  ").then(key => {",
                  "    return crypto.subtle.sign('HMAC', key, data);",
                  "}).then(signature => {",
                  "    const hmacBase64 = btoa(String.fromCharCode(...new Uint8Array(signature)));",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Hmac',",
                  "        value: `${apiAppId}:${hmacBase64}`",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Method',",
                  "        value: 'customer.exists'",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'Content-Type',",
                  "        value: 'application/json'",
                  "    });",
                  "});",
                  ""
                ],
                "type": "text/javascript",
                "packages": {}
              }
            }
          ],
          "protocolProfileBehavior": {
            "disableBodyPruning": true
          },
          "request": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{{requestBody}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}",
              "host": [
                "{{baseUrl}}"
              ]
            }
          },
          "response": []
        },
        {
          "name": "address.create",
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "exec": [
                  "const payload = JSON.stringify({",
                  "  customer_ident: \"46yq1898qmohrz57\",  // see response from customer.create",
                  "  delivery_title: 0,                   // 0 = Mister",
                  "  delivery_firstname: \"Max\",",
                  "  delivery_lastname: \"Mustermann\",",
                  "  delivery_company: \"Muster GmbH\",",
                  "  delivery_street: \"Lieferweg 5\",",
                  "  delivery_street2: \"Etage 3\",",
                  "  delivery_zipcode: \"54321\",",
                  "  delivery_city: \"Lieferstadt\",",
                  "  delivery_country: \"DE\",",
                  "  delivery_phone: \"+49 987 6543210\",",
                  "  delivery_phone_mobile: \"+49 171 1234567\"",
                  "});",
                  "",
                  "pm.environment.set(\"requestBody\", payload);",
                  "",
                  "// Copy the credential from billware (\"App\" => \"API\" => \"Show Credentials\")",
                  "// Change them in Postman -> Collection -> billware API -> Variables",
                  "const apiAppId = pm.collectionVariables.get(\"apiAppId\");",
                  "const apiSecret = pm.collectionVariables.get(\"apiSecret\");",
                  "",
                  "// Use TextEncoder to encode the string",
                  "const encoder = new TextEncoder();",
                  "const keyData = encoder.encode(apiSecret);",
                  "const data = encoder.encode(payload);",
                  "",
                  "// Create HMAC with SHA-256",
                  "crypto.subtle.importKey(",
                  "    'raw',",
                  "    keyData,",
                  "    { name: 'HMAC', hash: 'SHA-256' },",
                  "    false,",
                  "    ['sign']",
                  ").then(key => {",
                  "    return crypto.subtle.sign('HMAC', key, data);",
                  "}).then(signature => {",
                  "    const hmacBase64 = btoa(String.fromCharCode(...new Uint8Array(signature)));",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Hmac',",
                  "        value: `${apiAppId}:${hmacBase64}`",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Method',",
                  "        value: 'address.create'",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'Content-Type',",
                  "        value: 'application/json'",
                  "    });",
                  "});",
                  ""
                ],
                "type": "text/javascript",
                "packages": {}
              }
            }
          ],
          "protocolProfileBehavior": {
            "disableBodyPruning": true
          },
          "request": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{{requestBody}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}",
              "host": [
                "{{baseUrl}}"
              ]
            }
          },
          "response": []
        },
        {
          "name": "address.exists",
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "exec": [
                  "const payload = JSON.stringify({",
                  "  address_ident: \"61636lu6Et7324W8\", // see response from address.create",
                  "});",
                  "",
                  "pm.environment.set(\"requestBody\", payload);",
                  "",
                  "// Copy the credential from billware (\"App\" => \"API\" => \"Show Credentials\")",
                  "// Change them in Postman -> Collection -> billware API -> Variables",
                  "const apiAppId = pm.collectionVariables.get(\"apiAppId\");",
                  "const apiSecret = pm.collectionVariables.get(\"apiSecret\");",
                  "",
                  "// Use TextEncoder to encode the string",
                  "const encoder = new TextEncoder();",
                  "const keyData = encoder.encode(apiSecret);",
                  "const data = encoder.encode(payload);",
                  "",
                  "// Create HMAC with SHA-256",
                  "crypto.subtle.importKey(",
                  "    'raw',",
                  "    keyData,",
                  "    { name: 'HMAC', hash: 'SHA-256' },",
                  "    false,",
                  "    ['sign']",
                  ").then(key => {",
                  "    return crypto.subtle.sign('HMAC', key, data);",
                  "}).then(signature => {",
                  "    const hmacBase64 = btoa(String.fromCharCode(...new Uint8Array(signature)));",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Hmac',",
                  "        value: `${apiAppId}:${hmacBase64}`",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Method',",
                  "        value: 'address.exists'",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'Content-Type',",
                  "        value: 'application/json'",
                  "    });",
                  "});",
                  ""
                ],
                "type": "text/javascript",
                "packages": {}
              }
            }
          ],
          "protocolProfileBehavior": {
            "disableBodyPruning": true
          },
          "request": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{{requestBody}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}",
              "host": [
                "{{baseUrl}}"
              ]
            }
          },
          "response": []
        }
      ]
    },
    {
      "name": "Orders",
      "item": [
        {
          "name": "order.create",
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "exec": [
                  "const payload = JSON.stringify({",
                  "  customer_ident: \"46yq1898qmohrz57\",  // see response from customer.create",
                  "  order_date: \"2025-07-16 10:00:00\",",
                  "  due_date: \"2025-07-30 00:00:00\",",
                  "  is_paid: 0,",
                  "  invoice_number: null,",
                  "  is_quotation: 0,",
                  "  small_entrepreneur: 0,",
                  "  reverse_charge: 0,",
                  "  intra_community: 0,",
                  "  term_of_credit: 14,",
                  "  user_note: \"Bitte schnell liefern – Kaninchenstall wird dringend benötigt!\",",
                  "",
                  "  discount:{",
                  "      title: \"Sonderrabatt\",",
                  "      calculation_type: 0,      // 0 = Prozent",
                  "      price_type: 1,            // 1 = Brutto",
                  "      value: 10.0               // 10 % Rabatt",
                  "    },",
                  "",
                  "  payment:{",
                  "      name: \"Vorkasse\",",
                  "      calculation_type: 1,      // 1 = absolut",
                  "      price_type: 1,",
                  "      value: 0.00,",
                  "      cashback_active: 0,",
                  "      cashback: 0.0,",
                  "      cashback_days: 0",
                  "    },",
                  "",
                  "  shipping:{",
                  "      name: \"DHL Paket\",",
                  "      tracking: \"1234567890\",",
                  "      calculation_type: 1,      // 1 = absolut",
                  "      price_type: 1,",
                  "      value: 5.99",
                  "    },",
                  "",
                  "  articles: [",
                  "    {",
                  "      article_title: \"Kaninchenstall XL\",",
                  "      article_purchase_price: 75.00,",
                  "      article_price: 129.99,",
                  "      article_quantity: 1,",
                  "      article_country: \"DE\",",
                  "      article_tax_rate: 19.0,",
                  "      article_subtitle: \"Wetterfest mit Auslauf\",",
                  "      article_position: 1,",
                  "      article_unit: \"unit_ppu\",",
                  "      article_ean: \"4012345678901\",",
                  "      article_nr: \"KAN-XL-2025\"",
                  "    }",
                  "  ]",
                  "});",
                  "",
                  "pm.environment.set(\"requestBody\", payload);",
                  "",
                  "// Copy the credential from billware (\"App\" => \"API\" => \"Show Credentials\")",
                  "// Change them in Postman -> Collection -> billware API -> Variables",
                  "const apiAppId = pm.collectionVariables.get(\"apiAppId\");",
                  "const apiSecret = pm.collectionVariables.get(\"apiSecret\");",
                  "",
                  "// Use TextEncoder to encode the string",
                  "const encoder = new TextEncoder();",
                  "const keyData = encoder.encode(apiSecret);",
                  "const data = encoder.encode(payload);",
                  "",
                  "// Create HMAC with SHA-256",
                  "crypto.subtle.importKey(",
                  "    'raw',",
                  "    keyData,",
                  "    { name: 'HMAC', hash: 'SHA-256' },",
                  "    false,",
                  "    ['sign']",
                  ").then(key => {",
                  "    return crypto.subtle.sign('HMAC', key, data);",
                  "}).then(signature => {",
                  "    const hmacBase64 = btoa(String.fromCharCode(...new Uint8Array(signature)));",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Hmac',",
                  "        value: `${apiAppId}:${hmacBase64}`",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Method',",
                  "        value: 'order.create'",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'Content-Type',",
                  "        value: 'application/json'",
                  "    });",
                  "});",
                  ""
                ],
                "type": "text/javascript",
                "packages": {}
              }
            }
          ],
          "protocolProfileBehavior": {
            "disableBodyPruning": true
          },
          "request": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{{requestBody}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}",
              "host": [
                "{{baseUrl}}"
              ]
            }
          },
          "response": []
        },
        {
          "name": "order.read",
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "exec": [
                  "const payload = JSON.stringify({",
                  "  order_ident: \"aswm5o5i2v5hwlbp\", // see response from order.create",
                  "});",
                  "",
                  "pm.environment.set(\"requestBody\", payload);",
                  "",
                  "// Copy the credential from billware (\"App\" => \"API\" => \"Show Credentials\")",
                  "// Change them in Postman -> Collection -> billware API -> Variables",
                  "const apiAppId = pm.collectionVariables.get(\"apiAppId\");",
                  "const apiSecret = pm.collectionVariables.get(\"apiSecret\");",
                  "",
                  "// Use TextEncoder to encode the string",
                  "const encoder = new TextEncoder();",
                  "const keyData = encoder.encode(apiSecret);",
                  "const data = encoder.encode(payload);",
                  "",
                  "// Create HMAC with SHA-256",
                  "crypto.subtle.importKey(",
                  "    'raw',",
                  "    keyData,",
                  "    { name: 'HMAC', hash: 'SHA-256' },",
                  "    false,",
                  "    ['sign']",
                  ").then(key => {",
                  "    return crypto.subtle.sign('HMAC', key, data);",
                  "}).then(signature => {",
                  "    const hmacBase64 = btoa(String.fromCharCode(...new Uint8Array(signature)));",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Hmac',",
                  "        value: `${apiAppId}:${hmacBase64}`",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Method',",
                  "        value: 'order.read'",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'Content-Type',",
                  "        value: 'application/json'",
                  "    });",
                  "});",
                  ""
                ],
                "type": "text/javascript",
                "packages": {}
              }
            }
          ],
          "protocolProfileBehavior": {
            "disableBodyPruning": true
          },
          "request": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{{requestBody}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}",
              "host": [
                "{{baseUrl}}"
              ]
            }
          },
          "response": []
        },
        {
          "name": "order.list",
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "exec": [
                  "const payload = JSON.stringify({",
                  "    \"start_date\":\"2025-01-01 00:00:00\",",
                  "    \"end_date\":\"2025-08-01 00:00:00\",",
                  "    \"date_type\":\"date_updated\",",
                  "    \"page\":1",
                  "});",
                  "",
                  "pm.environment.set(\"requestBody\", payload);",
                  "",
                  "// Copy the credential from billware (\"App\" => \"API\" => \"Show Credentials\")",
                  "// Change them in Postman -> Collection -> billware API -> Variables",
                  "const apiAppId = pm.collectionVariables.get(\"apiAppId\");",
                  "const apiSecret = pm.collectionVariables.get(\"apiSecret\");",
                  "",
                  "// Use TextEncoder to encode the string",
                  "const encoder = new TextEncoder();",
                  "const keyData = encoder.encode(apiSecret);",
                  "const data = encoder.encode(payload);",
                  "",
                  "// Create HMAC with SHA-256",
                  "crypto.subtle.importKey(",
                  "    'raw',",
                  "    keyData,",
                  "    { name: 'HMAC', hash: 'SHA-256' },",
                  "    false,",
                  "    ['sign']",
                  ").then(key => {",
                  "    return crypto.subtle.sign('HMAC', key, data);",
                  "}).then(signature => {",
                  "    const hmacBase64 = btoa(String.fromCharCode(...new Uint8Array(signature)));",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Hmac',",
                  "        value: `${apiAppId}:${hmacBase64}`",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Method',",
                  "        value: 'order.list'",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'Content-Type',",
                  "        value: 'application/json'",
                  "    });",
                  "});",
                  ""
                ],
                "type": "text/javascript",
                "packages": {}
              }
            },
            {
              "listen": "test",
              "script": {
                "exec": [
                  ""
                ],
                "type": "text/javascript",
                "packages": {}
              }
            }
          ],
          "protocolProfileBehavior": {
            "disableBodyPruning": true
          },
          "request": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{{requestBody}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}",
              "host": [
                "{{baseUrl}}"
              ]
            }
          },
          "response": []
        },
        {
          "name": "order.update",
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "exec": [
                  "const payload = JSON.stringify({",
                  "  order_ident: \"aswm5o5i2v5hwlbp\", // see response from order.create",
                  "  user_note: \"An example Text\",",
                  "});",
                  "",
                  "pm.environment.set(\"requestBody\", payload);",
                  "",
                  "// Copy the credential from billware (\"App\" => \"API\" => \"Show Credentials\")",
                  "// Change them in Postman -> Collection -> billware API -> Variables",
                  "const apiAppId = pm.collectionVariables.get(\"apiAppId\");",
                  "const apiSecret = pm.collectionVariables.get(\"apiSecret\");",
                  "",
                  "// Use TextEncoder to encode the string",
                  "const encoder = new TextEncoder();",
                  "const keyData = encoder.encode(apiSecret);",
                  "const data = encoder.encode(payload);",
                  "",
                  "// Create HMAC with SHA-256",
                  "crypto.subtle.importKey(",
                  "    'raw',",
                  "    keyData,",
                  "    { name: 'HMAC', hash: 'SHA-256' },",
                  "    false,",
                  "    ['sign']",
                  ").then(key => {",
                  "    return crypto.subtle.sign('HMAC', key, data);",
                  "}).then(signature => {",
                  "    const hmacBase64 = btoa(String.fromCharCode(...new Uint8Array(signature)));",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Hmac',",
                  "        value: `${apiAppId}:${hmacBase64}`",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Method',",
                  "        value: 'order.update'",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'Content-Type',",
                  "        value: 'application/json'",
                  "    });",
                  "});"
                ],
                "type": "text/javascript",
                "packages": {}
              }
            }
          ],
          "protocolProfileBehavior": {
            "disableBodyPruning": true
          },
          "request": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{{requestBody}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}",
              "host": [
                "{{baseUrl}}"
              ]
            }
          },
          "response": []
        },
        {
          "name": "order.delete",
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "exec": [
                  "const payload = JSON.stringify({",
                  "  order_ident: \"aswm5o5i2v5hwlbp\", // see response from order.create",
                  "});",
                  "",
                  "pm.environment.set(\"requestBody\", payload);",
                  "",
                  "// Copy the credential from billware (\"App\" => \"API\" => \"Show Credentials\")",
                  "// Change them in Postman -> Collection -> billware API -> Variables",
                  "const apiAppId = pm.collectionVariables.get(\"apiAppId\");",
                  "const apiSecret = pm.collectionVariables.get(\"apiSecret\");",
                  "",
                  "// Use TextEncoder to encode the string",
                  "const encoder = new TextEncoder();",
                  "const keyData = encoder.encode(apiSecret);",
                  "const data = encoder.encode(payload);",
                  "",
                  "// Create HMAC with SHA-256",
                  "crypto.subtle.importKey(",
                  "    'raw',",
                  "    keyData,",
                  "    { name: 'HMAC', hash: 'SHA-256' },",
                  "    false,",
                  "    ['sign']",
                  ").then(key => {",
                  "    return crypto.subtle.sign('HMAC', key, data);",
                  "}).then(signature => {",
                  "    const hmacBase64 = btoa(String.fromCharCode(...new Uint8Array(signature)));",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Hmac',",
                  "        value: `${apiAppId}:${hmacBase64}`",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Method',",
                  "        value: 'order.delete'",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'Content-Type',",
                  "        value: 'application/json'",
                  "    });",
                  "});"
                ],
                "type": "text/javascript",
                "packages": {}
              }
            }
          ],
          "protocolProfileBehavior": {
            "disableBodyPruning": true
          },
          "request": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{{requestBody}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}",
              "host": [
                "{{baseUrl}}"
              ]
            }
          },
          "response": []
        },
        {
          "name": "order.exists",
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "exec": [
                  "const payload = JSON.stringify({",
                  "  order_ident: \"aswm5o5i2v5hwlbp\", // see response from order.create",
                  "});",
                  "",
                  "pm.environment.set(\"requestBody\", payload);",
                  "",
                  "// Copy the credential from billware (\"App\" => \"API\" => \"Show Credentials\")",
                  "// Change them in Postman -> Collection -> billware API -> Variables",
                  "const apiAppId = pm.collectionVariables.get(\"apiAppId\");",
                  "const apiSecret = pm.collectionVariables.get(\"apiSecret\");",
                  "",
                  "// Use TextEncoder to encode the string",
                  "const encoder = new TextEncoder();",
                  "const keyData = encoder.encode(apiSecret);",
                  "const data = encoder.encode(payload);",
                  "",
                  "// Create HMAC with SHA-256",
                  "crypto.subtle.importKey(",
                  "    'raw',",
                  "    keyData,",
                  "    { name: 'HMAC', hash: 'SHA-256' },",
                  "    false,",
                  "    ['sign']",
                  ").then(key => {",
                  "    return crypto.subtle.sign('HMAC', key, data);",
                  "}).then(signature => {",
                  "    const hmacBase64 = btoa(String.fromCharCode(...new Uint8Array(signature)));",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Hmac',",
                  "        value: `${apiAppId}:${hmacBase64}`",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Method',",
                  "        value: 'order.exists'",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'Content-Type',",
                  "        value: 'application/json'",
                  "    });",
                  "});"
                ],
                "type": "text/javascript",
                "packages": {}
              }
            }
          ],
          "protocolProfileBehavior": {
            "disableBodyPruning": true
          },
          "request": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{{requestBody}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}",
              "host": [
                "{{baseUrl}}"
              ]
            }
          },
          "response": []
        },
        {
          "name": "order.createPayment",
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "exec": [
                  "const payload = JSON.stringify({",
                  "  order_ident: \"aswm5o5i2v5hwlbp\", // see response from order.create",
                  "  \"amount\": 144.61,",
                  "  \"fee\": 0,",
                  "  \"payment_name\": \"payment_paypal\",",
                  "  \"date_paid\": \"2025-07-16 12:30:00\",",
                  "  \"external_ident\": \"TRANS123456\",",
                  "  \"set_paid\": 1",
                  "});",
                  "",
                  "pm.environment.set(\"requestBody\", payload);",
                  "",
                  "// Copy the credential from billware (\"App\" => \"API\" => \"Show Credentials\")",
                  "// Change them in Postman -> Collection -> billware API -> Variables",
                  "const apiAppId = pm.collectionVariables.get(\"apiAppId\");",
                  "const apiSecret = pm.collectionVariables.get(\"apiSecret\");",
                  "",
                  "// Use TextEncoder to encode the string",
                  "const encoder = new TextEncoder();",
                  "const keyData = encoder.encode(apiSecret);",
                  "const data = encoder.encode(payload);",
                  "",
                  "// Create HMAC with SHA-256",
                  "crypto.subtle.importKey(",
                  "    'raw',",
                  "    keyData,",
                  "    { name: 'HMAC', hash: 'SHA-256' },",
                  "    false,",
                  "    ['sign']",
                  ").then(key => {",
                  "    return crypto.subtle.sign('HMAC', key, data);",
                  "}).then(signature => {",
                  "    const hmacBase64 = btoa(String.fromCharCode(...new Uint8Array(signature)));",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Hmac',",
                  "        value: `${apiAppId}:${hmacBase64}`",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Method',",
                  "        value: 'order.createPayment'",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'Content-Type',",
                  "        value: 'application/json'",
                  "    });",
                  "});"
                ],
                "type": "text/javascript",
                "packages": {}
              }
            }
          ],
          "protocolProfileBehavior": {
            "disableBodyPruning": true
          },
          "request": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{{requestBody}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}",
              "host": [
                "{{baseUrl}}"
              ]
            }
          },
          "response": []
        },
        {
          "name": "order.createInvoiceNr",
          "event": [
            {
              "listen": "prerequest",
              "script": {
                "exec": [
                  "const payload = JSON.stringify({",
                  "  order_ident: \"aswm5o5i2v5hwlbp\", // see response from order.create",
                  "});",
                  "",
                  "pm.environment.set(\"requestBody\", payload);",
                  "",
                  "// Copy the credential from billware (\"App\" => \"API\" => \"Show Credentials\")",
                  "// Change them in Postman -> Collection -> billware API -> Variables",
                  "const apiAppId = pm.collectionVariables.get(\"apiAppId\");",
                  "const apiSecret = pm.collectionVariables.get(\"apiSecret\");",
                  "",
                  "// Use TextEncoder to encode the string",
                  "const encoder = new TextEncoder();",
                  "const keyData = encoder.encode(apiSecret);",
                  "const data = encoder.encode(payload);",
                  "",
                  "// Create HMAC with SHA-256",
                  "crypto.subtle.importKey(",
                  "    'raw',",
                  "    keyData,",
                  "    { name: 'HMAC', hash: 'SHA-256' },",
                  "    false,",
                  "    ['sign']",
                  ").then(key => {",
                  "    return crypto.subtle.sign('HMAC', key, data);",
                  "}).then(signature => {",
                  "    const hmacBase64 = btoa(String.fromCharCode(...new Uint8Array(signature)));",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Hmac',",
                  "        value: `${apiAppId}:${hmacBase64}`",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'X-Bw-Method',",
                  "        value: 'order.createInvoiceNr'",
                  "    });",
                  "",
                  "    pm.request.headers.add({",
                  "        key: 'Content-Type',",
                  "        value: 'application/json'",
                  "    });",
                  "});"
                ],
                "type": "text/javascript",
                "packages": {}
              }
            }
          ],
          "protocolProfileBehavior": {
            "disableBodyPruning": true
          },
          "request": {
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{{requestBody}}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}",
              "host": [
                "{{baseUrl}}"
              ]
            }
          },
          "response": []
        }
      ]
    }
  ],
  "event": [
    {
      "listen": "prerequest",
      "script": {
        "type": "text/javascript",
        "packages": {},
        "exec": [
          ""
        ]
      }
    },
    {
      "listen": "test",
      "script": {
        "type": "text/javascript",
        "packages": {},
        "exec": [
          ""
        ]
      }
    }
  ],
  "variable": [
    {
      "key": "apiAppId",
      "value": "YOUR_BILLWARE_API_APPID",
      "type": "string"
    },
    {
      "key": "apiSecret",
      "value": "YOUR_BILLWARE_API_SECRET",
      "type": "string"
    },
    {
      "key": "baseUrl",
      "value": "https://www.billware.de/api/",
      "type": "string"
    }
  ]
}
