@contractspec/example.integration-stripe 3.7.7 → 3.7.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +36 -33
- package/CHANGELOG.md +24 -0
- package/README.md +6 -3
- package/dist/blueprint.d.ts +1 -2
- package/dist/blueprint.js +62 -9
- package/dist/browser/blueprint.js +62 -9
- package/dist/browser/connection.sample.js +78 -2
- package/dist/browser/index.js +151 -66
- package/dist/browser/integration-stripe.feature.js +139 -3
- package/dist/browser/integration.js +78 -0
- package/dist/browser/workflow.js +4 -3
- package/dist/connection.sample.js +78 -2
- package/dist/contracts.test.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +151 -66
- package/dist/integration-stripe.feature.js +139 -3
- package/dist/integration.d.ts +1 -0
- package/dist/integration.js +79 -0
- package/dist/node/blueprint.js +62 -9
- package/dist/node/connection.sample.js +78 -2
- package/dist/node/index.js +151 -66
- package/dist/node/integration-stripe.feature.js +139 -3
- package/dist/node/integration.js +78 -0
- package/dist/node/workflow.js +4 -3
- package/dist/workflow.d.ts +1 -2
- package/dist/workflow.js +4 -3
- package/package.json +20 -6
- package/src/blueprint.ts +6 -6
- package/src/connection.sample.ts +3 -2
- package/src/contracts.test.ts +34 -0
- package/src/index.ts +1 -0
- package/src/integration-stripe.feature.ts +12 -4
- package/src/integration.ts +79 -0
- package/src/workflow.ts +4 -4
package/dist/node/index.js
CHANGED
|
@@ -1,10 +1,64 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/workflow.ts
|
|
2
2
|
import {
|
|
3
3
|
OwnersEnum,
|
|
4
4
|
StabilityEnum,
|
|
5
5
|
TagsEnum
|
|
6
6
|
} from "@contractspec/lib.contracts-spec/ownership";
|
|
7
|
-
|
|
7
|
+
import { defineWorkflow } from "@contractspec/lib.contracts-spec/workflow";
|
|
8
|
+
var collectPaymentWorkflow = defineWorkflow({
|
|
9
|
+
meta: {
|
|
10
|
+
key: "integration-stripe.workflow.payment",
|
|
11
|
+
version: "1.0.0",
|
|
12
|
+
title: "Collect Card Payment",
|
|
13
|
+
description: "Charge a customer using the tenant Stripe connection and record settlement details.",
|
|
14
|
+
domain: "payments",
|
|
15
|
+
owners: [OwnersEnum.PlatformCore],
|
|
16
|
+
tags: [TagsEnum.Marketplace, "stripe"],
|
|
17
|
+
stability: StabilityEnum.Experimental
|
|
18
|
+
},
|
|
19
|
+
definition: {
|
|
20
|
+
entryStepId: "prepare",
|
|
21
|
+
steps: [
|
|
22
|
+
{
|
|
23
|
+
id: "prepare",
|
|
24
|
+
type: "automation",
|
|
25
|
+
label: "Prepare charge parameters",
|
|
26
|
+
action: {
|
|
27
|
+
operation: { key: "payments.prepareCharge", version: "1.0.0" }
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: "charge",
|
|
32
|
+
type: "automation",
|
|
33
|
+
label: "Charge card via Stripe",
|
|
34
|
+
action: {
|
|
35
|
+
operation: { key: "payments.stripe.chargeCard", version: "1.0.0" }
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: "confirm",
|
|
40
|
+
type: "automation",
|
|
41
|
+
label: "Confirm settlement",
|
|
42
|
+
action: {
|
|
43
|
+
operation: { key: "payments.recordSettlement", version: "1.0.0" }
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
transitions: [
|
|
48
|
+
{ from: "prepare", to: "charge" },
|
|
49
|
+
{ from: "charge", to: "confirm", condition: "output.success === true" }
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// src/blueprint.ts
|
|
55
|
+
import { defineAppConfig } from "@contractspec/lib.contracts-spec/app-config/spec";
|
|
56
|
+
import {
|
|
57
|
+
OwnersEnum as OwnersEnum2,
|
|
58
|
+
StabilityEnum as StabilityEnum2,
|
|
59
|
+
TagsEnum as TagsEnum2
|
|
60
|
+
} from "@contractspec/lib.contracts-spec/ownership";
|
|
61
|
+
var artisanStripeBlueprint = defineAppConfig({
|
|
8
62
|
meta: {
|
|
9
63
|
key: "artisan.payments.stripe",
|
|
10
64
|
version: "1.0.0",
|
|
@@ -12,9 +66,9 @@ var artisanStripeBlueprint = {
|
|
|
12
66
|
title: "ArtisanOS Stripe Payments",
|
|
13
67
|
description: "Blueprint enabling card payments for ArtisanOS merchants via the Stripe integration.",
|
|
14
68
|
domain: "payments",
|
|
15
|
-
owners: [
|
|
16
|
-
tags: [
|
|
17
|
-
stability:
|
|
69
|
+
owners: [OwnersEnum2.PlatformCore],
|
|
70
|
+
tags: [TagsEnum2.Marketplace, "stripe", "payments"],
|
|
71
|
+
stability: StabilityEnum2.Experimental
|
|
18
72
|
},
|
|
19
73
|
capabilities: {
|
|
20
74
|
enabled: [{ key: "payments.psp", version: "1.0.0" }]
|
|
@@ -49,21 +103,96 @@ var artisanStripeBlueprint = {
|
|
|
49
103
|
},
|
|
50
104
|
workflows: {
|
|
51
105
|
collectPayment: {
|
|
52
|
-
key:
|
|
53
|
-
version:
|
|
106
|
+
key: collectPaymentWorkflow.meta.key,
|
|
107
|
+
version: collectPaymentWorkflow.meta.version
|
|
54
108
|
}
|
|
55
109
|
},
|
|
56
|
-
policies: [{ key: "artisan.payments.default", version: "1.0.0" }],
|
|
57
110
|
notes: "Install this blueprint and pair it with the Stripe integration connection to enable card collection."
|
|
58
|
-
};
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// src/integration.ts
|
|
114
|
+
import { defineIntegration } from "@contractspec/lib.contracts-spec/integrations/spec";
|
|
115
|
+
import {
|
|
116
|
+
OwnersEnum as OwnersEnum3,
|
|
117
|
+
StabilityEnum as StabilityEnum3,
|
|
118
|
+
TagsEnum as TagsEnum3
|
|
119
|
+
} from "@contractspec/lib.contracts-spec/ownership";
|
|
120
|
+
import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
|
|
121
|
+
var StripeConfigModel = defineSchemaModel({
|
|
122
|
+
name: "StripePaymentsIntegrationConfig",
|
|
123
|
+
description: "Managed configuration required to connect a Stripe account.",
|
|
124
|
+
fields: {
|
|
125
|
+
accountId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
126
|
+
webhookEndpoint: {
|
|
127
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
128
|
+
isOptional: false
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
var StripeSecretModel = defineSchemaModel({
|
|
133
|
+
name: "StripePaymentsIntegrationSecret",
|
|
134
|
+
description: "Secret material stored out-of-band for the Stripe provider.",
|
|
135
|
+
fields: {
|
|
136
|
+
apiKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
137
|
+
webhookSecret: {
|
|
138
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
139
|
+
isOptional: false
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
var StripePaymentsIntegrationSpec = defineIntegration({
|
|
144
|
+
meta: {
|
|
145
|
+
key: "integration-stripe.integration.psp",
|
|
146
|
+
version: "1.0.0",
|
|
147
|
+
title: "Stripe Payments Integration",
|
|
148
|
+
description: "Integration contract for managed or BYOK Stripe card processing.",
|
|
149
|
+
domain: "payments",
|
|
150
|
+
category: "payments",
|
|
151
|
+
owners: [OwnersEnum3.PlatformCore],
|
|
152
|
+
tags: [TagsEnum3.Marketplace, "stripe", "payments"],
|
|
153
|
+
stability: StabilityEnum3.Experimental
|
|
154
|
+
},
|
|
155
|
+
supportedModes: ["managed", "byok"],
|
|
156
|
+
capabilities: {
|
|
157
|
+
provides: [{ key: "payments.psp", version: "1.0.0" }]
|
|
158
|
+
},
|
|
159
|
+
configSchema: {
|
|
160
|
+
schema: StripeConfigModel,
|
|
161
|
+
example: {
|
|
162
|
+
accountId: "acct_demo_artisan",
|
|
163
|
+
webhookEndpoint: "https://pay.artisanos.dev/webhooks/stripe"
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
secretSchema: {
|
|
167
|
+
schema: StripeSecretModel,
|
|
168
|
+
example: {
|
|
169
|
+
apiKey: "sk_live_redacted",
|
|
170
|
+
webhookSecret: "whsec_redacted"
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
healthCheck: {
|
|
174
|
+
method: "ping",
|
|
175
|
+
timeoutMs: 5000
|
|
176
|
+
},
|
|
177
|
+
docsUrl: "https://docs.stripe.com",
|
|
178
|
+
constraints: {
|
|
179
|
+
rateLimit: {
|
|
180
|
+
rpm: 1000
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
byokSetup: {
|
|
184
|
+
setupInstructions: "Create a restricted API key and webhook endpoint, then bind the secret reference to the tenant connection.",
|
|
185
|
+
requiredScopes: ["charges:write", "customers:read", "webhooks:write"]
|
|
186
|
+
}
|
|
187
|
+
});
|
|
59
188
|
|
|
60
189
|
// src/connection.sample.ts
|
|
61
190
|
var stripeLiveConnection = {
|
|
62
191
|
meta: {
|
|
63
192
|
id: "conn-stripe-live",
|
|
64
193
|
tenantId: "artisan-co",
|
|
65
|
-
integrationKey:
|
|
66
|
-
integrationVersion:
|
|
194
|
+
integrationKey: StripePaymentsIntegrationSpec.meta.key,
|
|
195
|
+
integrationVersion: StripePaymentsIntegrationSpec.meta.version,
|
|
67
196
|
label: "Stripe Production",
|
|
68
197
|
environment: "production",
|
|
69
198
|
createdAt: "2026-01-01T00:00:00.000Z",
|
|
@@ -162,10 +291,17 @@ var IntegrationStripeFeature = defineFeature({
|
|
|
162
291
|
stability: "experimental"
|
|
163
292
|
},
|
|
164
293
|
integrations: [
|
|
165
|
-
{
|
|
294
|
+
{
|
|
295
|
+
key: StripePaymentsIntegrationSpec.meta.key,
|
|
296
|
+
version: StripePaymentsIntegrationSpec.meta.version
|
|
297
|
+
}
|
|
298
|
+
],
|
|
299
|
+
workflows: [
|
|
300
|
+
{
|
|
301
|
+
key: collectPaymentWorkflow.meta.key,
|
|
302
|
+
version: collectPaymentWorkflow.meta.version
|
|
303
|
+
}
|
|
166
304
|
],
|
|
167
|
-
workflows: [{ key: "integration-stripe.workflow.payment", version: "1.0.0" }],
|
|
168
|
-
policies: [{ key: "integration-stripe.policy.payments", version: "1.0.0" }],
|
|
169
305
|
docs: [
|
|
170
306
|
"docs.examples.integration-stripe",
|
|
171
307
|
"docs.examples.integration-stripe.usage"
|
|
@@ -224,63 +360,12 @@ var artisanStripeTenantConfig = {
|
|
|
224
360
|
},
|
|
225
361
|
notes: "Stripe connection bound for production payments."
|
|
226
362
|
};
|
|
227
|
-
|
|
228
|
-
// src/workflow.ts
|
|
229
|
-
import {
|
|
230
|
-
OwnersEnum as OwnersEnum2,
|
|
231
|
-
StabilityEnum as StabilityEnum2,
|
|
232
|
-
TagsEnum as TagsEnum2
|
|
233
|
-
} from "@contractspec/lib.contracts-spec/ownership";
|
|
234
|
-
var collectPaymentWorkflow = {
|
|
235
|
-
meta: {
|
|
236
|
-
key: "artisan.payments.collectPayment",
|
|
237
|
-
version: "1.0.0",
|
|
238
|
-
title: "Collect Card Payment",
|
|
239
|
-
description: "Charge a customer using the tenant Stripe connection and record settlement details.",
|
|
240
|
-
domain: "payments",
|
|
241
|
-
owners: [OwnersEnum2.PlatformCore],
|
|
242
|
-
tags: [TagsEnum2.Marketplace, "stripe"],
|
|
243
|
-
stability: StabilityEnum2.Experimental
|
|
244
|
-
},
|
|
245
|
-
definition: {
|
|
246
|
-
entryStepId: "prepare",
|
|
247
|
-
steps: [
|
|
248
|
-
{
|
|
249
|
-
id: "prepare",
|
|
250
|
-
type: "automation",
|
|
251
|
-
label: "Prepare charge parameters",
|
|
252
|
-
action: {
|
|
253
|
-
operation: { key: "payments.prepareCharge", version: "1.0.0" }
|
|
254
|
-
}
|
|
255
|
-
},
|
|
256
|
-
{
|
|
257
|
-
id: "charge",
|
|
258
|
-
type: "automation",
|
|
259
|
-
label: "Charge card via Stripe",
|
|
260
|
-
action: {
|
|
261
|
-
operation: { key: "payments.stripe.chargeCard", version: "1.0.0" }
|
|
262
|
-
}
|
|
263
|
-
},
|
|
264
|
-
{
|
|
265
|
-
id: "confirm",
|
|
266
|
-
type: "automation",
|
|
267
|
-
label: "Confirm settlement",
|
|
268
|
-
action: {
|
|
269
|
-
operation: { key: "payments.recordSettlement", version: "1.0.0" }
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
],
|
|
273
|
-
transitions: [
|
|
274
|
-
{ from: "prepare", to: "charge" },
|
|
275
|
-
{ from: "charge", to: "confirm", condition: "output.success === true" }
|
|
276
|
-
]
|
|
277
|
-
}
|
|
278
|
-
};
|
|
279
363
|
export {
|
|
280
364
|
stripeLiveConnection,
|
|
281
365
|
example_default as example,
|
|
282
366
|
collectPaymentWorkflow,
|
|
283
367
|
artisanStripeTenantConfig,
|
|
284
368
|
artisanStripeBlueprint,
|
|
369
|
+
StripePaymentsIntegrationSpec,
|
|
285
370
|
IntegrationStripeFeature
|
|
286
371
|
};
|
|
@@ -1,3 +1,132 @@
|
|
|
1
|
+
// src/workflow.ts
|
|
2
|
+
import {
|
|
3
|
+
OwnersEnum,
|
|
4
|
+
StabilityEnum,
|
|
5
|
+
TagsEnum
|
|
6
|
+
} from "@contractspec/lib.contracts-spec/ownership";
|
|
7
|
+
import { defineWorkflow } from "@contractspec/lib.contracts-spec/workflow";
|
|
8
|
+
var collectPaymentWorkflow = defineWorkflow({
|
|
9
|
+
meta: {
|
|
10
|
+
key: "integration-stripe.workflow.payment",
|
|
11
|
+
version: "1.0.0",
|
|
12
|
+
title: "Collect Card Payment",
|
|
13
|
+
description: "Charge a customer using the tenant Stripe connection and record settlement details.",
|
|
14
|
+
domain: "payments",
|
|
15
|
+
owners: [OwnersEnum.PlatformCore],
|
|
16
|
+
tags: [TagsEnum.Marketplace, "stripe"],
|
|
17
|
+
stability: StabilityEnum.Experimental
|
|
18
|
+
},
|
|
19
|
+
definition: {
|
|
20
|
+
entryStepId: "prepare",
|
|
21
|
+
steps: [
|
|
22
|
+
{
|
|
23
|
+
id: "prepare",
|
|
24
|
+
type: "automation",
|
|
25
|
+
label: "Prepare charge parameters",
|
|
26
|
+
action: {
|
|
27
|
+
operation: { key: "payments.prepareCharge", version: "1.0.0" }
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: "charge",
|
|
32
|
+
type: "automation",
|
|
33
|
+
label: "Charge card via Stripe",
|
|
34
|
+
action: {
|
|
35
|
+
operation: { key: "payments.stripe.chargeCard", version: "1.0.0" }
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: "confirm",
|
|
40
|
+
type: "automation",
|
|
41
|
+
label: "Confirm settlement",
|
|
42
|
+
action: {
|
|
43
|
+
operation: { key: "payments.recordSettlement", version: "1.0.0" }
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
transitions: [
|
|
48
|
+
{ from: "prepare", to: "charge" },
|
|
49
|
+
{ from: "charge", to: "confirm", condition: "output.success === true" }
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// src/integration.ts
|
|
55
|
+
import { defineIntegration } from "@contractspec/lib.contracts-spec/integrations/spec";
|
|
56
|
+
import {
|
|
57
|
+
OwnersEnum as OwnersEnum2,
|
|
58
|
+
StabilityEnum as StabilityEnum2,
|
|
59
|
+
TagsEnum as TagsEnum2
|
|
60
|
+
} from "@contractspec/lib.contracts-spec/ownership";
|
|
61
|
+
import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
|
|
62
|
+
var StripeConfigModel = defineSchemaModel({
|
|
63
|
+
name: "StripePaymentsIntegrationConfig",
|
|
64
|
+
description: "Managed configuration required to connect a Stripe account.",
|
|
65
|
+
fields: {
|
|
66
|
+
accountId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
67
|
+
webhookEndpoint: {
|
|
68
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
69
|
+
isOptional: false
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
var StripeSecretModel = defineSchemaModel({
|
|
74
|
+
name: "StripePaymentsIntegrationSecret",
|
|
75
|
+
description: "Secret material stored out-of-band for the Stripe provider.",
|
|
76
|
+
fields: {
|
|
77
|
+
apiKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
78
|
+
webhookSecret: {
|
|
79
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
80
|
+
isOptional: false
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
var StripePaymentsIntegrationSpec = defineIntegration({
|
|
85
|
+
meta: {
|
|
86
|
+
key: "integration-stripe.integration.psp",
|
|
87
|
+
version: "1.0.0",
|
|
88
|
+
title: "Stripe Payments Integration",
|
|
89
|
+
description: "Integration contract for managed or BYOK Stripe card processing.",
|
|
90
|
+
domain: "payments",
|
|
91
|
+
category: "payments",
|
|
92
|
+
owners: [OwnersEnum2.PlatformCore],
|
|
93
|
+
tags: [TagsEnum2.Marketplace, "stripe", "payments"],
|
|
94
|
+
stability: StabilityEnum2.Experimental
|
|
95
|
+
},
|
|
96
|
+
supportedModes: ["managed", "byok"],
|
|
97
|
+
capabilities: {
|
|
98
|
+
provides: [{ key: "payments.psp", version: "1.0.0" }]
|
|
99
|
+
},
|
|
100
|
+
configSchema: {
|
|
101
|
+
schema: StripeConfigModel,
|
|
102
|
+
example: {
|
|
103
|
+
accountId: "acct_demo_artisan",
|
|
104
|
+
webhookEndpoint: "https://pay.artisanos.dev/webhooks/stripe"
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
secretSchema: {
|
|
108
|
+
schema: StripeSecretModel,
|
|
109
|
+
example: {
|
|
110
|
+
apiKey: "sk_live_redacted",
|
|
111
|
+
webhookSecret: "whsec_redacted"
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
healthCheck: {
|
|
115
|
+
method: "ping",
|
|
116
|
+
timeoutMs: 5000
|
|
117
|
+
},
|
|
118
|
+
docsUrl: "https://docs.stripe.com",
|
|
119
|
+
constraints: {
|
|
120
|
+
rateLimit: {
|
|
121
|
+
rpm: 1000
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
byokSetup: {
|
|
125
|
+
setupInstructions: "Create a restricted API key and webhook endpoint, then bind the secret reference to the tenant connection.",
|
|
126
|
+
requiredScopes: ["charges:write", "customers:read", "webhooks:write"]
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
|
|
1
130
|
// src/integration-stripe.feature.ts
|
|
2
131
|
import { defineFeature } from "@contractspec/lib.contracts-spec";
|
|
3
132
|
var IntegrationStripeFeature = defineFeature({
|
|
@@ -12,10 +141,17 @@ var IntegrationStripeFeature = defineFeature({
|
|
|
12
141
|
stability: "experimental"
|
|
13
142
|
},
|
|
14
143
|
integrations: [
|
|
15
|
-
{
|
|
144
|
+
{
|
|
145
|
+
key: StripePaymentsIntegrationSpec.meta.key,
|
|
146
|
+
version: StripePaymentsIntegrationSpec.meta.version
|
|
147
|
+
}
|
|
148
|
+
],
|
|
149
|
+
workflows: [
|
|
150
|
+
{
|
|
151
|
+
key: collectPaymentWorkflow.meta.key,
|
|
152
|
+
version: collectPaymentWorkflow.meta.version
|
|
153
|
+
}
|
|
16
154
|
],
|
|
17
|
-
workflows: [{ key: "integration-stripe.workflow.payment", version: "1.0.0" }],
|
|
18
|
-
policies: [{ key: "integration-stripe.policy.payments", version: "1.0.0" }],
|
|
19
155
|
docs: [
|
|
20
156
|
"docs.examples.integration-stripe",
|
|
21
157
|
"docs.examples.integration-stripe.usage"
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// src/integration.ts
|
|
2
|
+
import { defineIntegration } from "@contractspec/lib.contracts-spec/integrations/spec";
|
|
3
|
+
import {
|
|
4
|
+
OwnersEnum,
|
|
5
|
+
StabilityEnum,
|
|
6
|
+
TagsEnum
|
|
7
|
+
} from "@contractspec/lib.contracts-spec/ownership";
|
|
8
|
+
import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
|
|
9
|
+
var StripeConfigModel = defineSchemaModel({
|
|
10
|
+
name: "StripePaymentsIntegrationConfig",
|
|
11
|
+
description: "Managed configuration required to connect a Stripe account.",
|
|
12
|
+
fields: {
|
|
13
|
+
accountId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
14
|
+
webhookEndpoint: {
|
|
15
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
16
|
+
isOptional: false
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
var StripeSecretModel = defineSchemaModel({
|
|
21
|
+
name: "StripePaymentsIntegrationSecret",
|
|
22
|
+
description: "Secret material stored out-of-band for the Stripe provider.",
|
|
23
|
+
fields: {
|
|
24
|
+
apiKey: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
|
|
25
|
+
webhookSecret: {
|
|
26
|
+
type: ScalarTypeEnum.String_unsecure(),
|
|
27
|
+
isOptional: false
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
var StripePaymentsIntegrationSpec = defineIntegration({
|
|
32
|
+
meta: {
|
|
33
|
+
key: "integration-stripe.integration.psp",
|
|
34
|
+
version: "1.0.0",
|
|
35
|
+
title: "Stripe Payments Integration",
|
|
36
|
+
description: "Integration contract for managed or BYOK Stripe card processing.",
|
|
37
|
+
domain: "payments",
|
|
38
|
+
category: "payments",
|
|
39
|
+
owners: [OwnersEnum.PlatformCore],
|
|
40
|
+
tags: [TagsEnum.Marketplace, "stripe", "payments"],
|
|
41
|
+
stability: StabilityEnum.Experimental
|
|
42
|
+
},
|
|
43
|
+
supportedModes: ["managed", "byok"],
|
|
44
|
+
capabilities: {
|
|
45
|
+
provides: [{ key: "payments.psp", version: "1.0.0" }]
|
|
46
|
+
},
|
|
47
|
+
configSchema: {
|
|
48
|
+
schema: StripeConfigModel,
|
|
49
|
+
example: {
|
|
50
|
+
accountId: "acct_demo_artisan",
|
|
51
|
+
webhookEndpoint: "https://pay.artisanos.dev/webhooks/stripe"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
secretSchema: {
|
|
55
|
+
schema: StripeSecretModel,
|
|
56
|
+
example: {
|
|
57
|
+
apiKey: "sk_live_redacted",
|
|
58
|
+
webhookSecret: "whsec_redacted"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
healthCheck: {
|
|
62
|
+
method: "ping",
|
|
63
|
+
timeoutMs: 5000
|
|
64
|
+
},
|
|
65
|
+
docsUrl: "https://docs.stripe.com",
|
|
66
|
+
constraints: {
|
|
67
|
+
rateLimit: {
|
|
68
|
+
rpm: 1000
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
byokSetup: {
|
|
72
|
+
setupInstructions: "Create a restricted API key and webhook endpoint, then bind the secret reference to the tenant connection.",
|
|
73
|
+
requiredScopes: ["charges:write", "customers:read", "webhooks:write"]
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
export {
|
|
77
|
+
StripePaymentsIntegrationSpec
|
|
78
|
+
};
|
package/dist/node/workflow.js
CHANGED
|
@@ -4,9 +4,10 @@ import {
|
|
|
4
4
|
StabilityEnum,
|
|
5
5
|
TagsEnum
|
|
6
6
|
} from "@contractspec/lib.contracts-spec/ownership";
|
|
7
|
-
|
|
7
|
+
import { defineWorkflow } from "@contractspec/lib.contracts-spec/workflow";
|
|
8
|
+
var collectPaymentWorkflow = defineWorkflow({
|
|
8
9
|
meta: {
|
|
9
|
-
key: "
|
|
10
|
+
key: "integration-stripe.workflow.payment",
|
|
10
11
|
version: "1.0.0",
|
|
11
12
|
title: "Collect Card Payment",
|
|
12
13
|
description: "Charge a customer using the tenant Stripe connection and record settlement details.",
|
|
@@ -48,7 +49,7 @@ var collectPaymentWorkflow = {
|
|
|
48
49
|
{ from: "charge", to: "confirm", condition: "output.success === true" }
|
|
49
50
|
]
|
|
50
51
|
}
|
|
51
|
-
};
|
|
52
|
+
});
|
|
52
53
|
export {
|
|
53
54
|
collectPaymentWorkflow
|
|
54
55
|
};
|
package/dist/workflow.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const collectPaymentWorkflow: WorkflowSpec;
|
|
1
|
+
export declare const collectPaymentWorkflow: import("@contractspec/lib.contracts-spec/workflow").WorkflowSpec;
|
package/dist/workflow.js
CHANGED
|
@@ -5,9 +5,10 @@ import {
|
|
|
5
5
|
StabilityEnum,
|
|
6
6
|
TagsEnum
|
|
7
7
|
} from "@contractspec/lib.contracts-spec/ownership";
|
|
8
|
-
|
|
8
|
+
import { defineWorkflow } from "@contractspec/lib.contracts-spec/workflow";
|
|
9
|
+
var collectPaymentWorkflow = defineWorkflow({
|
|
9
10
|
meta: {
|
|
10
|
-
key: "
|
|
11
|
+
key: "integration-stripe.workflow.payment",
|
|
11
12
|
version: "1.0.0",
|
|
12
13
|
title: "Collect Card Payment",
|
|
13
14
|
description: "Charge a customer using the tenant Stripe connection and record settlement details.",
|
|
@@ -49,7 +50,7 @@ var collectPaymentWorkflow = {
|
|
|
49
50
|
{ from: "charge", to: "confirm", condition: "output.success === true" }
|
|
50
51
|
]
|
|
51
52
|
}
|
|
52
|
-
};
|
|
53
|
+
});
|
|
53
54
|
export {
|
|
54
55
|
collectPaymentWorkflow
|
|
55
56
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contractspec/example.integration-stripe",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.10",
|
|
4
4
|
"description": "Integration example – Stripe Payments (blueprint + workflow + tenant config).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -47,6 +47,13 @@
|
|
|
47
47
|
"node": "./dist/node/example.js",
|
|
48
48
|
"default": "./dist/example.js"
|
|
49
49
|
},
|
|
50
|
+
"./integration": {
|
|
51
|
+
"types": "./dist/integration.d.ts",
|
|
52
|
+
"browser": "./dist/browser/integration.js",
|
|
53
|
+
"bun": "./dist/integration.js",
|
|
54
|
+
"node": "./dist/node/integration.js",
|
|
55
|
+
"default": "./dist/integration.js"
|
|
56
|
+
},
|
|
50
57
|
"./integration-stripe.feature": {
|
|
51
58
|
"types": "./dist/integration-stripe.feature.d.ts",
|
|
52
59
|
"browser": "./dist/browser/integration-stripe.feature.js",
|
|
@@ -85,14 +92,14 @@
|
|
|
85
92
|
"typecheck": "tsc --noEmit"
|
|
86
93
|
},
|
|
87
94
|
"dependencies": {
|
|
88
|
-
"@contractspec/lib.schema": "3.7.
|
|
89
|
-
"@contractspec/lib.contracts-spec": "4.
|
|
90
|
-
"@contractspec/lib.contracts-integrations": "3.
|
|
95
|
+
"@contractspec/lib.schema": "3.7.8",
|
|
96
|
+
"@contractspec/lib.contracts-spec": "4.1.2",
|
|
97
|
+
"@contractspec/lib.contracts-integrations": "3.8.2"
|
|
91
98
|
},
|
|
92
99
|
"devDependencies": {
|
|
93
|
-
"@contractspec/tool.typescript": "3.7.
|
|
100
|
+
"@contractspec/tool.typescript": "3.7.8",
|
|
94
101
|
"typescript": "^5.9.3",
|
|
95
|
-
"@contractspec/tool.bun": "3.7.
|
|
102
|
+
"@contractspec/tool.bun": "3.7.8"
|
|
96
103
|
},
|
|
97
104
|
"publishConfig": {
|
|
98
105
|
"access": "public",
|
|
@@ -139,6 +146,13 @@
|
|
|
139
146
|
"node": "./dist/node/example.js",
|
|
140
147
|
"default": "./dist/example.js"
|
|
141
148
|
},
|
|
149
|
+
"./integration": {
|
|
150
|
+
"types": "./dist/integration.d.ts",
|
|
151
|
+
"browser": "./dist/browser/integration.js",
|
|
152
|
+
"bun": "./dist/integration.js",
|
|
153
|
+
"node": "./dist/node/integration.js",
|
|
154
|
+
"default": "./dist/integration.js"
|
|
155
|
+
},
|
|
142
156
|
"./integration-stripe.feature": {
|
|
143
157
|
"types": "./dist/integration-stripe.feature.d.ts",
|
|
144
158
|
"browser": "./dist/browser/integration-stripe.feature.js",
|
package/src/blueprint.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { defineAppConfig } from '@contractspec/lib.contracts-spec/app-config/spec';
|
|
2
2
|
import {
|
|
3
3
|
OwnersEnum,
|
|
4
4
|
StabilityEnum,
|
|
5
5
|
TagsEnum,
|
|
6
6
|
} from '@contractspec/lib.contracts-spec/ownership';
|
|
7
|
+
import { collectPaymentWorkflow } from './workflow';
|
|
7
8
|
|
|
8
|
-
export const artisanStripeBlueprint
|
|
9
|
+
export const artisanStripeBlueprint = defineAppConfig({
|
|
9
10
|
meta: {
|
|
10
11
|
key: 'artisan.payments.stripe',
|
|
11
12
|
version: '1.0.0',
|
|
@@ -52,11 +53,10 @@ export const artisanStripeBlueprint: AppBlueprintSpec = {
|
|
|
52
53
|
},
|
|
53
54
|
workflows: {
|
|
54
55
|
collectPayment: {
|
|
55
|
-
key:
|
|
56
|
-
version:
|
|
56
|
+
key: collectPaymentWorkflow.meta.key,
|
|
57
|
+
version: collectPaymentWorkflow.meta.version,
|
|
57
58
|
},
|
|
58
59
|
},
|
|
59
|
-
policies: [{ key: 'artisan.payments.default', version: '1.0.0' }],
|
|
60
60
|
notes:
|
|
61
61
|
'Install this blueprint and pair it with the Stripe integration connection to enable card collection.',
|
|
62
|
-
};
|
|
62
|
+
});
|
package/src/connection.sample.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { IntegrationConnection } from '@contractspec/lib.contracts-integrations';
|
|
2
|
+
import { StripePaymentsIntegrationSpec } from './integration';
|
|
2
3
|
|
|
3
4
|
export const stripeLiveConnection: IntegrationConnection = {
|
|
4
5
|
meta: {
|
|
5
6
|
id: 'conn-stripe-live',
|
|
6
7
|
tenantId: 'artisan-co',
|
|
7
|
-
integrationKey:
|
|
8
|
-
integrationVersion:
|
|
8
|
+
integrationKey: StripePaymentsIntegrationSpec.meta.key,
|
|
9
|
+
integrationVersion: StripePaymentsIntegrationSpec.meta.version,
|
|
9
10
|
label: 'Stripe Production',
|
|
10
11
|
environment: 'production',
|
|
11
12
|
createdAt: '2026-01-01T00:00:00.000Z',
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
import {
|
|
3
|
+
artisanStripeBlueprint,
|
|
4
|
+
collectPaymentWorkflow,
|
|
5
|
+
IntegrationStripeFeature,
|
|
6
|
+
StripePaymentsIntegrationSpec,
|
|
7
|
+
stripeLiveConnection,
|
|
8
|
+
} from './index';
|
|
9
|
+
|
|
10
|
+
describe('@contractspec/example.integration-stripe', () => {
|
|
11
|
+
test('exports the canonical integration, workflow, and app config', () => {
|
|
12
|
+
expect(StripePaymentsIntegrationSpec.meta.key).toBe(
|
|
13
|
+
'integration-stripe.integration.psp'
|
|
14
|
+
);
|
|
15
|
+
expect(collectPaymentWorkflow.meta.key).toBe(
|
|
16
|
+
'integration-stripe.workflow.payment'
|
|
17
|
+
);
|
|
18
|
+
expect(artisanStripeBlueprint.workflows).toEqual({
|
|
19
|
+
collectPayment: {
|
|
20
|
+
key: collectPaymentWorkflow.meta.key,
|
|
21
|
+
version: collectPaymentWorkflow.meta.version,
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
expect(IntegrationStripeFeature.integrations).toEqual([
|
|
25
|
+
{
|
|
26
|
+
key: StripePaymentsIntegrationSpec.meta.key,
|
|
27
|
+
version: StripePaymentsIntegrationSpec.meta.version,
|
|
28
|
+
},
|
|
29
|
+
]);
|
|
30
|
+
expect(stripeLiveConnection.meta.integrationKey).toBe(
|
|
31
|
+
StripePaymentsIntegrationSpec.meta.key
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
});
|