|
| 1 | +import type { IntegrationPlugin } from "../registry"; |
| 2 | +import { registerIntegration } from "../registry"; |
| 3 | +import { StripeIcon } from "./icon"; |
| 4 | + |
| 5 | +const stripePlugin: IntegrationPlugin = { |
| 6 | + type: "stripe", |
| 7 | + label: "Stripe", |
| 8 | + description: "Payment processing and billing", |
| 9 | + |
| 10 | + icon: StripeIcon, |
| 11 | + |
| 12 | + formFields: [ |
| 13 | + { |
| 14 | + id: "apiKey", |
| 15 | + label: "Secret Key", |
| 16 | + type: "password", |
| 17 | + placeholder: "sk_live_... or sk_test_...", |
| 18 | + configKey: "apiKey", |
| 19 | + envVar: "STRIPE_SECRET_KEY", |
| 20 | + helpText: "Get your secret key from ", |
| 21 | + helpLink: { |
| 22 | + text: "dashboard.stripe.com/apikeys", |
| 23 | + url: "https://dashboard.stripe.com/apikeys", |
| 24 | + }, |
| 25 | + }, |
| 26 | + ], |
| 27 | + |
| 28 | + testConfig: { |
| 29 | + getTestFunction: async () => { |
| 30 | + const { testStripe } = await import("./test"); |
| 31 | + return testStripe; |
| 32 | + }, |
| 33 | + }, |
| 34 | + |
| 35 | + actions: [ |
| 36 | + { |
| 37 | + slug: "create-customer", |
| 38 | + label: "Create Customer", |
| 39 | + description: "Create a new customer in Stripe", |
| 40 | + category: "Stripe", |
| 41 | + stepFunction: "createCustomerStep", |
| 42 | + stepImportPath: "create-customer", |
| 43 | + outputFields: [ |
| 44 | + { field: "id", description: "Customer ID" }, |
| 45 | + { field: "email", description: "Customer email" }, |
| 46 | + ], |
| 47 | + configFields: [ |
| 48 | + { |
| 49 | + key: "email", |
| 50 | + label: "Email", |
| 51 | + type: "template-input", |
| 52 | + placeholder: "customer@example.com or {{NodeName.email}}", |
| 53 | + example: "customer@example.com", |
| 54 | + required: true, |
| 55 | + }, |
| 56 | + { |
| 57 | + key: "name", |
| 58 | + label: "Name", |
| 59 | + type: "template-input", |
| 60 | + placeholder: "John Doe or {{NodeName.name}}", |
| 61 | + example: "John Doe", |
| 62 | + }, |
| 63 | + { |
| 64 | + key: "phone", |
| 65 | + label: "Phone", |
| 66 | + type: "template-input", |
| 67 | + placeholder: "+1234567890", |
| 68 | + example: "+1234567890", |
| 69 | + }, |
| 70 | + { |
| 71 | + type: "group", |
| 72 | + label: "Additional Details", |
| 73 | + fields: [ |
| 74 | + { |
| 75 | + key: "description", |
| 76 | + label: "Description", |
| 77 | + type: "template-input", |
| 78 | + placeholder: "Internal notes about this customer", |
| 79 | + example: "VIP customer", |
| 80 | + }, |
| 81 | + { |
| 82 | + key: "metadata", |
| 83 | + label: "Metadata (JSON)", |
| 84 | + type: "template-textarea", |
| 85 | + placeholder: '{"key": "value"}', |
| 86 | + example: '{"plan": "enterprise", "source": "website"}', |
| 87 | + rows: 3, |
| 88 | + }, |
| 89 | + ], |
| 90 | + }, |
| 91 | + ], |
| 92 | + }, |
| 93 | + { |
| 94 | + slug: "get-customer", |
| 95 | + label: "Get Customer", |
| 96 | + description: "Retrieve a customer by ID or email", |
| 97 | + category: "Stripe", |
| 98 | + stepFunction: "getCustomerStep", |
| 99 | + stepImportPath: "get-customer", |
| 100 | + outputFields: [ |
| 101 | + { field: "id", description: "Customer ID" }, |
| 102 | + { field: "email", description: "Customer email" }, |
| 103 | + { field: "name", description: "Customer name" }, |
| 104 | + { field: "created", description: "Creation timestamp" }, |
| 105 | + ], |
| 106 | + configFields: [ |
| 107 | + { |
| 108 | + key: "customerId", |
| 109 | + label: "Customer ID", |
| 110 | + type: "template-input", |
| 111 | + placeholder: "cus_... or {{NodeName.customerId}}", |
| 112 | + example: "cus_ABC123", |
| 113 | + }, |
| 114 | + { |
| 115 | + key: "email", |
| 116 | + label: "Email (alternative lookup)", |
| 117 | + type: "template-input", |
| 118 | + placeholder: "customer@example.com", |
| 119 | + example: "customer@example.com", |
| 120 | + }, |
| 121 | + ], |
| 122 | + }, |
| 123 | + { |
| 124 | + slug: "create-invoice", |
| 125 | + label: "Create Invoice", |
| 126 | + description: "Create and optionally send an invoice", |
| 127 | + category: "Stripe", |
| 128 | + stepFunction: "createInvoiceStep", |
| 129 | + stepImportPath: "create-invoice", |
| 130 | + outputFields: [ |
| 131 | + { field: "id", description: "Invoice ID" }, |
| 132 | + { field: "number", description: "Invoice number" }, |
| 133 | + { field: "hostedInvoiceUrl", description: "Hosted invoice URL" }, |
| 134 | + { field: "status", description: "Invoice status" }, |
| 135 | + ], |
| 136 | + configFields: [ |
| 137 | + { |
| 138 | + key: "customerId", |
| 139 | + label: "Customer ID", |
| 140 | + type: "template-input", |
| 141 | + placeholder: "cus_... or {{NodeName.customerId}}", |
| 142 | + example: "cus_ABC123", |
| 143 | + required: true, |
| 144 | + }, |
| 145 | + { |
| 146 | + key: "description", |
| 147 | + label: "Description", |
| 148 | + type: "template-input", |
| 149 | + placeholder: "Invoice description", |
| 150 | + example: "Professional services - January 2024", |
| 151 | + }, |
| 152 | + { |
| 153 | + key: "lineItems", |
| 154 | + label: "Line Items (JSON array)", |
| 155 | + type: "template-textarea", |
| 156 | + placeholder: '[{"description": "Item", "amount": 1000, "quantity": 1}]', |
| 157 | + example: |
| 158 | + '[{"description": "Consulting", "amount": 15000, "quantity": 2}]', |
| 159 | + rows: 4, |
| 160 | + required: true, |
| 161 | + }, |
| 162 | + { |
| 163 | + type: "group", |
| 164 | + label: "Invoice Options", |
| 165 | + fields: [ |
| 166 | + { |
| 167 | + key: "daysUntilDue", |
| 168 | + label: "Days Until Due", |
| 169 | + type: "number", |
| 170 | + defaultValue: "30", |
| 171 | + min: 1, |
| 172 | + }, |
| 173 | + { |
| 174 | + key: "autoAdvance", |
| 175 | + label: "Auto-finalize", |
| 176 | + type: "select", |
| 177 | + options: [ |
| 178 | + { value: "true", label: "Yes" }, |
| 179 | + { value: "false", label: "No (draft)" }, |
| 180 | + ], |
| 181 | + defaultValue: "true", |
| 182 | + }, |
| 183 | + { |
| 184 | + key: "collectionMethod", |
| 185 | + label: "Collection Method", |
| 186 | + type: "select", |
| 187 | + options: [ |
| 188 | + { value: "send_invoice", label: "Send Invoice" }, |
| 189 | + { value: "charge_automatically", label: "Charge Automatically" }, |
| 190 | + ], |
| 191 | + defaultValue: "send_invoice", |
| 192 | + }, |
| 193 | + { |
| 194 | + key: "metadata", |
| 195 | + label: "Metadata (JSON)", |
| 196 | + type: "template-textarea", |
| 197 | + placeholder: '{"key": "value"}', |
| 198 | + example: '{"project": "website-redesign"}', |
| 199 | + rows: 3, |
| 200 | + }, |
| 201 | + ], |
| 202 | + }, |
| 203 | + ], |
| 204 | + }, |
| 205 | + ], |
| 206 | +}; |
| 207 | + |
| 208 | +registerIntegration(stripePlugin); |
| 209 | + |
| 210 | +export default stripePlugin; |
| 211 | + |
0 commit comments