@doujins/payments-ui 0.1.6 → 0.1.7
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 +37 -72
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +38 -73
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -724,12 +724,9 @@ var CardDetailsForm = ({
|
|
|
724
724
|
noValidate: true,
|
|
725
725
|
children: [
|
|
726
726
|
errorMessage && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-md border border-red-500/40 bg-red-500/10 px-4 py-2 text-sm text-red-400", children: errorMessage }),
|
|
727
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "
|
|
728
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
729
|
-
/* @__PURE__ */ jsxRuntime.
|
|
730
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.User, { className: "h-4 w-4" }),
|
|
731
|
-
" First name"
|
|
732
|
-
] }),
|
|
727
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4 md:flex-row", children: [
|
|
728
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 space-y-2", children: [
|
|
729
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: "payments-first", children: "First name" }),
|
|
733
730
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
734
731
|
Input,
|
|
735
732
|
{
|
|
@@ -740,11 +737,8 @@ var CardDetailsForm = ({
|
|
|
740
737
|
}
|
|
741
738
|
)
|
|
742
739
|
] }),
|
|
743
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
744
|
-
/* @__PURE__ */ jsxRuntime.
|
|
745
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.User, { className: "h-4 w-4" }),
|
|
746
|
-
" Last name"
|
|
747
|
-
] }),
|
|
740
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 space-y-2", children: [
|
|
741
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: "payments-last", children: "Last name" }),
|
|
748
742
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
749
743
|
Input,
|
|
750
744
|
{
|
|
@@ -808,10 +802,7 @@ var CardDetailsForm = ({
|
|
|
808
802
|
] }),
|
|
809
803
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-5 md:grid-cols-2", children: [
|
|
810
804
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
811
|
-
/* @__PURE__ */ jsxRuntime.
|
|
812
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.MapPin, { className: "h-4 w-4" }),
|
|
813
|
-
" Postal code"
|
|
814
|
-
] }),
|
|
805
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: "payments-postal", children: "Postal code" }),
|
|
815
806
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
816
807
|
Input,
|
|
817
808
|
{
|
|
@@ -853,17 +844,10 @@ var CardDetailsForm = ({
|
|
|
853
844
|
children: submitting || isTokenizing ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
854
845
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "mr-2 h-4 w-4 animate-spin" }),
|
|
855
846
|
" Processing\u2026"
|
|
856
|
-
] }) :
|
|
857
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.CreditCard, { className: "mr-2 h-4 w-4" }),
|
|
858
|
-
" ",
|
|
859
|
-
submitLabel
|
|
860
|
-
] })
|
|
847
|
+
] }) : submitLabel
|
|
861
848
|
}
|
|
862
849
|
),
|
|
863
|
-
/* @__PURE__ */ jsxRuntime.
|
|
864
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.CreditCard, { className: "h-4 w-4" }),
|
|
865
|
-
" Your payment information is encrypted and processed securely."
|
|
866
|
-
] })
|
|
850
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-white/60", children: "Your payment information is encrypted and processed securely." })
|
|
867
851
|
]
|
|
868
852
|
}
|
|
869
853
|
);
|
|
@@ -977,9 +961,7 @@ var formatCardLabel = (method) => {
|
|
|
977
961
|
var StoredPaymentMethods = ({
|
|
978
962
|
selectedMethodId,
|
|
979
963
|
onMethodSelect,
|
|
980
|
-
showAddButton = true
|
|
981
|
-
heading = "Payment Methods",
|
|
982
|
-
description = "Manage your saved cards"
|
|
964
|
+
showAddButton = true
|
|
983
965
|
}) => {
|
|
984
966
|
const { listQuery, createMutation, deleteMutation } = usePaymentMethods();
|
|
985
967
|
const [isModalOpen, setIsModalOpen] = React17.useState(false);
|
|
@@ -998,31 +980,18 @@ var StoredPaymentMethods = ({
|
|
|
998
980
|
);
|
|
999
981
|
};
|
|
1000
982
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
|
|
1001
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1002
|
-
|
|
1003
|
-
/* @__PURE__ */ jsxRuntime.jsxs("p", { className: "flex items-center gap-2 text-sm font-medium text-muted-foreground", children: [
|
|
1004
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.WalletCards, { className: "h-4 w-4" }),
|
|
1005
|
-
" ",
|
|
1006
|
-
heading
|
|
1007
|
-
] }),
|
|
1008
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: description })
|
|
1009
|
-
] }),
|
|
1010
|
-
showAddButton && /* @__PURE__ */ jsxRuntime.jsxs(Button, { size: "sm", variant: "outline", onClick: () => setIsModalOpen(true), children: [
|
|
1011
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.CreditCard, { className: "mr-2 h-4 w-4" }),
|
|
1012
|
-
" Add card"
|
|
1013
|
-
] })
|
|
1014
|
-
] }),
|
|
1015
|
-
listQuery.isLoading ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-center rounded-lg border border-dashed border-border/60 bg-muted/10 py-8 text-sm text-muted-foreground", children: [
|
|
983
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-start justify-between gap-4", children: showAddButton && /* @__PURE__ */ jsxRuntime.jsx(Button, { size: "sm", variant: "ghost", onClick: () => setIsModalOpen(true), children: "Add card" }) }),
|
|
984
|
+
listQuery.isLoading ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-center py-4 text-sm text-muted-foreground", children: [
|
|
1016
985
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "mr-2 h-4 w-4 animate-spin" }),
|
|
1017
|
-
" Loading cards
|
|
1018
|
-
] }) : payments.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "
|
|
986
|
+
" Loading cards..."
|
|
987
|
+
] }) : payments.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 text-center text-sm text-muted-foreground", children: "No saved payment methods yet." }) : /* @__PURE__ */ jsxRuntime.jsx(ScrollArea, { className: "max-h-[320px] pr-2", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-3", children: payments.map((method) => {
|
|
1019
988
|
const isSelected = selectedMethodId === method.id;
|
|
1020
989
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1021
990
|
"div",
|
|
1022
991
|
{
|
|
1023
992
|
className: cn(
|
|
1024
|
-
"flex flex-col gap-3 rounded-
|
|
1025
|
-
isSelected ? "
|
|
993
|
+
"flex flex-col gap-3 rounded-md px-4 py-3 transition-colors md:flex-row md:items-center md:justify-between",
|
|
994
|
+
isSelected ? "ring-1 ring-primary/70 bg-primary/5" : "ring-1 ring-border/40 bg-transparent"
|
|
1026
995
|
),
|
|
1027
996
|
children: [
|
|
1028
997
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
|
|
@@ -1049,7 +1018,8 @@ var StoredPaymentMethods = ({
|
|
|
1049
1018
|
Button,
|
|
1050
1019
|
{
|
|
1051
1020
|
size: "sm",
|
|
1052
|
-
variant:
|
|
1021
|
+
variant: "ghost",
|
|
1022
|
+
className: "px-3",
|
|
1053
1023
|
onClick: () => onMethodSelect(method),
|
|
1054
1024
|
children: isSelected ? "Selected" : "Use card"
|
|
1055
1025
|
}
|
|
@@ -1057,12 +1027,12 @@ var StoredPaymentMethods = ({
|
|
|
1057
1027
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1058
1028
|
Button,
|
|
1059
1029
|
{
|
|
1060
|
-
size: "
|
|
1061
|
-
variant: "
|
|
1062
|
-
className: "text-destructive",
|
|
1030
|
+
size: "sm",
|
|
1031
|
+
variant: "ghost",
|
|
1032
|
+
className: "px-3 text-destructive",
|
|
1063
1033
|
onClick: () => handleDelete(method),
|
|
1064
1034
|
disabled: deletingId === method.id && deleteMutation.isPending,
|
|
1065
|
-
children: deletingId === method.id && deleteMutation.isPending ?
|
|
1035
|
+
children: deletingId === method.id && deleteMutation.isPending ? "Removing\u2026" : "Remove"
|
|
1066
1036
|
}
|
|
1067
1037
|
)
|
|
1068
1038
|
] })
|
|
@@ -1801,7 +1771,7 @@ var SolanaPaymentView = ({
|
|
|
1801
1771
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
1802
1772
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-foreground", children: "Select token" }),
|
|
1803
1773
|
/* @__PURE__ */ jsxRuntime.jsxs(Select, { value: selectedToken?.symbol ?? "", onValueChange: handleTokenChange, children: [
|
|
1804
|
-
/* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "Select token" }) }),
|
|
1774
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectTrigger, { className: "border border-border/60 bg-transparent", children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "Select token" }) }),
|
|
1805
1775
|
/* @__PURE__ */ jsxRuntime.jsx(SelectContent, { className: "max-h-64", children: tokens.map((token) => /* @__PURE__ */ jsxRuntime.jsxs(SelectItem, { value: token.symbol, children: [
|
|
1806
1776
|
token.name,
|
|
1807
1777
|
" (",
|
|
@@ -1828,7 +1798,7 @@ var SolanaPaymentView = ({
|
|
|
1828
1798
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-2xl font-semibold text-foreground", children: "Pay with Solana" }),
|
|
1829
1799
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Choose a supported token and send the payment via Solana Pay QR code." })
|
|
1830
1800
|
] }),
|
|
1831
|
-
onClose && /* @__PURE__ */ jsxRuntime.
|
|
1801
|
+
onClose && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1832
1802
|
Button,
|
|
1833
1803
|
{
|
|
1834
1804
|
type: "button",
|
|
@@ -1836,11 +1806,8 @@ var SolanaPaymentView = ({
|
|
|
1836
1806
|
variant: "ghost",
|
|
1837
1807
|
onClick: handleClose,
|
|
1838
1808
|
disabled: paymentState === "processing" || paymentState === "confirming",
|
|
1839
|
-
className: "h-8 px-
|
|
1840
|
-
children:
|
|
1841
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowLeft, { className: "mr-2 h-4 w-4" }),
|
|
1842
|
-
" Back"
|
|
1843
|
-
]
|
|
1809
|
+
className: "h-8 px-3 text-sm",
|
|
1810
|
+
children: "Back"
|
|
1844
1811
|
}
|
|
1845
1812
|
)
|
|
1846
1813
|
] }),
|
|
@@ -1959,11 +1926,9 @@ var PaymentExperience = ({
|
|
|
1959
1926
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1960
1927
|
StoredPaymentMethods,
|
|
1961
1928
|
{
|
|
1962
|
-
|
|
1929
|
+
showAddButton: false,
|
|
1963
1930
|
selectedMethodId,
|
|
1964
|
-
onMethodSelect: handleMethodSelect
|
|
1965
|
-
description: "Select one of your stored payment methods.",
|
|
1966
|
-
showAddButton: false
|
|
1931
|
+
onMethodSelect: handleMethodSelect
|
|
1967
1932
|
}
|
|
1968
1933
|
),
|
|
1969
1934
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1972,7 +1937,7 @@ var PaymentExperience = ({
|
|
|
1972
1937
|
className: "w-full",
|
|
1973
1938
|
disabled: !selectedMethodId || savedStatus === "processing",
|
|
1974
1939
|
onClick: handleSavedPayment,
|
|
1975
|
-
children: savedStatus === "processing" ? "Processing
|
|
1940
|
+
children: savedStatus === "processing" ? "Processing..." : "Pay with selected card"
|
|
1976
1941
|
}
|
|
1977
1942
|
),
|
|
1978
1943
|
savedError && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-destructive", children: savedError })
|
|
@@ -2005,8 +1970,8 @@ var PaymentExperience = ({
|
|
|
2005
1970
|
/* @__PURE__ */ jsxRuntime.jsx(TabsTrigger, { value: "saved", disabled: !showStored, children: "Use saved card" }),
|
|
2006
1971
|
/* @__PURE__ */ jsxRuntime.jsx(TabsTrigger, { value: "new", disabled: !showNewCard, children: "Add new card" })
|
|
2007
1972
|
] }),
|
|
2008
|
-
/* @__PURE__ */ jsxRuntime.jsx(TabsContent, { value: "saved",
|
|
2009
|
-
/* @__PURE__ */ jsxRuntime.jsx(TabsContent, { value: "new",
|
|
1973
|
+
/* @__PURE__ */ jsxRuntime.jsx(TabsContent, { value: "saved", children: renderSavedTab() }),
|
|
1974
|
+
/* @__PURE__ */ jsxRuntime.jsx(TabsContent, { value: "new", children: renderNewTab() })
|
|
2010
1975
|
]
|
|
2011
1976
|
}
|
|
2012
1977
|
),
|
|
@@ -2194,11 +2159,11 @@ var SubscriptionCheckoutModal = ({
|
|
|
2194
2159
|
};
|
|
2195
2160
|
const handleNewCardPayment = async ({ token, billing }) => {
|
|
2196
2161
|
const response = await subscribeWithCard({
|
|
2197
|
-
|
|
2162
|
+
billing,
|
|
2198
2163
|
provider,
|
|
2164
|
+
idempotencyKey,
|
|
2199
2165
|
paymentToken: token,
|
|
2200
|
-
|
|
2201
|
-
idempotencyKey
|
|
2166
|
+
priceId: ensurePrice()
|
|
2202
2167
|
});
|
|
2203
2168
|
assertCheckoutSuccess(response.status, response.message);
|
|
2204
2169
|
notifySuccess();
|
|
@@ -2237,14 +2202,14 @@ var SubscriptionCheckoutModal = ({
|
|
|
2237
2202
|
{
|
|
2238
2203
|
usdAmount,
|
|
2239
2204
|
priceId: priceId ?? "",
|
|
2240
|
-
|
|
2205
|
+
initialMode,
|
|
2241
2206
|
onSolanaError: solanaError,
|
|
2207
|
+
onSolanaSuccess: solanaSuccess,
|
|
2242
2208
|
enableNewCard: Boolean(priceId),
|
|
2243
2209
|
enableStoredMethods: Boolean(priceId),
|
|
2244
2210
|
enableSolanaPay: enableSolanaPay && Boolean(priceId),
|
|
2245
2211
|
onNewCardPayment: priceId ? handleNewCardPayment : void 0,
|
|
2246
|
-
onSavedMethodPayment: priceId ? handleSavedMethodPayment : void 0
|
|
2247
|
-
initialMode
|
|
2212
|
+
onSavedMethodPayment: priceId ? handleSavedMethodPayment : void 0
|
|
2248
2213
|
}
|
|
2249
2214
|
)
|
|
2250
2215
|
] })
|
|
@@ -3158,7 +3123,7 @@ var PaymentMethodsSection = ({
|
|
|
3158
3123
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "mr-2 h-5 w-5 animate-spin" }),
|
|
3159
3124
|
" ",
|
|
3160
3125
|
t.loadingCards
|
|
3161
|
-
] }) : payments.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "
|
|
3126
|
+
] }) : payments.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-6 text-sm text-center", children: t.noPaymentMethods }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-3", children: payments.map((method) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3162
3127
|
"div",
|
|
3163
3128
|
{
|
|
3164
3129
|
className: "rounded-lg border border-white/10 bg-white/5 p-4 shadow-sm",
|