{
  "elementsLearnedData": [],
  "elementsTestData": [],
  "flow": {
    "id": "B8FEBC57-E2BA-4046-81C2-E6EE049BEFE9",
    "name": "FreshBooks: Stripe payments matched to invoices"
  },
  "flowVersion": {
    "clientMetadata": {
      "viewport": {
        "x": 136.56122708750718,
        "y": 52.4812398072728,
        "zoom": 0.5
      },
      "autoSave": true,
      "descriptions": {
        "flow": "When a Stripe payment succeeds, finds the customer's FreshBooks client and the open invoice it pays, by invoice number or exact amount, and records the payment with the Stripe reference. Anything it cannot match goes to finance in Slack.",
        "initialData": "",
        "initialDataFields": {}
      }
    },
    "description": "When a Stripe payment succeeds, finds the customer's FreshBooks client and the open invoice it pays, by invoice number or exact amount, and records the payment with the Stripe reference. Anything it cannot match goes to finance in Slack.",
    "elements": [
      {
        "clientMetadata": {
          "notes": "Lists your clients, with optional filters. Use this to look up customers or pull a list to work through.",
          "elementId": "EXTENSION:::SHARED:::default:::freshbooks:::findClients",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Find the client in FreshBooks Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::freshbooks:::findClients",
          "legacyElementId": "JS###v1###FreshBooksService###findClients",
          "methodName": "findClients",
          "position": {
            "x": 308,
            "y": 558
          }
        },
        "flowElementId": "E2490E70-1D39-433C-B212-B3CC0789013C",
        "groupId": null,
        "id": "F75EC2C5-E813-4A9E-8E6E-DA5FE275C48F",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "search",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Stripe customer",
                    "subPathSegments": [
                      {
                        "key": "email",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "14BD483A-2B2C-4245-B0FD-4B6A804ABBDD"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "onlyWithOutstanding",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "maxResults",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 100
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Find the client in FreshBooks', Error: OAuth Connection is required",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "findClients",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Clients",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "freshbooks",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Find the client in FreshBooks",
        "nextElementIds": [
          "C422A343-DC03-46DB-BC14-BC04E67EC62F"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Match the payment to an invoice Result"
          },
          "position": {
            "x": 1264,
            "y": 850
          }
        },
        "flowElementId": "5D49D53B-BFE4-4AC7-BBEC-8A1C6A299717",
        "groupId": null,
        "id": "C103B249-C6A5-4886-9E62-FC539808FDB3",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "invoices",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Client invoices",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "70DCAAFC-3F0C-4FD7-B90A-FABE69A61213"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "pay",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Payment details",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "191A44A5-F4C5-45F8-AC2C-F9B31AD4B751"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const list = Array.isArray(invoices) ? invoices : [];\nconst open = list.filter(i => !['paid', 'draft'].includes(String(i.v3_status || '').toLowerCase()) && i.vis_state !== 1);\nconst owed = i => Number((i.outstanding && i.outstanding.amount) || (i.amount && i.amount.amount) || 0);\nconst code = i => String(i.currency_code || (i.amount && i.amount.code) || '').toUpperCase();\nconst sameCurrency = i => !code(i) || !pay.currency || code(i) === pay.currency;\nconst escape = s => String(s).replace(/[.*+?^$()|[\\]\\\\]/g, '\\\\$&');\nconst ref = String(pay.reference || '');\nlet how = 'invoice number';\nlet hit = open.find(i => i.invoice_number && sameCurrency(i) && owed(i) + 0.005 >= pay.amount && new RegExp('(^|[^0-9A-Za-z])' + escape(i.invoice_number) + '($|[^0-9A-Za-z])').test(ref));\nif (!hit) {\n  how = 'amount';\n  hit = open\n    .filter(i => sameCurrency(i) && Math.abs(owed(i) - pay.amount) < 0.005)\n    .sort((a, b) => String(a.create_date || '').localeCompare(String(b.create_date || '')))[0];\n}\nreturn {\n  matched: Boolean(hit),\n  invoiceId: hit ? String(hit.invoiceid || hit.id) : '',\n  invoiceNumber: hit ? String(hit.invoice_number || '') : '',\n  how: hit ? how : '',\n};"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Invoice match",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Match the payment to an invoice",
        "nextElementIds": [
          "9922B8F4-B46A-4DD6-8100-7B6C3F357AA7"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 690,
            "y": 230
          }
        },
        "flowElementId": "D2BAB0B2-E0BD-4FD0-89B3-46FFBDEE1558",
        "groupId": null,
        "id": "380527E6-01EA-4061-B1CA-F90D6A3C44DA",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "43ea8c68-dbb8-46a0-9977-bb462adbfa39",
                "nestedOperation": null,
                "operation": "isNotEmpty",
                "property": {
                  "expression": [
                    {
                      "id": "RESULT",
                      "label": "Payment",
                      "subPathSegments": [
                        {
                          "key": "customer",
                          "optional": false
                        }
                      ],
                      "type": "TRIGGER_DATA",
                      "value": "30C61A44-FAE5-4B71-9CFB-D98DB0CC0A1A"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "STRING",
                "values": []
              }
            ],
            "grouping": [
              "43ea8c68-dbb8-46a0-9977-bb462adbfa39"
            ]
          },
          "elseComponent": {
            "componentId": "3433F0A4-087D-4C2B-9216-D4DB8FF2E5E3",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "hascust",
          "storeResult": false,
          "thenComponent": {
            "componentId": "14BD483A-2B2C-4245-B0FD-4B6A804ABBDD",
            "componentType": "ELEMENT"
          }
        },
        "name": "Customer on the payment?",
        "nextElementIds": [
          "14BD483A-2B2C-4245-B0FD-4B6A804ABBDD",
          "3433F0A4-087D-4C2B-9216-D4DB8FF2E5E3"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 632,
            "y": 704
          }
        },
        "flowElementId": "02F69450-252D-49C3-A730-630E210739D6",
        "groupId": null,
        "id": "A8AF8C69-CEA1-4A53-8938-22D23E35C0F9",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "7a957e6c-6a91-4558-8c6f-bceb6d2b5476",
                "nestedOperation": null,
                "operation": "isTrue",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Client match",
                      "subPathSegments": [
                        {
                          "key": "found",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "C422A343-DC03-46DB-BC14-BC04E67EC62F"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "BOOLEAN",
                "values": []
              }
            ],
            "grouping": [
              "7a957e6c-6a91-4558-8c6f-bceb6d2b5476"
            ]
          },
          "elseComponent": {
            "componentId": "3433F0A4-087D-4C2B-9216-D4DB8FF2E5E3",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "found",
          "storeResult": false,
          "thenComponent": {
            "componentId": "70DCAAFC-3F0C-4FD7-B90A-FABE69A61213",
            "componentType": "ELEMENT"
          }
        },
        "name": "Client in FreshBooks?",
        "nextElementIds": [
          "3433F0A4-087D-4C2B-9216-D4DB8FF2E5E3",
          "70DCAAFC-3F0C-4FD7-B90A-FABE69A61213"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "elementId": "condition",
          "isFirstElement": false,
          "blockDefinitionId": "condition",
          "position": {
            "x": 1332,
            "y": 672
          }
        },
        "flowElementId": "05461086-F10C-4531-B312-1D214C0E1567",
        "groupId": null,
        "id": "9922B8F4-B46A-4DD6-8100-7B6C3F357AA7",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "condition": {
            "conditionParts": [
              {
                "id": "c2a7ba18-0c40-4cec-8d20-b21167a4bd6f",
                "nestedOperation": null,
                "operation": "isTrue",
                "property": {
                  "expression": [
                    {
                      "id": "ELEMENT_RESULT",
                      "label": "Invoice match",
                      "subPathSegments": [
                        {
                          "key": "matched",
                          "optional": false
                        }
                      ],
                      "type": "ELEMENT_LINK",
                      "value": "C103B249-C6A5-4886-9E62-FC539808FDB3"
                    }
                  ],
                  "mode": "EXPRESSION",
                  "parseJsonString": false,
                  "resultType": null
                },
                "propertyType": "BOOLEAN",
                "values": []
              }
            ],
            "grouping": [
              "c2a7ba18-0c40-4cec-8d20-b21167a4bd6f"
            ]
          },
          "elseComponent": {
            "componentId": "3433F0A4-087D-4C2B-9216-D4DB8FF2E5E3",
            "componentType": "ELEMENT"
          },
          "logging": null,
          "onFailElemId": null,
          "resultAlias": "ifound",
          "storeResult": false,
          "thenComponent": {
            "componentId": "C9960D12-CC36-4F6C-A84C-CA60FD5CD67F",
            "componentType": "ELEMENT"
          }
        },
        "name": "Open invoice found?",
        "nextElementIds": [
          "C9960D12-CC36-4F6C-A84C-CA60FD5CD67F",
          "3433F0A4-087D-4C2B-9216-D4DB8FF2E5E3"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "preferredDateFormats": []
        },
        "type": "CONDITION"
      },
      {
        "clientMetadata": {
          "notes": "Records a payment received against an invoice. Use this to mark an invoice paid (in full or partially).",
          "elementId": "EXTENSION:::SHARED:::default:::freshbooks:::recordPayment",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Record the payment in FreshBooks Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::freshbooks:::recordPayment",
          "legacyElementId": "JS###v1###FreshBooksService###recordPayment",
          "methodName": "recordPayment",
          "position": {
            "x": 1616,
            "y": 506
          }
        },
        "flowElementId": "B474C8AB-CE2B-44A6-AB9B-6F87122E4707",
        "groupId": null,
        "id": "C9960D12-CC36-4F6C-A84C-CA60FD5CD67F",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "invoiceId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Invoice match",
                    "subPathSegments": [
                      {
                        "key": "invoiceId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C103B249-C6A5-4886-9E62-FC539808FDB3"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "amount",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Payment details",
                    "subPathSegments": [
                      {
                        "key": "amount",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "191A44A5-F4C5-45F8-AC2C-F9B31AD4B751"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "currency",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Payment details",
                    "subPathSegments": [
                      {
                        "key": "currency",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "191A44A5-F4C5-45F8-AC2C-F9B31AD4B751"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "date",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Payment details",
                    "subPathSegments": [
                      {
                        "key": "date",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "191A44A5-F4C5-45F8-AC2C-F9B31AD4B751"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "type",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Payment details",
                    "subPathSegments": [
                      {
                        "key": "method",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "191A44A5-F4C5-45F8-AC2C-F9B31AD4B751"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "notifyClient",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "note",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Payment details",
                    "subPathSegments": [
                      {
                        "key": "note",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "191A44A5-F4C5-45F8-AC2C-F9B31AD4B751"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Record the payment in FreshBooks', Error: OAuth Connection is required",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "recordPayment",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Recorded payment",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "freshbooks",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Record the payment in FreshBooks",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Retrieves the details of an existing customer. You need to supply the unique customer ID from either a customer creation request or the Stripe dashboard.",
          "elementId": "EXTENSION:::SHARED:::default:::stripe:::getCustomer",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Get the Stripe customer Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::stripe:::getCustomer",
          "legacyElementId": "JS###v1###Stripe###getCustomer",
          "methodName": "getCustomer",
          "position": {
            "x": 332.96207190545965,
            "y": 404.4628873236319
          }
        },
        "flowElementId": "78097DE0-E738-408F-902C-1B04B38DCEF2",
        "groupId": null,
        "id": "14BD483A-2B2C-4245-B0FD-4B6A804ABBDD",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "id",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Payment",
                    "subPathSegments": [
                      {
                        "key": "customer",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "30C61A44-FAE5-4B71-9CFB-D98DB0CC0A1A"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Get the Stripe customer', Error: OAuth Connection is required",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "getCustomer",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Stripe customer",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "stripe",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Get the Stripe customer",
        "nextElementIds": [
          "F75EC2C5-E813-4A9E-8E6E-DA5FE275C48F"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Sends messages to Slack channels with optional Block Kit rich layouts. Supports plain text with Slack formatting, or advanced Block Kit JSON for buttons, menus, and interactive elements. Returns the message timestamp and channel ID for later updates or tracking.",
          "elementId": "EXTENSION:::SHARED:::default:::slack:::sendMessageToChannel",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Send unmatched payment to finance Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::slack:::sendMessageToChannel",
          "legacyElementId": "JS###v1###Slack###sendMessageToChannel",
          "methodName": "sendMessageToChannel",
          "position": {
            "x": 1012,
            "y": 462
          }
        },
        "flowElementId": "C69B66C8-BE02-4196-8903-92EAE13728FD",
        "groupId": null,
        "id": "3433F0A4-087D-4C2B-9216-D4DB8FF2E5E3",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "channelId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ""
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "messageText",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": "A Stripe payment of "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Payment details",
                    "subPathSegments": [
                      {
                        "key": "amountText",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "191A44A5-F4C5-45F8-AC2C-F9B31AD4B751"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": " could not be matched to an open FreshBooks invoice, so it was not recorded. Stripe payment: "
                  },
                  {
                    "id": "RESULT",
                    "label": "Payment",
                    "subPathSegments": [
                      {
                        "key": "id",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "30C61A44-FAE5-4B71-9CFB-D98DB0CC0A1A"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ". Customer email: "
                  },
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Stripe customer",
                    "subPathSegments": [
                      {
                        "key": "email",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "14BD483A-2B2C-4245-B0FD-4B6A804ABBDD"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ". Description: "
                  },
                  {
                    "id": "RESULT",
                    "label": "Payment",
                    "subPathSegments": [
                      {
                        "key": "description",
                        "optional": false
                      }
                    ],
                    "type": "TRIGGER_DATA",
                    "value": "30C61A44-FAE5-4B71-9CFB-D98DB0CC0A1A"
                  },
                  {
                    "id": "TEXT",
                    "label": null,
                    "type": "INPUT",
                    "value": ". Please record it in FreshBooks by hand."
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "threadId",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "sendAsBot",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "botName",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "botIcon",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "replyBroadcast",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "K_FALSE",
                    "label": null,
                    "type": "KEYWORD",
                    "value": false
                  }
                ],
                "mode": "BASIC",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "imageURL",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "blocks",
              "type": "COMPLEX_LIST",
              "value": []
            }
          ],
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "sendMessageToChannel",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Unmatched payment message",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "slack",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Send unmatched payment to finance",
        "nextElementIds": [],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "notes": "Triggers when a payment is received: a Payment Intent completes successfully (`payment_intent.succeeded`), whether it came from Checkout, a Payment Link, an invoice or your own integration.",
          "elementId": "EXTENSION:::SHARED:::default:::stripe:::onPaymentIntentSucceeded",
          "isFirstElement": true,
          "blockDefinitionId": "EXTENSION:::SHARED:::default:::stripe:::onPaymentIntentSucceeded",
          "newElementId": "EXTENSION:::SHARED:::default:::stripe:::onPaymentIntentSucceeded",
          "legacyElementId": "JS###v1###Stripe###onPaymentIntentSucceeded",
          "methodName": "onPaymentIntentSucceeded",
          "position": {
            "x": 110,
            "y": 230
          }
        },
        "flowElementId": "B934ADCB-5F1E-497B-826C-8492FE946143",
        "groupId": null,
        "id": "30C61A44-FAE5-4B71-9CFB-D98DB0CC0A1A",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": "Block: 'Payment received in Stripe', Error: OAuth Connection is required",
            "valid": false
          },
          "condition": null,
          "connectionId": null,
          "dynamicData": [],
          "eventName": "onPaymentIntentSucceeded",
          "frequency": {
            "repeat": {
              "every": 300
            },
            "schedule": "custom"
          },
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": null
          },
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Payment",
          "serviceId": "stripe",
          "slaConditions": [],
          "staticData": {},
          "storeResult": true,
          "subtype": "POLLING",
          "type": "CUSTOM"
        },
        "name": "Payment received in Stripe",
        "nextElementIds": [
          "191A44A5-F4C5-45F8-AC2C-F9B31AD4B751"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "TRIGGER"
      },
      {
        "clientMetadata": {
          "notes": "Lists invoices, with optional filters by client, status, and date. Use this to find invoices to act on or report.",
          "elementId": "EXTENSION:::SHARED:::default:::freshbooks:::findInvoices",
          "isFirstElement": false,
          "blockDefinitionId": "api-service-method",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Find the client's invoices Result"
          },
          "newElementId": "EXTENSION:::SHARED:::default:::freshbooks:::findInvoices",
          "legacyElementId": "JS###v1###FreshBooksService###findInvoices",
          "methodName": "findInvoices",
          "position": {
            "x": 950,
            "y": 850
          }
        },
        "flowElementId": "A44837D5-1E2E-4B91-8D71-577E97872929",
        "groupId": null,
        "id": "70DCAAFC-3F0C-4FD7-B90A-FABE69A61213",
        "metaInfo": {
          "bodyParams": [
            {
              "name": "clientId",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Client match",
                    "subPathSegments": [
                      {
                        "key": "clientId",
                        "optional": false
                      }
                    ],
                    "type": "ELEMENT_LINK",
                    "value": "C422A343-DC03-46DB-BC14-BC04E67EC62F"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "status",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "fromDate",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "toDate",
              "type": "SIMPLE",
              "value": {
                "expression": [],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "maxResults",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "NUMBER",
                    "label": null,
                    "type": "INPUT",
                    "value": 100
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "clientValidationState": {
            "errorMessage": "Block: 'Find the client's invoices', Error: OAuth Connection is required",
            "valid": false
          },
          "connectionId": null,
          "enabled": true,
          "hostType": "SHARED",
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "methodName": "findInvoices",
          "onFailElemId": null,
          "packageId": "default",
          "resultAlias": "Client invoices",
          "retryPolicy": null,
          "saveToVariable": null,
          "serviceId": "freshbooks",
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "subtype": "API_SERVICE",
          "type": "EXTENSION"
        },
        "name": "Find the client's invoices",
        "nextElementIds": [
          "C103B249-C6A5-4886-9E62-FC539808FDB3"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Read the payment Result"
          },
          "position": {
            "x": 400,
            "y": 230
          }
        },
        "flowElementId": "D1F99CF1-22E5-4E0E-B414-A0E9CC5C62BA",
        "groupId": null,
        "id": "191A44A5-F4C5-45F8-AC2C-F9B31AD4B751",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "payment",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "RESULT",
                    "label": "Payment",
                    "subPathSegments": null,
                    "type": "TRIGGER_DATA",
                    "value": "30C61A44-FAE5-4B71-9CFB-D98DB0CC0A1A"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const zeroDecimal = ['bif', 'clp', 'djf', 'gnf', 'jpy', 'kmf', 'krw', 'mga', 'pyg', 'rwf', 'ugx', 'vnd', 'vuv', 'xaf', 'xof', 'xpf'];\nconst cur = String(payment.currency || '').toLowerCase();\nconst minor = Number(payment.amount_received || payment.amount || 0);\nconst whole = zeroDecimal.includes(cur);\nconst amount = whole ? minor : minor / 100;\nconst created = Number(payment.created || payment.eventCreated || Math.floor(Date.now() / 1000));\nconst types = payment.payment_method_types || [];\nconst method = types.includes('card') ? 'Credit Card' : types.some(t => /bank|ach|sepa|acss|bacs|becs|transfer/.test(t)) ? 'Bank Transfer' : 'Other';\nconst meta = payment.metadata && typeof payment.metadata === 'object' ? Object.values(payment.metadata) : [];\nreturn {\n  amount,\n  currency: cur.toUpperCase(),\n  amountText: amount.toFixed(whole ? 0 : 2) + ' ' + cur.toUpperCase(),\n  date: new Date(created * 1000).toISOString().slice(0, 10),\n  method,\n  reference: [payment.description, ...meta].filter(Boolean).join(' '),\n  note: 'Stripe payment ' + payment.id + (payment.latest_charge ? ', charge ' + payment.latest_charge : ''),\n};"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Payment details",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Read the payment",
        "nextElementIds": [
          "380527E6-01EA-4061-B1CA-F90D6A3C44DA"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      },
      {
        "clientMetadata": {
          "elementId": "custom-cloud-code",
          "isFirstElement": false,
          "blockDefinitionId": "custom-cloud-code",
          "setResultToVariable": false,
          "saveToVariable": {
            "dataBucket": "Default",
            "variable": "Match the client by email Result"
          },
          "position": {
            "x": 326,
            "y": 702
          }
        },
        "flowElementId": "90B958D6-F87B-4F3F-8135-12CA3FDF8EEB",
        "groupId": null,
        "id": "C422A343-DC03-46DB-BC14-BC04E67EC62F",
        "metaInfo": {
          "clientValidationState": {
            "errorMessage": null,
            "valid": true
          },
          "codeArguments": [
            {
              "name": "customer",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Stripe customer",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "14BD483A-2B2C-4245-B0FD-4B6A804ABBDD"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            },
            {
              "name": "clients",
              "type": "SIMPLE",
              "value": {
                "expression": [
                  {
                    "id": "ELEMENT_RESULT",
                    "label": "Clients",
                    "subPathSegments": null,
                    "type": "ELEMENT_LINK",
                    "value": "F75EC2C5-E813-4A9E-8E6E-DA5FE275C48F"
                  }
                ],
                "mode": "EXPRESSION",
                "parseJsonString": false,
                "resultType": null
              }
            }
          ],
          "codeBody": {
            "expression": [
              {
                "id": "TEXT",
                "label": null,
                "type": "INPUT",
                "value": "const email = String((customer && customer.email) || '').trim().toLowerCase();\nconst list = Array.isArray(clients) ? clients : [];\nconst hit = email ? list.find(c => String(c.email || '').trim().toLowerCase() === email) : null;\nreturn { found: Boolean(hit), clientId: hit ? String(hit.id) : '', email };"
              }
            ],
            "mode": "EXPRESSION",
            "parseJsonString": false,
            "resultType": null
          },
          "enabled": true,
          "logging": {
            "input": {
              "logData": false,
              "message": null
            },
            "output": {
              "logData": false,
              "message": null
            }
          },
          "onFailElemId": null,
          "resultAlias": "Client match",
          "retryPolicy": null,
          "saveToVariable": null,
          "simulationResult": null,
          "slaConditions": [],
          "storeResult": true,
          "type": "CUSTOM_CLOUD_CODE"
        },
        "name": "Match the client by email",
        "nextElementIds": [
          "A8AF8C69-CEA1-4A53-8938-22D23E35C0F9"
        ],
        "nextGroupIds": [],
        "serverFields": {
          "learningStatus": "OFF"
        },
        "type": "ACTION"
      }
    ],
    "firstElementId": "30C61A44-FAE5-4B71-9CFB-D98DB0CC0A1A",
    "groups": [],
    "id": "268F7CF2-023D-43AD-892B-632F23208814",
    "metaInfo": {
      "clientValidationState": {
        "errorMessage": "Please fix problems before start. Blocks with issues have red badge in the top-right corner of a block, hover it to see what needs to be done.",
        "valid": false
      },
      "errorMessage": "Please fix problems before start. Blocks with issues have red badge in the top-right corner of a block, hover it to see what needs to be done.",
      "executionStaticData": [],
      "initialData": null,
      "initialDataDefaultValues": {},
      "ownerFlowVersionId": null,
      "schedule": null,
      "sharedMemory": {
        "anchor": {
          "missingAnchorPolicy": null,
          "path": null,
          "type": "FLOW_MEMORY"
        },
        "expirationInSec": null
      },
      "wasLive": false
    }
  },
  "slaCalendars": [],
  "slaGoals": [],
  "subFlows": [],
  "exportDate": "2026-11-18T10:20:06.876Z"
}
