@financedistrict/medusa-plugin-prism-payment 0.1.0

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.
Files changed (33) hide show
  1. package/.medusa/server/src/admin/index.js +22 -0
  2. package/.medusa/server/src/admin/index.mjs +23 -0
  3. package/.medusa/server/src/index.d.ts +57 -0
  4. package/.medusa/server/src/index.d.ts.map +1 -0
  5. package/.medusa/server/src/index.js +71 -0
  6. package/.medusa/server/src/index.js.map +1 -0
  7. package/.medusa/server/src/lib/prism-client.d.ts +85 -0
  8. package/.medusa/server/src/lib/prism-client.d.ts.map +1 -0
  9. package/.medusa/server/src/lib/prism-client.js +107 -0
  10. package/.medusa/server/src/lib/prism-client.js.map +1 -0
  11. package/.medusa/server/src/modules/prism-payment/index.d.ts +3 -0
  12. package/.medusa/server/src/modules/prism-payment/index.d.ts.map +1 -0
  13. package/.medusa/server/src/modules/prism-payment/index.js +11 -0
  14. package/.medusa/server/src/modules/prism-payment/index.js.map +1 -0
  15. package/.medusa/server/src/modules/prism-payment/service.d.ts +90 -0
  16. package/.medusa/server/src/modules/prism-payment/service.d.ts.map +1 -0
  17. package/.medusa/server/src/modules/prism-payment/service.js +344 -0
  18. package/.medusa/server/src/modules/prism-payment/service.js.map +1 -0
  19. package/.medusa/server/src/modules/prism-payment/types.d.ts +111 -0
  20. package/.medusa/server/src/modules/prism-payment/types.d.ts.map +1 -0
  21. package/.medusa/server/src/modules/prism-payment/types.js +39 -0
  22. package/.medusa/server/src/modules/prism-payment/types.js.map +1 -0
  23. package/.medusa/server/src/modules/prism-payment-handler/index.d.ts +7 -0
  24. package/.medusa/server/src/modules/prism-payment-handler/index.d.ts.map +1 -0
  25. package/.medusa/server/src/modules/prism-payment-handler/index.js +13 -0
  26. package/.medusa/server/src/modules/prism-payment-handler/index.js.map +1 -0
  27. package/.medusa/server/src/modules/prism-payment-handler/service.d.ts +40 -0
  28. package/.medusa/server/src/modules/prism-payment-handler/service.d.ts.map +1 -0
  29. package/.medusa/server/src/modules/prism-payment-handler/service.js +184 -0
  30. package/.medusa/server/src/modules/prism-payment-handler/service.js.map +1 -0
  31. package/LICENSE +21 -0
  32. package/README.md +262 -0
  33. package/package.json +58 -0
