@authvia/payment-method-create 0.3.0 → 0.5.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.
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Builds derived colors from the base primary using real opacity percentages.
3
+ * Uses `color-mix(..., transparent)` so values read directly as percentages.
4
+ */
5
+ /** Default when `color` / `data-color` is omitted. */
6
+ export declare const DEFAULT_AVWC_PRIMARY_COLOR = "#4CAF50";
7
+ /**
8
+ * Trims `color`; empty or missing → {@link DEFAULT_AVWC_PRIMARY_COLOR}.
9
+ */
10
+ export declare function resolveAvwcPrimaryColor(color: string | null | undefined): string;
11
+ /**
12
+ * Derived `--avwc-color-*` for the form root (surface, border, label, hover, pressed, filled-button hover).
13
+ */
14
+ export declare function getAvwcDerivedThemeVariables(color?: string | null): Record<string, string>;
@@ -1,4 +1,4 @@
1
- import { PaymentOptions } from './types';
1
+ import { PaymentOptions } from '../types';
2
2
  export declare const PAYMENT_METHOD_TYPES: string[];
3
3
  export declare const walletConstants: Record<string, any>;
4
4
  /**
@@ -10,4 +10,6 @@ export type { AuthviaPaymentMethodFormProps, PaymentMethodFormData, VuetifyProps
10
10
  export { ErrorHandler, ErrorCodes } from '../utils/errors';
11
11
  export { config, getApiEndpoint, getCdnUrl, isDevelopment, isProduction } from '../utils/config';
12
12
  export { getInputSpacingClasses, getSpacingCSSVariables } from '../utils/spacing';
13
+ /** Theme: primary accent resolution and derived `--avwc-color-*` (same logic as the form root inline style). */
14
+ export { DEFAULT_AVWC_PRIMARY_COLOR, getAvwcDerivedThemeVariables, resolveAvwcPrimaryColor, } from '../constants/themeAvwcDerived';
13
15
  export { usePaymentMethodService } from '../composables/usePaymentMethodService';
