@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.js CHANGED
@@ -11,7 +11,7 @@ import { SolflareWalletAdapter } from '@solana/wallet-adapter-solflare';
11
11
  import { TrustWalletAdapter } from '@solana/wallet-adapter-trust';
12
12
  import { CoinbaseWalletAdapter } from '@solana/wallet-adapter-coinbase';
13
13
  import * as DialogPrimitive from '@radix-ui/react-dialog';
14
- import { X, ChevronDown, ChevronUp, Check, User, MapPin, Loader2, CreditCard, WalletCards, Trash2, ArrowLeft, CheckCircle, AlertCircle, Wallet, Ban, TriangleAlert, Shield, UserRound, Calendar, KeyRound, Sparkles, XCircle, RotateCcw, RefreshCw } from 'lucide-react';
14
+ import { X, ChevronDown, ChevronUp, Check, Loader2, CheckCircle, AlertCircle, Wallet, Ban, TriangleAlert, WalletCards, CreditCard, Trash2, Shield, UserRound, Calendar, KeyRound, Sparkles, XCircle, RotateCcw, RefreshCw } from 'lucide-react';
15
15
  import { clsx } from 'clsx';
16
16
  import { twMerge } from 'tailwind-merge';
17
17
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
@@ -692,12 +692,9 @@ var CardDetailsForm = ({
692
692
  noValidate: true,
693
693
  children: [
694
694
  errorMessage && /* @__PURE__ */ 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 }),
695
- /* @__PURE__ */ jsxs("div", { className: "grid gap-5 md:grid-cols-2", children: [
696
- /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
697
- /* @__PURE__ */ jsxs(Label, { htmlFor: "payments-first", className: "flex items-center gap-2 text-white/70", children: [
698
- /* @__PURE__ */ jsx(User, { className: "h-4 w-4" }),
699
- " First name"
700
- ] }),
695
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 md:flex-row", children: [
696
+ /* @__PURE__ */ jsxs("div", { className: "flex-1 space-y-2", children: [
697
+ /* @__PURE__ */ jsx(Label, { htmlFor: "payments-first", children: "First name" }),
701
698
  /* @__PURE__ */ jsx(
702
699
  Input,
703
700
  {
@@ -708,11 +705,8 @@ var CardDetailsForm = ({
708
705
  }
709
706
  )
710
707
  ] }),
711
- /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
712
- /* @__PURE__ */ jsxs(Label, { htmlFor: "payments-last", className: "flex items-center gap-2 text-white/70", children: [
713
- /* @__PURE__ */ jsx(User, { className: "h-4 w-4" }),
714
- " Last name"
715
- ] }),
708
+ /* @__PURE__ */ jsxs("div", { className: "flex-1 space-y-2", children: [
709
+ /* @__PURE__ */ jsx(Label, { htmlFor: "payments-last", children: "Last name" }),
716
710
  /* @__PURE__ */ jsx(
717
711
  Input,
718
712
  {
@@ -776,10 +770,7 @@ var CardDetailsForm = ({
776
770
  ] }),
777
771
  /* @__PURE__ */ jsxs("div", { className: "grid gap-5 md:grid-cols-2", children: [
778
772
  /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
779
- /* @__PURE__ */ jsxs(Label, { htmlFor: "payments-postal", className: "flex items-center gap-2 text-white/70", children: [
780
- /* @__PURE__ */ jsx(MapPin, { className: "h-4 w-4" }),
781
- " Postal code"
782
- ] }),
773
+ /* @__PURE__ */ jsx(Label, { htmlFor: "payments-postal", children: "Postal code" }),
783
774
  /* @__PURE__ */ jsx(
784
775
  Input,
785
776
  {
@@ -821,17 +812,10 @@ var CardDetailsForm = ({
821
812
  children: submitting || isTokenizing ? /* @__PURE__ */ jsxs(Fragment, { children: [
822
813
  /* @__PURE__ */ jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }),
823
814
  " Processing\u2026"
824
- ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
825
- /* @__PURE__ */ jsx(CreditCard, { className: "mr-2 h-4 w-4" }),
826
- " ",
827
- submitLabel
828
- ] })
815
+ ] }) : submitLabel
829
816
  }
830
817
  ),
831
- /* @__PURE__ */ jsxs("p", { className: "flex items-center gap-2 text-xs text-white/50", children: [
832
- /* @__PURE__ */ jsx(CreditCard, { className: "h-4 w-4" }),
833
- " Your payment information is encrypted and processed securely."
834
- ] })
818
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-white/60", children: "Your payment information is encrypted and processed securely." })
835
819
  ]
836
820
  }
837
821
  );
@@ -945,9 +929,7 @@ var formatCardLabel = (method) => {
945
929
  var StoredPaymentMethods = ({
946
930
  selectedMethodId,
947
931
  onMethodSelect,
948
- showAddButton = true,
949
- heading = "Payment Methods",
950
- description = "Manage your saved cards"
932
+ showAddButton = true
951
933
  }) => {
952
934
  const { listQuery, createMutation, deleteMutation } = usePaymentMethods();
953
935
  const [isModalOpen, setIsModalOpen] = useState(false);
@@ -966,31 +948,18 @@ var StoredPaymentMethods = ({
966
948
  );
967
949
  };
968
950
  return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
969
- /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between", children: [
970
- /* @__PURE__ */ jsxs("div", { children: [
971
- /* @__PURE__ */ jsxs("p", { className: "flex items-center gap-2 text-sm font-medium text-muted-foreground", children: [
972
- /* @__PURE__ */ jsx(WalletCards, { className: "h-4 w-4" }),
973
- " ",
974
- heading
975
- ] }),
976
- /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: description })
977
- ] }),
978
- showAddButton && /* @__PURE__ */ jsxs(Button, { size: "sm", variant: "outline", onClick: () => setIsModalOpen(true), children: [
979
- /* @__PURE__ */ jsx(CreditCard, { className: "mr-2 h-4 w-4" }),
980
- " Add card"
981
- ] })
982
- ] }),
983
- listQuery.isLoading ? /* @__PURE__ */ 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: [
951
+ /* @__PURE__ */ jsx("div", { className: "flex items-start justify-between gap-4", children: showAddButton && /* @__PURE__ */ jsx(Button, { size: "sm", variant: "ghost", onClick: () => setIsModalOpen(true), children: "Add card" }) }),
952
+ listQuery.isLoading ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center py-4 text-sm text-muted-foreground", children: [
984
953
  /* @__PURE__ */ jsx(Loader2, { className: "mr-2 h-4 w-4 animate-spin" }),
985
- " Loading cards\u2026"
986
- ] }) : payments.length === 0 ? /* @__PURE__ */ jsx("div", { className: "rounded-lg border border-dashed border-border/60 bg-muted/10 px-4 py-6 text-sm text-muted-foreground", children: "No saved payment methods yet." }) : /* @__PURE__ */ jsx(ScrollArea, { className: "max-h-[320px] pr-2", children: /* @__PURE__ */ jsx("div", { className: "space-y-3", children: payments.map((method) => {
954
+ " Loading cards..."
955
+ ] }) : payments.length === 0 ? /* @__PURE__ */ jsx("div", { className: "p-4 text-center text-sm text-muted-foreground", children: "No saved payment methods yet." }) : /* @__PURE__ */ jsx(ScrollArea, { className: "max-h-[320px] pr-2", children: /* @__PURE__ */ jsx("div", { className: "space-y-3", children: payments.map((method) => {
987
956
  const isSelected = selectedMethodId === method.id;
988
957
  return /* @__PURE__ */ jsxs(
989
958
  "div",
990
959
  {
991
960
  className: cn(
992
- "flex flex-col gap-3 rounded-lg border px-4 py-3 transition-colors md:flex-row md:items-center md:justify-between",
993
- isSelected ? "border-primary/60 bg-primary/5" : "border-border/60 bg-background"
961
+ "flex flex-col gap-3 rounded-md px-4 py-3 transition-colors md:flex-row md:items-center md:justify-between",
962
+ isSelected ? "ring-1 ring-primary/70 bg-primary/5" : "ring-1 ring-border/40 bg-transparent"
994
963
  ),
995
964
  children: [
996
965
  /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
@@ -1017,7 +986,8 @@ var StoredPaymentMethods = ({
1017
986
  Button,
1018
987
  {
1019
988
  size: "sm",
1020
- variant: isSelected ? "default" : "outline",
989
+ variant: "ghost",
990
+ className: "px-3",
1021
991
  onClick: () => onMethodSelect(method),
1022
992
  children: isSelected ? "Selected" : "Use card"
1023
993
  }
@@ -1025,12 +995,12 @@ var StoredPaymentMethods = ({
1025
995
  /* @__PURE__ */ jsx(
1026
996
  Button,
1027
997
  {
1028
- size: "icon",
1029
- variant: "outline",
1030
- className: "text-destructive",
998
+ size: "sm",
999
+ variant: "ghost",
1000
+ className: "px-3 text-destructive",
1031
1001
  onClick: () => handleDelete(method),
1032
1002
  disabled: deletingId === method.id && deleteMutation.isPending,
1033
- children: deletingId === method.id && deleteMutation.isPending ? /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx(Trash2, { className: "h-4 w-4" })
1003
+ children: deletingId === method.id && deleteMutation.isPending ? "Removing\u2026" : "Remove"
1034
1004
  }
1035
1005
  )
1036
1006
  ] })
@@ -1769,7 +1739,7 @@ var SolanaPaymentView = ({
1769
1739
  /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
1770
1740
  /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-foreground", children: "Select token" }),
1771
1741
  /* @__PURE__ */ jsxs(Select, { value: selectedToken?.symbol ?? "", onValueChange: handleTokenChange, children: [
1772
- /* @__PURE__ */ jsx(SelectTrigger, { children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select token" }) }),
1742
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "border border-border/60 bg-transparent", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select token" }) }),
1773
1743
  /* @__PURE__ */ jsx(SelectContent, { className: "max-h-64", children: tokens.map((token) => /* @__PURE__ */ jsxs(SelectItem, { value: token.symbol, children: [
1774
1744
  token.name,
1775
1745
  " (",
@@ -1796,7 +1766,7 @@ var SolanaPaymentView = ({
1796
1766
  /* @__PURE__ */ jsx("p", { className: "text-2xl font-semibold text-foreground", children: "Pay with Solana" }),
1797
1767
  /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: "Choose a supported token and send the payment via Solana Pay QR code." })
1798
1768
  ] }),
1799
- onClose && /* @__PURE__ */ jsxs(
1769
+ onClose && /* @__PURE__ */ jsx(
1800
1770
  Button,
1801
1771
  {
1802
1772
  type: "button",
@@ -1804,11 +1774,8 @@ var SolanaPaymentView = ({
1804
1774
  variant: "ghost",
1805
1775
  onClick: handleClose,
1806
1776
  disabled: paymentState === "processing" || paymentState === "confirming",
1807
- className: "h-8 px-2 text-sm",
1808
- children: [
1809
- /* @__PURE__ */ jsx(ArrowLeft, { className: "mr-2 h-4 w-4" }),
1810
- " Back"
1811
- ]
1777
+ className: "h-8 px-3 text-sm",
1778
+ children: "Back"
1812
1779
  }
1813
1780
  )
1814
1781
  ] }),
@@ -1927,11 +1894,9 @@ var PaymentExperience = ({
1927
1894
  /* @__PURE__ */ jsx(
1928
1895
  StoredPaymentMethods,
1929
1896
  {
1930
- heading: "Saved cards",
1897
+ showAddButton: false,
1931
1898
  selectedMethodId,
1932
- onMethodSelect: handleMethodSelect,
1933
- description: "Select one of your stored payment methods.",
1934
- showAddButton: false
1899
+ onMethodSelect: handleMethodSelect
1935
1900
  }
1936
1901
  ),
1937
1902
  /* @__PURE__ */ jsx(
@@ -1940,7 +1905,7 @@ var PaymentExperience = ({
1940
1905
  className: "w-full",
1941
1906
  disabled: !selectedMethodId || savedStatus === "processing",
1942
1907
  onClick: handleSavedPayment,
1943
- children: savedStatus === "processing" ? "Processing\u2026" : "Pay with selected card"
1908
+ children: savedStatus === "processing" ? "Processing..." : "Pay with selected card"
1944
1909
  }
1945
1910
  ),
1946
1911
  savedError && /* @__PURE__ */ jsx("p", { className: "text-sm text-destructive", children: savedError })
@@ -1973,8 +1938,8 @@ var PaymentExperience = ({
1973
1938
  /* @__PURE__ */ jsx(TabsTrigger, { value: "saved", disabled: !showStored, children: "Use saved card" }),
1974
1939
  /* @__PURE__ */ jsx(TabsTrigger, { value: "new", disabled: !showNewCard, children: "Add new card" })
1975
1940
  ] }),
1976
- /* @__PURE__ */ jsx(TabsContent, { value: "saved", className: "space-y-4", children: renderSavedTab() }),
1977
- /* @__PURE__ */ jsx(TabsContent, { value: "new", className: "space-y-4", children: renderNewTab() })
1941
+ /* @__PURE__ */ jsx(TabsContent, { value: "saved", children: renderSavedTab() }),
1942
+ /* @__PURE__ */ jsx(TabsContent, { value: "new", children: renderNewTab() })
1978
1943
  ]
1979
1944
  }
1980
1945
  ),
@@ -2162,11 +2127,11 @@ var SubscriptionCheckoutModal = ({
2162
2127
  };
2163
2128
  const handleNewCardPayment = async ({ token, billing }) => {
2164
2129
  const response = await subscribeWithCard({
2165
- priceId: ensurePrice(),
2130
+ billing,
2166
2131
  provider,
2132
+ idempotencyKey,
2167
2133
  paymentToken: token,
2168
- billing,
2169
- idempotencyKey
2134
+ priceId: ensurePrice()
2170
2135
  });
2171
2136
  assertCheckoutSuccess(response.status, response.message);
2172
2137
  notifySuccess();
@@ -2205,14 +2170,14 @@ var SubscriptionCheckoutModal = ({
2205
2170
  {
2206
2171
  usdAmount,
2207
2172
  priceId: priceId ?? "",
2208
- onSolanaSuccess: solanaSuccess,
2173
+ initialMode,
2209
2174
  onSolanaError: solanaError,
2175
+ onSolanaSuccess: solanaSuccess,
2210
2176
  enableNewCard: Boolean(priceId),
2211
2177
  enableStoredMethods: Boolean(priceId),
2212
2178
  enableSolanaPay: enableSolanaPay && Boolean(priceId),
2213
2179
  onNewCardPayment: priceId ? handleNewCardPayment : void 0,
2214
- onSavedMethodPayment: priceId ? handleSavedMethodPayment : void 0,
2215
- initialMode
2180
+ onSavedMethodPayment: priceId ? handleSavedMethodPayment : void 0
2216
2181
  }
2217
2182
  )
2218
2183
  ] })
@@ -3126,7 +3091,7 @@ var PaymentMethodsSection = ({
3126
3091
  /* @__PURE__ */ jsx(Loader2, { className: "mr-2 h-5 w-5 animate-spin" }),
3127
3092
  " ",
3128
3093
  t.loadingCards
3129
- ] }) : payments.length === 0 ? /* @__PURE__ */ jsx("div", { className: "rounded-lg border border-dashed border-white/20 bg-white/5 p-6 text-sm text-white/60", children: t.noPaymentMethods }) : /* @__PURE__ */ jsx("div", { className: "space-y-3", children: payments.map((method) => /* @__PURE__ */ jsxs(
3094
+ ] }) : payments.length === 0 ? /* @__PURE__ */ jsx("div", { className: "p-6 text-sm text-center", children: t.noPaymentMethods }) : /* @__PURE__ */ jsx("div", { className: "space-y-3", children: payments.map((method) => /* @__PURE__ */ jsxs(
3130
3095
  "div",
3131
3096
  {
3132
3097
  className: "rounded-lg border border-white/10 bg-white/5 p-4 shadow-sm",