@alphawebai/medusa-custom-payments-react 0.1.0-rc.39 → 0.1.0-rc.40

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/README.md CHANGED
@@ -52,3 +52,8 @@ For redirect-based payment methods, the host must recognize the returned
52
52
  payment session before rendering this component again, stop rendering Elements,
53
53
  and resume its server-authoritative checkout completion contract. Do not mount
54
54
  this component with a PaymentIntent that may already be terminal.
55
+
56
+ Deferred Stripe consumers that own a page-level error surface can set
57
+ `errorPresentation="external"`. The `onError` callback then identifies whether
58
+ Stripe already presented the error (`presentation: "provider"`) or the host must
59
+ present it (`presentation: "host"`), so the same message is never rendered twice.
@@ -47,6 +47,38 @@ function normalizeStripePaymentIntent(paymentIntent) {
47
47
  }
48
48
  }
49
49
 
50
+ // src/prism/stripe-error-presentation.ts
51
+ var paymentElementErrorCodes = /* @__PURE__ */ new Set([
52
+ "card_declined",
53
+ "card_velocity_exceeded",
54
+ "expired_card",
55
+ "fraudulent",
56
+ "generic_decline",
57
+ "incorrect_cvc",
58
+ "incorrect_number",
59
+ "incorrect_zip",
60
+ "insufficient_funds",
61
+ "invalid_cvc",
62
+ "invalid_expiry_month",
63
+ "invalid_expiry_year",
64
+ "live_mode_test_card",
65
+ "lost_card",
66
+ "processing_error",
67
+ "stolen_card",
68
+ "test_mode_live_card"
69
+ ]);
70
+ function stripeErrorContext(phase, error) {
71
+ const paymentElementOwnsMessage = error.type === "validation_error" || error.code !== void 0 && paymentElementErrorCodes.has(error.code) || error.decline_code !== void 0 && paymentElementErrorCodes.has(error.decline_code);
72
+ return {
73
+ connector: "stripe",
74
+ phase,
75
+ presentation: paymentElementOwnsMessage ? "provider" : "host"
76
+ };
77
+ }
78
+ function hostErrorContext(phase) {
79
+ return { connector: "stripe", phase, presentation: "host" };
80
+ }
81
+
50
82
  // src/prism/PrismDeferredPaymentElement.tsx
51
83
  import { jsx, jsxs } from "react/jsx-runtime";
52
84
  var stripeByPublishableKey = /* @__PURE__ */ new Map();
@@ -113,21 +145,34 @@ function DeferredPaymentElementForm(props) {
113
145
  onPending: props.onPending,
114
146
  onRequiresAction: props.onRequiresAction
115
147
  };