@@ -39,7 +39,8 @@ declare class AuthviaPaymentMethodFormElement extends HTMLElement {
39
39
  private getAttributeValue;
40
40
  /**
41
41
  * Dialog overlays mount under {@link AuthviaPaymentMethodFormElement.container}, a sibling of the
42
- * Vue form root, so they do not inherit inline --avwc-* from the inner div. Mirror theme tokens here.
42
+ * Vue form root, so they do not inherit the inner div’s inline style. Sets accent, radius, and
43
+ * `getAvwcDerivedThemeVariables` on the container so teleports inherit the same tokens.
43
44
  */
44
45
  private syncContainerThemeTokens;
45
46
  private getComponentProps;
@@ -1,16 +1,29 @@
1
1
  import { PaymentMethodType } from '../model';
2
+ /**
3
+ * Runtime error from a specific payment method flow (card, ACH, Paze, PayPal, Venmo).
4
+ * Inner components attach `type` so hosts can branch without parsing `message`.
5
+ */
6
+ export interface PaymentMethodFlowError {
7
+ message?: string;
8
+ type?: PaymentMethodType;
9
+ [key: string]: unknown;
10
+ }
2
11
  export interface PaymentMethodDisplayText {
3
12
  title?: string;
4
13
  subtitle?: string;
5
14
  order?: number;
6
15
  }
7
16
  export interface PaymentMethodDisplayConfigMap {
17
+ /** Vertical spacing between option rows (CSS `gap`, e.g. `12px`, `1rem`). */
18
+ gap?: string;
8
19
  ach?: PaymentMethodDisplayText;
9
20
  card?: PaymentMethodDisplayText;
10
21
  paypal?: PaymentMethodDisplayText;
11
22
  paze?: PaymentMethodDisplayText;
12
23
  venmo?: PaymentMethodDisplayText;
13
24
  }
25
+ /** Keys under `paymentMethodDisplay` that configure a single method (excludes list-level `gap`). */
26
+ export type PaymentMethodDisplayRowKey = Exclude<keyof PaymentMethodDisplayConfigMap, 'gap'>;
14
27
  export interface TermsLinkConfig {
15
28
  show?: boolean;
16
29
  text?: string;
@@ -43,7 +56,6 @@ export interface AuthviaPaymentMethodFormProps {
43
56
  token?: string;
44
57
  merchantId?: string;
45
58
  card?: {
46
- allow?: boolean;
47
59
  demoMode?: boolean;
48
60
  title?: string;
49
61
  subtitle?: string;
@@ -17,8 +17,7 @@ export declare const config: {
17
17
  */
18
18
  export declare function getApiEndpoint(path: string): string;
19
19
  /**
20
- * Default path (relative to {@link config.cdnUrl}) for the credit-card loader script.
21
- * Matches the legacy hardcoded `/js/authvia-credit-card.js` used before env-based layout overrides.
20
+ * Default `src` for the credit-card loader script (absolute URL). {@link getCdnUrl} does not prefix {@link config.cdnUrl} onto http(s) URLs.
22
21
  */
23
22
  export declare const DEFAULT_CREDIT_CARD_SCRIPT_PATH: string;
24
23
  /**
@@ -18,13 +18,32 @@ export declare function getPaypalSdkUrlFromEnv(): string;
18
18
  * @param url - Candidate base URL (typically from env via `getPaypalSdkUrlFromEnv()`)
19
19
  */
20
20
  export declare function isValidPaypalSdkBaseUrl(url: string): boolean;
21
+ /**
22
+ * True when the host enabled PayPal in the picker (`paypal` is boolean `true` or a config object).
23
+ * For `intent` other than `payouts`, the picker only lists PayPal when {@link isPayPalVenmoWalletReadyForNonPayoutIntent}
24
+ * is satisfied (same checks as the wallet open flow).
25
+ */
26
+ export declare function isPayPalPropProvided(value: unknown): boolean;
21
27
  /**
22
28
  * Type guard: PayPal module config (`merchantId` required; optional `redirectUrl`).
23
- * Legacy embeds may still send `clientId` on this object; it is ignored — the JS SDK uses
24
- * `VITE_APP_PAYPAL_CLIENT_ID` only (validated on click).
29
+ * Extra payload fields do not fail the guard. The PayPal JS SDK client id is injected at build time via
30
+ * `VITE_APP_PAYPAL_CLIENT_ID` (CI/CD per environment); the UI validates on click.
25
31
  */
26
32
  export declare function isPayPalConfig(value: unknown): value is PayPalConfig;
27
33
  /**
28
34
  * Type guard: Venmo-only wallet config (same shape as PayPal; no `paypal` prop required).
29
35
  */
30
36
  export declare function isVenmoWalletConfig(value: unknown): value is PayPalConfig;
37
+ /**
38
+ * Resolves PayPal/Venmo wallet settings (`merchantId`, `redirectUrl`, `venmo` flag) for the options layer.
39
+ * Keep in sync with `pvSettings` on `AuthviaPaymentMethodForm`.
40
+ *
41
+ * @param redirectUrlFallback - Typically `window.location.href` in the browser; use `''` in tests.
42
+ */
43
+ export declare function buildPayPalVenmoPvSettings(paypal: unknown, venmo: unknown, redirectUrlFallback: string): Record<string, unknown>;
44
+ /** True when `pv.merchantId` is present and non-empty after trim. */
45
+ export declare function hasPaypalMerchantIdInPv(pv: Record<string, unknown> | null | undefined): boolean;
46
+ /**
47
+ * For `intent` other than `payouts`, opening PayPal/Venmo requires merchant id and `VITE_APP_PAYPAL_CLIENT_ID`.
48
+ */
49
+ export declare function isPayPalVenmoWalletReadyForNonPayoutIntent(pv: Record<string, unknown>): boolean;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Paze wallet init requires all of these on the `paze` prop (non-empty after trim).
3
+ * Aligns with validation in `AuthviaPaymentMethodOptions` before opening the Paze flow.
4
+ */
5
+ export declare const PAZE_SETTINGS_REQUIRED_KEYS: readonly ["amount", "clientId", "profileId", "name"];
6
+ /**
7
+ * True when every required Paze field is present and non-empty (strings or numbers OK for `amount`).
8
+ */
9
+ export declare function isPazeConfigComplete(value: unknown): boolean;
@@ -41,3 +41,8 @@ export declare function getUserAndToken(authToken: string | undefined): UserAndT
41
41
  * @returns true if the token is expired or has no exp claim (treated as expired)
42
42
  */
43
43
  export declare function isTokenExpired(tokenParam: string, bufferSeconds?: number): boolean;
44
+ /**
45
+ * Whether the JWT `scope` claim lists `payment_methods:create` (space-delimited scopes).
46
+ * Returns false if the token cannot be parsed or `scope` is missing.
47
+ */
48
+ export declare function hasPaymentMethodsCreateScope(tokenParam: string): boolean;