@@ -0,0 +1,344 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utils_1 = require("@medusajs/framework/utils");
4
+ /**
5
+ * Prism Payment Provider for Medusa v2
6
+ *
7
+ * Handles stablecoin payments via the x402 protocol:
8
+ * 1. Agent wallet signs EIP-3009 transferWithAuthorization (off-chain)
9
+ * 2. Authorization is passed through ACP/UCP checkout complete
10
+ * 3. This provider validates and forwards to Prism facilitator
11
+ * 4. Prism executes the on-chain transfer
12
+ *
13
+ * Settlement flow:
14
+ * initiatePayment -> stores amount/currency, returns session ID
15
+ * authorizePayment -> validates EIP-3009 authorization, optionally verifies with Prism
16
+ * capturePayment -> calls Prism /api/v2/payment/settle for on-chain execution
17
+ */
18
+ class PrismPaymentProviderService extends utils_1.AbstractPaymentProvider {
19
+ constructor(cradle, config) {
20
+ super(cradle, config);
21
+ this.apiUrl = config.api_url;
22
+ this.apiKey = config.api_key;
23
+ this.supportedChains = config.supported_chains || ["base"];
24
+ this.supportedAssets = config.supported_assets || ["usdc"];
25
+ this.autoCapture = config.auto_capture !== false;
26
+ this.verifyBeforeSettle = config.verify_before_settle !== false;
27
+ }
28
+ static validateOptions(options) {
29
+ if (!options.api_url)
30
+ throw new Error("Prism payment provider requires api_url");
31
+ if (!options.api_key) {
32
+ console.warn("[prism-payment] No PRISM_API_KEY configured — Prism payment provider will run in passthrough mode");
33
+ }
34
+ }
35
+ // =====================================================
36
+ // Core Payment Lifecycle
37
+ // =====================================================
38
+ /**
39
+ * Called when a payment session is created for the cart.
40
+ * Stores the payment amount and currency for later verification.
41
+ */
42
+ async initiatePayment(input) {
43
+ const sessionId = crypto.randomUUID();
44
+ const inputData = (input.data || {});
45
+ const data = {
46
+ prism_session_id: sessionId,
47
+ amount: input.amount,
48
+ currency_code: input.currency_code,
49
+ supported_chains: this.supportedChains,
50
+ supported_assets: this.supportedAssets,
51
+ };
52
+ // Carry forward EIP-3009 authorization if provided during session creation
53
+ if (inputData.eip3009_authorization) {
54
+ data.eip3009_authorization = inputData.eip3009_authorization;
55
+ }
56
+ if (inputData.x402_version) {
57
+ data.x402_version = inputData.x402_version;
58
+ }
59
+ return { id: sessionId, data };
60
+ }
61
+ /**
62
+ * Called during cart completion (order placement).
63
+ * Validates the EIP-3009 authorization and optionally verifies with Prism.
64
+ *
65
+ * If auto_capture is enabled, also settles the payment on-chain.
66
+ */
67
+ async authorizePayment(input) {
68
+ const data = (input.data || {});
69
+ const authorizationB64 = data.eip3009_authorization;
70
+ if (!authorizationB64) {
71
+ // No authorization provided — system default fallback or test mode
72
+ console.warn("[prism-payment] No EIP-3009 authorization provided, auto-authorizing");
73
+ return { data, status: "authorized" };
74
+ }
75
+ // Decode the base64-encoded x402 PaymentAuthorizationResult
76
+ let authorization;
77
+ try {
78
+ const decoded = Buffer.from(authorizationB64, "base64").toString("utf-8");
79
+ authorization = JSON.parse(decoded);
80
+ }
81
+ catch (error) {
82
+ console.error("[prism-payment] Failed to decode authorization:", error);
83
+ return {
84
+ data: { ...data, error: "invalid_authorization_format" },
85
+ status: "error",
86
+ };
87
+ }
88
+ // Validate basic structure
89
+ if (!authorization.paymentPayload?.payload?.authorization) {
90
+ return {
91
+ data: { ...data, error: "missing_eip3009_fields" },
92
+ status: "error",
93
+ };
94
+ }
95
+ const eip3009 = authorization.paymentPayload.payload.authorization;
96
+ // Verify chain is supported
97
+ const network = authorization.paymentPayload.network?.toLowerCase();
98
+ if (network && !this.supportedChains.includes(network)) {
99
+ return {
100
+ data: { ...data, error: `unsupported_chain: ${network}` },
101
+ status: "error",
102
+ };
103
+ }
104
+ // Verify the authorization hasn't expired
105
+ const now = Math.floor(Date.now() / 1000);
106
+ const validBefore = parseInt(eip3009.validBefore, 10);
107
+ if (validBefore && validBefore < now) {
108
+ return {
109
+ data: { ...data, error: "authorization_expired" },
110
+ status: "error",
111
+ };
112
+ }
113
+ // Optionally verify with Prism before authorizing
114
+ if (this.verifyBeforeSettle) {
115
+ try {
116
+ const verifyResult = await this.verifyWithPrism(authorization);
117
+ if (!verifyResult.valid) {
118
+ return {
119
+ data: { ...data, error: `prism_verification_failed: ${verifyResult.reason}` },
120
+ status: "error",
121
+ };
122
+ }
123
+ }
124
+ catch (error) {
125
+ const message = error instanceof Error ? error.message : "Unknown error";
126
+ console.error("[prism-payment] Prism verification failed:", message);
127
+ // Don't block on verification failure — settlement will catch actual issues
128
+ }
129
+ }
130
+ // If auto_capture, settle immediately during authorization
131
+ if (this.autoCapture) {
132
+ try {
133
+ const settleResult = await this.settleWithPrism(authorization);
134
+ if (!settleResult.success) {
135
+ return {
136
+ data: {
137
+ ...data,
138
+ error: `settlement_failed: ${settleResult.errorCode}`,
139
+ error_message: settleResult.errorMessage,
140
+ },
141
+ status: "error",
142
+ };
143
+ }
144
+ return {
145
+ data: {
146
+ ...data,
147
+ prism_tx_id: settleResult.facilitatorTransactionId,
148
+ prism_status: settleResult.status,
149
+ settled_at: settleResult.acceptedAt,
150
+ network,
151
+ payer: eip3009.from,
152
+ amount: eip3009.value,
153
+ },
154
+ status: "authorized",
155
+ };
156
+ }
157
+ catch (error) {
158
+ const message = error instanceof Error ? error.message : "Unknown error";
159
+ console.error("[prism-payment] Settlement failed:", message);
160
+ return {
161
+ data: { ...data, error: `settlement_error: ${message}` },
162
+ status: "error",
163
+ };
164
+ }
165
+ }
166
+ // Non-auto-capture: authorize only, settle on capture
167
+ return {
168
+ data: {
169
+ ...data,
170
+ x402_authorization: authorizationB64, // Preserve for capture step
171
+ network,
172
+ payer: eip3009.from,
173
+ amount: eip3009.value,
174
+ verified: true,
175
+ },
176
+ status: "authorized",
177
+ };
178
+ }
179
+ /**
180
+ * Called when admin captures the payment.
181
+ * If auto_capture was used, this is a no-op (already settled).
182
+ * Otherwise, calls Prism to execute the on-chain transfer.
183
+ */
184
+ async capturePayment(input) {
185
+ const data = (input.data || {});
186
+ // Already settled during authorization (auto_capture)
187
+ if (data.prism_tx_id) {
188
+ return { data: { ...data, captured: true } };
189
+ }
190
+ // Need to settle now
191
+ const authorizationB64 = data.x402_authorization;
192
+ if (!authorizationB64) {
193
+ // System default / test mode — auto-capture
194
+ return { data: { ...data, captured: true } };
195
+ }
196
+ try {
197
+ const authorization = JSON.parse(Buffer.from(authorizationB64, "base64").toString("utf-8"));
198
+ const settleResult = await this.settleWithPrism(authorization);
199
+ if (!settleResult.success) {
200
+ throw new Error(`Settlement failed: ${settleResult.errorCode} - ${settleResult.errorMessage}`);
201
+ }
202
+ return {
203
+ data: {
204
+ ...data,
205
+ prism_tx_id: settleResult.facilitatorTransactionId,
206
+ prism_status: settleResult.status,
207
+ settled_at: settleResult.acceptedAt,
208
+ captured: true,
209
+ },
210
+ };
211
+ }
212
+ catch (error) {
213
+ const message = error instanceof Error ? error.message : "Unknown error";
214
+ throw new Error(`[prism-payment] Capture failed: ${message}`);
215
+ }
216
+ }
217
+ /**
218
+ * Cancel an authorized payment.
219
+ * For EIP-3009, the authorization simply expires (no on-chain action needed).
220
+ */
221
+ async cancelPayment(input) {
222
+ return {
223
+ data: {
224
+ ...(input.data || {}),
225
+ canceled: true,
226
+ canceled_at: new Date().toISOString(),
227
+ },
228
+ };
229
+ }
230
+ /**
231
+ * Refund a captured payment.
232
+ * Requires a reverse transfer via Prism (out of scope for Phase 4).
233
+ */
234
+ async refundPayment(input) {
235
+ // TODO: Phase 5 — implement reverse transfer via Prism
236
+ console.warn("[prism-payment] Refund not yet implemented — manual processing required");
237
+ return {
238
+ data: {
239
+ ...(input.data || {}),
240
+ refund_requested: true,
241
+ refund_amount: String(input.amount),
242
+ refund_status: "pending_manual",
243
+ },
244
+ };
245
+ }
246
+ /**
247
+ * Delete a payment session (customer switches payment method).
248
+ */
249
+ async deletePayment(_input) {
250
+ return { data: {} };
251
+ }
252
+ /**
253
+ * Retrieve payment data from the provider.
254
+ */
255
+ async retrievePayment(input) {
256
+ return { data: (input.data || {}) };
257
+ }
258
+ /**
259
+ * Update a payment session (e.g., cart total changed).
260
+ */
261
+ async updatePayment(input) {
262
+ return {
263
+ data: {
264
+ ...(input.data || {}),
265
+ amount: input.amount,
266
+ currency_code: input.currency_code,
267
+ },
268
+ };
269
+ }
270
+ /**
271
+ * Get current payment status from the provider.
272
+ */
273
+ async getPaymentStatus(input) {
274
+ const data = (input.data || {});
275
+ if (data.error)
276
+ return { data, status: "error" };
277
+ if (data.captured || data.prism_tx_id)
278
+ return { data, status: "captured" };
279
+ if (data.canceled)
280
+ return { data, status: "canceled" };
281
+ if (data.verified || data.x402_authorization)
282
+ return { data, status: "authorized" };
283
+ return { data, status: "pending" };
284
+ }
285
+ /**
286
+ * Handle incoming webhooks from Prism (settlement confirmations, etc.)
287
+ */
288
+ async getWebhookActionAndData(_data) {
289
+ // TODO: Phase 5 — handle Prism webhook events (settlement confirmed, failed, etc.)
290
+ return { action: "not_supported" };
291
+ }
292
+ // =====================================================
293
+ // Prism API Client Methods
294
+ // =====================================================
295
+ /**
296
+ * Verify an EIP-3009 authorization with Prism before settlement.
297
+ */
298
+ async verifyWithPrism(authorization) {
299
+ const version = authorization.x402Version || 2;
300
+ const response = await fetch(`${this.apiUrl}/api/v${version}/payment/verify`, {
301
+ method: "POST",
302
+ headers: {
303
+ "Content-Type": "application/json",
304
+ "X-API-Key": this.apiKey,
305
+ },
306
+ body: JSON.stringify({
307
+ x402Version: version,
308
+ paymentPayload: authorization.paymentPayload,
309
+ paymentRequirements: authorization.paymentRequirements,
310
+ }),
311
+ });
312
+ if (!response.ok) {
313
+ const errorText = await response.text().catch(() => "Unknown error");
314
+ throw new Error(`Prism verify returned ${response.status}: ${errorText}`);
315
+ }
316
+ return response.json();
317
+ }
318
+ /**
319
+ * Settle (execute on-chain) an EIP-3009 authorization via Prism.
320
+ */
321
+ async settleWithPrism(authorization) {
322
+ const version = authorization.x402Version || 2;
323
+ const response = await fetch(`${this.apiUrl}/api/v${version}/payment/settle`, {
324
+ method: "POST",
325
+ headers: {
326
+ "Content-Type": "application/json",
327
+ "X-API-Key": this.apiKey,
328
+ },
329
+ body: JSON.stringify({
330
+ x402Version: version,
331
+ paymentPayload: authorization.paymentPayload,
332
+ paymentRequirements: authorization.paymentRequirements,
333
+ }),
334
+ });
335
+ if (!response.ok) {
336
+ const errorText = await response.text().catch(() => "Unknown error");
337
+ throw new Error(`Prism settle returned ${response.status}: ${errorText}`);
338
+ }
339
+ return response.json();
340
+ }
341
+ }
342
+ PrismPaymentProviderService.identifier = "prism";
343
+ exports.default = PrismPaymentProviderService;
344
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../../../../src/modules/prism-payment/service.ts"],"names":[],"mappings":";;AAAA,qDAAmE;AA+BnE;;;;;;;;;;;;;GAaG;AACH,MAAM,2BAA4B,SAAQ,+BAA2C;IAUnF,YAAY,MAA+B,EAAE,MAA0B;QACrE,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QAErB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,OAAO,CAAA;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,OAAO,CAAA;QAC5B,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,gBAAgB,IAAI,CAAC,MAAM,CAAC,CAAA;QAC1D,IAAI,CAAC,eAAe,GAAG,MAAM,CAAC,gBAAgB,IAAI,CAAC,MAAM,CAAC,CAAA;QAC1D,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,YAAY,KAAK,KAAK,CAAA;QAChD,IAAI,CAAC,kBAAkB,GAAG,MAAM,CAAC,oBAAoB,KAAK,KAAK,CAAA;IACjE,CAAC;IAED,MAAM,CAAC,eAAe,CAAC,OAAgC;QACrD,IAAI,CAAC,OAAO,CAAC,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,yCAAyC,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O,QAAQ,CAAC,IAAI,EAAkC,CAAA;IACxD,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,eAAe,CAC3B,aAAuC;QAEvC,MAAM,OAAO,GAAG,aAAa,CAAC,WAAW,IAAI,CAAC,CAAA;QAC9C,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,MAAM,SAAS,OAAO,iBAAiB,EAAE;YAC5E,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,WAAW,EAAE,IAAI,CAAC,MAAM;aACzB;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACnB,WAAW,EAAE,OAAO;gBACpB,cAAc,EAAE,aAAa,CAAC,cAAc;gBAC5C,mBAAmB,EAAE,aAAa,CAAC,mBAAmB;aACvD,CAAC;SACH,CAAC,CAAA;QAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,CAAA;YACpE,MAAM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC,CAAA;QAC3E,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,EAAkC,CAAA;IACxD,CAAC;;AAnXM,sCAAU,GAAG,OAAO,CAAA;AAsX7B,kBAAe,2BAA2B,CAAA"}
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Types for the Prism Payment Provider
3
+ *
4
+ * Covers:
5
+ * - EIP-3009 authorization structure (from Agent Wallet's authorizePayment tool)
6
+ * - Prism facilitator API request/response
7
+ * - Payment handler instrument schema for ACP/UCP
8
+ */
9
+ /**
10
+ * The credential payload inside an instrument of type "eip3009_authorization".
11
+ * This is what the agent submits at checkout complete.
12
+ *
13
+ * Two modes:
14
+ * - "payload" mode: Agent sends the full x402 PaymentAuthorizationResult
15
+ * (base64-encoded JSON containing paymentPayload + paymentRequirements)
16
+ * - "raw" mode: Agent sends individual EIP-3009 fields (from, to, value, signature, etc.)
17
+ */
18
+ export type Eip3009Credential = {
19
+ /** Base64-encoded JSON of the full x402 PaymentAuthorizationResult */
20
+ authorization: string;
21
+ /** x402 protocol version used (1 or 2). Defaults to 2. */
22
+ x402_version?: number;
23
+ };
24
+ /**
25
+ * Decoded x402 PaymentAuthorizationResult
26
+ * (what's inside the base64-encoded authorization string)
27
+ */
28
+ export type X402PaymentAuthorization = {
29
+ x402Version: number;
30
+ paymentPayload: X402PaymentPayload;
31
+ paymentRequirements: Record<string, unknown>;
32
+ };
33
+ export type X402PaymentPayload = {
34
+ x402Version: number;
35
+ scheme: string;
36
+ network: string;
37
+ payload: EvmPayloadData;
38
+ };
39
+ export type EvmPayloadData = {
40
+ signature: string;
41
+ authorization: Eip3009Authorization;
42
+ };
43
+ export type Eip3009Authorization = {
44
+ from: string;
45
+ to: string;
46
+ value: string;
47
+ validAfter: string;
48
+ validBefore: string;
49
+ nonce: string;
50
+ };
51
+ /** Request to Prism Gateway POST /api/v2/payment/settle */
52
+ export type PrismSettleRequest = {
53
+ x402Version: number;
54
+ paymentPayload: X402PaymentPayload;
55
+ paymentRequirements: Record<string, unknown>;
56
+ };
57
+ /** Response from Prism Gateway POST /api/v2/payment/settle */
58
+ export type PrismSettleResponse = {
59
+ success: boolean;
60
+ facilitatorTransactionId: string;
61
+ status: "Accepted" | "Queued" | "Processing" | "Settled" | "Failed";
62
+ acceptedAt: string;
63
+ errorMessage?: string;
64
+ errorCode?: string;
65
+ };
66
+ /** Request to Prism Gateway POST /api/v2/payment/verify */
67
+ export type PrismVerifyRequest = PrismSettleRequest;
68
+ /** Response from Prism Gateway POST /api/v2/payment/verify */
69
+ export type PrismVerifyResponse = {
70
+ valid: boolean;
71
+ reason?: string;
72
+ };
73
+ export type PrismPaymentConfig = {
74
+ /** Prism Gateway API base URL */
75
+ api_url: string;
76
+ /** API key for Prism Gateway authentication (identifies merchant + settlement config) */
77
+ api_key: string;
78
+ /** Supported chains (default: ["base"]) */
79
+ supported_chains?: string[];
80
+ /** Supported assets (default: ["usdc"]) */
81
+ supported_assets?: string[];
82
+ /** Whether to auto-capture on authorization (default: true) */
83
+ auto_capture?: boolean;
84
+ /** Whether to verify authorization before settling (default: true) */
85
+ verify_before_settle?: boolean;
86
+ };
87
+ /**
88
+ * The instrument schema for xyz.fd.prism_payment handler.
89
+ * Published in ACP/UCP discovery so agents know what to submit.
90
+ */
91
+ export declare const PRISM_HANDLER_ID = "xyz.fd.prism_payment";
92
+ export declare const PRISM_INSTRUMENT_SCHEMA: {
93
+ readonly type: "eip3009_authorization";
94
+ readonly credential_schema: {
95
+ readonly type: "object";
96
+ readonly required: readonly ["authorization"];
97
+ readonly properties: {
98
+ readonly authorization: {
99
+ readonly type: "string";
100
+ readonly description: "Base64-encoded JSON of the x402 PaymentAuthorizationResult from the agent wallet's authorizePayment tool";
101
+ };
102
+ readonly x402_version: {
103
+ readonly type: "integer";
104
+ readonly enum: readonly [1, 2];
105
+ readonly default: 2;
106
+ readonly description: "x402 protocol version";
107
+ };
108
+ };
109
+ };
110
+ };
111
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/modules/prism-payment/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH;;;;;;;;GAQG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,sEAAsE;IACtE,aAAa,EAAE,MAAM,CAAA;IACrB,0DAA0D;IAC1D,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,EAAE,kBAAkB,CAAA;IAClC,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC7C,CAAA;AAED,MAAM,MA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IACf,yFAAyF;IACzF,OAAO,EAAE,MAAM,CAAA;IACf,2CAA2C;IAC3C,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC3B,2CAA2C;IAC3C,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC3B,+DAA+D;IAC/D,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,sEAAsE;IACtE,oBAAoB,CAAC,EAAE,OAAO,CAAA;CAC/B,CAAA;AAMD;;;GAGG;AACH,eAAO,MAAM,gBAAgB,yBAAyB,CAAA;AAEtD,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;CAkB1B,CAAA"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ /**
3
+ * Types for the Prism Payment Provider
4
+ *
5
+ * Covers:
6
+ * - EIP-3009 authorization structure (from Agent Wallet's authorizePayment tool)
7
+ * - Prism facilitator API request/response
8
+ * - Payment handler instrument schema for ACP/UCP
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.PRISM_INSTRUMENT_SCHEMA = exports.PRISM_HANDLER_ID = void 0;
12
+ // =====================================================
13
+ // Handler / Instrument Schema (for protocol discovery)
14
+ // =====================================================
15
+ /**
16
+ * The instrument schema for xyz.fd.prism_payment handler.
17
+ * Published in ACP/UCP discovery so agents know what to submit.
18
+ */
19
+ exports.PRISM_HANDLER_ID = "xyz.fd.prism_payment";
20
+ exports.PRISM_INSTRUMENT_SCHEMA = {
21
+ type: "eip3009_authorization",
22
+ credential_schema: {
23
+ type: "object",
24
+ required: ["authorization"],
25
+ properties: {
26
+ authorization: {
27
+ type: "string",
28
+ description: "Base64-encoded JSON of the x402 PaymentAuthorizationResult from the agent wallet's authorizePayment tool",
29
+ },
30
+ x402_version: {
31
+ type: "integer",
32
+ enum: [1, 2],
33
+ default: 2,
34
+ description: "x402 protocol version",
35
+ },
36
+ },
37
+ },
38
+ };
39
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/modules/prism-payment/types.ts"],"names":[],"mappings":";AAAA;;;;;;;GAOG;;;AAsGH,wDAAwD;AACxD,uDAAuD;AACvD,wDAAwD;AAExD;;;GAGG;AACU,QAAA,gBAAgB,GAAG,sBAAsB,CAAA;AAEzC,QAAA,uBAAuB,GAAG;IACrC,IAAI,EAAE,uBAAuB;IAC7B,iBAAiB,EAAE;QACjB,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,CAAC,eAAe,CAAC;QAC3B,UAAU,EAAE;YACV,aAAa,EAAE;gBACb,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,0GAA0G;aACxH;YACD,YAAY,EAAE;gBACZ,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;gBACZ,OAAO,EAAE,CAAC;gBACV,WAAW,EAAE,uBAAuB;aACrC;SACF;KACF;CACO,CAAA"}
@@ -0,0 +1,7 @@
1
+ import PrismPaymentHandlerAdapter from "./service";
2
+ export declare const PRISM_PAYMENT_HANDLER_MODULE = "prismPaymentHandler";
3
+ declare const _default: import("@medusajs/types").ModuleExports<typeof PrismPaymentHandlerAdapter> & {
4
+ linkable: Record<string, any>;
5
+ };
6
+ export default _default;
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/modules/prism-payment-handler/index.ts"],"names":[],"mappings":"AACA,OAAO,0BAA0B,MAAM,WAAW,CAAA;AAElD,eAAO,MAAM,4BAA4B,wBAAwB,CAAA;;;;AAEjE,wBAEE"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.PRISM_PAYMENT_HANDLER_MODULE = void 0;
7
+ const utils_1 = require("@medusajs/framework/utils");
8
+ const service_1 = __importDefault(require("./service"));
9
+ exports.PRISM_PAYMENT_HANDLER_MODULE = "prismPaymentHandler";
10
+ exports.default = (0, utils_1.Module)(exports.PRISM_PAYMENT_HANDLER_MODULE, {
11
+ service: service_1.default,
12
+ });
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/prism-payment-handler/index.ts"],"names":[],"mappings":";;;;;;AAAA,qDAAkD;AAClD,wDAAkD;AAErC,QAAA,4BAA4B,GAAG,qBAAqB,CAAA;AAEjE,kBAAe,IAAA,cAAM,EAAC,oCAA4B,EAAE;IAClD,OAAO,EAAE,iBAA0B;CACpC,CAAC,CAAA"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Prism Payment Handler Adapter
3
+ *
4
+ * Implements the PaymentHandlerAdapter interface from
5
+ * @financedistrict/medusa-plugin-agentic-commerce.
6
+ *
7
+ * Provides x402 stablecoin payment support via the Prism Gateway:
8
+ * - Discovery: advertises Prism payment handlers in .well-known/ucp and .well-known/acp.json
9
+ * - Checkout preparation: calls Prism checkout-prepare to get x402 payment requirements
10
+ * - Response formatting: includes Prism payment config in checkout session responses
11
+ *
12
+ * Register this module in medusa-config.ts, then reference "prismPaymentHandler"
13
+ * in the agentic commerce plugin's payment_handler_adapters option.
14
+ */
15
+ import type { PaymentHandlerAdapter, CheckoutPrepareInput } from "@financedistrict/medusa-plugin-agentic-commerce";
16
+ import type { CheckoutPrepareResult } from "../../lib/prism-client";
17
+ /** Metadata key where checkout-prepare config is stored on the cart */
18
+ export declare const PRISM_CHECKOUT_CONFIG_KEY = "prism_checkout_config";
19
+ export type PrismPaymentHandlerOptions = {
20
+ /** Prism Gateway API base URL (default: https://prism-gw.fd.xyz) */
21
+ api_url?: string;
22
+ /** Prism Gateway API key for merchant authentication */
23
+ api_key?: string;
24
+ };
25
+ export default class PrismPaymentHandlerAdapter implements PaymentHandlerAdapter {
26
+ readonly id = "xyz.fd.prism_payment";
27
+ readonly name = "Finance District Prism";
28
+ private client;
29
+ /** Cached Prism payment-profile for discovery (5 min TTL) */
30
+ private profileCache;
31
+ private readonly PROFILE_TTL;
32
+ constructor(_container: Record<string, unknown>, options?: PrismPaymentHandlerOptions);
33
+ getUcpDiscoveryHandlers(): Promise<Record<string, unknown[]>>;
34
+ getAcpDiscoveryHandlers(): Promise<unknown[]>;
35
+ prepareCheckoutPayment(input: CheckoutPrepareInput): Promise<CheckoutPrepareResult | null>;
36
+ getUcpCheckoutHandlers(cartMetadata?: Record<string, unknown>): Record<string, unknown[]>;
37
+ getAcpCheckoutHandlers(cartMetadata?: Record<string, unknown>): unknown[];
38
+ private fetchProfile;
39
+ }
40
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../../../src/modules/prism-payment-handler/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,iDAAiD,CAAA;AAElH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AAOnE,uEAAuE;AACvE,eAAO,MAAM,yBAAyB,0BAA0B,CAAA;AAMhE,MAAM,MAAM,0BAA0B,GAAG;IACvC,oEAAoE;IACpE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAMD,MAAM,CAAC,OAAO,OAAO,0BAA2B,YAAW,qBAAqB;IAC9E,QAAQ,CAAC,EAAE,0BAAmB;IAC9B,QAAQ,CAAC,IAAI,4BAA2B;IAExC,OAAO,CAAC,MAAM,CAAa;IAE3B,6DAA6D;IAC7D,OAAO,CAAC,YAAY,CAAmE;IACvF,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAgB;gBAEhC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAA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