@doujins/payments-ui 0.0.9 → 0.0.11
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/dist/index.cjs +270 -112
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +41 -1
- package/dist/index.d.ts +41 -1
- package/dist/index.js +269 -114
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -505,6 +505,30 @@ interface SolanaPaymentSelectorProps {
|
|
|
505
505
|
}
|
|
506
506
|
declare const SolanaPaymentSelector: React.FC<SolanaPaymentSelectorProps>;
|
|
507
507
|
|
|
508
|
+
interface SubscriptionCheckoutModalProps {
|
|
509
|
+
open: boolean;
|
|
510
|
+
onOpenChange: (open: boolean) => void;
|
|
511
|
+
priceId?: string | null;
|
|
512
|
+
usdAmount?: number;
|
|
513
|
+
planName?: string;
|
|
514
|
+
amountLabel?: string;
|
|
515
|
+
billingPeriodLabel?: string;
|
|
516
|
+
userEmail?: string | null;
|
|
517
|
+
provider?: string;
|
|
518
|
+
onSuccess?: () => void;
|
|
519
|
+
enableSolanaPay?: boolean;
|
|
520
|
+
}
|
|
521
|
+
declare const SubscriptionCheckoutModal: React.FC<SubscriptionCheckoutModalProps>;
|
|
522
|
+
|
|
523
|
+
interface SubscriptionSuccessDialogProps {
|
|
524
|
+
open: boolean;
|
|
525
|
+
planName?: string;
|
|
526
|
+
amountLabel?: string;
|
|
527
|
+
billingPeriodLabel?: string;
|
|
528
|
+
onClose: () => void;
|
|
529
|
+
}
|
|
530
|
+
declare const SubscriptionSuccessDialog: React.FC<SubscriptionSuccessDialogProps>;
|
|
531
|
+
|
|
508
532
|
declare const usePaymentMethods: () => {
|
|
509
533
|
listQuery: _tanstack_react_query.UseQueryResult<PaginatedPaymentMethods, Error>;
|
|
510
534
|
createMutation: _tanstack_react_query.UseMutationResult<PaymentMethod, Error, {
|
|
@@ -683,4 +707,20 @@ declare const useSubscriptionActions: () => {
|
|
|
683
707
|
generateFlexFormUrl: ({ priceId, firstName, lastName, address1, city, state, zipCode, country, }: GenerateFlexFormParams) => Promise<FlexFormResponse>;
|
|
684
708
|
};
|
|
685
709
|
|
|
686
|
-
|
|
710
|
+
interface FlexFormPayload {
|
|
711
|
+
priceId: string;
|
|
712
|
+
firstName: string;
|
|
713
|
+
lastName: string;
|
|
714
|
+
address1: string;
|
|
715
|
+
city: string;
|
|
716
|
+
state: string;
|
|
717
|
+
zipCode: string;
|
|
718
|
+
country: string;
|
|
719
|
+
}
|
|
720
|
+
declare const useAlternativePaymentProvider: () => {
|
|
721
|
+
openFlexForm: (payload: FlexFormPayload) => Promise<void>;
|
|
722
|
+
isLoading: boolean;
|
|
723
|
+
error: string | null;
|
|
724
|
+
};
|
|
725
|
+
|
|
726
|
+
export { type AsyncStatus, type AuthTokenProvider, type BillingDetails, type CCBillSubscribePayload, CardDetailsForm, type CardDetailsFormProps, CardPaymentService, type CardTokenizeResult, type CreatePaymentMethodPayload, type FlexFormResponse, type GenerateFlexFormParams, type GenerateFlexFormURLBodyParams, type GeneratePaymentRequest, type GeneratePaymentResponse, type ListParams, type NmiSubscribePayload, type PaginatedPaymentMethods, PaymentApp, type PaymentAppOptions, type PaymentCallbacks, type PaymentConfig, type PaymentContextValue, type PaymentEndpoints, type PaymentError, PaymentExperience, type PaymentExperienceProps, type PaymentFeatureFlags, type PaymentFetcher, type PaymentMethod, type PaymentMethodOption, PaymentMethodService, type PaymentPlatform, PaymentProvider, type PaymentProviderProps, type PaymentServices, type PaymentState, type PaymentStatusPayload, type PaymentStatusResponse, type PaymentStep, type PaymentStoreOptions, type PaymentStoreState, type PaymentSuccessPayload, type PaymentUserDetails, type SolanaFlowConfig, type SolanaFlowState, type SolanaPayQRCodeIntent, type SolanaPayStatusResponse, type SolanaPayTransaction, type SolanaPaymentMethod, SolanaPaymentSelector, SolanaPaymentService, StoredPaymentMethods, type StoredPaymentMethodsProps, type SubmitPaymentRequest, type SubmitPaymentResponse, type SubscribeWithCCBillParams, type SubscribeWithCardParams, type SubscribeWithSavedMethodParams, SubscriptionCheckoutModal, type SubscriptionCheckoutPayload, type SubscriptionResponse, SubscriptionService, SubscriptionSuccessDialog, type SupportedTokensResponse, type TokenBalance, TokenCatalog, type TokenCatalogOptions, type TokenInfo, type TransactionStatus, type WalletAccount, type WalletAdapterLike, WalletGateway, createPaymentStore, useAlternativePaymentProvider, useDirectWalletPayment, usePaymentContext, usePaymentMethodService, usePaymentMethods, usePaymentStatus, usePaymentStore, useSolanaDirectPayment, useSolanaQrPayment, useSolanaService, useSubscriptionActions, useSupportedTokens, useTokenBalance };
|
package/dist/index.d.ts
CHANGED
|
@@ -505,6 +505,30 @@ interface SolanaPaymentSelectorProps {
|
|
|
505
505
|
}
|
|
506
506
|
declare const SolanaPaymentSelector: React.FC<SolanaPaymentSelectorProps>;
|
|
507
507
|
|
|
508
|
+
interface SubscriptionCheckoutModalProps {
|
|
509
|
+
open: boolean;
|
|
510
|
+
onOpenChange: (open: boolean) => void;
|
|
511
|
+
priceId?: string | null;
|
|
512
|
+
usdAmount?: number;
|
|
513
|
+
planName?: string;
|
|
514
|
+
amountLabel?: string;
|
|
515
|
+
billingPeriodLabel?: string;
|
|
516
|
+
userEmail?: string | null;
|
|
517
|
+
provider?: string;
|
|
518
|
+
onSuccess?: () => void;
|
|
519
|
+
enableSolanaPay?: boolean;
|
|
520
|
+
}
|
|
521
|
+
declare const SubscriptionCheckoutModal: React.FC<SubscriptionCheckoutModalProps>;
|
|
522
|
+
|
|
523
|
+
interface SubscriptionSuccessDialogProps {
|
|
524
|
+
open: boolean;
|
|
525
|
+
planName?: string;
|
|
526
|
+
amountLabel?: string;
|
|
527
|
+
billingPeriodLabel?: string;
|
|
528
|
+
onClose: () => void;
|
|
529
|
+
}
|
|
530
|
+
declare const SubscriptionSuccessDialog: React.FC<SubscriptionSuccessDialogProps>;
|
|
531
|
+
|
|
508
532
|
declare const usePaymentMethods: () => {
|
|
509
533
|
listQuery: _tanstack_react_query.UseQueryResult<PaginatedPaymentMethods, Error>;
|
|
510
534
|
createMutation: _tanstack_react_query.UseMutationResult<PaymentMethod, Error, {
|
|
@@ -683,4 +707,20 @@ declare const useSubscriptionActions: () => {
|
|
|
683
707
|
generateFlexFormUrl: ({ priceId, firstName, lastName, address1, city, state, zipCode, country, }: GenerateFlexFormParams) => Promise<FlexFormResponse>;
|
|
684
708
|
};
|
|
685
709
|
|
|
686
|
-
|
|
710
|
+
interface FlexFormPayload {
|
|
711
|
+
priceId: string;
|
|
712
|
+
firstName: string;
|
|
713
|
+
lastName: string;
|
|
714
|
+
address1: string;
|
|
715
|
+
city: string;
|
|
716
|
+
state: string;
|
|
717
|
+
zipCode: string;
|
|
718
|
+
country: string;
|
|
719
|
+
}
|
|
720
|
+
declare const useAlternativePaymentProvider: () => {
|
|
721
|
+
openFlexForm: (payload: FlexFormPayload) => Promise<void>;
|
|
722
|
+
isLoading: boolean;
|
|
723
|
+
error: string | null;
|
|
724
|
+
};
|
|
725
|
+
|
|
726
|
+
export { type AsyncStatus, type AuthTokenProvider, type BillingDetails, type CCBillSubscribePayload, CardDetailsForm, type CardDetailsFormProps, CardPaymentService, type CardTokenizeResult, type CreatePaymentMethodPayload, type FlexFormResponse, type GenerateFlexFormParams, type GenerateFlexFormURLBodyParams, type GeneratePaymentRequest, type GeneratePaymentResponse, type ListParams, type NmiSubscribePayload, type PaginatedPaymentMethods, PaymentApp, type PaymentAppOptions, type PaymentCallbacks, type PaymentConfig, type PaymentContextValue, type PaymentEndpoints, type PaymentError, PaymentExperience, type PaymentExperienceProps, type PaymentFeatureFlags, type PaymentFetcher, type PaymentMethod, type PaymentMethodOption, PaymentMethodService, type PaymentPlatform, PaymentProvider, type PaymentProviderProps, type PaymentServices, type PaymentState, type PaymentStatusPayload, type PaymentStatusResponse, type PaymentStep, type PaymentStoreOptions, type PaymentStoreState, type PaymentSuccessPayload, type PaymentUserDetails, type SolanaFlowConfig, type SolanaFlowState, type SolanaPayQRCodeIntent, type SolanaPayStatusResponse, type SolanaPayTransaction, type SolanaPaymentMethod, SolanaPaymentSelector, SolanaPaymentService, StoredPaymentMethods, type StoredPaymentMethodsProps, type SubmitPaymentRequest, type SubmitPaymentResponse, type SubscribeWithCCBillParams, type SubscribeWithCardParams, type SubscribeWithSavedMethodParams, SubscriptionCheckoutModal, type SubscriptionCheckoutPayload, type SubscriptionResponse, SubscriptionService, SubscriptionSuccessDialog, type SupportedTokensResponse, type TokenBalance, TokenCatalog, type TokenCatalogOptions, type TokenInfo, type TransactionStatus, type WalletAccount, type WalletAdapterLike, WalletGateway, createPaymentStore, useAlternativePaymentProvider, useDirectWalletPayment, usePaymentContext, usePaymentMethodService, usePaymentMethods, usePaymentStatus, usePaymentStore, useSolanaDirectPayment, useSolanaQrPayment, useSolanaService, useSubscriptionActions, useSupportedTokens, useTokenBalance };
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import * as React3 from 'react';
|
|
|
2
2
|
import { createContext, useMemo, useEffect, useContext, useState, useCallback, useRef } from 'react';
|
|
3
3
|
import { createStore } from 'zustand/vanilla';
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
|
-
import { ChevronDown, ChevronUp, Check, X, User, MapPin, Loader2, CreditCard, WalletCards, Trash2, Sparkles,
|
|
5
|
+
import { ChevronDown, ChevronUp, Check, X, User, MapPin, Loader2, CreditCard, WalletCards, Trash2, Sparkles, CheckCircle, AlertCircle, Wallet, XCircle, RotateCcw, RefreshCw } from 'lucide-react';
|
|
6
6
|
import countryList from 'country-list';
|
|
7
7
|
import { cva } from 'class-variance-authority';
|
|
8
8
|
import { clsx } from 'clsx';
|
|
@@ -1818,13 +1818,10 @@ var useSolanaQrPayment = (options) => {
|
|
|
1818
1818
|
const resetState = useCallback(
|
|
1819
1819
|
(message) => {
|
|
1820
1820
|
clearTimers();
|
|
1821
|
-
setIntent(
|
|
1822
|
-
setQrDataUri(
|
|
1823
|
-
setTimeRemaining(
|
|
1824
|
-
setError(
|
|
1825
|
-
const next = message === void 0 ? null : message;
|
|
1826
|
-
return prev === next ? prev : next;
|
|
1827
|
-
});
|
|
1821
|
+
setIntent(null);
|
|
1822
|
+
setQrDataUri(null);
|
|
1823
|
+
setTimeRemaining(0);
|
|
1824
|
+
setError(message ?? null);
|
|
1828
1825
|
},
|
|
1829
1826
|
[clearTimers]
|
|
1830
1827
|
);
|
|
@@ -2658,6 +2655,245 @@ var PaymentExperience = ({
|
|
|
2658
2655
|
)
|
|
2659
2656
|
] });
|
|
2660
2657
|
};
|
|
2658
|
+
var SubscriptionSuccessDialog = ({
|
|
2659
|
+
open,
|
|
2660
|
+
planName = "Premium Plan",
|
|
2661
|
+
amountLabel = "$0.00",
|
|
2662
|
+
billingPeriodLabel = "billing period",
|
|
2663
|
+
onClose
|
|
2664
|
+
}) => {
|
|
2665
|
+
return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange: (value) => {
|
|
2666
|
+
if (!value) onClose();
|
|
2667
|
+
}, children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-w-sm text-center", children: [
|
|
2668
|
+
/* @__PURE__ */ jsxs(DialogHeader, { children: [
|
|
2669
|
+
/* @__PURE__ */ jsxs(DialogTitle, { className: "flex flex-col items-center gap-3 text-foreground", children: [
|
|
2670
|
+
/* @__PURE__ */ jsx(CheckCircle, { className: "h-10 w-10 text-primary" }),
|
|
2671
|
+
"Subscription activated"
|
|
2672
|
+
] }),
|
|
2673
|
+
/* @__PURE__ */ jsxs(DialogDescription, { className: "text-base text-muted-foreground", children: [
|
|
2674
|
+
"You now have access to ",
|
|
2675
|
+
planName,
|
|
2676
|
+
". Billing: ",
|
|
2677
|
+
amountLabel,
|
|
2678
|
+
" / ",
|
|
2679
|
+
billingPeriodLabel,
|
|
2680
|
+
"."
|
|
2681
|
+
] })
|
|
2682
|
+
] }),
|
|
2683
|
+
/* @__PURE__ */ jsx(Button, { className: "mt-6 w-full", onClick: onClose, children: "Continue" })
|
|
2684
|
+
] }) });
|
|
2685
|
+
};
|
|
2686
|
+
var useSubscriptionActions = () => {
|
|
2687
|
+
const { services } = usePaymentContext();
|
|
2688
|
+
const ensurePrice = (priceId) => {
|
|
2689
|
+
if (!priceId) {
|
|
2690
|
+
throw new Error("payments-ui: priceId is required for subscription actions");
|
|
2691
|
+
}
|
|
2692
|
+
return priceId;
|
|
2693
|
+
};
|
|
2694
|
+
const subscribeWithCard = useCallback(
|
|
2695
|
+
async ({
|
|
2696
|
+
priceId,
|
|
2697
|
+
processor = "nmi",
|
|
2698
|
+
provider,
|
|
2699
|
+
paymentToken,
|
|
2700
|
+
billing
|
|
2701
|
+
}) => {
|
|
2702
|
+
const payload = {
|
|
2703
|
+
priceId: ensurePrice(priceId),
|
|
2704
|
+
paymentToken,
|
|
2705
|
+
processor,
|
|
2706
|
+
provider,
|
|
2707
|
+
email: billing.email,
|
|
2708
|
+
firstName: billing.firstName,
|
|
2709
|
+
lastName: billing.lastName,
|
|
2710
|
+
address1: billing.address1,
|
|
2711
|
+
city: billing.city,
|
|
2712
|
+
state: billing.stateRegion,
|
|
2713
|
+
zipCode: billing.postalCode,
|
|
2714
|
+
country: billing.country
|
|
2715
|
+
};
|
|
2716
|
+
return services.subscriptions.subscribe("nmi", payload);
|
|
2717
|
+
},
|
|
2718
|
+
[services]
|
|
2719
|
+
);
|
|
2720
|
+
const subscribeWithSavedMethod = useCallback(
|
|
2721
|
+
async ({
|
|
2722
|
+
priceId,
|
|
2723
|
+
processor = "nmi",
|
|
2724
|
+
provider,
|
|
2725
|
+
paymentMethodId,
|
|
2726
|
+
email
|
|
2727
|
+
}) => {
|
|
2728
|
+
const payload = {
|
|
2729
|
+
priceId: ensurePrice(priceId),
|
|
2730
|
+
paymentMethodId,
|
|
2731
|
+
processor,
|
|
2732
|
+
provider,
|
|
2733
|
+
email
|
|
2734
|
+
};
|
|
2735
|
+
return services.subscriptions.subscribe("nmi", payload);
|
|
2736
|
+
},
|
|
2737
|
+
[services]
|
|
2738
|
+
);
|
|
2739
|
+
const subscribeWithCCBill = useCallback(
|
|
2740
|
+
async ({
|
|
2741
|
+
priceId,
|
|
2742
|
+
email,
|
|
2743
|
+
firstName,
|
|
2744
|
+
lastName,
|
|
2745
|
+
zipCode,
|
|
2746
|
+
country,
|
|
2747
|
+
processor = "ccbill"
|
|
2748
|
+
}) => {
|
|
2749
|
+
const payload = {
|
|
2750
|
+
priceId: ensurePrice(priceId),
|
|
2751
|
+
email,
|
|
2752
|
+
firstName,
|
|
2753
|
+
lastName,
|
|
2754
|
+
zipCode,
|
|
2755
|
+
country,
|
|
2756
|
+
processor
|
|
2757
|
+
};
|
|
2758
|
+
return services.subscriptions.subscribe("ccbill", payload);
|
|
2759
|
+
},
|
|
2760
|
+
[services]
|
|
2761
|
+
);
|
|
2762
|
+
const generateFlexFormUrl = useCallback(
|
|
2763
|
+
async ({
|
|
2764
|
+
priceId,
|
|
2765
|
+
firstName,
|
|
2766
|
+
lastName,
|
|
2767
|
+
address1,
|
|
2768
|
+
city,
|
|
2769
|
+
state,
|
|
2770
|
+
zipCode,
|
|
2771
|
+
country
|
|
2772
|
+
}) => {
|
|
2773
|
+
const payload = {
|
|
2774
|
+
price_id: ensurePrice(priceId),
|
|
2775
|
+
first_name: firstName,
|
|
2776
|
+
last_name: lastName,
|
|
2777
|
+
address1,
|
|
2778
|
+
city,
|
|
2779
|
+
state,
|
|
2780
|
+
zip_code: zipCode,
|
|
2781
|
+
country
|
|
2782
|
+
};
|
|
2783
|
+
return services.subscriptions.generateFlexFormUrl(payload);
|
|
2784
|
+
},
|
|
2785
|
+
[services]
|
|
2786
|
+
);
|
|
2787
|
+
return {
|
|
2788
|
+
subscribeWithCard,
|
|
2789
|
+
subscribeWithSavedMethod,
|
|
2790
|
+
subscribeWithCCBill,
|
|
2791
|
+
generateFlexFormUrl
|
|
2792
|
+
};
|
|
2793
|
+
};
|
|
2794
|
+
var SubscriptionCheckoutModal = ({
|
|
2795
|
+
open,
|
|
2796
|
+
onOpenChange,
|
|
2797
|
+
priceId,
|
|
2798
|
+
usdAmount = 0,
|
|
2799
|
+
planName,
|
|
2800
|
+
amountLabel,
|
|
2801
|
+
billingPeriodLabel,
|
|
2802
|
+
userEmail,
|
|
2803
|
+
provider = "mobius",
|
|
2804
|
+
onSuccess,
|
|
2805
|
+
enableSolanaPay = true
|
|
2806
|
+
}) => {
|
|
2807
|
+
const [showSuccess, setShowSuccess] = useState(false);
|
|
2808
|
+
const { subscribeWithCard, subscribeWithSavedMethod } = useSubscriptionActions();
|
|
2809
|
+
const handleClose = useCallback(
|
|
2810
|
+
(nextOpen) => {
|
|
2811
|
+
onOpenChange(nextOpen);
|
|
2812
|
+
if (!nextOpen) {
|
|
2813
|
+
setShowSuccess(false);
|
|
2814
|
+
}
|
|
2815
|
+
},
|
|
2816
|
+
[onOpenChange]
|
|
2817
|
+
);
|
|
2818
|
+
const ensurePrice = () => {
|
|
2819
|
+
if (!priceId) {
|
|
2820
|
+
throw new Error("Select a plan before subscribing.");
|
|
2821
|
+
}
|
|
2822
|
+
return priceId;
|
|
2823
|
+
};
|
|
2824
|
+
const notifySuccess = (result) => {
|
|
2825
|
+
setShowSuccess(true);
|
|
2826
|
+
onSuccess?.();
|
|
2827
|
+
if (result && typeof window !== "undefined") {
|
|
2828
|
+
console.debug("[payments-ui] subscription success", result);
|
|
2829
|
+
}
|
|
2830
|
+
};
|
|
2831
|
+
const handleNewCardPayment = async ({ token, billing }) => {
|
|
2832
|
+
await subscribeWithCard({
|
|
2833
|
+
priceId: ensurePrice(),
|
|
2834
|
+
provider,
|
|
2835
|
+
paymentToken: token,
|
|
2836
|
+
billing
|
|
2837
|
+
});
|
|
2838
|
+
notifySuccess();
|
|
2839
|
+
};
|
|
2840
|
+
const handleSavedMethodPayment = async ({ paymentMethodId }) => {
|
|
2841
|
+
await subscribeWithSavedMethod({
|
|
2842
|
+
priceId: ensurePrice(),
|
|
2843
|
+
provider,
|
|
2844
|
+
paymentMethodId,
|
|
2845
|
+
email: userEmail ?? ""
|
|
2846
|
+
});
|
|
2847
|
+
notifySuccess();
|
|
2848
|
+
};
|
|
2849
|
+
const solanaSuccess = (result) => {
|
|
2850
|
+
notifySuccess(result);
|
|
2851
|
+
onOpenChange(false);
|
|
2852
|
+
};
|
|
2853
|
+
const summary = useMemo(() => {
|
|
2854
|
+
if (!planName && !amountLabel) return null;
|
|
2855
|
+
return /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-border/60 bg-muted/10 p-3 text-sm text-muted-foreground", children: [
|
|
2856
|
+
/* @__PURE__ */ jsx("p", { className: "font-medium text-foreground", children: planName ?? "Selected plan" }),
|
|
2857
|
+
/* @__PURE__ */ jsxs("p", { children: [
|
|
2858
|
+
amountLabel ?? `$${usdAmount.toFixed(2)}`,
|
|
2859
|
+
" ",
|
|
2860
|
+
billingPeriodLabel ? `/ ${billingPeriodLabel}` : ""
|
|
2861
|
+
] })
|
|
2862
|
+
] });
|
|
2863
|
+
}, [planName, amountLabel, billingPeriodLabel, usdAmount]);
|
|
2864
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2865
|
+
/* @__PURE__ */ jsx(Dialog, { open, onOpenChange: handleClose, children: /* @__PURE__ */ jsxs(DialogContent, { className: "sm:max-w-3xl", children: [
|
|
2866
|
+
!priceId && /* @__PURE__ */ jsxs("div", { className: "mb-4 flex items-center gap-2 rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive", children: [
|
|
2867
|
+
/* @__PURE__ */ jsx(AlertCircle, { className: "h-4 w-4" }),
|
|
2868
|
+
" Select a subscription plan to continue."
|
|
2869
|
+
] }),
|
|
2870
|
+
/* @__PURE__ */ jsx(
|
|
2871
|
+
PaymentExperience,
|
|
2872
|
+
{
|
|
2873
|
+
priceId: priceId ?? "",
|
|
2874
|
+
usdAmount,
|
|
2875
|
+
checkoutSummary: summary,
|
|
2876
|
+
onNewCardPayment: priceId ? handleNewCardPayment : void 0,
|
|
2877
|
+
onSavedMethodPayment: priceId ? handleSavedMethodPayment : void 0,
|
|
2878
|
+
enableNewCard: Boolean(priceId),
|
|
2879
|
+
enableStoredMethods: Boolean(priceId),
|
|
2880
|
+
enableSolanaPay: enableSolanaPay && Boolean(priceId),
|
|
2881
|
+
onSolanaSuccess: solanaSuccess
|
|
2882
|
+
}
|
|
2883
|
+
)
|
|
2884
|
+
] }) }),
|
|
2885
|
+
/* @__PURE__ */ jsx(
|
|
2886
|
+
SubscriptionSuccessDialog,
|
|
2887
|
+
{
|
|
2888
|
+
open: showSuccess,
|
|
2889
|
+
onClose: () => setShowSuccess(false),
|
|
2890
|
+
planName,
|
|
2891
|
+
amountLabel: amountLabel ?? `$${usdAmount.toFixed(2)}`,
|
|
2892
|
+
billingPeriodLabel
|
|
2893
|
+
}
|
|
2894
|
+
)
|
|
2895
|
+
] });
|
|
2896
|
+
};
|
|
2661
2897
|
var useTokenBalance = (tokens) => {
|
|
2662
2898
|
const { publicKey } = useWallet();
|
|
2663
2899
|
const { connection } = useConnection();
|
|
@@ -3149,115 +3385,34 @@ var usePaymentStatus = (options = {}) => {
|
|
|
3149
3385
|
isPending: getConfirmationStatus() === "pending"
|
|
3150
3386
|
};
|
|
3151
3387
|
};
|
|
3152
|
-
var
|
|
3153
|
-
const
|
|
3154
|
-
const
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
firstName: billing.firstName,
|
|
3175
|
-
lastName: billing.lastName,
|
|
3176
|
-
address1: billing.address1,
|
|
3177
|
-
city: billing.city,
|
|
3178
|
-
state: billing.stateRegion,
|
|
3179
|
-
zipCode: billing.postalCode,
|
|
3180
|
-
country: billing.country
|
|
3181
|
-
};
|
|
3182
|
-
return services.subscriptions.subscribe("nmi", payload);
|
|
3183
|
-
},
|
|
3184
|
-
[services]
|
|
3185
|
-
);
|
|
3186
|
-
const subscribeWithSavedMethod = useCallback(
|
|
3187
|
-
async ({
|
|
3188
|
-
priceId,
|
|
3189
|
-
processor = "nmi",
|
|
3190
|
-
provider,
|
|
3191
|
-
paymentMethodId,
|
|
3192
|
-
email
|
|
3193
|
-
}) => {
|
|
3194
|
-
const payload = {
|
|
3195
|
-
priceId: ensurePrice(priceId),
|
|
3196
|
-
paymentMethodId,
|
|
3197
|
-
processor,
|
|
3198
|
-
provider,
|
|
3199
|
-
email
|
|
3200
|
-
};
|
|
3201
|
-
return services.subscriptions.subscribe("nmi", payload);
|
|
3202
|
-
},
|
|
3203
|
-
[services]
|
|
3204
|
-
);
|
|
3205
|
-
const subscribeWithCCBill = useCallback(
|
|
3206
|
-
async ({
|
|
3207
|
-
priceId,
|
|
3208
|
-
email,
|
|
3209
|
-
firstName,
|
|
3210
|
-
lastName,
|
|
3211
|
-
zipCode,
|
|
3212
|
-
country,
|
|
3213
|
-
processor = "ccbill"
|
|
3214
|
-
}) => {
|
|
3215
|
-
const payload = {
|
|
3216
|
-
priceId: ensurePrice(priceId),
|
|
3217
|
-
email,
|
|
3218
|
-
firstName,
|
|
3219
|
-
lastName,
|
|
3220
|
-
zipCode,
|
|
3221
|
-
country,
|
|
3222
|
-
processor
|
|
3223
|
-
};
|
|
3224
|
-
return services.subscriptions.subscribe("ccbill", payload);
|
|
3225
|
-
},
|
|
3226
|
-
[services]
|
|
3227
|
-
);
|
|
3228
|
-
const generateFlexFormUrl = useCallback(
|
|
3229
|
-
async ({
|
|
3230
|
-
priceId,
|
|
3231
|
-
firstName,
|
|
3232
|
-
lastName,
|
|
3233
|
-
address1,
|
|
3234
|
-
city,
|
|
3235
|
-
state,
|
|
3236
|
-
zipCode,
|
|
3237
|
-
country
|
|
3238
|
-
}) => {
|
|
3239
|
-
const payload = {
|
|
3240
|
-
price_id: ensurePrice(priceId),
|
|
3241
|
-
first_name: firstName,
|
|
3242
|
-
last_name: lastName,
|
|
3243
|
-
address1,
|
|
3244
|
-
city,
|
|
3245
|
-
state,
|
|
3246
|
-
zip_code: zipCode,
|
|
3247
|
-
country
|
|
3248
|
-
};
|
|
3249
|
-
return services.subscriptions.generateFlexFormUrl(payload);
|
|
3388
|
+
var useAlternativePaymentProvider = () => {
|
|
3389
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
3390
|
+
const [error, setError] = useState(null);
|
|
3391
|
+
const { generateFlexFormUrl } = useSubscriptionActions();
|
|
3392
|
+
const openFlexForm = useCallback(
|
|
3393
|
+
async (payload) => {
|
|
3394
|
+
setIsLoading(true);
|
|
3395
|
+
setError(null);
|
|
3396
|
+
try {
|
|
3397
|
+
const response = await generateFlexFormUrl(payload);
|
|
3398
|
+
if (response?.iframe_url) {
|
|
3399
|
+
window.location.href = response.iframe_url;
|
|
3400
|
+
} else {
|
|
3401
|
+
throw new Error("Unable to launch payment provider.");
|
|
3402
|
+
}
|
|
3403
|
+
} catch (err) {
|
|
3404
|
+
const message = err instanceof Error ? err.message : "Failed to open payment provider.";
|
|
3405
|
+
setError(message);
|
|
3406
|
+
console.error("[payments-ui] failed to open alternative payment provider", err);
|
|
3407
|
+
} finally {
|
|
3408
|
+
setIsLoading(false);
|
|
3409
|
+
}
|
|
3250
3410
|
},
|
|
3251
|
-
[
|
|
3411
|
+
[generateFlexFormUrl]
|
|
3252
3412
|
);
|
|
3253
|
-
return {
|
|
3254
|
-
subscribeWithCard,
|
|
3255
|
-
subscribeWithSavedMethod,
|
|
3256
|
-
subscribeWithCCBill,
|
|
3257
|
-
generateFlexFormUrl
|
|
3258
|
-
};
|
|
3413
|
+
return { openFlexForm, isLoading, error };
|
|
3259
3414
|
};
|
|
3260
3415
|
|
|
3261
|
-
export { CardDetailsForm, CardPaymentService, PaymentApp, PaymentExperience, PaymentMethodService, PaymentProvider, SolanaPaymentSelector, SolanaPaymentService, StoredPaymentMethods, SubscriptionService, TokenCatalog, WalletGateway, createPaymentStore, useDirectWalletPayment, usePaymentContext, usePaymentMethodService, usePaymentMethods, usePaymentStatus, usePaymentStore, useSolanaDirectPayment, useSolanaQrPayment, useSolanaService, useSubscriptionActions, useSupportedTokens, useTokenBalance };
|
|
3416
|
+
export { CardDetailsForm, CardPaymentService, PaymentApp, PaymentExperience, PaymentMethodService, PaymentProvider, SolanaPaymentSelector, SolanaPaymentService, StoredPaymentMethods, SubscriptionCheckoutModal, SubscriptionService, SubscriptionSuccessDialog, TokenCatalog, WalletGateway, createPaymentStore, useAlternativePaymentProvider, useDirectWalletPayment, usePaymentContext, usePaymentMethodService, usePaymentMethods, usePaymentStatus, usePaymentStore, useSolanaDirectPayment, useSolanaQrPayment, useSolanaService, useSubscriptionActions, useSupportedTokens, useTokenBalance };
|
|
3262
3417
|
//# sourceMappingURL=index.js.map
|
|
3263
3418
|
//# sourceMappingURL=index.js.map
|