148
+ function reportError(error, context) {
149
+ setMessage(
150
+ context.presentation === "host" && props.errorPresentation !== "external" ? error.message : null
151
+ );
152
+ props.onError(error, context);
153
+ }
116
154
  async function submit(event) {
117
155
  event.preventDefault();
118
156
  if (!stripe || !elements || submitting || props.disabled) return;
119
157
  setSubmitting(true);
120
158
  props.onSubmittingChange?.(true);
121
159
  setMessage(null);
160
+ let phase = "details";
122
161
  try {
123
162
  const submitted = await elements.submit();
124
163
  if (submitted.error) {
125
- throw new Error(
126
- submitted.error.message ?? "Payment details are incomplete."
164
+ reportError(
165
+ new Error(
166
+ submitted.error.message ?? "Payment details are incomplete."
167
+ ),
168
+ stripeErrorContext("details", submitted.error)
127
169
  );
170
+ return;
128
171
  }
172
+ phase = "prepare";
129
173
  const prepared = await props.onPrepare();
130
174
  const clientSecret = assertPreparedClientSecret(prepared?.clientSecret);
175
+ phase = "confirm";
131
176
  const result = await stripe.confirmPayment({
132
177
  elements,
133
178
  clientSecret,
@@ -142,19 +187,23 @@ function DeferredPaymentElementForm(props) {
142
187
  redirect: "if_required"
143
188
  });
144
189
  if (result.error) {
145
- throw new Error(result.error.message ?? "Stripe could not confirm payment.");
190
+ reportError(
191
+ new Error(result.error.message ?? "Stripe could not confirm payment."),
192
+ stripeErrorContext("confirm", result.error)
193
+ );
194
+ return;
146
195
  }
147
196
  if (!result.paymentIntent) {
148
197
  throw new Error("Stripe did not return a payment result.");
149
198
  }
199
+ phase = "outcome";
150
200
  await dispatchOutcome(
151
201
  normalizeStripePaymentIntent(result.paymentIntent),
152
202
  callbacks
153
203
  );
154
204
  } catch (error) {
155
205
  const safeError = error instanceof Error ? error : new Error("Payment could not be completed.");
156
- setMessage(safeError.message);
157
- props.onError(safeError);
206
+ reportError(safeError, hostErrorContext(phase));
158
207
  } finally {
159
208
  setSubmitting(false);
160
209
  props.onSubmittingChange?.(false);
@@ -174,8 +223,7 @@ function DeferredPaymentElementForm(props) {
174
223
  onReady: () => setReady(true),
175
224
  onLoadError: (event) => {
176
225
  const error = new Error(event.error.message);
177
- setMessage(error.message);
178
- props.onError(error);
226
+ reportError(error, hostErrorContext("load"));
179
227
  }
180
228
  }
181
229
  ),
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
- import { P as PrismDeferredPaymentElementProps, a as PrismPaymentElementProps } from './types-CHvHlDN6.mjs';
3
- export { b as PrismCheckoutProviderContext, c as PrismClickTimePayPalButtonProps, d as PrismClickTimePayPalOrder, e as PrismDeferredPaymentSurfaceProps, f as PrismDeferredStripePreparedPayment, g as PrismPayPalApprovalOutcome, h as PrismPayPalCheckoutProviderContext, i as PrismPayPalPaymentButtonClassNames, j as PrismPayPalPaymentButtonProps, k as PrismPaymentBillingDetails, l as PrismPaymentOutcome, m as PrismPaymentSurfaceProps, n as PrismPreparedPayPalPaymentSession, o as PrismPreparedPaymentSession, p as PrismPreparedStripePaymentSession, q as PrismStripeCheckoutProviderContext, r as PrismStripeDisplayPolicy, S as StripeSupportedTermMethod } from './types-CHvHlDN6.mjs';
2
+ import { P as PrismDeferredPaymentElementProps, a as PrismPaymentElementProps } from './types-DY41P1Ua.mjs';
3
+ export { b as PrismCheckoutProviderContext, c as PrismClickTimePayPalButtonProps, d as PrismClickTimePayPalOrder, e as PrismDeferredPaymentSurfaceProps, f as PrismDeferredStripePreparedPayment, g as PrismPayPalApprovalOutcome, h as PrismPayPalCheckoutProviderContext, i as PrismPayPalPaymentButtonClassNames, j as PrismPayPalPaymentButtonProps, k as PrismPaymentBillingDetails, l as PrismPaymentErrorContext, m as PrismPaymentErrorPhase, n as PrismPaymentErrorPresentation, o as PrismPaymentOutcome, p as PrismPaymentSurfaceProps, q as PrismPreparedPayPalPaymentSession, r as PrismPreparedPaymentSession, s as PrismPreparedStripePaymentSession, t as PrismStripeCheckoutProviderContext, u as PrismStripeDisplayPolicy, S as StripeSupportedTermMethod } from './types-DY41P1Ua.mjs';
4
4
  import '@stripe/stripe-js';
5
5
 
6
6
  declare function PrismDeferredPaymentElement(props: PrismDeferredPaymentElementProps): react.JSX.Element;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
- import { P as PrismDeferredPaymentElementProps, a as PrismPaymentElementProps } from './types-CHvHlDN6.js';
3
- export { b as PrismCheckoutProviderContext, c as PrismClickTimePayPalButtonProps, d as PrismClickTimePayPalOrder, e as PrismDeferredPaymentSurfaceProps, f as PrismDeferredStripePreparedPayment, g as PrismPayPalApprovalOutcome, h as PrismPayPalCheckoutProviderContext, i as PrismPayPalPaymentButtonClassNames, j as PrismPayPalPaymentButtonProps, k as PrismPaymentBillingDetails, l as PrismPaymentOutcome, m as PrismPaymentSurfaceProps, n as PrismPreparedPayPalPaymentSession, o as PrismPreparedPaymentSession, p as PrismPreparedStripePaymentSession, q as PrismStripeCheckoutProviderContext, r as PrismStripeDisplayPolicy, S as StripeSupportedTermMethod } from './types-CHvHlDN6.js';
2
+ import { P as PrismDeferredPaymentElementProps, a as PrismPaymentElementProps } from './types-DY41P1Ua.js';
3
+ export { b as PrismCheckoutProviderContext, c as PrismClickTimePayPalButtonProps, d as PrismClickTimePayPalOrder, e as PrismDeferredPaymentSurfaceProps, f as PrismDeferredStripePreparedPayment, g as PrismPayPalApprovalOutcome, h as PrismPayPalCheckoutProviderContext, i as PrismPayPalPaymentButtonClassNames, j as PrismPayPalPaymentButtonProps, k as PrismPaymentBillingDetails, l as PrismPaymentErrorContext, m as PrismPaymentErrorPhase, n as PrismPaymentErrorPresentation, o as PrismPaymentOutcome, p as PrismPaymentSurfaceProps, q as PrismPreparedPayPalPaymentSession, r as PrismPreparedPaymentSession, s as PrismPreparedStripePaymentSession, t as PrismStripeCheckoutProviderContext, u as PrismStripeDisplayPolicy, S as StripeSupportedTermMethod } from './types-DY41P1Ua.js';
4
4
  import '@stripe/stripe-js';
5
5
 
6
6
  declare function PrismDeferredPaymentElement(props: PrismDeferredPaymentElementProps): react.JSX.Element;
package/dist/index.js CHANGED
@@ -67,6 +67,38 @@ function normalizeStripePaymentIntent(paymentIntent) {
67
67
  }
68
68
  }
69
69
 
70
+ // src/prism/stripe-error-presentation.ts
71
+ var paymentElementErrorCodes = /* @__PURE__ */ new Set([
72
+ "card_declined",
73
+ "card_velocity_exceeded",
74
+ "expired_card",
75
+ "fraudulent",
76
+ "generic_decline",
77
+ "incorrect_cvc",
78
+ "incorrect_number",
79
+ "incorrect_zip",
80
+ "insufficient_funds",
81
+ "invalid_cvc",
82
+ "invalid_expiry_month",
83
+ "invalid_expiry_year",
84
+ "live_mode_test_card",
85
+ "lost_card",
86
+ "processing_error",
87
+ "stolen_card",
88
+ "test_mode_live_card"
89
+ ]);
90
+ function stripeErrorContext(phase, error) {
91
+ const paymentElementOwnsMessage = error.type === "validation_error" || error.code !== void 0 && paymentElementErrorCodes.has(error.code) || error.decline_code !== void 0 && paymentElementErrorCodes.has(error.decline_code);
92
+ return {
93
+ connector: "stripe",
94
+ phase,
95
+ presentation: paymentElementOwnsMessage ? "provider" : "host"
96
+ };
97
+ }
98
+ function hostErrorContext(phase) {
99
+ return { connector: "stripe", phase, presentation: "host" };
100
+ }
101
+
70
102
  // src/prism/PrismDeferredPaymentElement.tsx
71
103
  var import_jsx_runtime = require("react/jsx-runtime");
72
104
  var stripeByPublishableKey = /* @__PURE__ */ new Map();
@@ -133,21 +165,34 @@ function DeferredPaymentElementForm(props) {
133
165
  onPending: props.onPending,
134
166
  onRequiresAction: props.onRequiresAction
135
167
  };
168
+ function reportError(error, context) {
169
+ setMessage(
170
+ context.presentation === "host" && props.errorPresentation !== "external" ? error.message : null
171
+ );
172
+ props.onError(error, context);
173
+ }
136
174
  async function submit(event) {
137
175
  event.preventDefault();
138
176
  if (!stripe || !elements || submitting || props.disabled) return;
139
177
  setSubmitting(true);
140
178
  props.onSubmittingChange?.(true);
141
179
  setMessage(null);
180
+ let phase = "details";
142
181
  try {
143
182
  const submitted = await elements.submit();
144
183
  if (submitted.error) {
145
- throw new Error(
146
- submitted.error.message ?? "Payment details are incomplete."
184
+ reportError(
185
+ new Error(
186
+ submitted.error.message ?? "Payment details are incomplete."
187
+ ),
188
+ stripeErrorContext("details", submitted.error)
147
189
  );
190
+ return;
148
191
  }
192
+ phase = "prepare";
149
193
  const prepared = await props.onPrepare();
150
194
  const clientSecret = assertPreparedClientSecret(prepared?.clientSecret);
195
+ phase = "confirm";
151
196
  const result = await stripe.confirmPayment({
152
197
  elements,
153
198
  clientSecret,
@@ -162,19 +207,23 @@ function DeferredPaymentElementForm(props) {
162
207
  redirect: "if_required"
163
208
  });
164
209
  if (result.error) {
165
- throw new Error(result.error.message ?? "Stripe could not confirm payment.");
210
+ reportError(
211
+ new Error(result.error.message ?? "Stripe could not confirm payment."),
212
+ stripeErrorContext("confirm", result.error)
213
+ );
214
+ return;
166
215
  }
167
216
  if (!result.paymentIntent) {
168
217
  throw new Error("Stripe did not return a payment result.");
169
218
  }
219
+ phase = "outcome";
170
220
  await dispatchOutcome(
171
221
  normalizeStripePaymentIntent(result.paymentIntent),
172
222
  callbacks
173
223
  );
174
224
  } catch (error) {
175
225
  const safeError = error instanceof Error ? error : new Error("Payment could not be completed.");
176
- setMessage(safeError.message);
177
- props.onError(safeError);
226
+ reportError(safeError, hostErrorContext(phase));
178
227
  } finally {
179
228
  setSubmitting(false);
180
229
  props.onSubmittingChange?.(false);
@@ -194,8 +243,7 @@ function DeferredPaymentElementForm(props) {
194
243
  onReady: () => setReady(true),
195
244
  onLoadError: (event) => {
196
245
  const error = new Error(event.error.message);
197
- setMessage(error.message);
198
- props.onError(error);
246
+ reportError(error, hostErrorContext("load"));
199
247
  }
200
248
  }
201
249
  ),
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  PrismDeferredPaymentElement,
3
3
  PrismPaymentElement
4
- } from "./chunk-CNZSWNL2.mjs";
4
+ } from "./chunk-FMPWH5MM.mjs";
5
5
  export {
6
6
  PrismDeferredPaymentElement,
7
7
  PrismPaymentElement
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
- import { e as PrismDeferredPaymentSurfaceProps, m as PrismPaymentSurfaceProps } from './types-CHvHlDN6.mjs';
3
- export { b as PrismCheckoutProviderContext, h as PrismPayPalCheckoutProviderContext, o as PrismPreparedPaymentSession, q as PrismStripeCheckoutProviderContext } from './types-CHvHlDN6.mjs';
2
+ import { e as PrismDeferredPaymentSurfaceProps, p as PrismPaymentSurfaceProps } from './types-DY41P1Ua.mjs';
3
+ export { b as PrismCheckoutProviderContext, h as PrismPayPalCheckoutProviderContext, l as PrismPaymentErrorContext, m as PrismPaymentErrorPhase, n as PrismPaymentErrorPresentation, r as PrismPreparedPaymentSession, t as PrismStripeCheckoutProviderContext } from './types-DY41P1Ua.mjs';
4
4
  import '@stripe/stripe-js';
5
5
 
6
6
  /**
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
- import { e as PrismDeferredPaymentSurfaceProps, m as PrismPaymentSurfaceProps } from './types-CHvHlDN6.js';
3
- export { b as PrismCheckoutProviderContext, h as PrismPayPalCheckoutProviderContext, o as PrismPreparedPaymentSession, q as PrismStripeCheckoutProviderContext } from './types-CHvHlDN6.js';
2
+ import { e as PrismDeferredPaymentSurfaceProps, p as PrismPaymentSurfaceProps } from './types-DY41P1Ua.js';
3
+ export { b as PrismCheckoutProviderContext, h as PrismPayPalCheckoutProviderContext, l as PrismPaymentErrorContext, m as PrismPaymentErrorPhase, n as PrismPaymentErrorPresentation, r as PrismPreparedPaymentSession, t as PrismStripeCheckoutProviderContext } from './types-DY41P1Ua.js';
4
4
  import '@stripe/stripe-js';
5
5
 
6
6
  /**
@@ -187,6 +187,38 @@ function normalizeStripePaymentIntent(paymentIntent) {
187
187
  }
188
188
  }
189
189
 
190
+ // src/prism/stripe-error-presentation.ts
191
+ var paymentElementErrorCodes = /* @__PURE__ */ new Set([
192
+ "card_declined",
193
+ "card_velocity_exceeded",
194
+ "expired_card",
195
+ "fraudulent",
196
+ "generic_decline",
197
+ "incorrect_cvc",
198
+ "incorrect_number",
199
+ "incorrect_zip",
200
+ "insufficient_funds",
201
+ "invalid_cvc",
202
+ "invalid_expiry_month",
203
+ "invalid_expiry_year",
204
+ "live_mode_test_card",
205
+ "lost_card",
206
+ "processing_error",
207
+ "stolen_card",
208
+ "test_mode_live_card"
209
+ ]);
210
+ function stripeErrorContext(phase, error) {
211
+ const paymentElementOwnsMessage = error.type === "validation_error" || error.code !== void 0 && paymentElementErrorCodes.has(error.code) || error.decline_code !== void 0 && paymentElementErrorCodes.has(error.decline_code);
212
+ return {
213
+ connector: "stripe",
214
+ phase,
215
+ presentation: paymentElementOwnsMessage ? "provider" : "host"
216
+ };
217
+ }
218
+ function hostErrorContext(phase) {
219
+ return { connector: "stripe", phase, presentation: "host" };
220
+ }
221
+
190
222
  // src/prism/PrismDeferredPaymentElement.tsx
191
223
  var import_jsx_runtime2 = require("react/jsx-runtime");
192
224
  var stripeByPublishableKey = /* @__PURE__ */ new Map();
@@ -253,21 +285,34 @@ function DeferredPaymentElementForm(props) {
253
285
  onPending: props.onPending,
254
286
  onRequiresAction: props.onRequiresAction
255
287
  };
288
+ function reportError(error, context) {
289
+ setMessage(
290
+ context.presentation === "host" && props.errorPresentation !== "external" ? error.message : null
291
+ );
292
+ props.onError(error, context);
293
+ }
256
294
  async function submit(event) {
257
295
  event.preventDefault();
258
296
  if (!stripe || !elements || submitting || props.disabled) return;
259
297
  setSubmitting(true);
260
298
  props.onSubmittingChange?.(true);
261
299
  setMessage(null);
300
+ let phase = "details";
262
301
  try {
263
302
  const submitted = await elements.submit();
264
303
  if (submitted.error) {
265
- throw new Error(
266
- submitted.error.message ?? "Payment details are incomplete."
304
+ reportError(
305
+ new Error(
306
+ submitted.error.message ?? "Payment details are incomplete."
307
+ ),
308
+ stripeErrorContext("details", submitted.error)
267
309
  );
310
+ return;
268
311
  }
312
+ phase = "prepare";
269
313
  const prepared = await props.onPrepare();
270
314
  const clientSecret = assertPreparedClientSecret(prepared?.clientSecret);
315
+ phase = "confirm";
271
316
  const result = await stripe.confirmPayment({
272
317
  elements,
273
318
  clientSecret,
@@ -282,19 +327,23 @@ function DeferredPaymentElementForm(props) {
282
327
  redirect: "if_required"
283
328
  });
284
329
  if (result.error) {
285
- throw new Error(result.error.message ?? "Stripe could not confirm payment.");
330
+ reportError(
331
+ new Error(result.error.message ?? "Stripe could not confirm payment."),
332
+ stripeErrorContext("confirm", result.error)
333
+ );
334
+ return;
286
335
  }
287
336
  if (!result.paymentIntent) {
288
337
  throw new Error("Stripe did not return a payment result.");
289
338
  }
339
+ phase = "outcome";
290
340
  await dispatchOutcome(
291
341
  normalizeStripePaymentIntent(result.paymentIntent),
292
342
  callbacks
293
343
  );
294
344
  } catch (error) {
295
345
  const safeError3 = error instanceof Error ? error : new Error("Payment could not be completed.");
296
- setMessage(safeError3.message);
297
- props.onError(safeError3);
346
+ reportError(safeError3, hostErrorContext(phase));
298
347
  } finally {
299
348
  setSubmitting(false);
300
349
  props.onSubmittingChange?.(false);
@@ -314,8 +363,7 @@ function DeferredPaymentElementForm(props) {
314
363
  onReady: () => setReady(true),
315
364
  onLoadError: (event) => {
316
365
  const error = new Error(event.error.message);
317
- setMessage(error.message);
318
- props.onError(error);
366
+ reportError(error, hostErrorContext("load"));
319
367
  }
320
368
  }
321
369
  ),
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  PrismDeferredPaymentElement,
3
3
  PrismPaymentElement
4
- } from "./chunk-CNZSWNL2.mjs";
4
+ } from "./chunk-FMPWH5MM.mjs";
5
5
  import {
6
6
  PrismClickTimePayPalButton,
7
7
  PrismPayPalPaymentButton
package/dist/paypal.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
- import { c as PrismClickTimePayPalButtonProps, j as PrismPayPalPaymentButtonProps } from './types-CHvHlDN6.mjs';
3
- export { d as PrismClickTimePayPalOrder, g as PrismPayPalApprovalOutcome, h as PrismPayPalCheckoutProviderContext, i as PrismPayPalPaymentButtonClassNames, n as PrismPreparedPayPalPaymentSession } from './types-CHvHlDN6.mjs';
2
+ import { c as PrismClickTimePayPalButtonProps, j as PrismPayPalPaymentButtonProps } from './types-DY41P1Ua.mjs';
3
+ export { d as PrismClickTimePayPalOrder, g as PrismPayPalApprovalOutcome, h as PrismPayPalCheckoutProviderContext, i as PrismPayPalPaymentButtonClassNames, q as PrismPreparedPayPalPaymentSession } from './types-DY41P1Ua.mjs';
4
4
  import '@stripe/stripe-js';
5
5
 
6
6
  declare function PrismClickTimePayPalButton(props: PrismClickTimePayPalButtonProps): react.JSX.Element;
package/dist/paypal.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
- import { c as PrismClickTimePayPalButtonProps, j as PrismPayPalPaymentButtonProps } from './types-CHvHlDN6.js';
3
- export { d as PrismClickTimePayPalOrder, g as PrismPayPalApprovalOutcome, h as PrismPayPalCheckoutProviderContext, i as PrismPayPalPaymentButtonClassNames, n as PrismPreparedPayPalPaymentSession } from './types-CHvHlDN6.js';
2
+ import { c as PrismClickTimePayPalButtonProps, j as PrismPayPalPaymentButtonProps } from './types-DY41P1Ua.js';
3
+ export { d as PrismClickTimePayPalOrder, g as PrismPayPalApprovalOutcome, h as PrismPayPalCheckoutProviderContext, i as PrismPayPalPaymentButtonClassNames, q as PrismPreparedPayPalPaymentSession } from './types-DY41P1Ua.js';
4
4
  import '@stripe/stripe-js';
5
5
 
6
6
  declare function PrismClickTimePayPalButton(props: PrismClickTimePayPalButtonProps): react.JSX.Element;
@@ -51,6 +51,13 @@ interface PrismPaymentElementClassNames {
51
51
  submitButton?: string;
52
52
  status?: string;
53
53
  }
54
+ type PrismPaymentErrorPresentation = "provider" | "host";
55
+ type PrismPaymentErrorPhase = "load" | "details" | "prepare" | "confirm" | "outcome";
56
+ interface PrismPaymentErrorContext {
57
+ connector: "stripe";
58
+ phase: PrismPaymentErrorPhase;
59
+ presentation: PrismPaymentErrorPresentation;
60
+ }
54
61
  interface PrismPaymentOutcome {
55
62
  connector: "stripe";
56
63
  paymentIntentId: string;
@@ -130,13 +137,14 @@ interface PrismDeferredPaymentElementProps {
130
137
  displayPolicy?: "if_required" | PrismStripeDisplayPolicy;
131
138
  appearance?: StripeElementsOptions["appearance"];
132
139
  classNames?: PrismPaymentElementClassNames;
140
+ errorPresentation?: "inline" | "external";
133
141
  submitLabel?: string;
134
142
  disabled?: boolean;
135
143
  onSubmittingChange?: (submitting: boolean) => void;
136
144
  onAuthorized: (outcome: PrismPaymentOutcome) => void | Promise<void>;
137
145
  onPending: (outcome: PrismPaymentOutcome) => void | Promise<void>;
138
146
  onRequiresAction: (outcome: PrismPaymentOutcome) => void | Promise<void>;
139
- onError: (error: Error) => void;
147
+ onError: (error: Error, context: PrismPaymentErrorContext) => void;
140
148
  }
141
149
  interface PrismClickTimePayPalOrder {
142
150
  orderId: string;
@@ -158,4 +166,4 @@ interface PrismClickTimePayPalButtonProps {
158
166
  }
159
167
  type PrismDeferredPaymentSurfaceProps = PrismDeferredPaymentElementProps | PrismClickTimePayPalButtonProps;
160
168
 
161
- export type { PrismDeferredPaymentElementProps as P, StripeSupportedTermMethod as S, PrismPaymentElementProps as a, PrismCheckoutProviderContext as b, PrismClickTimePayPalButtonProps as c, PrismClickTimePayPalOrder as d, PrismDeferredPaymentSurfaceProps as e, PrismDeferredStripePreparedPayment as f, PrismPayPalApprovalOutcome as g, PrismPayPalCheckoutProviderContext as h, PrismPayPalPaymentButtonClassNames as i, PrismPayPalPaymentButtonProps as j, PrismPaymentBillingDetails as k, PrismPaymentOutcome as l, PrismPaymentSurfaceProps as m, PrismPreparedPayPalPaymentSession as n, PrismPreparedPaymentSession as o, PrismPreparedStripePaymentSession as p, PrismStripeCheckoutProviderContext as q, PrismStripeDisplayPolicy as r };
169
+ export type { PrismDeferredPaymentElementProps as P, StripeSupportedTermMethod as S, PrismPaymentElementProps as a, PrismCheckoutProviderContext as b, PrismClickTimePayPalButtonProps as c, PrismClickTimePayPalOrder as d, PrismDeferredPaymentSurfaceProps as e, PrismDeferredStripePreparedPayment as f, PrismPayPalApprovalOutcome as g, PrismPayPalCheckoutProviderContext as h, PrismPayPalPaymentButtonClassNames as i, PrismPayPalPaymentButtonProps as j, PrismPaymentBillingDetails as k, PrismPaymentErrorContext as l, PrismPaymentErrorPhase as m, PrismPaymentErrorPresentation as n, PrismPaymentOutcome as o, PrismPaymentSurfaceProps as p, PrismPreparedPayPalPaymentSession as q, PrismPreparedPaymentSession as r, PrismPreparedStripePaymentSession as s, PrismStripeCheckoutProviderContext as t, PrismStripeDisplayPolicy as u };
@@ -51,6 +51,13 @@ interface PrismPaymentElementClassNames {
51
51
  submitButton?: string;
52
52
  status?: string;
53
53
  }
54
+ type PrismPaymentErrorPresentation = "provider" | "host";
55
+ type PrismPaymentErrorPhase = "load" | "details" | "prepare" | "confirm" | "outcome";
56
+ interface PrismPaymentErrorContext {
57
+ connector: "stripe";
58
+ phase: PrismPaymentErrorPhase;
59
+ presentation: PrismPaymentErrorPresentation;
60
+ }
54
61
  interface PrismPaymentOutcome {
55
62
  connector: "stripe";
56
63
  paymentIntentId: string;
@@ -130,13 +137,14 @@ interface PrismDeferredPaymentElementProps {
130
137
  displayPolicy?: "if_required" | PrismStripeDisplayPolicy;
131
138
  appearance?: StripeElementsOptions["appearance"];
132
139
  classNames?: PrismPaymentElementClassNames;
140
+ errorPresentation?: "inline" | "external";
133
141
  submitLabel?: string;
134
142
  disabled?: boolean;
135
143
  onSubmittingChange?: (submitting: boolean) => void;
136
144
  onAuthorized: (outcome: PrismPaymentOutcome) => void | Promise<void>;
137
145
  onPending: (outcome: PrismPaymentOutcome) => void | Promise<void>;
138
146
  onRequiresAction: (outcome: PrismPaymentOutcome) => void | Promise<void>;
139
- onError: (error: Error) => void;
147
+ onError: (error: Error, context: PrismPaymentErrorContext) => void;
140
148
  }
141
149
  interface PrismClickTimePayPalOrder {
142
150
  orderId: string;
@@ -158,4 +166,4 @@ interface PrismClickTimePayPalButtonProps {
158
166
  }
159
167
  type PrismDeferredPaymentSurfaceProps = PrismDeferredPaymentElementProps | PrismClickTimePayPalButtonProps;
160
168
 
161
- export type { PrismDeferredPaymentElementProps as P, StripeSupportedTermMethod as S, PrismPaymentElementProps as a, PrismCheckoutProviderContext as b, PrismClickTimePayPalButtonProps as c, PrismClickTimePayPalOrder as d, PrismDeferredPaymentSurfaceProps as e, PrismDeferredStripePreparedPayment as f, PrismPayPalApprovalOutcome as g, PrismPayPalCheckoutProviderContext as h, PrismPayPalPaymentButtonClassNames as i, PrismPayPalPaymentButtonProps as j, PrismPaymentBillingDetails as k, PrismPaymentOutcome as l, PrismPaymentSurfaceProps as m, PrismPreparedPayPalPaymentSession as n, PrismPreparedPaymentSession as o, PrismPreparedStripePaymentSession as p, PrismStripeCheckoutProviderContext as q, PrismStripeDisplayPolicy as r };
169
+ export type { PrismDeferredPaymentElementProps as P, StripeSupportedTermMethod as S, PrismPaymentElementProps as a, PrismCheckoutProviderContext as b, PrismClickTimePayPalButtonProps as c, PrismClickTimePayPalOrder as d, PrismDeferredPaymentSurfaceProps as e, PrismDeferredStripePreparedPayment as f, PrismPayPalApprovalOutcome as g, PrismPayPalCheckoutProviderContext as h, PrismPayPalPaymentButtonClassNames as i, PrismPayPalPaymentButtonProps as j, PrismPaymentBillingDetails as k, PrismPaymentErrorContext as l, PrismPaymentErrorPhase as m, PrismPaymentErrorPresentation as n, PrismPaymentOutcome as o, PrismPaymentSurfaceProps as p, PrismPreparedPayPalPaymentSession as q, PrismPreparedPaymentSession as r, PrismPreparedStripePaymentSession as s, PrismStripeCheckoutProviderContext as t, PrismStripeDisplayPolicy as u };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alphawebai/medusa-custom-payments-react",
3
- "version": "0.1.0-rc.39",
3
+ "version": "0.1.0-rc.40",
4
4
  "description": "AlphaWeb-owned Prism Stripe and PayPal checkout surfaces for Medusa storefronts",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",