@donotdev/billing 0.0.3 → 0.0.5
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/components/ProductCard.js +1 -1
- package/dist/components/PurchaseButton.js +1 -1
- package/dist/components/SecurityNotice.js +1 -1
- package/dist/components/StripeCheckoutButton.d.ts.map +1 -1
- package/dist/components/StripeCheckoutButton.js +1 -1
- package/dist/components/SubscriptionButton.js +1 -1
- package/dist/components/SubscriptionManager.d.ts.map +1 -1
- package/dist/components/SubscriptionManager.js +1 -1
- package/dist/components/index.d.ts +0 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/useStripeBilling.d.ts.map +1 -1
- package/dist/useStripeBilling.js +1 -1
- package/package.json +5 -5
- package/dist/components/PaymentRedirectOverlay.d.ts +0 -23
- package/dist/components/PaymentRedirectOverlay.d.ts.map +0 -1
- package/dist/components/PaymentRedirectOverlay.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as t,jsxs as i}from"react/jsx-runtime";import{Crown as s,Check as F}from"lucide-react";import{Card as E,Badge as b,BADGE_VARIANT as x,Stack as o}from"@donotdev/components";import{useTranslation as R,maybeTranslate as d,translateArray as U}from"@donotdev/core";import{PurchaseButton as k}from"./PurchaseButton";import{SubscriptionButton as P}from"./SubscriptionButton";function X({namespace:S="billing",configKey:m,id:V,name:l,price:e,currency:p,description:w,features:n,popular:a=!1,limitedTime:z=!1,mode:g,priceId:h,allowPromotionCodes:u=!0,metadata:f={},successUrl:y="/billing/success",cancelUrl:v="/purchase",className:C=""}){const{t:r}=R([S,"billing"]),N=e==="Free"?"Free":e,T=g==="subscription"?"/month":"",A=d(r,l),B=d(r,w),j=Array.isArray(n)?n.map(c=>d(r,c)):n?U(r,n,10):[];return i(E,{className:C,style:{position:"relative",...a&&{boxShadow:"var(--shadow-xl)",transform:"scale(1.05)"}},title:i("div",{style:{textAlign:"center"},children:[t(o,{align:"center",style:{marginBottom:"var(--gap-md)"},children:t(s,{className:"dndev-size-touch",style:{color:"var(--warning)"}})}),i(o,{direction:"row",align:"center",justify:"center",gap:"tight",style:{fontSize:"var(--font-size-2xl)"},children:[A,z&&t(b,{as:"span",variant:x.DESTRUCTIVE,children:r("billing:components.productCard.limitedTime")})]}),i("div",{style:{fontSize:"var(--font-size-3xl)",fontWeight:700,color:"var(--primary)"},children:[N,e!=="Free"&&i("span",{style:{fontSize:"var(--font-size-lg)",fontWeight:400,color:"var(--muted-foreground)"},children:[T," ",r("billing:components.productCard.exclVat")]})]})]}),subtitle:B,children:[t(o,{as:"ul",gap:"tight",style:{marginBottom:"var(--gap-lg)"},children:j.map((c,D)=>i(o,{as:"li",direction:"row",align:"start",children:[t(F,{className:"dndev-size-md",style:{color:"var(--success)",marginRight:"var(--gap-md)",marginTop:"0.125rem",flexShrink:0}}),t("span",{style:{fontSize:"var(--font-size-sm)"},children:c})]},D))}),g==="payment"?t(k,{configKey:m,config:{type:"StripePayment",name:l,price:e,currency:p,priceId:h,tier:"premium",duration:"lifetime",metadata:f,allowPromotionCodes:u},successUrl:y,cancelUrl:v,variant:a?"primary":"outline",className:"dndev-w-full",icon:s,children:r("billing:components.productCard.purchaseNow")}):t(P,{configKey:m,config:{type:"StripeSubscription",name:l,price:e,currency:p,priceId:h,tier:"pro",duration:"1year",metadata:f,allowPromotionCodes:u},successUrl:y,cancelUrl:v,variant:a?"primary":"outline",className:"dndev-w-full",icon:s,children:r("billing:components.productCard.subscribeNow")}),a&&t("div",{style:{position:"absolute",top:"-0.75rem",left:"50%",transform:"translateX(-50%)"},children:i(b,{variant:x.DEFAULT,children:[t(s,{style:{width:"0.75rem",height:"0.75rem",marginRight:"0.25rem"}}),r("billing:components.productCard.mostPopular")]})})]})}export{X as ProductCard};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as o}from"react/jsx-runtime";import{useTranslation as n}from"@donotdev/core";import{StripeCheckoutButton as i}from"./StripeCheckoutButton";function s({config:t,children:e,...r}){const{t:a}=n("billing");return o(i,{...r,priceId:t.priceId,mode:"payment",metadata:{tier:t.tier,duration:t.duration,...t.metadata,...r.metadata},children:e||a("components.buttons.purchase")})}export{s as PurchaseButton};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as
|
|
1
|
+
"use client";import{jsx as e,jsxs as s}from"react/jsx-runtime";import{Shield as y,Lock as g,CreditCard as v,X as h}from"lucide-react";import{useState as o,useEffect as m}from"react";import{Card as S,Button as w,BUTTON_VARIANT as b,Stack as r}from"@donotdev/components";import{useTranslation as N}from"@donotdev/core";function T({dismissible:n=!0,className:t="",show:d=!0,onDismiss:c}){const{t:i}=N("billing"),[u,a]=o(d),[f,l]=o(!1);m(()=>{typeof window<"u"&&localStorage.getItem("billing-security-notice-dismissed")==="true"&&(l(!0),a(!1))},[]);const p=()=>{typeof window<"u"&&localStorage.setItem("billing-security-notice-dismissed","true"),l(!0),a(!1),c?.()};return!u||f?null:e(S,{className:t,style:{border:"1px solid var(--primary)",backgroundColor:"var(--primary)",opacity:"var(--opacity-subtle)"},children:e("div",{style:{padding:"var(--gap-md)"},children:s(r,{direction:"row",align:"start",justify:"between",children:[s(r,{direction:"row",align:"start",gap:"tight",children:[e("div",{className:"dndev-flex-shrink-0",children:e(y,{className:"dndev-size-md",style:{color:"var(--primary)"}})}),s("div",{className:"dndev-flex-1",children:[e("h3",{style:{fontSize:"var(--font-size-sm)",fontWeight:500,color:"var(--foreground)"},children:i("security.title","Secure Payment Processing")}),s("div",{style:{marginTop:"var(--gap-md)",fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:[e("p",{style:{marginBottom:"var(--gap-md)"},children:i("security.description","Your payment information is processed securely by Stripe, a PCI DSS Level 1 certified payment processor.")}),s(r,{direction:"row",align:"center",gap:"tight",style:{fontSize:"var(--font-size-xs)"},children:[s(r,{direction:"row",align:"center",gap:"tight",children:[e(g,{className:"dndev-size-md"}),e("span",{children:i("security.encrypted","256-bit SSL encryption")})]}),s(r,{direction:"row",align:"center",gap:"tight",children:[e(v,{className:"dndev-size-md"}),e("span",{children:i("security.stripe","Powered by Stripe")})]})]})]})]})]}),n&&e(w,{variant:b.GHOST,onClick:p,className:"dndev-flex-shrink-0 dndev-size-touch","aria-label":i("security.dismiss","Dismiss security notice"),children:e(h,{className:"dndev-size-md"})})]})})})}function j(){const[n,t]=o(!1);return m(()=>{if(typeof window<"u"){const i=localStorage.getItem("billing-security-notice-dismissed");t(i==="true")}},[]),{isDismissed:n,dismiss:()=>{typeof window<"u"&&localStorage.setItem("billing-security-notice-dismissed","true"),t(!0)},reset:()=>{typeof window<"u"&&localStorage.removeItem("billing-security-notice-dismissed"),t(!1)}}}export{T as SecurityNotice,j as useSecurityNotice};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StripeCheckoutButton.d.ts","sourceRoot":"","sources":["../../src/components/StripeCheckoutButton.tsx"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,EAAc,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"StripeCheckoutButton.d.ts","sourceRoot":"","sources":["../../src/components/StripeCheckoutButton.tsx"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,EAAc,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAGL,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAC;AAIxB,MAAM,WAAW,yBAA0B,SAAQ,IAAI,CACrD,WAAW,EACX,SAAS,GAAG,UAAU,GAAG,SAAS,CACnC;IACC,uFAAuF;IACvF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sBAAsB;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,mBAAmB;IACnB,IAAI,EAAE,YAAY,CAAC;IACnB,2BAA2B;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0BAA0B;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,4BAA4B;IAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,mBAAmB;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qBAAqB;IACrB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,yCAAyC;IACzC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,SAAS,EACT,OAAO,EACP,IAAI,EACJ,UAAU,EACV,SAAS,EACT,QAAa,EACb,mBAA0B,EAC1B,OAAmB,EACnB,SAAS,EACT,QAAQ,EACR,WAAW,EACX,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,GAAG,WAAW,EACf,EAAE,yBAAyB,2CAmF3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as i,Fragment as w}from"react/jsx-runtime";import{Button as x,cn as y}from"@donotdev/components";import{useTranslation as E,redirectToExternalUrlWithErrorHandling as F}from"@donotdev/core";import{useStripeBilling as c}from"../useStripeBilling";function R({configKey:n,priceId:l,mode:r,successUrl:a,cancelUrl:u,metadata:d={},allowPromotionCodes:p=!0,variant:h="primary",className:g,disabled:s,loadingText:k,icon:m,children:C,onError:f,...B}){const{t:o}=E("billing"),b=c("checkout"),e=c("status")==="initializing",S=k||o("components.buttons.processing"),U=C||o(r==="payment"?"components.buttons.purchase":"components.buttons.subscribe");return i(w,{children:i(x,{...B,onClick:async()=>{if(!(e||s))try{const t=await b({priceId:l,mode:r,successUrl:a,cancelUrl:u,metadata:{...n&&{billingConfigKey:n},...d},allowPromotionCodes:p});t.sessionUrl&&await F(t.sessionUrl,{},"Failed to redirect to payment page")}catch(t){f?.(t instanceof Error?t:new Error("Checkout failed"))}},disabled:s||e,variant:h,className:y("dndev-w-full",g),icon:m,children:e?S:U})})}export{R as StripeCheckoutButton};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as i}from"react/jsx-runtime";import{useTranslation as a}from"@donotdev/core";import{StripeCheckoutButton as n}from"./StripeCheckoutButton";function d({config:t,children:r,...o}){const{t:e}=a("billing");return i(n,{...o,priceId:t.priceId,mode:"subscription",allowPromotionCodes:!0,metadata:{tier:t.tier,duration:t.duration,...t.metadata,...o.metadata},children:r||e("components.buttons.subscribe")})}export{d as SubscriptionButton};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubscriptionManager.d.ts","sourceRoot":"","sources":["../../src/components/SubscriptionManager.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SubscriptionManager.d.ts","sourceRoot":"","sources":["../../src/components/SubscriptionManager.tsx"],"names":[],"mappings":"AA0EA,MAAM,WAAW,wBAAwB;IACvC,4CAA4C;IAC5C,cAAc,CAAC,EAAE,KAAK,CAAC;QACrB,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,gBAAgB,EAAE,MAAM,CAAC;KAC1B,CAAC,CAAC;IACH,0BAA0B;IAC1B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,uBAAuB;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,cAAmB,EACnB,eAAuB,EACvB,SAAc,GACf,EAAE,wBAAwB,2CAwS1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{jsx as e,jsxs as
|
|
1
|
+
"use client";import{jsx as e,jsxs as t}from"react/jsx-runtime";import{AlertCircle as D,CreditCard as I,AlertTriangle as k}from"lucide-react";import{useState as U,lazy as P,Suspense as x}from"react";import{isClient as B}from"@donotdev/core";import{Card as y,Button as p,BUTTON_VARIANT as g,Badge as c,BADGE_VARIANT as l,Stack as s}from"@donotdev/components";import{SUBSCRIPTION_STATUS as m,useTranslation as L}from"@donotdev/core";import{useStripeBilling as d}from"../useStripeBilling";const O=()=>null,V=P(async()=>{try{return{default:(await import("@donotdev/auth")).FeatureGuard}}catch{return{default:O}}});let f=null;B()&&import("@donotdev/auth").then(a=>{f=a.useAuth}).catch(()=>{});function _(a){return a==="user"?null:a==="status"?"degraded":(()=>{})}function j(a){return f?f(a):_(a)}function X({availablePlans:a=[],allowPlanChange:E=!1,className:v=""}){const{t:n}=L("billing"),b=j("user"),T=d("cancelSubscription"),A=d("changePlan"),M=d("openCustomerPortal"),u=d("status")==="initializing",C=d("error"),[w,h]=U(!1),i=b?.customClaims?.subscription,N=async()=>{try{const r=await T();h(!1);const o=new Date(r.endsAt).toLocaleDateString();alert(n("components.subscriptionManager.subscriptionEnds",{date:o}))}catch{}},R=async(r,o)=>{try{await A(r,o),alert(n("components.subscriptionManager.planChanged"))}catch{}},z=r=>{switch(r){case m.ACTIVE:return e(c,{children:n("components.subscriptionManager.status.active")});case m.CANCELED:return e(c,{variant:l.DESTRUCTIVE,children:n("components.subscriptionManager.status.cancelled")});case m.PAST_DUE:return e(c,{variant:l.DESTRUCTIVE,children:n("components.subscriptionManager.status.pastDue")});case m.TRIALING:return e(c,{variant:l.SECONDARY,children:n("components.subscriptionManager.status.trialing")});default:return e(c,{variant:l.OUTLINE,children:r})}},S=r=>e(y,{className:v,children:e("p",{style:{color:"var(--muted-foreground)"},children:n(b?"components.subscriptionManager.noSubscription":"components.subscriptionManager.signInRequired")})});return e(x,{fallback:e(S,{}),children:e(V,{subscription:!0,fallback:S,children:e(y,{className:v,title:n("components.subscriptionManager.title"),children:t(s,{gap:"medium",children:[t("div",{children:[e("h3",{style:{fontSize:"var(--font-size-sm)",fontWeight:500,marginBottom:"var(--gap-md)"},children:n("components.subscriptionManager.currentPlan")}),t(s,{direction:"row",align:"center",justify:"between",style:{padding:"var(--gap-md)",border:"1px solid var(--border)",borderRadius:"var(--radius-lg)"},children:[t("div",{children:[e("p",{style:{fontWeight:600},children:i.tier}),e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:z(i.status)})]}),i.cancelAtPeriodEnd&&t(s,{direction:"row",align:"center",style:{color:"var(--warning)"},children:[e(k,{className:"dndev-size-md",style:{marginRight:"var(--gap-md)"}}),t("span",{style:{fontSize:"var(--font-size-sm)"},children:[n("components.subscriptionManager.ends")," ",new Date(i.subscriptionEnd).toLocaleDateString()]})]})]})]}),t(s,{gap:"large",children:[e(p,{variant:g.OUTLINE,className:"dndev-w-full",onClick:()=>M(),disabled:u,icon:I,children:n("components.subscriptionManager.managePaymentMethod")}),!i.cancelAtPeriodEnd&&e(p,{variant:g.DESTRUCTIVE,className:"dndev-w-full",onClick:()=>h(!0),disabled:u,icon:D,children:n("components.subscriptionManager.cancelSubscription")})]}),w&&t("div",{className:"dndev-surface","data-variant":"default",style:{padding:"var(--gap-md)",border:"1px solid var(--warning)",borderRadius:"var(--radius-lg)",backgroundColor:"var(--muted)"},children:[e("p",{style:{fontSize:"var(--font-size-sm)",marginBottom:"var(--gap-md)"},children:n("components.subscriptionManager.cancelConfirm",{date:new Date(i.subscriptionEnd).toLocaleDateString()})}),t(s,{direction:"row",gap:"tight",children:[e(p,{variant:g.DESTRUCTIVE,onClick:N,disabled:u,children:n("components.subscriptionManager.yesCancel")}),e(p,{variant:g.OUTLINE,onClick:()=>h(!1),children:n("components.subscriptionManager.noKeep")})]})]}),E&&a.length>0&&t("div",{children:[e("h3",{style:{fontSize:"var(--font-size-sm)",fontWeight:500,marginBottom:"var(--gap-md)"},children:n("components.subscriptionManager.changePlan")}),e(s,{gap:"tight",children:a.map(r=>e("button",{className:"dndev-w-full",style:{padding:"var(--gap-md)",border:"1px solid var(--border)",borderRadius:"var(--radius-lg)",textAlign:"left",backgroundColor:"transparent",cursor:"pointer"},onMouseEnter:o=>{o.currentTarget.style.backgroundColor="var(--accent)"},onMouseLeave:o=>{o.currentTarget.style.backgroundColor="transparent"},onClick:()=>R(r.priceId,r.billingConfigKey),disabled:u||i.tier===r.id,children:t(s,{direction:"row",justify:"between",align:"center",children:[t("div",{children:[e("p",{style:{fontWeight:500},children:r.name}),t("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--muted-foreground)"},children:[r.currency==="EUR"?"\u20AC":"$",r.price,"/month"]})]}),i.tier===r.id&&e(c,{variant:l.SECONDARY,children:n("components.subscriptionManager.current")})]})},r.id))})]}),C&&e("div",{className:"dndev-surface","data-variant":"destructive",style:{padding:"var(--gap-md)",backgroundColor:"var(--muted)",border:"1px solid var(--destructive)",borderRadius:"var(--radius-lg)"},children:e("p",{style:{fontSize:"var(--font-size-sm)",color:"var(--destructive-foreground)"},children:C})})]})})})})}export{X as SubscriptionManager};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC"}
|
package/dist/components/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./
|
|
1
|
+
export*from"./ProductCard";export*from"./PurchaseButton";export*from"./SecurityNotice";export*from"./StripeCheckoutButton";export*from"./SubscriptionButton";export*from"./SubscriptionManager";
|
package/dist/index.d.ts
CHANGED
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
* @author AMBROISE PARK Consulting
|
|
7
7
|
*/
|
|
8
8
|
export { useStripeBilling, type BillingAuthState } from './useStripeBilling';
|
|
9
|
-
export {
|
|
9
|
+
export { ProductCard, SecurityNotice, StripeCheckoutButton, SubscriptionManager, } from './components';
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAGH,OAAO,EAAE,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAG7E,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAGH,OAAO,EAAE,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAG7E,OAAO,EACL,WAAW,EACX,cAAc,EACd,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useStripeBilling as
|
|
1
|
+
import{useStripeBilling as e}from"./useStripeBilling";import{ProductCard as i,SecurityNotice as u,StripeCheckoutButton as c,SubscriptionManager as p}from"./components";export{i as ProductCard,u as SecurityNotice,c as StripeCheckoutButton,p as SubscriptionManager,e as useStripeBilling};
|