{ "kind": "open-flow-workflow", "version": 1, "name": "Stripe Checkout Customer and Product", "content": { "modelVersion": 14, "document": { "bindings": {}, "graph": { "nodes": { "n_778e0fd5dce24c77": { "name": "Receive completed Checkout", "kind": "integration", "config": { "apiVersion": { "kind": "value", "value": "" }, "events": { "kind": "value", "value": [ "checkout.session.completed" ] }, "includeConnectedAccounts": { "kind": "value", "value": false } }, "definition": { "configInputs": [ { "jsonSchema": { "type": "string", "maxLength": 40 }, "nullable": false, "handle": "apiVersion", "value": "" }, { "jsonSchema": { "type": "array", "items": { "type": "string", "maxLength": 120, "pattern": "^(\\*|[a-z0-9_]+(?:\\.[a-z0-9_]+)+)$" }, "minItems": 1, "uniqueItems": true }, "nullable": false, "handle": "events" }, { "jsonSchema": { "type": "boolean" }, "nullable": false, "handle": "includeConnectedAccounts", "value": false } ], "definitionVersion": 2, "description": "Triggers when selected Stripe events happen on the connected account.", "displayName": "Account Event", "key": "stripe.on_event", "name": "on_event", "outputs": [ { "jsonSchema": { "type": "object" }, "nullable": false, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "event" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "eventId" }, { "jsonSchema": { "type": "boolean" }, "nullable": false, "handle": "livemode" } ], "provider": "stripe", "type": "integration", "endpoint": { "body": { "allowArray": false, "allowEmpty": false, "formats": [ "json" ] }, "methods": [ "POST" ], "successStatus": 202 } } }, "n_e5fa5fe1957e6fa0": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_778e0fd5dce24c77", "output": "body" } ] }, "eventId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_778e0fd5dce24c77", "output": "eventId" } ] } }, "name": "Select Checkout Session", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "object", "additionalProperties": true }, "nullable": false, "handle": "body" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "eventId" } ], "outputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "sessionId" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "endpoint" } ], "name": "Select Checkout Session", "moduleId": "n_e1585af51d853ce5", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_3baae45eba2d83e0": { "inputs": { "endpoint": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_e5fa5fe1957e6fa0", "output": "endpoint" } ] }, "query.expand[]": { "kind": "value", "value": "line_items" } }, "name": "Read Checkout Session", "kind": "task", "task": { "inputs": [ { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "endpoint" }, { "jsonSchema": { "type": [ "string", "number", "boolean", "null" ] }, "nullable": true, "handle": "query.expand[]" } ], "outputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" }, { "jsonSchema": { "type": "object", "additionalProperties": { "type": "string" } }, "nullable": false, "handle": "headers" }, { "jsonSchema": { "const": "base64" }, "nullable": true, "handle": "bodyEncoding" } ], "name": "Read Checkout Session", "executor": { "providerId": "stripe", "method": "GET", "query": { "mode": "fields", "names": [ "expand[]" ] }, "headers": { "mode": "fields", "names": [] }, "bodyFormat": "none", "kind": "connector-proxy" } } }, "n_44b751b87662f69f": { "inputs": { "body": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_3baae45eba2d83e0", "output": "body" } ] }, "statusCode": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_3baae45eba2d83e0", "output": "statusCode" } ] }, "bodyEncoding": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_3baae45eba2d83e0", "output": "bodyEncoding" } ] }, "sessionId": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_e5fa5fe1957e6fa0", "output": "sessionId" } ] } }, "name": "Extract customer and product", "kind": "task", "task": { "inputs": [ { "jsonSchema": {}, "nullable": true, "handle": "body" }, { "jsonSchema": { "type": "integer" }, "nullable": false, "handle": "statusCode" }, { "jsonSchema": { "const": "base64" }, "nullable": true, "handle": "bodyEncoding" }, { "jsonSchema": { "type": "string" }, "nullable": false, "handle": "sessionId" } ], "outputs": [ { "jsonSchema": { "type": [ "string", "null" ] }, "nullable": true, "handle": "customerName" }, { "jsonSchema": { "type": [ "string", "null" ] }, "nullable": true, "handle": "customerEmail" }, { "jsonSchema": { "type": [ "string", "null" ] }, "nullable": true, "handle": "productDescription" } ], "name": "Extract customer and product", "moduleId": "n_210150110bf9bfdf", "capabilities": [ { "kind": "connector", "mode": "independent", "actions": [] } ] } }, "n_665d7024a35831eb": { "name": "Checkout details", "kind": "outputs", "outputDefs": [ { "jsonSchema": { "type": [ "string", "null" ] }, "nullable": true, "handle": "customerName" }, { "jsonSchema": { "type": [ "string", "null" ] }, "nullable": true, "handle": "customerEmail" }, { "jsonSchema": { "type": [ "string", "null" ] }, "nullable": true, "handle": "productDescription" } ], "outputMappings": { "customerName": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_44b751b87662f69f", "output": "customerName" } ] }, "customerEmail": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_44b751b87662f69f", "output": "customerEmail" } ] }, "productDescription": { "kind": "sources", "sources": [ { "kind": "node", "nodeId": "n_44b751b87662f69f", "output": "productDescription" } ] } } } }, "edges": [ { "source": "n_778e0fd5dce24c77", "target": "n_e5fa5fe1957e6fa0" }, { "source": "n_e5fa5fe1957e6fa0", "target": "n_3baae45eba2d83e0" }, { "source": "n_3baae45eba2d83e0", "target": "n_44b751b87662f69f" }, { "source": "n_44b751b87662f69f", "target": "n_665d7024a35831eb" } ] } }, "modules": { "n_e1585af51d853ce5": { "name": "Select Checkout Session", "imports": [], "source": "export default function checkoutRequest({body,eventId}) {if(body?.type!=='checkout.session.completed'||body.id!==eventId||typeof eventId!=='string'||!eventId)throw Error('Invalid Stripe event');const sessionId=body.data?.object?.id;if(typeof sessionId!=='string'||!/^cs_(?:test|live)_[A-Za-z0-9]+$/.test(sessionId))throw Error('Invalid Checkout Session ID');return {sessionId,endpoint:'/v1/checkout/sessions/'+encodeURIComponent(sessionId)};}\n" }, "n_210150110bf9bfdf": { "name": "Extract customer and product", "imports": [], "source": "export default function checkoutResult({body,statusCode,bodyEncoding,sessionId}) {if(statusCode<200||statusCode>=300||bodyEncoding!=null||!body||typeof body!=='object'||Array.isArray(body)||body.id!==sessionId)throw Error('Stripe did not return the requested Checkout Session');const details=body.customer_details;if(details!=null&&(typeof details!=='object'||Array.isArray(details)))throw Error('Invalid customer details');const rows=body.line_items?.data;if(!Array.isArray(rows))throw Error('Expanded line items are missing');const text=(v)=>{if(v==null)return null;if(typeof v!=='string')throw Error('Invalid Checkout Session field');return v};return {customerName:text(details?.name),customerEmail:text(details?.email),productDescription:text(rows[0]?.description)};}\n" } } }, "presentation": { "designer": { "version": 1, "flow": { "direction": "vertical" } } } }