@funnelfox/billing 0.13.2 → 0.14.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.
- package/README.md +58 -0
- package/dist/chunk-index.cjs.js +785 -14
- package/dist/chunk-index.es.js +785 -15
- package/dist/funnelfox-billing.cjs.js +1 -0
- package/dist/funnelfox-billing.esm.js +1 -1
- package/dist/funnelfox-billing.js +785 -14
- package/dist/funnelfox-billing.min.js +1 -1
- package/package.json +2 -2
- package/src/types.d.ts +86 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@funnelfox/billing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Funnelfox",
|
|
6
6
|
"description": "JavaScript SDK for Funnelfox billing with Primer integration",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"scripts": {
|
|
27
27
|
"build": "rm -rf dist && rollup -c",
|
|
28
28
|
"build:watch": "rollup -c -w",
|
|
29
|
-
"build:examples": "npm run build && npm pack && npm i ./funnelfox-billing-0.
|
|
29
|
+
"build:examples": "npm run build && npm pack && npm i ./funnelfox-billing-0.14.0.tgz --prefix examples/basic && npm run build --prefix examples/basic",
|
|
30
30
|
"version": "node scripts/sync-version.js",
|
|
31
31
|
"release:patch": "npm version patch --no-git-tag-version",
|
|
32
32
|
"release:minor": "npm version minor --no-git-tag-version",
|
package/src/types.d.ts
CHANGED
|
@@ -484,7 +484,10 @@ export interface SilentPurchaseOptions {
|
|
|
484
484
|
initiationType?: 'cit' | 'mit';
|
|
485
485
|
/** CIT card networks (sent only when set). `[]` = all networks. */
|
|
486
486
|
citCardNetworks?: string[];
|
|
487
|
-
/**
|
|
487
|
+
/**
|
|
488
|
+
* @deprecated Not sent any more: a saved Google Pay token is never charged as CIT, and the
|
|
489
|
+
* backend ignores the field. Wallet buyers confirm the upsell again with `mountWalletUpsell`.
|
|
490
|
+
*/
|
|
488
491
|
citGooglePayPanOnly?: boolean;
|
|
489
492
|
}
|
|
490
493
|
|
|
@@ -548,6 +551,71 @@ export interface OneClickResult {
|
|
|
548
551
|
failedRequest?: OneClickFailedRequest;
|
|
549
552
|
}
|
|
550
553
|
|
|
554
|
+
export type WalletKind = 'APPLE_PAY' | 'GOOGLE_PAY';
|
|
555
|
+
|
|
556
|
+
export interface MountWalletUpsellOptions {
|
|
557
|
+
orgId: string;
|
|
558
|
+
priceId: string;
|
|
559
|
+
externalId: string;
|
|
560
|
+
clientMetadata?: Record<string, unknown>;
|
|
561
|
+
/** Default: the `configure()` value, else https://billing.funnelfox.com. */
|
|
562
|
+
baseUrl?: string;
|
|
563
|
+
style?: {
|
|
564
|
+
/** Default `plain`. A type the wallet does not have falls back to `plain`. */
|
|
565
|
+
buttonType?: 'plain' | 'buy' | 'pay' | 'continue';
|
|
566
|
+
/** Default `black`. Google Pay shows `white-outline` as `white`. */
|
|
567
|
+
buttonColor?: 'black' | 'white' | 'white-outline';
|
|
568
|
+
/** px, default 54. */
|
|
569
|
+
height?: number;
|
|
570
|
+
/** px, default 28. */
|
|
571
|
+
borderRadius?: number;
|
|
572
|
+
};
|
|
573
|
+
/** The customer tapped the button and the wallet sheet opens. */
|
|
574
|
+
onStart?: () => void;
|
|
575
|
+
/** Fired once when the 3DS window becomes visible, as in `silentPurchase({ handle3DS: true })`. */
|
|
576
|
+
onThreeDSStart?: (info: { orderId: string }) => void;
|
|
577
|
+
/** Fired exactly once per `onThreeDSStart`, before `onResult`. */
|
|
578
|
+
onThreeDSEnd?: (info: { result: ThreeDSResult }) => void;
|
|
579
|
+
/**
|
|
580
|
+
* Called exactly once per attempt. After `cancelled` the button stays active and can be
|
|
581
|
+
* tapped again; after any other outcome it is disabled for good.
|
|
582
|
+
*/
|
|
583
|
+
onResult: (result: WalletUpsellResult) => void;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
export type WalletUpsellMount =
|
|
587
|
+
| {
|
|
588
|
+
mounted: true;
|
|
589
|
+
wallet: WalletKind;
|
|
590
|
+
setDisabled(disabled: boolean): void;
|
|
591
|
+
destroy(): void;
|
|
592
|
+
}
|
|
593
|
+
/** The customer's saved method is not a Primer wallet: use `silentPurchase`. */
|
|
594
|
+
| { mounted: false; reason: 'not_wallet' }
|
|
595
|
+
/** This device cannot show the customer's wallet. */
|
|
596
|
+
| { mounted: false; reason: 'wallet_unavailable'; wallet: WalletKind }
|
|
597
|
+
| { mounted: false; reason: 'error'; error: Error };
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* `cancelled`: the customer closed the wallet sheet and nothing was charged. The other outcomes
|
|
601
|
+
* mean what they mean for `silentPurchase({ handle3DS: true })`.
|
|
602
|
+
*/
|
|
603
|
+
export type WalletUpsellResult = Omit<OneClickResult, 'outcome'> & {
|
|
604
|
+
outcome: OneClickOutcome | 'cancelled';
|
|
605
|
+
};
|
|
606
|
+
|
|
607
|
+
/**
|
|
608
|
+
* One-click upsell confirmed in the Apple Pay / Google Pay sheet (wallet re-authentication):
|
|
609
|
+
* call when the upsell screen loads, not on tap. Mounts Primer's native wallet button into
|
|
610
|
+
* `container` for a customer whose saved method is a Primer wallet; the upsell is then charged
|
|
611
|
+
* with the fresh wallet token as a customer-initiated payment. Rejects only with
|
|
612
|
+
* `ValidationError`; with `mounted: false` nothing is left in `container`.
|
|
613
|
+
*/
|
|
614
|
+
export declare function mountWalletUpsell(
|
|
615
|
+
container: HTMLElement,
|
|
616
|
+
options: MountWalletUpsellOptions
|
|
617
|
+
): Promise<WalletUpsellMount>;
|
|
618
|
+
|
|
551
619
|
/**
|
|
552
620
|
* One-click purchase with the customer's saved payment method.
|
|
553
621
|
* Legacy mode (no `handle3DS`): resolves `true` for any 2xx `status: 'success'` response
|
|
@@ -630,6 +698,7 @@ export declare const Billing: {
|
|
|
630
698
|
createClientSession: typeof createClientSession;
|
|
631
699
|
initMethod: typeof initMethod;
|
|
632
700
|
silentPurchase: typeof silentPurchase;
|
|
701
|
+
mountWalletUpsell: typeof mountWalletUpsell;
|
|
633
702
|
getAvailablePaymentMethods: typeof getAvailablePaymentMethods;
|
|
634
703
|
stripe: {
|
|
635
704
|
createCardForm: typeof createStripeCardForm;
|
|
@@ -836,6 +905,21 @@ export interface OneClickRequest {
|
|
|
836
905
|
client_metadata: Record<string, string | number | boolean>;
|
|
837
906
|
initiation_type?: 'cit' | 'mit';
|
|
838
907
|
cit_card_networks?: string[];
|
|
839
|
-
cit_google_pay_pan_only?: boolean;
|
|
840
908
|
idempotency_key?: string;
|
|
909
|
+
/** Wallet re-auth: the single-use token of the confirmed wallet sheet, with `session_id`. */
|
|
910
|
+
payment_method_token?: string;
|
|
911
|
+
session_id?: string;
|
|
912
|
+
}
|
|
913
|
+
|
|
914
|
+
export interface OneClickWalletSessionData {
|
|
915
|
+
wallet: WalletKind | null;
|
|
916
|
+
reason?: string | null;
|
|
917
|
+
client_token?: string | null;
|
|
918
|
+
session_id?: string | null;
|
|
919
|
+
order_id?: string | null;
|
|
920
|
+
/** Minor units, tax included when collected. */
|
|
921
|
+
amount?: number | null;
|
|
922
|
+
currency?: string | null;
|
|
923
|
+
/** UTC ISO. */
|
|
924
|
+
expires_at?: string | null;
|
|
841
925
|
}
|