@flopay/shared 1.14.8 → 1.14.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/README.md CHANGED
@@ -211,6 +211,8 @@ try {
211
211
  | `PayPalPaymentResult` | Stripe-hosted PayPal outcome: `status`, `paymentIntentId?`, `paymentMethodId?`, `error?` |
212
212
  | `CreateSessionIntentRequest` | Discriminated Stripe wallet/APM or direct-PayPal intent request. PayPal sends `intentKind: 'payment'` for Orders and subscriptions and `'setup'` for a standalone setup token. Direct card is not representable. |
213
213
  | `SessionIntent` | Matching discriminated response. Stripe carries `clientSecret`; PayPal carries a server-derived `providerObjectType`. Provider, payment-method category, type, and id, intent kind, and provider object id are separate fields. |
214
+ | `SessionIntentResult` | What `createSessionIntent` resolves to: a `SessionIntent`, or a `SettledSessionIntent` when the session was still processing an earlier payment (`202 checkout_processing`). Use `isSettledSessionIntent(result)` to tell them apart. |
215
+ | `SettledSessionIntent` | `{ settled: true, response }`. There is no intent to confirm. `response` is the `Response` that processing a payment would give for the earlier payment's outcome: `204` succeeded, `200` authorized, `400` declined. |
214
216
  | `PayPalProviderObjectType` | `'order'` / `'subscription'` / `'setup_token'`: the direct-PayPal continuation selected by the billing API and verified by the SDK |
215
217
  | `PayPalApprovalPresentation` | `'app_switch'` / `'redirect'`: a billing-API-advertised, one-time Order mode. It carries no return URL or resume credential. |
216
218
  | `SessionIntentDeclineRequest` | Non-card provider decline classification. Runtime reporting accepts safe classification codes only and rejects messages or identifier-shaped values. |
@@ -0,0 +1,48 @@
1
+ import { FloPayError } from './errors.js';
2
+ /** Public code for a session create or read that never got an HTTP response. */
3
+ export declare const NETWORK_REQUEST_FAILED_CODE = "network_request_failed";
4
+ /** Public code for a payment provider script (Stripe.js, PayPal SDK) that failed to load. */
5
+ export declare const PROVIDER_LOAD_FAILED_CODE = "provider_load_failed";
6
+ /** Where in checkout start the failure happened. */
7
+ type CheckoutInitFailureStage =
8
+ /** The session create or read request itself (no session in hand yet). */
9
+ 'session_request'
10
+ /** Loading a payment provider script (Stripe.js, PayPal SDK) after the session was read. */
11
+ | 'provider_load'
12
+ /** Anything else once the session exists. */
13
+ | 'post_session';
14
+ export interface CheckoutInitErrorContext {
15
+ stage: CheckoutInitFailureStage;
16
+ /** The provider whose script failed to load; read for `provider_load`. */
17
+ provider?: 'stripe' | 'paypal';
18
+ /** The checkout session id, when one exists. Never the nonce. */
19
+ sessionId?: string;
20
+ }
21
+ /**
22
+ * Mark an error raised after a session create or read got its HTTP response:
23
+ * reading or normalizing the body (a malformed 200 throws a plain
24
+ * `TypeError`). Checkout start then never reports it as a request that got no
25
+ * response. Returns the same error, for rethrowing. A `FloPayError` keeps its
26
+ * own type and code, so it is left as it is, and so is a non-object or frozen
27
+ * error.
28
+ */
29
+ export declare function markSessionResponseReceived<T>(error: T): T;
30
+ /**
31
+ * Map a checkout-start failure to the one public `FloPayError` merchants see
32
+ * through `onError` / the `error` slot. Shared by React and Vue so the two
33
+ * cannot drift.
34
+ *
35
+ * - A provider script that failed to load is `network_error` /
36
+ * `provider_load_failed`, naming the provider.
37
+ * - A session create or read that never got an HTTP response (a fetch
38
+ * `TypeError`, after the client's retries) is `network_error` /
39
+ * `network_request_failed`. A failure handling a response that did arrive
40
+ * (marked by {@link markSessionResponseReceived}) is not.
41
+ * - Any `FloPayError` (an HTTP error response, an expired session, …) is kept.
42
+ * - Anything else is the generic `api_error` / `CheckoutInitializationFailed`.
43
+ *
44
+ * The original error is the `cause` of a `network_error`, and the session id
45
+ * is set whenever one exists.
46
+ */
47
+ export declare function toPublicCheckoutInitError(error: unknown, context: CheckoutInitErrorContext): FloPayError;
48
+ export {};
@@ -1,6 +1,6 @@
1
1
  import type { AVSFieldConfig, ButtonsLayoutStyles, ButtonsLayoutTheme, CountryOption, CurrencyInfo, FloPayAppearance, ThemeBundle, ThemeBundleId, ThemeId } from './types.js';
2
2
  /** Current SDK version. */
3
- export declare const SDK_VERSION = "1.14.8";
3
+ export declare const SDK_VERSION = "1.14.10";
4
4
  /**
5
5
  * HTTP header the SDK sends on checkout-session create/read requests so the
6
6
  * backend can observe compatibility. Version 1.4.9 is the first release that
package/dist/errors.d.ts CHANGED
@@ -29,6 +29,8 @@ export declare class FloPayError extends Error {
29
29
  * session nonce.
30
30
  */
31
31
  readonly sessionId?: string;
32
+ /** The payment provider whose script failed to load (`provider_load_failed`). */
33
+ readonly provider?: 'stripe' | 'paypal';
32
34
  /** The underlying error when this one wraps another (the standard `Error.cause` slot). */
33
35
  readonly cause?: unknown;
34
36
  constructor(message: string, type: FloPayErrorType, options?: {
@@ -38,6 +40,7 @@ export declare class FloPayError extends Error {
38
40
  statusCode?: number;
39
41
  details?: ExternalMethodFailureDetails;
40
42
  sessionId?: string;
43
+ provider?: 'stripe' | 'paypal';
41
44
  cause?: unknown;
42
45
  });
43
46
  }