@lockerverse/react 0.2.26 โ 0.2.27
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.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ type LockerversePaymentStyle = CSSProperties & {
|
|
|
37
37
|
type LockerversePaymentProps = CreateLockerverseWidgetOptions & Omit<ComponentPropsWithoutRef<"section">, "children" | "onError"> & {
|
|
38
38
|
branding?: LockerversePaymentBranding;
|
|
39
39
|
includeServiceFee?: boolean;
|
|
40
|
+
metadata?: Record<string, string>;
|
|
40
41
|
onPaymentComplete?: (result: LockerversePaymentCompletion) => void;
|
|
41
42
|
returnUrl?: string;
|
|
42
43
|
selection: LockerversePaymentSelectionItem[];
|
|
@@ -52,6 +53,7 @@ type LockerverseCheckoutSessionProviderProps = CreateLockerverseWidgetOptions &
|
|
|
52
53
|
accentColor?: string;
|
|
53
54
|
email?: string;
|
|
54
55
|
includeServiceFee?: boolean;
|
|
56
|
+
metadata?: Record<string, string>;
|
|
55
57
|
returnUrl: string;
|
|
56
58
|
selection: LockerversePaymentSelectionItem[];
|
|
57
59
|
unstable_stripeLoader?: CheckoutSessionStripeLoader;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/checkout-session-payment.tsx"],"mappings":";;;;KAIY;EACN;EAAqB;;EACrB;EAAqB;;KAEf;KAEA;EACV;EACA;EACA;;KAGU;EACV;EACA;;KAGU,0BAA0B;EACpC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;KAGU,0BAA0B,iCACpC,KAAK;EACH,WAAW;EACX;EACA,qBAAqB,QAAQ;EAC7B;EACA,WAAW;EACX,+BAA+B;EAC/B,QAAQ;EACR,QAAQ;EACR;;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/checkout-session-payment.tsx"],"mappings":";;;;KAIY;EACN;EAAqB;;EACrB;EAAqB;;KAEf;KAEA;EACV;EACA;EACA;;KAGU;EACV;EACA;;KAGU,0BAA0B;EACpC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;KAGU,0BAA0B,iCACpC,KAAK;EACH,WAAW;EACX;EACA,WAAW;EACX,qBAAqB,QAAQ;EAC7B;EACA,WAAW;EACX,+BAA+B;EAC/B,QAAQ;EACR,QAAQ;EACR;;;;KCFC,qCAAqC;KAE9B,0CACV,iCACE;EACE;EACA;EACA;EACA,WAAW;EACX;EACA,WAAW;EACX,wBAAwB;EACxB;EACA;;KAaD;EACH,iBAAiB,sBAAsB;EACvC,SAAS;EACT,UAAU;IACR,qBAAqB;IACrB;IACA;IACA;IACA;IACA;QACI,QAAQ;EACd;EACA;IACE;IACA;IACA;IACA;;EAEF;EACA,gBAAgB;IACd;IACA;QACI,QAAQ;;iBA6RA,mCACd,OAAO,0DAAuC,IAAA;iBA4JhC,iCAA6B;iBA6F7B,wCACd,UACA;EAEA,WAAW;EACX,cAAc,QAAQ;oBACvB,IAAA;iBA+Se,mBAAmB,OAAO,0CAAuB,IAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createLockerverseCheckoutClient as e}from"@lockerverse/sdk/checkout";import{BillingAddressElement as t,CheckoutElementsProvider as n,PaymentElement as r,ShippingAddressElement as i,useCheckoutElements as a}from"@stripe/react-stripe-js/checkout";import{loadStripe as o}from"@stripe/stripe-js/pure/index.js";import{createContext as s,useContext as c,useEffect as l,useMemo as u,useRef as d,useState as f}from"react";import{pipe as p,regex as m,safeParse as h,string as g}from"valibot";import{Select as _}from"@base-ui/react/select";import{Fragment as v,jsx as y,jsxs as b}from"react/jsx-runtime";const x=/^#([\da-f]{3}|[\da-f]{6})$/i;function S(e){let t=x.exec(e.trim());if(!t)return;let[,n]=t;if(!n)return;let r=n.length===3?Array.from(n,e=>`${e}${e}`).join(``):n;return[0,2,4].map(e=>Number.parseInt(r.slice(e,e+2),16))}function C([e,t,n]){let[r=0,i=0,a=0]=[e,t,n].map((e=0)=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4});return .2126*r+.7152*i+.0722*a}function w(e){let t=S(e);if(!t)return;let n=C(t);return(n+.05)/.05>=1.05/(n+.05)?`#000`:`#fff`}const T=s(void 0);function E({children:e,container:t}){return y(T.Provider,{value:t,children:e})}function D(){return y(`svg`,{"aria-hidden":`true`,fill:`none`,viewBox:`0 0 16 16`,children:y(`path`,{d:`m4 6 4 4 4-4`})})}function O(){return y(`svg`,{"aria-hidden":`true`,fill:`none`,viewBox:`0 0 16 16`,children:y(`path`,{d:`m3 8 3 3 7-7`})})}function k({ariaDescribedBy:e,ariaLabel:t,ariaLabelledBy:n,className:r,id:i,invalid:a=!1,name:o,onValueChange:s,options:l,required:u=!1,value:d}){let f=c(T),p=[`lockerverse-payment__select`,r].filter(Boolean).join(` `);return y(`div`,{className:p,children:b(_.Root,{id:i,items:l,name:o,onValueChange:e=>{e!==null&&s(e)},required:u,value:d,children:[b(_.Trigger,{"aria-describedby":e,"aria-invalid":a||void 0,"aria-label":t,"aria-labelledby":n,className:`lockerverse-payment__select-trigger`,children:[y(_.Value,{}),y(_.Icon,{"aria-hidden":`true`,className:`lockerverse-payment__select-icon`,children:y(D,{})})]}),y(_.Portal,{container:f,children:y(_.Positioner,{alignItemWithTrigger:!1,className:`lockerverse-payment__select-positioner`,sideOffset:6,children:y(_.Popup,{className:`lockerverse-payment__select-popup`,children:y(_.List,{className:`lockerverse-payment__select-list`,children:l.map(e=>b(_.Item,{className:`lockerverse-payment__select-item`,value:e.value,children:[y(_.ItemText,{children:e.label}),y(_.ItemIndicator,{"aria-hidden":`true`,className:`lockerverse-payment__select-item-indicator`,children:y(O,{})})]},e.value))})})})})]})})}const A=[{callingCode:`+1`,label:`๐บ๐ธ +1`,value:`US`},{callingCode:`+52`,label:`๐ฒ๐ฝ +52`,value:`MX`},{callingCode:`+380`,label:`๐บ๐ฆ +380`,value:`UA`},{callingCode:`+48`,label:`๐ต๐ฑ +48`,value:`PL`},{callingCode:`+1`,label:`๐จ๐ฆ +1`,value:`CA`},{callingCode:`+49`,label:`๐ฉ๐ช +49`,value:`DE`},{callingCode:`+44`,label:`๐ฌ๐ง +44`,value:`GB`},{callingCode:`+46`,label:`๐ธ๐ช +46`,value:`SE`},{callingCode:`+358`,label:`๐ซ๐ฎ +358`,value:`FI`},{callingCode:`+1`,label:`๐ต๐ท +1`,value:`PR`}],j=[{label:`15%`,percent:15,value:`15`},{label:`12%`,percent:12,value:`12`},{label:`10%`,percent:10,value:`10`},{label:`5%`,percent:5,value:`5`},{label:`Other`,percent:null,value:`custom`}];function M({label:e}){return b(`div`,{className:`lockerverse-payment__stripe-loader`,role:`status`,children:[y(`p`,{children:e}),b(`div`,{"aria-hidden":`true`,children:[y(`span`,{}),y(`span`,{}),y(`span`,{})]})]})}function ee({fields:e,onChange:t,values:n}){return e.map(e=>{let r=n[e.id]??(e.type.includes(`multi`)||e.type===`checkboxes`?[]:``);if(e.type===`textarea`)return b(`label`,{children:[y(`span`,{children:e.label}),y(`textarea`,{name:e.id,onChange:n=>t(e.id,n.currentTarget.value),required:e.required,value:String(r)})]},e.id);if(e.type===`select`){let n=`lockerverse-custom-${e.id}-label`;return b(`div`,{className:`lockerverse-payment__field`,children:[y(`span`,{id:n,children:e.label}),y(k,{ariaLabelledBy:n,name:e.id,onValueChange:n=>t(e.id,n),options:[{label:`Selectโฆ`,value:``},...e.options.map(e=>({label:e.label,value:e.id}))],required:e.required,value:String(r)})]},e.id)}if(e.type===`radio`||e.type===`checkboxes`||e.type===`multi_select`){let n=Array.isArray(r)?r:[r];return b(`fieldset`,{children:[y(`legend`,{children:e.label}),e.options.map(r=>{let i=n.includes(r.id);return b(`label`,{className:`lockerverse-payment__choice`,children:[y(`input`,{checked:i,name:e.id,onChange:()=>{if(e.type===`radio`){t(e.id,r.id);return}t(e.id,i?n.filter(e=>e!==r.id):[...n,r.id])},required:e.required&&n.length===0,type:e.type===`radio`?`radio`:`checkbox`,value:r.id}),y(`span`,{children:r.label})]},r.id)})]},e.id)}return b(`label`,{children:[y(`span`,{children:e.label}),y(`input`,{name:e.id,onChange:n=>t(e.id,n.currentTarget.value),required:e.required,type:`text`,value:String(r)})]},e.id)})}function te({busy:e,enabled:t,onCustomTipBlur:n,onCustomTipChange:r,onSelect:i,tipInput:a,tipOption:o}){return t?b(`div`,{className:`lockerverse-payment__tip`,children:[y(`strong`,{children:`Add a tip to support the Lockerverse platform`}),y(`div`,{"aria-label":`Tip amount`,role:`radiogroup`,children:j.map(t=>y(`button`,{"aria-pressed":o===t.value,disabled:e,onClick:()=>i(t),type:`button`,children:t.label},t.value))}),o===`custom`?b(`label`,{children:[y(`span`,{children:`Custom tip`}),b(`div`,{className:`lockerverse-payment__money-input`,children:[y(`span`,{"aria-hidden":`true`,children:`$`}),y(`input`,{inputMode:`decimal`,name:`customTip`,onBlur:n,onChange:e=>r(e.currentTarget.value),placeholder:`0.00`,value:a})]})]}):null]}):null}function N({email:e,fields:t,onEmailChange:n,onPhoneChange:r,onPhoneCountryChange:i,phone:a,phoneCountry:o}){return b(`div`,{className:`lockerverse-payment__contact`,children:[b(`label`,{children:[y(`span`,{children:`Email`}),y(`input`,{autoComplete:`email`,inputMode:`email`,name:`email`,onChange:e=>n(e.currentTarget.value),placeholder:`name@example.com`,required:!0,type:`email`,value:e})]}),t.phone?b(`label`,{children:[y(`span`,{children:`Phone`}),b(`div`,{className:`lockerverse-payment__phone-control`,children:[y(k,{ariaLabel:`Phone country`,className:`lockerverse-payment__select--phone-country`,name:`phoneCountry`,onValueChange:i,options:A,value:o}),y(`input`,{autoComplete:`tel`,inputMode:`tel`,name:`phone`,onChange:e=>r(e.currentTarget.value),placeholder:`(201) 555-0123`,required:!0,type:`tel`,value:a})]})]}):null]})}function P({fields:e,isBillingAddressReady:n,isPaymentReady:a,isShippingAddressReady:o,onBillingAddressReady:s,onPaymentReady:c,onShippingAddressReady:l,onShippingMatchesBillingChange:u,shippingMatchesBilling:d,totalCents:f}){return b(v,{children:[b(`div`,{className:`lockerverse-payment__stripe-element`,"data-ready":a,hidden:f===0,children:[a?null:y(M,{label:`Loading payment form...`}),y(`div`,{className:`lockerverse-payment__stripe-mount`,children:y(r,{onReady:c,options:{fields:{billingDetails:{address:`never`,email:`never`,name:`never`,phone:`never`}},layout:`tabs`,paymentMethodOrder:[`card`,`apple_pay`,`paypal`],terms:{applePay:`auto`,card:`always`,googlePay:`never`,paypal:`auto`,usBankAccount:`never`},wallets:{applePay:`auto`,googlePay:`never`}}})})]}),b(`div`,{className:`lockerverse-payment__address`,children:[y(`h2`,{children:`Billing address`}),b(`div`,{className:`lockerverse-payment__stripe-element lockerverse-payment__stripe-element--address`,"data-ready":n,children:[n?null:y(M,{label:`Loading billing address...`}),y(`div`,{className:`lockerverse-payment__stripe-mount`,children:y(t,{onReady:s})})]})]}),e.shipping?b(`div`,{className:`lockerverse-payment__shipping`,children:[b(`label`,{className:`lockerverse-payment__check-row`,children:[y(`input`,{checked:d,name:`shippingMatchesBilling`,onChange:e=>u(e.currentTarget.checked),type:`checkbox`}),y(`span`,{children:`Shipping is same as billing information`})]}),d?null:b(`div`,{className:`lockerverse-payment__address`,children:[y(`h2`,{children:`Shipping address`}),b(`div`,{className:`lockerverse-payment__stripe-element lockerverse-payment__stripe-element--address`,"data-ready":o,children:[o?null:y(M,{label:`Loading shipping address...`}),y(`div`,{className:`lockerverse-payment__stripe-mount`,children:y(i,{onReady:l})})]})]})]}):null]})}function ne({fields:e,memberId:t,merchSize:n,onMemberIdChange:r,onMerchSizeChange:i}){return b(v,{children:[e.memberId?b(`label`,{children:[y(`span`,{children:`Member ID`}),y(`input`,{name:`memberId`,onChange:e=>r(e.currentTarget.value),required:!0,type:`text`,value:t})]}):null,e.merchSize?b(`div`,{className:`lockerverse-payment__field`,children:[y(`span`,{id:`lockerverse-merch-size-label`,children:`Size`}),y(k,{ariaLabelledBy:`lockerverse-merch-size-label`,name:`merchSize`,onValueChange:i,options:[`XS`,`S`,`M`,`L`,`XL`,`XXL`,`XXXL`].map(e=>({label:e,value:e})),required:!0,value:n})]}):null]})}function F(){return b(`div`,{className:`lockerverse-payment__skeleton-loader-block`,children:[y(`span`,{className:`lockerverse-payment__skeleton-loader-label`}),b(`div`,{className:`lockerverse-payment__skeleton-loader-content`,children:[y(`span`,{className:`lockerverse-payment__skeleton-loader-full`}),b(`div`,{className:`lockerverse-payment__skeleton-loader-grid`,children:[y(`span`,{className:`lockerverse-payment__skeleton-loader-half`}),y(`span`,{className:`lockerverse-payment__skeleton-loader-half`})]})]})]})}function I(){return b(`div`,{className:`lockerverse-payment__loading`,children:[y(`span`,{className:`lockerverse-payment__sr-only`,role:`status`,children:`Preparing secure checkoutโฆ`}),b(`div`,{"aria-hidden":`true`,className:`lockerverse-payment__skeleton`,children:[b(`div`,{className:`lockerverse-payment__skeleton-branding`,children:[y(`span`,{className:`lockerverse-payment__skeleton-avatar`}),y(`span`,{className:`lockerverse-payment__skeleton-community`})]}),b(`div`,{className:`lockerverse-payment__skeleton-contact`,children:[b(`div`,{className:`lockerverse-payment__skeleton-field`,children:[y(`span`,{className:`lockerverse-payment__skeleton-label`}),y(`span`,{className:`lockerverse-payment__skeleton-input`})]}),b(`div`,{className:`lockerverse-payment__skeleton-field`,children:[y(`span`,{className:`lockerverse-payment__skeleton-label`}),y(`span`,{className:`lockerverse-payment__skeleton-input`})]})]}),y(F,{}),y(F,{}),b(`div`,{className:`lockerverse-payment__skeleton-actions`,children:[y(`span`,{className:`lockerverse-payment__skeleton-check-line`}),y(`span`,{className:`lockerverse-payment__skeleton-button`})]})]})]})}const L=s(null),R=p(g(),m(/^\d+(?:\.\d{1,2})?$/));function z(e){let t=e.trim();if(!t)return 0;let n=h(R,t);if(!n.success)return null;let[r=`0`,i=``]=n.output.split(`.`),a=BigInt(r)*100n+BigInt(i.padEnd(2,`0`));return a<=BigInt(2**53-1)?Number(a):null}function re(e){return new Intl.NumberFormat(`en-US`,{currency:`USD`,style:`currency`}).format(e/100)}function B(e,t){let n=e.trim(),r=n.replace(/\D/g,``);return n.startsWith(`+`)?`+${r}`:`${A.find(e=>e.value===t)?.callingCode??`+1`}${r}`}function V(e,t){if(!t.length)throw Error(`Select at least one Product before opening checkout.`);return t.map(t=>{let n=e.products.find(e=>e.slug===t.productSlug);if(!n)throw Error(`Product ${t.productSlug} is unavailable.`);return`amountCents`in t?{amountCents:t.amountCents,productId:n.id}:{productId:n.id,quantity:t.quantity}})}function H(e,t){return t.reduce((t,n)=>{if(`amountCents`in n)return t+n.amountCents;let r=e.products.find(e=>e.slug===n.productSlug);if(!r||r.amountCents===null)throw Error(`Product ${n.productSlug} has invalid pricing.`);return t+r.amountCents*n.quantity},0)}function U(e){let t={communitySlug:e.communitySlug,...e.fetch?{fetch:e.fetch}:{},...e.onError?{onError:e.onError}:{},...e.requestTimeoutMs===void 0?{}:{requestTimeoutMs:e.requestTimeoutMs},...e.sentryDsn===void 0?{}:{sentryDsn:e.sentryDsn},widgetSlug:e.widgetSlug};return e.apiBaseUrl?{...t,apiBaseUrl:e.apiBaseUrl,environment:e.environment}:{...t,environment:`production`}}function W(e,t,n){if(!e)return null;let r=t??`#38d77a`,i=n===`light`;return{clientSecret:e.session.clientSecret,elementsOptions:{appearance:{rules:{".Input:focus":{borderColor:r,boxShadow:`0 0 0 1px ${r}`,outline:`none`}},theme:i?`stripe`:`night`,variables:{borderRadius:`10px`,colorBackground:i?`#f5f6f7`:`#121212`,colorDanger:i?`#c52b3e`:`#f08a98`,colorPrimary:r,colorText:i?`#121416`:`#ffffff`,colorTextPlaceholder:i?`#72767d`:`#6b6b6b`,colorTextSecondary:i?`#62666d`:`#a1a1aa`,focusBoxShadow:`none`,focusOutline:`none`,fontSizeBase:`16px`}},syncAddressCheckbox:`none`}}}function G({children:e,loaded:t}){let n=a();return n.type===`loading`?y(I,{}):n.type===`error`?y(`div`,{role:`alert`,children:n.error.message}):y(q,{checkout:n.checkout,loaded:t,children:e})}function K(e){return{includeServiceFee:e.includeServiceFee,serviceFeeAmountCents:Math.round(e.subtotalCents*e.catalog.pricingPolicy.serviceFeeRateBasisPoints/1e4),subtotalCents:e.subtotalCents,tipCents:e.tipCents}}function q({checkout:e,children:t,loaded:n}){let[r,i]=f(()=>K(n));l(()=>{i(K(n))},[n]);let a={async applyPromoCode(t){let r=await e.runServerUpdate(()=>n.client.updateSessionDiscount({paymentReference:n.session.paymentReference,...t.trim()?{promoCode:t.trim()}:{}}));return r.type===`error`?r.error.message:null},catalog:n.catalog,async confirm(t){if(t.shippingMatchesBilling){if(!e.billingAddress)throw Error(`Billing address is required.`);let t=await e.updateShippingAddress(e.billingAddress);if(t.type===`error`)throw Error(t.error.message)}let r=await e.runServerUpdate(()=>n.client.updateSessionDetails({...t.customFieldAnswers?{customFieldAnswers:t.customFieldAnswers}:{},email:t.email,...t.memberId?{memberId:t.memberId}:{},...t.merchSize?{merchSize:t.merchSize}:{},paymentReference:n.session.paymentReference,...t.phone?{phone:t.phone}:{}}));if(r.type===`error`)throw Error(r.error.message);let i=await X(e,t.email,t.phone??``,e.total.total.minorUnitsAmount>0);if(`error`in i)throw Error(i.error);let a=await e.confirm({email:i.email,...i.phone?{phoneNumber:i.phone}:{},redirect:`if_required`});if(a.type===`error`)throw Error(a.error.message);return{paymentReference:n.session.paymentReference,sessionId:n.session.sessionId}},paymentReference:n.session.paymentReference,pricing:r,totalCents:e.total.total.minorUnitsAmount,async updatePricing(t){let r,a=await e.runServerUpdate(()=>n.client.updateSessionPricing({...t,paymentReference:n.session.paymentReference}).then(e=>(r=e,e)));if(a.type===`error`)throw Error(a.error.message);if(!r)throw Error(`Lockerverse returned no updated pricing.`);let o=r;return i(e=>({...e,includeServiceFee:o.includeServiceFee,tipCents:o.tipCents})),o}};return y(L.Provider,{value:a,children:t})}function J(t){let[r,i]=f(null),[a,s]=f(null),[c,p]=f(0),m=d(null),h=JSON.stringify({email:t.email,includeServiceFee:t.includeServiceFee,returnUrl:t.returnUrl,selection:t.selection,tipCents:t.tipCents}),g=d({email:t.email,includeServiceFee:t.includeServiceFee,key:h,requestKey:globalThis.crypto.randomUUID(),returnUrl:t.returnUrl,selection:t.selection,tipCents:t.tipCents}),_=u(()=>U(t),[t.apiBaseUrl,t.communitySlug,t.environment,t.fetch,t.onError,t.requestTimeoutMs,t.sentryDsn,t.widgetSlug]);l(()=>{let t=!0;if(m.current?.clientOptions!==_||c>0){let t=e(_),n=g.current;m.current={clientOptions:_,promise:(async()=>{let e=await t.load(),r=V(e,n.selection),i=H(e,n.selection),a=n.includeServiceFee??e.widget.fields.serviceFee,o=n.tipCents??(e.widget.fields.tipping?Math.round(i*.1):0),s=await t.createSession({...n.email?{email:n.email}:{},...e.widget.fields.serviceFee?{includeServiceFee:a}:{},items:r,requestKey:n.requestKey,returnUrl:n.returnUrl,...e.widget.fields.tipping?{tipCents:o}:{}});return{catalog:e,client:t,includeServiceFee:a,returnUrl:n.returnUrl,session:s,subtotalCents:i,tipCents:o}})()}}return i(null),s(null),m.current.promise.then(e=>{t&&i(e)}).catch(e=>{t&&s(e instanceof Error?e.message:`Unable to load checkout.`)}),()=>{t=!1}},[_,c]);let v=u(()=>r?(t.unstable_stripeLoader??o)(r.catalog.payment.publishableKey,{betas:[`custom_checkout_server_updates_1`],...r.session.connectedAccountId?{stripeAccount:r.session.connectedAccountId}:{}}):null,[r,t.unstable_stripeLoader]),x=u(()=>W(r,t.accentColor,t.theme),[r,t.accentColor,t.theme]);return h===g.current.key?a?b(`div`,{className:`lockerverse-payment__payment-status`,role:`alert`,children:[y(`p`,{children:a}),y(`button`,{onClick:()=>p(e=>e+1),type:`button`,children:`Try again`})]}):r&&x?y(n,{options:x,stripe:v,children:y(G,{loaded:r,children:t.children})}):y(I,{}):y(`div`,{className:`lockerverse-payment__payment-status`,role:`alert`,children:`Checkout selection changed. Remount this payment component for the new selection.`})}function Y(){let e=c(L);if(!e)throw Error(`useLockerverseCheckoutSession must be used inside LockerverseCheckoutSessionProvider.`);return e}async function X(e,t,n,r){let i=t.trim().toLowerCase();if(!i)return{error:`Email is required.`};let a=await e.updateEmail(i);if(a.type===`error`)return{error:a.error.message};let o=n.trim();if(o&&(await e.updatePhoneNumber(o)).type===`error`)return{error:`Phone number is invalid.`};if(r){let t=await e.validateElements();if(t.type===`error`)return{error:t.error.message}}return{email:i,phone:o}}function ie(e,t){return e===0?`Complete free order`:t>0?`Process Payment ($${((e-t)/100).toFixed(2)}) + $${(t/100).toFixed(2)} tip`:`Process Payment ($${(e/100).toFixed(2)})`}function ae({catalog:e,customFieldValues:t,email:n,memberId:r,merchSize:i,phone:a,phoneCountry:o,shippingMatchesBilling:s}){return{customFieldAnswers:e.widget.customFields.map(e=>({fieldId:e.id,value:t[e.id]??null})),email:n,...r?{memberId:r}:{},...i?{merchSize:i}:{},...a?{phone:B(a,o)}:{},...e.widget.fields.shipping?{shippingMatchesBilling:s}:{}}}function Z({branding:e,onComplete:t}){let{applyPromoCode:n,catalog:r,confirm:i,pricing:a,totalCents:o,updatePricing:s}=Y(),[c,u]=f(``),[p,m]=f(``),[h,g]=f(`US`),[_,v]=f(``),[x,S]=f(`M`),[C,w]=f({}),[T,E]=f(``),[D,O]=f(null),[k,A]=f(!1),[M,F]=f(!1),[I,L]=f(!1),[R,B]=f(!1),[V,H]=f(!1),[U,W]=f(!0),G=j.find(e=>e.percent!==null&&Math.round(a.subtotalCents*e.percent/100)===a.tipCents)?.value??`custom`,[K,q]=f(G),[J,X]=f(G===`custom`&&a.tipCents>0?(a.tipCents/100).toFixed(2):``),Z=d({includeServiceFee:a.includeServiceFee,tipCents:a.tipCents}),Q=d(Promise.resolve(!0));l(()=>{Z.current={includeServiceFee:a.includeServiceFee,tipCents:a.tipCents}},[a.includeServiceFee,a.tipCents]);function $(e){let t=(async()=>{F(!0),O(null);try{let t=await s(e);return Z.current={includeServiceFee:t.includeServiceFee,tipCents:t.tipCents},!0}catch(e){return O(e instanceof Error?e.message:`Unable to update checkout.`),!1}finally{F(!1)}})();return Q.current=t,t}async function oe(e){if(e.percent===null){q(e.value);return}let t=Math.round(a.subtotalCents*e.percent/100);await $({includeServiceFee:a.includeServiceFee,tipCents:t})&&(X(``),q(e.value))}function se(){let e=z(J);if(e===null){O(`Enter a valid tip with no more than two decimal places.`);return}return $({includeServiceFee:a.includeServiceFee,tipCents:e})}async function ce(e){await $({includeServiceFee:e,tipCents:a.tipCents})}async function le(){A(!0),O(null);try{O(await n(T))}catch(e){O(e instanceof Error?e.message:`Unable to update checkout.`)}finally{A(!1)}}async function ue(){if(!await Q.current)return!1;if(K!==`custom`)return!0;let e=z(J);return e===null?(O(`Enter a valid tip with no more than two decimal places.`),!1):e===Z.current.tipCents||$({includeServiceFee:Z.current.includeServiceFee,tipCents:e})}async function de(e){e.preventDefault(),A(!0),O(null);try{if(!await ue())return;let e=await i(ae({catalog:r,customFieldValues:C,email:c,memberId:_,merchSize:x,phone:p,phoneCountry:h,shippingMatchesBilling:U}));t?.(e)}catch(e){O(e instanceof Error?e.message:`Unable to complete checkout.`)}finally{A(!1)}}return b(`form`,{className:`lockerverse-payment__form`,onSubmit:de,children:[b(`header`,{children:[r.widget.showCommunityBranding&&e?b(`div`,{className:`lockerverse-payment__branding`,children:[e.imageUrl?y(`img`,{alt:e.name,height:`48`,src:e.imageUrl,width:`48`}):null,y(`strong`,{children:e.name})]}):null,y(`h1`,{children:r.widget.title??r.widget.name}),r.widget.description?y(`p`,{children:r.widget.description}):null]}),y(te,{busy:k||M,enabled:r.widget.fields.tipping,onCustomTipBlur:se,onCustomTipChange:X,onSelect:oe,tipInput:J,tipOption:K}),y(N,{email:c,fields:r.widget.fields,onEmailChange:u,onPhoneChange:m,onPhoneCountryChange:g,phone:p,phoneCountry:h}),y(P,{fields:r.widget.fields,isBillingAddressReady:I,isPaymentReady:R,isShippingAddressReady:V,onBillingAddressReady:()=>L(!0),onPaymentReady:()=>B(!0),onShippingAddressReady:()=>H(!0),onShippingMatchesBillingChange:e=>{W(e),e||H(!1)},shippingMatchesBilling:U,totalCents:o}),y(ne,{fields:r.widget.fields,memberId:_,merchSize:x,onMemberIdChange:v,onMerchSizeChange:S}),r.widget.fields.promoCode?b(`div`,{className:`lockerverse-payment__additional-fields`,children:[b(`label`,{children:[y(`span`,{children:`Promo code`}),y(`input`,{name:`promoCode`,onChange:e=>E(e.currentTarget.value),placeholder:`Optional`,value:T})]}),y(`button`,{disabled:k,onClick:le,type:`button`,children:T.trim()?`Apply code`:`Remove code`})]}):null,r.widget.customFields.length?y(`div`,{className:`lockerverse-payment__custom-fields`,children:y(ee,{fields:r.widget.customFields,onChange:(e,t)=>w(n=>({...n,[e]:t})),values:C})}):null,D?y(`div`,{role:`alert`,children:D}):null,b(`div`,{className:`lockerverse-payment__actions`,children:[r.widget.fields.serviceFee?b(`label`,{className:`lockerverse-payment__check-row`,children:[y(`input`,{checked:a.includeServiceFee,disabled:k||M,name:`includeServiceFee`,onChange:e=>ce(e.currentTarget.checked),type:`checkbox`}),b(`span`,{children:[`Add `,re(a.serviceFeeAmountCents),` to help cover processing fees`]})]}):null,y(`button`,{disabled:k,type:`submit`,children:ie(o,a.tipCents)})]})]})}function Q(e){let t=d(null),{apiBaseUrl:n,branding:r,className:i,communitySlug:a,environment:o,fetch:s,includeServiceFee:c,onError:l,onPaymentComplete:u,requestTimeoutMs:f,returnUrl:p,selection:m,sentryDsn:h,unstable_stripeLoader:g,style:_,theme:v=`dark`,tipCents:b,widgetSlug:x,...S}=e,C=p??(globalThis.location===void 0?`https://lockerverse.com`:globalThis.location.href),T=[`lockerverse-payment`,i].filter(Boolean).join(` `),D=n?{apiBaseUrl:n,communitySlug:a,environment:o,widgetSlug:x}:{communitySlug:a,environment:`production`,widgetSlug:x},O=_?.[`--lockerverse-accent`]??r?.accentColor,k=O?{..._,"--lockerverse-accent":O,"--lockerverse-accent-contrast":_?.[`--lockerverse-accent-contrast`]??w(O)??`#08110c`}:_;return y(`section`,{...S,className:T,"data-lockerverse-theme":v,ref:t,style:k,children:y(E,{container:t,children:y(J,{...D,...O?{accentColor:O}:{},...s?{fetch:s}:{},...c===void 0?{}:{includeServiceFee:c},...l?{onError:l}:{},...f===void 0?{}:{requestTimeoutMs:f},returnUrl:C,selection:m,...h===void 0?{}:{sentryDsn:h},...g?{unstable_stripeLoader:g}:{},theme:v,...b===void 0?{}:{tipCents:b},children:y(Z,{...r?{branding:r}:{},...u?{onComplete:u}:{}})})})})}export{Z as LockerverseCheckoutSessionPaymentForm,J as LockerverseCheckoutSessionProvider,Q as LockerversePayment,Y as useLockerverseCheckoutSession};
|
|
1
|
+
import{createLockerverseCheckoutClient as e}from"@lockerverse/sdk/checkout";import{BillingAddressElement as t,CheckoutElementsProvider as n,PaymentElement as r,ShippingAddressElement as i,useCheckoutElements as a}from"@stripe/react-stripe-js/checkout";import{loadStripe as o}from"@stripe/stripe-js/pure/index.js";import{createContext as s,useContext as c,useEffect as l,useMemo as u,useRef as d,useState as f}from"react";import{pipe as p,regex as m,safeParse as h,string as g}from"valibot";import{Select as _}from"@base-ui/react/select";import{Fragment as v,jsx as y,jsxs as b}from"react/jsx-runtime";const x=/^#([\da-f]{3}|[\da-f]{6})$/i;function S(e){let t=x.exec(e.trim());if(!t)return;let[,n]=t;if(!n)return;let r=n.length===3?Array.from(n,e=>`${e}${e}`).join(``):n;return[0,2,4].map(e=>Number.parseInt(r.slice(e,e+2),16))}function C([e,t,n]){let[r=0,i=0,a=0]=[e,t,n].map((e=0)=>{let t=e/255;return t<=.04045?t/12.92:((t+.055)/1.055)**2.4});return .2126*r+.7152*i+.0722*a}function w(e){let t=S(e);if(!t)return;let n=C(t);return(n+.05)/.05>=1.05/(n+.05)?`#000`:`#fff`}const T=s(void 0);function E({children:e,container:t}){return y(T.Provider,{value:t,children:e})}function D(){return y(`svg`,{"aria-hidden":`true`,fill:`none`,viewBox:`0 0 16 16`,children:y(`path`,{d:`m4 6 4 4 4-4`})})}function O(){return y(`svg`,{"aria-hidden":`true`,fill:`none`,viewBox:`0 0 16 16`,children:y(`path`,{d:`m3 8 3 3 7-7`})})}function k({ariaDescribedBy:e,ariaLabel:t,ariaLabelledBy:n,className:r,id:i,invalid:a=!1,name:o,onValueChange:s,options:l,required:u=!1,value:d}){let f=c(T),p=[`lockerverse-payment__select`,r].filter(Boolean).join(` `);return y(`div`,{className:p,children:b(_.Root,{id:i,items:l,name:o,onValueChange:e=>{e!==null&&s(e)},required:u,value:d,children:[b(_.Trigger,{"aria-describedby":e,"aria-invalid":a||void 0,"aria-label":t,"aria-labelledby":n,className:`lockerverse-payment__select-trigger`,children:[y(_.Value,{}),y(_.Icon,{"aria-hidden":`true`,className:`lockerverse-payment__select-icon`,children:y(D,{})})]}),y(_.Portal,{container:f,children:y(_.Positioner,{alignItemWithTrigger:!1,className:`lockerverse-payment__select-positioner`,sideOffset:6,children:y(_.Popup,{className:`lockerverse-payment__select-popup`,children:y(_.List,{className:`lockerverse-payment__select-list`,children:l.map(e=>b(_.Item,{className:`lockerverse-payment__select-item`,value:e.value,children:[y(_.ItemText,{children:e.label}),y(_.ItemIndicator,{"aria-hidden":`true`,className:`lockerverse-payment__select-item-indicator`,children:y(O,{})})]},e.value))})})})})]})})}const A=[{callingCode:`+1`,label:`๐บ๐ธ +1`,value:`US`},{callingCode:`+52`,label:`๐ฒ๐ฝ +52`,value:`MX`},{callingCode:`+380`,label:`๐บ๐ฆ +380`,value:`UA`},{callingCode:`+48`,label:`๐ต๐ฑ +48`,value:`PL`},{callingCode:`+1`,label:`๐จ๐ฆ +1`,value:`CA`},{callingCode:`+49`,label:`๐ฉ๐ช +49`,value:`DE`},{callingCode:`+44`,label:`๐ฌ๐ง +44`,value:`GB`},{callingCode:`+46`,label:`๐ธ๐ช +46`,value:`SE`},{callingCode:`+358`,label:`๐ซ๐ฎ +358`,value:`FI`},{callingCode:`+1`,label:`๐ต๐ท +1`,value:`PR`}],j=[{label:`15%`,percent:15,value:`15`},{label:`12%`,percent:12,value:`12`},{label:`10%`,percent:10,value:`10`},{label:`5%`,percent:5,value:`5`},{label:`Other`,percent:null,value:`custom`}];function M({label:e}){return b(`div`,{className:`lockerverse-payment__stripe-loader`,role:`status`,children:[y(`p`,{children:e}),b(`div`,{"aria-hidden":`true`,children:[y(`span`,{}),y(`span`,{}),y(`span`,{})]})]})}function ee({fields:e,onChange:t,values:n}){return e.map(e=>{let r=n[e.id]??(e.type.includes(`multi`)||e.type===`checkboxes`?[]:``);if(e.type===`textarea`)return b(`label`,{children:[y(`span`,{children:e.label}),y(`textarea`,{name:e.id,onChange:n=>t(e.id,n.currentTarget.value),required:e.required,value:String(r)})]},e.id);if(e.type===`select`){let n=`lockerverse-custom-${e.id}-label`;return b(`div`,{className:`lockerverse-payment__field`,children:[y(`span`,{id:n,children:e.label}),y(k,{ariaLabelledBy:n,name:e.id,onValueChange:n=>t(e.id,n),options:[{label:`Selectโฆ`,value:``},...e.options.map(e=>({label:e.label,value:e.id}))],required:e.required,value:String(r)})]},e.id)}if(e.type===`radio`||e.type===`checkboxes`||e.type===`multi_select`){let n=Array.isArray(r)?r:[r];return b(`fieldset`,{children:[y(`legend`,{children:e.label}),e.options.map(r=>{let i=n.includes(r.id);return b(`label`,{className:`lockerverse-payment__choice`,children:[y(`input`,{checked:i,name:e.id,onChange:()=>{if(e.type===`radio`){t(e.id,r.id);return}t(e.id,i?n.filter(e=>e!==r.id):[...n,r.id])},required:e.required&&n.length===0,type:e.type===`radio`?`radio`:`checkbox`,value:r.id}),y(`span`,{children:r.label})]},r.id)})]},e.id)}return b(`label`,{children:[y(`span`,{children:e.label}),y(`input`,{name:e.id,onChange:n=>t(e.id,n.currentTarget.value),required:e.required,type:`text`,value:String(r)})]},e.id)})}function te({busy:e,enabled:t,onCustomTipBlur:n,onCustomTipChange:r,onSelect:i,tipInput:a,tipOption:o}){return t?b(`div`,{className:`lockerverse-payment__tip`,children:[y(`strong`,{children:`Add a tip to support the Lockerverse platform`}),y(`div`,{"aria-label":`Tip amount`,role:`radiogroup`,children:j.map(t=>y(`button`,{"aria-pressed":o===t.value,disabled:e,onClick:()=>i(t),type:`button`,children:t.label},t.value))}),o===`custom`?b(`label`,{children:[y(`span`,{children:`Custom tip`}),b(`div`,{className:`lockerverse-payment__money-input`,children:[y(`span`,{"aria-hidden":`true`,children:`$`}),y(`input`,{inputMode:`decimal`,name:`customTip`,onBlur:n,onChange:e=>r(e.currentTarget.value),placeholder:`0.00`,value:a})]})]}):null]}):null}function ne({email:e,fields:t,onEmailChange:n,onPhoneChange:r,onPhoneCountryChange:i,phone:a,phoneCountry:o}){return b(`div`,{className:`lockerverse-payment__contact`,children:[b(`label`,{children:[y(`span`,{children:`Email`}),y(`input`,{autoComplete:`email`,inputMode:`email`,name:`email`,onChange:e=>n(e.currentTarget.value),placeholder:`name@example.com`,required:!0,type:`email`,value:e})]}),t.phone?b(`label`,{children:[y(`span`,{children:`Phone`}),b(`div`,{className:`lockerverse-payment__phone-control`,children:[y(k,{ariaLabel:`Phone country`,className:`lockerverse-payment__select--phone-country`,name:`phoneCountry`,onValueChange:i,options:A,value:o}),y(`input`,{autoComplete:`tel`,inputMode:`tel`,name:`phone`,onChange:e=>r(e.currentTarget.value),placeholder:`(201) 555-0123`,required:!0,type:`tel`,value:a})]})]}):null]})}function N({fields:e,isBillingAddressReady:n,isPaymentReady:a,isShippingAddressReady:o,onBillingAddressReady:s,onPaymentReady:c,onShippingAddressReady:l,onShippingMatchesBillingChange:u,shippingMatchesBilling:d,totalCents:f}){return b(v,{children:[b(`div`,{className:`lockerverse-payment__stripe-element`,"data-ready":a,hidden:f===0,children:[a?null:y(M,{label:`Loading payment form...`}),y(`div`,{className:`lockerverse-payment__stripe-mount`,children:y(r,{onReady:c,options:{fields:{billingDetails:{address:`never`,email:`never`,name:`never`,phone:`never`}},layout:`tabs`,paymentMethodOrder:[`card`,`apple_pay`,`paypal`],terms:{applePay:`auto`,card:`always`,googlePay:`never`,paypal:`auto`,usBankAccount:`never`},wallets:{applePay:`auto`,googlePay:`never`}}})})]}),b(`div`,{className:`lockerverse-payment__address`,children:[y(`h2`,{children:`Billing address`}),b(`div`,{className:`lockerverse-payment__stripe-element lockerverse-payment__stripe-element--address`,"data-ready":n,children:[n?null:y(M,{label:`Loading billing address...`}),y(`div`,{className:`lockerverse-payment__stripe-mount`,children:y(t,{onReady:s})})]})]}),e.shipping?b(`div`,{className:`lockerverse-payment__shipping`,children:[b(`label`,{className:`lockerverse-payment__check-row`,children:[y(`input`,{checked:d,name:`shippingMatchesBilling`,onChange:e=>u(e.currentTarget.checked),type:`checkbox`}),y(`span`,{children:`Shipping is same as billing information`})]}),d?null:b(`div`,{className:`lockerverse-payment__address`,children:[y(`h2`,{children:`Shipping address`}),b(`div`,{className:`lockerverse-payment__stripe-element lockerverse-payment__stripe-element--address`,"data-ready":o,children:[o?null:y(M,{label:`Loading shipping address...`}),y(`div`,{className:`lockerverse-payment__stripe-mount`,children:y(i,{onReady:l})})]})]})]}):null]})}function re({fields:e,memberId:t,merchSize:n,onMemberIdChange:r,onMerchSizeChange:i}){return b(v,{children:[e.memberId?b(`label`,{children:[y(`span`,{children:`Member ID`}),y(`input`,{name:`memberId`,onChange:e=>r(e.currentTarget.value),required:!0,type:`text`,value:t})]}):null,e.merchSize?b(`div`,{className:`lockerverse-payment__field`,children:[y(`span`,{id:`lockerverse-merch-size-label`,children:`Size`}),y(k,{ariaLabelledBy:`lockerverse-merch-size-label`,name:`merchSize`,onValueChange:i,options:[`XS`,`S`,`M`,`L`,`XL`,`XXL`,`XXXL`].map(e=>({label:e,value:e})),required:!0,value:n})]}):null]})}function P(){return b(`div`,{className:`lockerverse-payment__skeleton-loader-block`,children:[y(`span`,{className:`lockerverse-payment__skeleton-loader-label`}),b(`div`,{className:`lockerverse-payment__skeleton-loader-content`,children:[y(`span`,{className:`lockerverse-payment__skeleton-loader-full`}),b(`div`,{className:`lockerverse-payment__skeleton-loader-grid`,children:[y(`span`,{className:`lockerverse-payment__skeleton-loader-half`}),y(`span`,{className:`lockerverse-payment__skeleton-loader-half`})]})]})]})}function F(){return b(`div`,{className:`lockerverse-payment__loading`,children:[y(`span`,{className:`lockerverse-payment__sr-only`,role:`status`,children:`Preparing secure checkoutโฆ`}),b(`div`,{"aria-hidden":`true`,className:`lockerverse-payment__skeleton`,children:[b(`div`,{className:`lockerverse-payment__skeleton-branding`,children:[y(`span`,{className:`lockerverse-payment__skeleton-avatar`}),y(`span`,{className:`lockerverse-payment__skeleton-community`})]}),b(`div`,{className:`lockerverse-payment__skeleton-contact`,children:[b(`div`,{className:`lockerverse-payment__skeleton-field`,children:[y(`span`,{className:`lockerverse-payment__skeleton-label`}),y(`span`,{className:`lockerverse-payment__skeleton-input`})]}),b(`div`,{className:`lockerverse-payment__skeleton-field`,children:[y(`span`,{className:`lockerverse-payment__skeleton-label`}),y(`span`,{className:`lockerverse-payment__skeleton-input`})]})]}),y(P,{}),y(P,{}),b(`div`,{className:`lockerverse-payment__skeleton-actions`,children:[y(`span`,{className:`lockerverse-payment__skeleton-check-line`}),y(`span`,{className:`lockerverse-payment__skeleton-button`})]})]})]})}const I=s(null),L=p(g(),m(/^\d+(?:\.\d{1,2})?$/));function R(e){let t=e.trim();if(!t)return 0;let n=h(L,t);if(!n.success)return null;let[r=`0`,i=``]=n.output.split(`.`),a=BigInt(r)*100n+BigInt(i.padEnd(2,`0`));return a<=BigInt(2**53-1)?Number(a):null}function ie(e){return new Intl.NumberFormat(`en-US`,{currency:`USD`,style:`currency`}).format(e/100)}function z(e,t){let n=e.trim(),r=n.replace(/\D/g,``);return n.startsWith(`+`)?`+${r}`:`${A.find(e=>e.value===t)?.callingCode??`+1`}${r}`}function B(e,t){if(!t.length)throw Error(`Select at least one Product before opening checkout.`);return t.map(t=>{let n=e.products.find(e=>e.slug===t.productSlug);if(!n)throw Error(`Product ${t.productSlug} is unavailable.`);return`amountCents`in t?{amountCents:t.amountCents,productId:n.id}:{productId:n.id,quantity:t.quantity}})}function V(e,t){return t.reduce((t,n)=>{if(`amountCents`in n)return t+n.amountCents;let r=e.products.find(e=>e.slug===n.productSlug);if(!r||r.amountCents===null)throw Error(`Product ${n.productSlug} has invalid pricing.`);return t+r.amountCents*n.quantity},0)}function H(e){let t={communitySlug:e.communitySlug,...e.fetch?{fetch:e.fetch}:{},...e.onError?{onError:e.onError}:{},...e.requestTimeoutMs===void 0?{}:{requestTimeoutMs:e.requestTimeoutMs},...e.sentryDsn===void 0?{}:{sentryDsn:e.sentryDsn},widgetSlug:e.widgetSlug};return e.apiBaseUrl?{...t,apiBaseUrl:e.apiBaseUrl,environment:e.environment}:{...t,environment:`production`}}function U(e){return e?{metadata:e}:{}}function W(e,t,n){if(!e)return null;let r=t??`#38d77a`,i=n===`light`;return{clientSecret:e.session.clientSecret,elementsOptions:{appearance:{rules:{".Input:focus":{borderColor:r,boxShadow:`0 0 0 1px ${r}`,outline:`none`}},theme:i?`stripe`:`night`,variables:{borderRadius:`10px`,colorBackground:i?`#f5f6f7`:`#121212`,colorDanger:i?`#c52b3e`:`#f08a98`,colorPrimary:r,colorText:i?`#121416`:`#ffffff`,colorTextPlaceholder:i?`#72767d`:`#6b6b6b`,colorTextSecondary:i?`#62666d`:`#a1a1aa`,focusBoxShadow:`none`,focusOutline:`none`,fontSizeBase:`16px`}},syncAddressCheckbox:`none`}}}function G({children:e,loaded:t}){let n=a();return n.type===`loading`?y(F,{}):n.type===`error`?y(`div`,{role:`alert`,children:n.error.message}):y(q,{checkout:n.checkout,loaded:t,children:e})}function K(e){return{includeServiceFee:e.includeServiceFee,serviceFeeAmountCents:Math.round(e.subtotalCents*e.catalog.pricingPolicy.serviceFeeRateBasisPoints/1e4),subtotalCents:e.subtotalCents,tipCents:e.tipCents}}function q({checkout:e,children:t,loaded:n}){let[r,i]=f(()=>K(n));l(()=>{i(K(n))},[n]);let a={async applyPromoCode(t){let r=await e.runServerUpdate(()=>n.client.updateSessionDiscount({paymentReference:n.session.paymentReference,...t.trim()?{promoCode:t.trim()}:{}}));return r.type===`error`?r.error.message:null},catalog:n.catalog,async confirm(t){if(t.shippingMatchesBilling){if(!e.billingAddress)throw Error(`Billing address is required.`);let t=await e.updateShippingAddress(e.billingAddress);if(t.type===`error`)throw Error(t.error.message)}let r=await e.runServerUpdate(()=>n.client.updateSessionDetails({...t.customFieldAnswers?{customFieldAnswers:t.customFieldAnswers}:{},email:t.email,...t.memberId?{memberId:t.memberId}:{},...t.merchSize?{merchSize:t.merchSize}:{},paymentReference:n.session.paymentReference,...t.phone?{phone:t.phone}:{}}));if(r.type===`error`)throw Error(r.error.message);let i=await X(e,t.email,t.phone??``,e.total.total.minorUnitsAmount>0);if(`error`in i)throw Error(i.error);let a=await e.confirm({email:i.email,...i.phone?{phoneNumber:i.phone}:{},redirect:`if_required`});if(a.type===`error`)throw Error(a.error.message);return{paymentReference:n.session.paymentReference,sessionId:n.session.sessionId}},paymentReference:n.session.paymentReference,pricing:r,totalCents:e.total.total.minorUnitsAmount,async updatePricing(t){let r,a=await e.runServerUpdate(()=>n.client.updateSessionPricing({...t,paymentReference:n.session.paymentReference}).then(e=>(r=e,e)));if(a.type===`error`)throw Error(a.error.message);if(!r)throw Error(`Lockerverse returned no updated pricing.`);let o=r;return i(e=>({...e,includeServiceFee:o.includeServiceFee,tipCents:o.tipCents})),o}};return y(I.Provider,{value:a,children:t})}function J(t){let[r,i]=f(null),[a,s]=f(null),[c,p]=f(0),m=d(null),h=JSON.stringify({email:t.email,includeServiceFee:t.includeServiceFee,metadata:t.metadata,returnUrl:t.returnUrl,selection:t.selection,tipCents:t.tipCents}),g=d({email:t.email,includeServiceFee:t.includeServiceFee,key:h,metadata:t.metadata,requestKey:globalThis.crypto.randomUUID(),returnUrl:t.returnUrl,selection:t.selection,tipCents:t.tipCents}),_=u(()=>H(t),[t.apiBaseUrl,t.communitySlug,t.environment,t.fetch,t.onError,t.requestTimeoutMs,t.sentryDsn,t.widgetSlug]);l(()=>{let t=!0;if(m.current?.clientOptions!==_||c>0){let t=e(_),n=g.current;m.current={clientOptions:_,promise:(async()=>{let e=await t.load(),r=B(e,n.selection),i=V(e,n.selection),a=n.includeServiceFee??e.widget.fields.serviceFee,o=n.tipCents??(e.widget.fields.tipping?Math.round(i*.1):0),s=await t.createSession({...n.email?{email:n.email}:{},...e.widget.fields.serviceFee?{includeServiceFee:a}:{},items:r,...U(n.metadata),requestKey:n.requestKey,returnUrl:n.returnUrl,...e.widget.fields.tipping?{tipCents:o}:{}});return{catalog:e,client:t,includeServiceFee:a,returnUrl:n.returnUrl,session:s,subtotalCents:i,tipCents:o}})()}}return i(null),s(null),m.current.promise.then(e=>{t&&i(e)}).catch(e=>{t&&s(e instanceof Error?e.message:`Unable to load checkout.`)}),()=>{t=!1}},[_,c]);let v=u(()=>r?(t.unstable_stripeLoader??o)(r.catalog.payment.publishableKey,{betas:[`custom_checkout_server_updates_1`],...r.session.connectedAccountId?{stripeAccount:r.session.connectedAccountId}:{}}):null,[r,t.unstable_stripeLoader]),x=u(()=>W(r,t.accentColor??r?.catalog.community?.accentColor??void 0,t.theme),[r,t.accentColor,t.theme]);return h===g.current.key?a?b(`div`,{className:`lockerverse-payment__payment-status`,role:`alert`,children:[y(`p`,{children:a}),y(`button`,{onClick:()=>p(e=>e+1),type:`button`,children:`Try again`})]}):r&&x?y(n,{options:x,stripe:v,children:y(G,{loaded:r,children:t.children})}):y(F,{}):y(`div`,{className:`lockerverse-payment__payment-status`,role:`alert`,children:`Checkout selection changed. Remount this payment component for the new selection.`})}function Y(){let e=c(I);if(!e)throw Error(`useLockerverseCheckoutSession must be used inside LockerverseCheckoutSessionProvider.`);return e}async function X(e,t,n,r){let i=t.trim().toLowerCase();if(!i)return{error:`Email is required.`};let a=await e.updateEmail(i);if(a.type===`error`)return{error:a.error.message};let o=n.trim();if(o&&(await e.updatePhoneNumber(o)).type===`error`)return{error:`Phone number is invalid.`};if(r){let t=await e.validateElements();if(t.type===`error`)return{error:t.error.message}}return{email:i,phone:o}}function ae(e,t){return e===0?`Complete free order`:t>0?`Process Payment ($${((e-t)/100).toFixed(2)}) + $${(t/100).toFixed(2)} tip`:`Process Payment ($${(e/100).toFixed(2)})`}function oe({catalog:e,customFieldValues:t,email:n,memberId:r,merchSize:i,phone:a,phoneCountry:o,shippingMatchesBilling:s}){return{customFieldAnswers:e.widget.customFields.map(e=>({fieldId:e.id,value:t[e.id]??null})),email:n,...r?{memberId:r}:{},...i?{merchSize:i}:{},...a?{phone:z(a,o)}:{},...e.widget.fields.shipping?{shippingMatchesBilling:s}:{}}}function Z({branding:e,onComplete:t}){let{applyPromoCode:n,catalog:r,confirm:i,pricing:a,totalCents:o,updatePricing:s}=Y(),c=r.community?{accentColor:r.community.accentColor??void 0,imageUrl:r.community.imageUrl,name:r.community.name,...e}:e,[u,p]=f(``),[m,h]=f(``),[g,_]=f(`US`),[v,x]=f(``),[S,C]=f(`M`),[w,T]=f({}),[E,D]=f(``),[O,k]=f(null),[A,M]=f(!1),[P,F]=f(!1),[I,L]=f(!1),[z,B]=f(!1),[V,H]=f(!1),[U,W]=f(!0),G=j.find(e=>e.percent!==null&&Math.round(a.subtotalCents*e.percent/100)===a.tipCents)?.value??`custom`,[K,q]=f(G),[J,X]=f(G===`custom`&&a.tipCents>0?(a.tipCents/100).toFixed(2):``),Z=d({includeServiceFee:a.includeServiceFee,tipCents:a.tipCents}),Q=d(Promise.resolve(!0));l(()=>{Z.current={includeServiceFee:a.includeServiceFee,tipCents:a.tipCents}},[a.includeServiceFee,a.tipCents]);function $(e){let t=(async()=>{F(!0),k(null);try{let t=await s(e);return Z.current={includeServiceFee:t.includeServiceFee,tipCents:t.tipCents},!0}catch(e){return k(e instanceof Error?e.message:`Unable to update checkout.`),!1}finally{F(!1)}})();return Q.current=t,t}async function se(e){if(e.percent===null){q(e.value);return}let t=Math.round(a.subtotalCents*e.percent/100);await $({includeServiceFee:a.includeServiceFee,tipCents:t})&&(X(``),q(e.value))}function ce(){let e=R(J);if(e===null){k(`Enter a valid tip with no more than two decimal places.`);return}return $({includeServiceFee:a.includeServiceFee,tipCents:e})}async function le(e){await $({includeServiceFee:e,tipCents:a.tipCents})}async function ue(){M(!0),k(null);try{k(await n(E))}catch(e){k(e instanceof Error?e.message:`Unable to update checkout.`)}finally{M(!1)}}async function de(){if(!await Q.current)return!1;if(K!==`custom`)return!0;let e=R(J);return e===null?(k(`Enter a valid tip with no more than two decimal places.`),!1):e===Z.current.tipCents||$({includeServiceFee:Z.current.includeServiceFee,tipCents:e})}async function fe(e){e.preventDefault(),M(!0),k(null);try{if(!await de())return;let e=await i(oe({catalog:r,customFieldValues:w,email:u,memberId:v,merchSize:S,phone:m,phoneCountry:g,shippingMatchesBilling:U}));t?.(e)}catch(e){k(e instanceof Error?e.message:`Unable to complete checkout.`)}finally{M(!1)}}return b(`form`,{className:`lockerverse-payment__form`,onSubmit:fe,children:[b(`header`,{children:[r.widget.showCommunityBranding&&c?b(`div`,{className:`lockerverse-payment__branding`,children:[c.imageUrl?y(`img`,{alt:c.name,height:`48`,src:c.imageUrl,width:`48`}):null,y(`strong`,{children:c.name})]}):null,y(`h1`,{children:r.widget.title??r.widget.name}),r.widget.description?y(`p`,{children:r.widget.description}):null]}),y(te,{busy:A||P,enabled:r.widget.fields.tipping,onCustomTipBlur:ce,onCustomTipChange:X,onSelect:se,tipInput:J,tipOption:K}),y(ne,{email:u,fields:r.widget.fields,onEmailChange:p,onPhoneChange:h,onPhoneCountryChange:_,phone:m,phoneCountry:g}),y(N,{fields:r.widget.fields,isBillingAddressReady:I,isPaymentReady:z,isShippingAddressReady:V,onBillingAddressReady:()=>L(!0),onPaymentReady:()=>B(!0),onShippingAddressReady:()=>H(!0),onShippingMatchesBillingChange:e=>{W(e),e||H(!1)},shippingMatchesBilling:U,totalCents:o}),y(re,{fields:r.widget.fields,memberId:v,merchSize:S,onMemberIdChange:x,onMerchSizeChange:C}),r.widget.fields.promoCode?b(`div`,{className:`lockerverse-payment__additional-fields`,children:[b(`label`,{children:[y(`span`,{children:`Promo code`}),y(`input`,{name:`promoCode`,onChange:e=>D(e.currentTarget.value),placeholder:`Optional`,value:E})]}),y(`button`,{disabled:A,onClick:ue,type:`button`,children:E.trim()?`Apply code`:`Remove code`})]}):null,r.widget.customFields.length?y(`div`,{className:`lockerverse-payment__custom-fields`,children:y(ee,{fields:r.widget.customFields,onChange:(e,t)=>T(n=>({...n,[e]:t})),values:w})}):null,O?y(`div`,{role:`alert`,children:O}):null,b(`div`,{className:`lockerverse-payment__actions`,children:[r.widget.fields.serviceFee?b(`label`,{className:`lockerverse-payment__check-row`,children:[y(`input`,{checked:a.includeServiceFee,disabled:A||P,name:`includeServiceFee`,onChange:e=>le(e.currentTarget.checked),type:`checkbox`}),b(`span`,{children:[`Add `,ie(a.serviceFeeAmountCents),` to help cover processing fees`]})]}):null,y(`button`,{disabled:A,type:`submit`,children:ae(o,a.tipCents)})]})]})}function Q(e){let t=d(null),{apiBaseUrl:n,branding:r,className:i,communitySlug:a,environment:o,fetch:s,includeServiceFee:c,metadata:l,onError:u,onPaymentComplete:f,requestTimeoutMs:p,returnUrl:m,selection:h,sentryDsn:g,unstable_stripeLoader:_,style:v,theme:b=`dark`,tipCents:x,widgetSlug:S,...C}=e,T=m??(globalThis.location===void 0?`https://lockerverse.com`:globalThis.location.href),D=[`lockerverse-payment`,i].filter(Boolean).join(` `),O=n?{apiBaseUrl:n,communitySlug:a,environment:o,widgetSlug:S}:{communitySlug:a,environment:`production`,widgetSlug:S},k=v?.[`--lockerverse-accent`]??r?.accentColor,A=k?{...v,"--lockerverse-accent":k,"--lockerverse-accent-contrast":v?.[`--lockerverse-accent-contrast`]??w(k)??`#08110c`}:v;return y(`section`,{...C,className:D,"data-lockerverse-theme":b,ref:t,style:A,children:y(E,{container:t,children:y(J,{...O,...k?{accentColor:k}:{},...s?{fetch:s}:{},...c===void 0?{}:{includeServiceFee:c},...l?{metadata:l}:{},...u?{onError:u}:{},...p===void 0?{}:{requestTimeoutMs:p},returnUrl:T,selection:h,...g===void 0?{}:{sentryDsn:g},..._?{unstable_stripeLoader:_}:{},theme:b,...x===void 0?{}:{tipCents:x},children:y(Z,{...r?{branding:r}:{},...f?{onComplete:f}:{}})})})})}export{Z as LockerverseCheckoutSessionPaymentForm,J as LockerverseCheckoutSessionProvider,Q as LockerversePayment,Y as useLockerverseCheckoutSession};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/accent-contrast.ts","../src/select-control.tsx","../src/checkout-session-form-fields.tsx","../src/checkout-session-loading.tsx","../src/checkout-session-payment.tsx"],"sourcesContent":["const HEX_COLOR = /^#([\\da-f]{3}|[\\da-f]{6})$/i;\n\nfunction parseHexColor(color: string) {\n const match = HEX_COLOR.exec(color.trim());\n if (!match) {\n return;\n }\n const [, value] = match;\n if (!value) {\n return;\n }\n const expanded =\n value.length === 3\n ? Array.from(value, (character) => `${character}${character}`).join(\"\")\n : value;\n return [0, 2, 4].map((offset) =>\n Number.parseInt(expanded.slice(offset, offset + 2), 16)\n );\n}\n\nfunction relativeLuminance([red, green, blue]: number[]) {\n const [linearRed = 0, linearGreen = 0, linearBlue = 0] = [\n red,\n green,\n blue,\n ].map((channel = 0) => {\n const normalized = channel / 255;\n return normalized <= 0.040_45\n ? normalized / 12.92\n : ((normalized + 0.055) / 1.055) ** 2.4;\n });\n return 0.2126 * linearRed + 0.7152 * linearGreen + 0.0722 * linearBlue;\n}\n\nexport function getAccentContrast(color: string) {\n const parsed = parseHexColor(color);\n if (!parsed) {\n return;\n }\n const luminance = relativeLuminance(parsed);\n const blackContrast = (luminance + 0.05) / 0.05;\n const whiteContrast = 1.05 / (luminance + 0.05);\n return blackContrast >= whiteContrast ? \"#000\" : \"#fff\";\n}\n","import { Select } from \"@base-ui/react/select\";\nimport {\n createContext,\n type ReactNode,\n type RefObject,\n useContext,\n} from \"react\";\n\nexport type LockerverseSelectOption = {\n label: string;\n value: string;\n};\n\nconst SelectPortalContext = createContext<\n RefObject<HTMLElement | null> | undefined\n>(undefined);\n\nexport function SelectPortalProvider({\n children,\n container,\n}: {\n children: ReactNode;\n container: RefObject<HTMLElement | null>;\n}) {\n return (\n <SelectPortalContext.Provider value={container}>\n {children}\n </SelectPortalContext.Provider>\n );\n}\n\nfunction SelectIcon() {\n return (\n <svg aria-hidden=\"true\" fill=\"none\" viewBox=\"0 0 16 16\">\n <path d=\"m4 6 4 4 4-4\" />\n </svg>\n );\n}\n\nfunction SelectedIcon() {\n return (\n <svg aria-hidden=\"true\" fill=\"none\" viewBox=\"0 0 16 16\">\n <path d=\"m3 8 3 3 7-7\" />\n </svg>\n );\n}\n\nexport function LockerverseSelect({\n ariaDescribedBy,\n ariaLabel,\n ariaLabelledBy,\n className,\n id,\n invalid = false,\n name,\n onValueChange,\n options,\n required = false,\n value,\n}: {\n ariaDescribedBy?: string;\n ariaLabel?: string;\n ariaLabelledBy?: string;\n className?: string;\n id?: string;\n invalid?: boolean;\n name: string;\n onValueChange: (value: string) => void;\n options: readonly LockerverseSelectOption[];\n required?: boolean;\n value: string;\n}) {\n const portalContainer = useContext(SelectPortalContext);\n const rootClassName = [\"lockerverse-payment__select\", className]\n .filter(Boolean)\n .join(\" \");\n\n return (\n <div className={rootClassName}>\n <Select.Root\n id={id}\n items={options}\n name={name}\n onValueChange={(nextValue) => {\n if (nextValue !== null) {\n onValueChange(nextValue);\n }\n }}\n required={required}\n value={value}\n >\n <Select.Trigger\n aria-describedby={ariaDescribedBy}\n aria-invalid={invalid || undefined}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n className=\"lockerverse-payment__select-trigger\"\n >\n <Select.Value />\n <Select.Icon\n aria-hidden=\"true\"\n className=\"lockerverse-payment__select-icon\"\n >\n <SelectIcon />\n </Select.Icon>\n </Select.Trigger>\n <Select.Portal container={portalContainer}>\n <Select.Positioner\n alignItemWithTrigger={false}\n className=\"lockerverse-payment__select-positioner\"\n sideOffset={6}\n >\n <Select.Popup className=\"lockerverse-payment__select-popup\">\n <Select.List className=\"lockerverse-payment__select-list\">\n {options.map((option) => (\n <Select.Item\n className=\"lockerverse-payment__select-item\"\n key={option.value}\n value={option.value}\n >\n <Select.ItemText>{option.label}</Select.ItemText>\n <Select.ItemIndicator\n aria-hidden=\"true\"\n className=\"lockerverse-payment__select-item-indicator\"\n >\n <SelectedIcon />\n </Select.ItemIndicator>\n </Select.Item>\n ))}\n </Select.List>\n </Select.Popup>\n </Select.Positioner>\n </Select.Portal>\n </Select.Root>\n </div>\n );\n}\n","import type {\n LockerverseCatalog,\n LockerverseCustomField,\n} from \"@lockerverse/sdk/checkout\";\nimport {\n BillingAddressElement,\n PaymentElement,\n ShippingAddressElement,\n} from \"@stripe/react-stripe-js/checkout\";\nimport { LockerverseSelect } from \"./select-control.tsx\";\n\nexport const PHONE_COUNTRIES = [\n { callingCode: \"+1\", label: \"๐บ๐ธ +1\", value: \"US\" },\n { callingCode: \"+52\", label: \"๐ฒ๐ฝ +52\", value: \"MX\" },\n { callingCode: \"+380\", label: \"๐บ๐ฆ +380\", value: \"UA\" },\n { callingCode: \"+48\", label: \"๐ต๐ฑ +48\", value: \"PL\" },\n { callingCode: \"+1\", label: \"๐จ๐ฆ +1\", value: \"CA\" },\n { callingCode: \"+49\", label: \"๐ฉ๐ช +49\", value: \"DE\" },\n { callingCode: \"+44\", label: \"๐ฌ๐ง +44\", value: \"GB\" },\n { callingCode: \"+46\", label: \"๐ธ๐ช +46\", value: \"SE\" },\n { callingCode: \"+358\", label: \"๐ซ๐ฎ +358\", value: \"FI\" },\n { callingCode: \"+1\", label: \"๐ต๐ท +1\", value: \"PR\" },\n] as const;\n\nexport const TIP_OPTIONS = [\n { label: \"15%\", percent: 15, value: \"15\" },\n { label: \"12%\", percent: 12, value: \"12\" },\n { label: \"10%\", percent: 10, value: \"10\" },\n { label: \"5%\", percent: 5, value: \"5\" },\n { label: \"Other\", percent: null, value: \"custom\" },\n] as const;\n\nfunction StripeElementLoader({ label }: { label: string }) {\n return (\n <div className=\"lockerverse-payment__stripe-loader\" role=\"status\">\n <p>{label}</p>\n <div aria-hidden=\"true\">\n <span />\n <span />\n <span />\n </div>\n </div>\n );\n}\n\nexport function LockerverseCustomFields({\n fields,\n onChange,\n values,\n}: {\n fields: LockerverseCustomField[];\n onChange: (fieldId: string, value: string | string[]) => void;\n values: Record<string, string | string[]>;\n}) {\n return fields.map((field) => {\n const value =\n values[field.id] ??\n (field.type.includes(\"multi\") || field.type === \"checkboxes\" ? [] : \"\");\n if (field.type === \"textarea\") {\n return (\n <label key={field.id}>\n <span>{field.label}</span>\n <textarea\n name={field.id}\n onChange={(event) => onChange(field.id, event.currentTarget.value)}\n required={field.required}\n value={String(value)}\n />\n </label>\n );\n }\n if (field.type === \"select\") {\n const labelId = `lockerverse-custom-${field.id}-label`;\n return (\n <div className=\"lockerverse-payment__field\" key={field.id}>\n <span id={labelId}>{field.label}</span>\n <LockerverseSelect\n ariaLabelledBy={labelId}\n name={field.id}\n onValueChange={(nextValue) => onChange(field.id, nextValue)}\n options={[\n { label: \"Selectโฆ\", value: \"\" },\n ...field.options.map((option) => ({\n label: option.label,\n value: option.id,\n })),\n ]}\n required={field.required}\n value={String(value)}\n />\n </div>\n );\n }\n if (\n field.type === \"radio\" ||\n field.type === \"checkboxes\" ||\n field.type === \"multi_select\"\n ) {\n const selected = Array.isArray(value) ? value : [value];\n return (\n <fieldset key={field.id}>\n <legend>{field.label}</legend>\n {field.options.map((option) => {\n const checked = selected.includes(option.id);\n return (\n <label className=\"lockerverse-payment__choice\" key={option.id}>\n <input\n checked={checked}\n name={field.id}\n onChange={() => {\n if (field.type === \"radio\") {\n onChange(field.id, option.id);\n return;\n }\n onChange(\n field.id,\n checked\n ? selected.filter((id) => id !== option.id)\n : [...selected, option.id]\n );\n }}\n required={field.required && selected.length === 0}\n type={field.type === \"radio\" ? \"radio\" : \"checkbox\"}\n value={option.id}\n />\n <span>{option.label}</span>\n </label>\n );\n })}\n </fieldset>\n );\n }\n return (\n <label key={field.id}>\n <span>{field.label}</span>\n <input\n name={field.id}\n onChange={(event) => onChange(field.id, event.currentTarget.value)}\n required={field.required}\n type=\"text\"\n value={String(value)}\n />\n </label>\n );\n });\n}\n\nexport function TipSelector({\n busy,\n enabled,\n onCustomTipBlur,\n onCustomTipChange,\n onSelect,\n tipInput,\n tipOption,\n}: {\n busy: boolean;\n enabled: boolean;\n onCustomTipBlur: () => Promise<unknown> | undefined;\n onCustomTipChange: (value: string) => void;\n onSelect: (option: (typeof TIP_OPTIONS)[number]) => Promise<void>;\n tipInput: string;\n tipOption: string;\n}) {\n if (!enabled) {\n return null;\n }\n return (\n <div className=\"lockerverse-payment__tip\">\n <strong>Add a tip to support the Lockerverse platform</strong>\n <div aria-label=\"Tip amount\" role=\"radiogroup\">\n {TIP_OPTIONS.map((option) => (\n <button\n aria-pressed={tipOption === option.value}\n disabled={busy}\n key={option.value}\n onClick={() => onSelect(option)}\n type=\"button\"\n >\n {option.label}\n </button>\n ))}\n </div>\n {tipOption === \"custom\" ? (\n <label>\n <span>Custom tip</span>\n <div className=\"lockerverse-payment__money-input\">\n <span aria-hidden=\"true\">$</span>\n <input\n inputMode=\"decimal\"\n name=\"customTip\"\n onBlur={onCustomTipBlur}\n onChange={(event) => onCustomTipChange(event.currentTarget.value)}\n placeholder=\"0.00\"\n value={tipInput}\n />\n </div>\n </label>\n ) : null}\n </div>\n );\n}\n\nexport function ContactFields({\n email,\n fields,\n onEmailChange,\n onPhoneChange,\n onPhoneCountryChange,\n phone,\n phoneCountry,\n}: {\n email: string;\n fields: LockerverseCatalog[\"widget\"][\"fields\"];\n onEmailChange: (value: string) => void;\n onPhoneChange: (value: string) => void;\n onPhoneCountryChange: (value: string) => void;\n phone: string;\n phoneCountry: string;\n}) {\n return (\n <div className=\"lockerverse-payment__contact\">\n <label>\n <span>Email</span>\n <input\n autoComplete=\"email\"\n inputMode=\"email\"\n name=\"email\"\n onChange={(event) => onEmailChange(event.currentTarget.value)}\n placeholder=\"name@example.com\"\n required\n type=\"email\"\n value={email}\n />\n </label>\n {fields.phone ? (\n <label>\n <span>Phone</span>\n <div className=\"lockerverse-payment__phone-control\">\n <LockerverseSelect\n ariaLabel=\"Phone country\"\n className=\"lockerverse-payment__select--phone-country\"\n name=\"phoneCountry\"\n onValueChange={onPhoneCountryChange}\n options={PHONE_COUNTRIES}\n value={phoneCountry}\n />\n <input\n autoComplete=\"tel\"\n inputMode=\"tel\"\n name=\"phone\"\n onChange={(event) => onPhoneChange(event.currentTarget.value)}\n placeholder=\"(201) 555-0123\"\n required\n type=\"tel\"\n value={phone}\n />\n </div>\n </label>\n ) : null}\n </div>\n );\n}\n\nexport function StripeCheckoutFields({\n fields,\n isBillingAddressReady,\n isPaymentReady,\n isShippingAddressReady,\n onBillingAddressReady,\n onPaymentReady,\n onShippingAddressReady,\n onShippingMatchesBillingChange,\n shippingMatchesBilling,\n totalCents,\n}: {\n fields: LockerverseCatalog[\"widget\"][\"fields\"];\n isBillingAddressReady: boolean;\n isPaymentReady: boolean;\n isShippingAddressReady: boolean;\n onBillingAddressReady: () => void;\n onPaymentReady: () => void;\n onShippingAddressReady: () => void;\n onShippingMatchesBillingChange: (value: boolean) => void;\n shippingMatchesBilling: boolean;\n totalCents: number;\n}) {\n return (\n <>\n <div\n className=\"lockerverse-payment__stripe-element\"\n data-ready={isPaymentReady}\n hidden={totalCents === 0}\n >\n {isPaymentReady ? null : (\n <StripeElementLoader label=\"Loading payment form...\" />\n )}\n <div className=\"lockerverse-payment__stripe-mount\">\n <PaymentElement\n onReady={onPaymentReady}\n options={{\n fields: {\n billingDetails: {\n address: \"never\",\n email: \"never\",\n name: \"never\",\n phone: \"never\",\n },\n },\n layout: \"tabs\",\n paymentMethodOrder: [\"card\", \"apple_pay\", \"paypal\"],\n terms: {\n applePay: \"auto\",\n card: \"always\",\n googlePay: \"never\",\n paypal: \"auto\",\n usBankAccount: \"never\",\n },\n wallets: { applePay: \"auto\", googlePay: \"never\" },\n }}\n />\n </div>\n </div>\n <div className=\"lockerverse-payment__address\">\n <h2>Billing address</h2>\n <div\n className=\"lockerverse-payment__stripe-element lockerverse-payment__stripe-element--address\"\n data-ready={isBillingAddressReady}\n >\n {isBillingAddressReady ? null : (\n <StripeElementLoader label=\"Loading billing address...\" />\n )}\n <div className=\"lockerverse-payment__stripe-mount\">\n <BillingAddressElement onReady={onBillingAddressReady} />\n </div>\n </div>\n </div>\n {fields.shipping ? (\n <div className=\"lockerverse-payment__shipping\">\n <label className=\"lockerverse-payment__check-row\">\n <input\n checked={shippingMatchesBilling}\n name=\"shippingMatchesBilling\"\n onChange={(event) =>\n onShippingMatchesBillingChange(event.currentTarget.checked)\n }\n type=\"checkbox\"\n />\n <span>Shipping is same as billing information</span>\n </label>\n {shippingMatchesBilling ? null : (\n <div className=\"lockerverse-payment__address\">\n <h2>Shipping address</h2>\n <div\n className=\"lockerverse-payment__stripe-element lockerverse-payment__stripe-element--address\"\n data-ready={isShippingAddressReady}\n >\n {isShippingAddressReady ? null : (\n <StripeElementLoader label=\"Loading shipping address...\" />\n )}\n <div className=\"lockerverse-payment__stripe-mount\">\n <ShippingAddressElement onReady={onShippingAddressReady} />\n </div>\n </div>\n </div>\n )}\n </div>\n ) : null}\n </>\n );\n}\n\nexport function CustomerFields({\n fields,\n memberId,\n merchSize,\n onMemberIdChange,\n onMerchSizeChange,\n}: {\n fields: LockerverseCatalog[\"widget\"][\"fields\"];\n memberId: string;\n merchSize: string;\n onMemberIdChange: (value: string) => void;\n onMerchSizeChange: (value: string) => void;\n}) {\n return (\n <>\n {fields.memberId ? (\n <label>\n <span>Member ID</span>\n <input\n name=\"memberId\"\n onChange={(event) => onMemberIdChange(event.currentTarget.value)}\n required\n type=\"text\"\n value={memberId}\n />\n </label>\n ) : null}\n {fields.merchSize ? (\n <div className=\"lockerverse-payment__field\">\n <span id=\"lockerverse-merch-size-label\">Size</span>\n <LockerverseSelect\n ariaLabelledBy=\"lockerverse-merch-size-label\"\n name=\"merchSize\"\n onValueChange={onMerchSizeChange}\n options={[\"XS\", \"S\", \"M\", \"L\", \"XL\", \"XXL\", \"XXXL\"].map((size) => ({\n label: size,\n value: size,\n }))}\n required\n value={merchSize}\n />\n </div>\n ) : null}\n </>\n );\n}\n","function SkeletonLoaderBlock() {\n return (\n <div className=\"lockerverse-payment__skeleton-loader-block\">\n <span className=\"lockerverse-payment__skeleton-loader-label\" />\n <div className=\"lockerverse-payment__skeleton-loader-content\">\n <span className=\"lockerverse-payment__skeleton-loader-full\" />\n <div className=\"lockerverse-payment__skeleton-loader-grid\">\n <span className=\"lockerverse-payment__skeleton-loader-half\" />\n <span className=\"lockerverse-payment__skeleton-loader-half\" />\n </div>\n </div>\n </div>\n );\n}\n\nexport function PaymentSkeleton() {\n return (\n <div className=\"lockerverse-payment__loading\">\n <span className=\"lockerverse-payment__sr-only\" role=\"status\">\n Preparing secure checkoutโฆ\n </span>\n <div aria-hidden=\"true\" className=\"lockerverse-payment__skeleton\">\n <div className=\"lockerverse-payment__skeleton-branding\">\n <span className=\"lockerverse-payment__skeleton-avatar\" />\n <span className=\"lockerverse-payment__skeleton-community\" />\n </div>\n <div className=\"lockerverse-payment__skeleton-contact\">\n <div className=\"lockerverse-payment__skeleton-field\">\n <span className=\"lockerverse-payment__skeleton-label\" />\n <span className=\"lockerverse-payment__skeleton-input\" />\n </div>\n <div className=\"lockerverse-payment__skeleton-field\">\n <span className=\"lockerverse-payment__skeleton-label\" />\n <span className=\"lockerverse-payment__skeleton-input\" />\n </div>\n </div>\n <SkeletonLoaderBlock />\n <SkeletonLoaderBlock />\n <div className=\"lockerverse-payment__skeleton-actions\">\n <span className=\"lockerverse-payment__skeleton-check-line\" />\n <span className=\"lockerverse-payment__skeleton-button\" />\n </div>\n </div>\n </div>\n );\n}\n","import type {\n CreateLockerverseWidgetOptions,\n LockerverseCatalog,\n LockerverseCheckoutClient,\n LockerverseCheckoutItem,\n LockerverseCheckoutSession,\n LockerverseCheckoutSessionPricing,\n LockerverseCustomFieldAnswer,\n} from \"@lockerverse/sdk/checkout\";\nimport { createLockerverseCheckoutClient } from \"@lockerverse/sdk/checkout\";\nimport type { StripeCheckoutElementsValue } from \"@stripe/react-stripe-js/checkout\";\nimport {\n CheckoutElementsProvider,\n useCheckoutElements,\n} from \"@stripe/react-stripe-js/checkout\";\nimport { loadStripe } from \"@stripe/stripe-js/pure\";\nimport {\n createContext,\n type FormEvent,\n type PropsWithChildren,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { pipe, regex, safeParse, string } from \"valibot\";\nimport { getAccentContrast } from \"./accent-contrast.ts\";\nimport {\n ContactFields,\n CustomerFields,\n LockerverseCustomFields,\n PHONE_COUNTRIES,\n StripeCheckoutFields,\n TIP_OPTIONS,\n TipSelector,\n} from \"./checkout-session-form-fields.tsx\";\nimport { PaymentSkeleton } from \"./checkout-session-loading.tsx\";\nimport { SelectPortalProvider } from \"./select-control.tsx\";\nimport type {\n LockerversePaymentBranding,\n LockerversePaymentCompletion,\n LockerversePaymentProps,\n LockerversePaymentSelectionItem,\n} from \"./types.ts\";\n\ntype CheckoutSessionStripeLoader = typeof loadStripe;\n\nexport type LockerverseCheckoutSessionProviderProps =\n CreateLockerverseWidgetOptions &\n PropsWithChildren<{\n accentColor?: string;\n email?: string;\n includeServiceFee?: boolean;\n returnUrl: string;\n selection: LockerversePaymentSelectionItem[];\n unstable_stripeLoader?: CheckoutSessionStripeLoader;\n theme?: \"dark\" | \"light\";\n tipCents?: number;\n }>;\n\ntype LoadedCheckout = {\n catalog: LockerverseCatalog;\n client: LockerverseCheckoutClient;\n includeServiceFee: boolean;\n returnUrl: string;\n session: LockerverseCheckoutSession;\n subtotalCents: number;\n tipCents: number;\n};\n\ntype CheckoutContextValue = {\n applyPromoCode: (promoCode: string) => Promise<string | null>;\n catalog: LockerverseCatalog;\n confirm: (contact: {\n customFieldAnswers?: LockerverseCustomFieldAnswer[];\n email: string;\n memberId?: string;\n merchSize?: \"XS\" | \"S\" | \"M\" | \"L\" | \"XL\" | \"XXL\" | \"XXXL\";\n phone?: string;\n shippingMatchesBilling?: boolean;\n }) => Promise<LockerversePaymentCompletion>;\n paymentReference: string;\n pricing: {\n includeServiceFee: boolean;\n serviceFeeAmountCents: number;\n subtotalCents: number;\n tipCents: number;\n };\n totalCents: number;\n updatePricing: (input: {\n includeServiceFee: boolean;\n tipCents: number;\n }) => Promise<LockerverseCheckoutSessionPricing>;\n};\n\nconst CheckoutContext = createContext<CheckoutContextValue | null>(null);\n\nconst customTipSchema = pipe(string(), regex(/^\\d+(?:\\.\\d{1,2})?$/));\n\nfunction parseCustomTipCents(value: string) {\n const normalized = value.trim();\n if (!normalized) {\n return 0;\n }\n const parsed = safeParse(customTipSchema, normalized);\n if (!parsed.success) {\n return null;\n }\n const [dollars = \"0\", cents = \"\"] = parsed.output.split(\".\");\n const amount = BigInt(dollars) * 100n + BigInt(cents.padEnd(2, \"0\"));\n return amount <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(amount) : null;\n}\n\nfunction formatMoney(amountCents: number) {\n return new Intl.NumberFormat(\"en-US\", {\n currency: \"USD\",\n style: \"currency\",\n }).format(amountCents / 100);\n}\n\nfunction getInternationalPhone(phone: string, country: string) {\n const normalized = phone.trim();\n const digits = normalized.replace(/\\D/g, \"\");\n if (normalized.startsWith(\"+\")) {\n return `+${digits}`;\n }\n const callingCode =\n PHONE_COUNTRIES.find((option) => option.value === country)?.callingCode ??\n \"+1\";\n return `${callingCode}${digits}`;\n}\n\nfunction resolveItems(\n catalog: LockerverseCatalog,\n selection: LockerversePaymentSelectionItem[]\n) {\n if (!selection.length) {\n throw new Error(\"Select at least one Product before opening checkout.\");\n }\n return selection.map((selected): LockerverseCheckoutItem => {\n const product = catalog.products.find(\n (candidate) => candidate.slug === selected.productSlug\n );\n if (!product) {\n throw new Error(`Product ${selected.productSlug} is unavailable.`);\n }\n return \"amountCents\" in selected\n ? { amountCents: selected.amountCents, productId: product.id }\n : { productId: product.id, quantity: selected.quantity };\n });\n}\n\nfunction getSelectionSubtotalCents(\n catalog: LockerverseCatalog,\n selection: LockerversePaymentSelectionItem[]\n) {\n return selection.reduce((total, selected) => {\n if (\"amountCents\" in selected) {\n return total + selected.amountCents;\n }\n const product = catalog.products.find(\n (candidate) => candidate.slug === selected.productSlug\n );\n if (!product || product.amountCents === null) {\n throw new Error(`Product ${selected.productSlug} has invalid pricing.`);\n }\n return total + product.amountCents * selected.quantity;\n }, 0);\n}\n\nfunction createClientOptions(\n props: LockerverseCheckoutSessionProviderProps\n): CreateLockerverseWidgetOptions {\n const common = {\n communitySlug: props.communitySlug,\n ...(props.fetch ? { fetch: props.fetch } : {}),\n ...(props.onError ? { onError: props.onError } : {}),\n ...(props.requestTimeoutMs === undefined\n ? {}\n : { requestTimeoutMs: props.requestTimeoutMs }),\n ...(props.sentryDsn === undefined ? {} : { sentryDsn: props.sentryDsn }),\n widgetSlug: props.widgetSlug,\n };\n return props.apiBaseUrl\n ? {\n ...common,\n apiBaseUrl: props.apiBaseUrl,\n environment: props.environment,\n }\n : { ...common, environment: \"production\" };\n}\n\nfunction createStripeProviderOptions(\n loaded: LoadedCheckout | null,\n accentColor: string | undefined,\n theme: \"dark\" | \"light\" | undefined\n) {\n if (!loaded) {\n return null;\n }\n const accent = accentColor ?? \"#38d77a\";\n const light = theme === \"light\";\n return {\n clientSecret: loaded.session.clientSecret,\n elementsOptions: {\n appearance: {\n rules: {\n \".Input:focus\": {\n borderColor: accent,\n boxShadow: `0 0 0 1px ${accent}`,\n outline: \"none\",\n },\n },\n theme: light ? (\"stripe\" as const) : (\"night\" as const),\n variables: {\n borderRadius: \"10px\",\n colorBackground: light ? \"#f5f6f7\" : \"#121212\",\n colorDanger: light ? \"#c52b3e\" : \"#f08a98\",\n colorPrimary: accent,\n colorText: light ? \"#121416\" : \"#ffffff\",\n colorTextPlaceholder: light ? \"#72767d\" : \"#6b6b6b\",\n colorTextSecondary: light ? \"#62666d\" : \"#a1a1aa\",\n focusBoxShadow: \"none\",\n focusOutline: \"none\",\n fontSizeBase: \"16px\",\n },\n },\n syncAddressCheckbox: \"none\" as const,\n },\n };\n}\n\nfunction CheckoutBridge({\n children,\n loaded,\n}: PropsWithChildren<{ loaded: LoadedCheckout }>) {\n const result = useCheckoutElements();\n if (result.type === \"loading\") {\n return <PaymentSkeleton />;\n }\n if (result.type === \"error\") {\n return <div role=\"alert\">{result.error.message}</div>;\n }\n return (\n <ReadyCheckoutBridge checkout={result.checkout} loaded={loaded}>\n {children}\n </ReadyCheckoutBridge>\n );\n}\n\nfunction initialPricing(loaded: LoadedCheckout) {\n return {\n includeServiceFee: loaded.includeServiceFee,\n serviceFeeAmountCents: Math.round(\n (loaded.subtotalCents *\n loaded.catalog.pricingPolicy.serviceFeeRateBasisPoints) /\n 10_000\n ),\n subtotalCents: loaded.subtotalCents,\n tipCents: loaded.tipCents,\n };\n}\n\nfunction ReadyCheckoutBridge({\n checkout,\n children,\n loaded,\n}: PropsWithChildren<{\n checkout: StripeCheckoutElementsValue;\n loaded: LoadedCheckout;\n}>) {\n const [pricing, setPricing] = useState(() => initialPricing(loaded));\n useEffect(() => {\n setPricing(initialPricing(loaded));\n }, [loaded]);\n const value: CheckoutContextValue = {\n async applyPromoCode(promoCode) {\n const update = await checkout.runServerUpdate(() =>\n loaded.client.updateSessionDiscount({\n paymentReference: loaded.session.paymentReference,\n ...(promoCode.trim() ? { promoCode: promoCode.trim() } : {}),\n })\n );\n return update.type === \"error\" ? update.error.message : null;\n },\n catalog: loaded.catalog,\n async confirm(contact) {\n if (contact.shippingMatchesBilling) {\n if (!checkout.billingAddress) {\n throw new Error(\"Billing address is required.\");\n }\n const addressUpdate = await checkout.updateShippingAddress(\n checkout.billingAddress\n );\n if (addressUpdate.type === \"error\") {\n throw new Error(addressUpdate.error.message);\n }\n }\n const detailsUpdate = await checkout.runServerUpdate(() =>\n loaded.client.updateSessionDetails({\n ...(contact.customFieldAnswers\n ? { customFieldAnswers: contact.customFieldAnswers }\n : {}),\n email: contact.email,\n ...(contact.memberId ? { memberId: contact.memberId } : {}),\n ...(contact.merchSize ? { merchSize: contact.merchSize } : {}),\n paymentReference: loaded.session.paymentReference,\n ...(contact.phone ? { phone: contact.phone } : {}),\n })\n );\n if (detailsUpdate.type === \"error\") {\n throw new Error(detailsUpdate.error.message);\n }\n const prepared = await prepareCheckoutContact(\n checkout,\n contact.email,\n contact.phone ?? \"\",\n checkout.total.total.minorUnitsAmount > 0\n );\n if (\"error\" in prepared) {\n throw new Error(prepared.error);\n }\n const confirmation = await checkout.confirm({\n email: prepared.email,\n ...(prepared.phone ? { phoneNumber: prepared.phone } : {}),\n redirect: \"if_required\",\n });\n if (confirmation.type === \"error\") {\n throw new Error(confirmation.error.message);\n }\n return {\n paymentReference: loaded.session.paymentReference,\n sessionId: loaded.session.sessionId,\n };\n },\n paymentReference: loaded.session.paymentReference,\n pricing,\n totalCents: checkout.total.total.minorUnitsAmount,\n async updatePricing(input) {\n let updatedPricing: LockerverseCheckoutSessionPricing | undefined;\n const update = await checkout.runServerUpdate(() =>\n loaded.client\n .updateSessionPricing({\n ...input,\n paymentReference: loaded.session.paymentReference,\n })\n .then((response) => {\n updatedPricing = response;\n return response;\n })\n );\n if (update.type === \"error\") {\n throw new Error(update.error.message);\n }\n if (!updatedPricing) {\n throw new Error(\"Lockerverse returned no updated pricing.\");\n }\n const nextPricing = updatedPricing;\n setPricing((current) => ({\n ...current,\n includeServiceFee: nextPricing.includeServiceFee,\n tipCents: nextPricing.tipCents,\n }));\n return nextPricing;\n },\n };\n return (\n <CheckoutContext.Provider value={value}>\n {children}\n </CheckoutContext.Provider>\n );\n}\n\nexport function LockerverseCheckoutSessionProvider(\n props: LockerverseCheckoutSessionProviderProps\n) {\n const [loaded, setLoaded] = useState<LoadedCheckout | null>(null);\n const [failure, setFailure] = useState<string | null>(null);\n const [revision, setRevision] = useState(0);\n const preparation = useRef<{\n clientOptions: CreateLockerverseWidgetOptions;\n promise: Promise<LoadedCheckout>;\n } | null>(null);\n const currentCheckoutKey = JSON.stringify({\n email: props.email,\n includeServiceFee: props.includeServiceFee,\n returnUrl: props.returnUrl,\n selection: props.selection,\n tipCents: props.tipCents,\n });\n const initialCheckout = useRef({\n email: props.email,\n includeServiceFee: props.includeServiceFee,\n key: currentCheckoutKey,\n requestKey: globalThis.crypto.randomUUID(),\n returnUrl: props.returnUrl,\n selection: props.selection,\n tipCents: props.tipCents,\n });\n const clientOptions = useMemo(\n () => createClientOptions(props),\n [\n props.apiBaseUrl,\n props.communitySlug,\n props.environment,\n props.fetch,\n props.onError,\n props.requestTimeoutMs,\n props.sentryDsn,\n props.widgetSlug,\n ]\n );\n\n useEffect(() => {\n let active = true;\n if (preparation.current?.clientOptions !== clientOptions || revision > 0) {\n const client = createLockerverseCheckoutClient(clientOptions);\n const checkoutInput = initialCheckout.current;\n preparation.current = {\n clientOptions,\n promise: (async () => {\n const catalog = await client.load();\n const items = resolveItems(catalog, checkoutInput.selection);\n const subtotalCents = getSelectionSubtotalCents(\n catalog,\n checkoutInput.selection\n );\n const includeServiceFee =\n checkoutInput.includeServiceFee ?? catalog.widget.fields.serviceFee;\n const tipCents =\n checkoutInput.tipCents ??\n (catalog.widget.fields.tipping\n ? Math.round(subtotalCents * 0.1)\n : 0);\n const session = await client.createSession({\n ...(checkoutInput.email ? { email: checkoutInput.email } : {}),\n ...(catalog.widget.fields.serviceFee ? { includeServiceFee } : {}),\n items,\n requestKey: checkoutInput.requestKey,\n returnUrl: checkoutInput.returnUrl,\n ...(catalog.widget.fields.tipping ? { tipCents } : {}),\n });\n return {\n catalog,\n client,\n includeServiceFee,\n returnUrl: checkoutInput.returnUrl,\n session,\n subtotalCents,\n tipCents,\n };\n })(),\n };\n }\n setLoaded(null);\n setFailure(null);\n preparation.current.promise\n .then((next) => {\n if (active) {\n setLoaded(next);\n }\n })\n .catch((error: unknown) => {\n if (active) {\n setFailure(\n error instanceof Error ? error.message : \"Unable to load checkout.\"\n );\n }\n });\n return () => {\n active = false;\n };\n }, [clientOptions, revision]);\n\n const stripe = useMemo(() => {\n if (!loaded) {\n return null;\n }\n const stripeLoader = props.unstable_stripeLoader ?? loadStripe;\n return stripeLoader(loaded.catalog.payment.publishableKey, {\n betas: [\"custom_checkout_server_updates_1\"],\n ...(loaded.session.connectedAccountId\n ? { stripeAccount: loaded.session.connectedAccountId }\n : {}),\n });\n }, [loaded, props.unstable_stripeLoader]);\n const providerOptions = useMemo(\n () => createStripeProviderOptions(loaded, props.accentColor, props.theme),\n [loaded, props.accentColor, props.theme]\n );\n\n if (currentCheckoutKey !== initialCheckout.current.key) {\n return (\n <div className=\"lockerverse-payment__payment-status\" role=\"alert\">\n Checkout selection changed. Remount this payment component for the new\n selection.\n </div>\n );\n }\n if (failure) {\n return (\n <div className=\"lockerverse-payment__payment-status\" role=\"alert\">\n <p>{failure}</p>\n <button onClick={() => setRevision((value) => value + 1)} type=\"button\">\n Try again\n </button>\n </div>\n );\n }\n if (!(loaded && providerOptions)) {\n return <PaymentSkeleton />;\n }\n\n return (\n <CheckoutElementsProvider options={providerOptions} stripe={stripe}>\n <CheckoutBridge loaded={loaded}>{props.children}</CheckoutBridge>\n </CheckoutElementsProvider>\n );\n}\n\nexport function useLockerverseCheckoutSession() {\n const value = useContext(CheckoutContext);\n if (!value) {\n throw new Error(\n \"useLockerverseCheckoutSession must be used inside LockerverseCheckoutSessionProvider.\"\n );\n }\n return value;\n}\n\nasync function prepareCheckoutContact(\n checkout: StripeCheckoutElementsValue,\n email: string,\n phone: string,\n requirePaymentDetails: boolean\n) {\n const normalizedEmail = email.trim().toLowerCase();\n if (!normalizedEmail) {\n return { error: \"Email is required.\" } as const;\n }\n const emailResult = await checkout.updateEmail(normalizedEmail);\n if (emailResult.type === \"error\") {\n return { error: emailResult.error.message } as const;\n }\n const normalizedPhone = phone.trim();\n if (normalizedPhone) {\n const phoneResult = await checkout.updatePhoneNumber(normalizedPhone);\n if (phoneResult.type === \"error\") {\n return { error: \"Phone number is invalid.\" } as const;\n }\n }\n if (requirePaymentDetails) {\n const validation = await checkout.validateElements();\n if (validation.type === \"error\") {\n return { error: validation.error.message } as const;\n }\n }\n return { email: normalizedEmail, phone: normalizedPhone } as const;\n}\n\nfunction getPaymentButtonLabel(totalCents: number, tipCents: number) {\n if (totalCents === 0) {\n return \"Complete free order\";\n }\n if (tipCents > 0) {\n return `Process Payment ($${((totalCents - tipCents) / 100).toFixed(2)}) + $${(tipCents / 100).toFixed(2)} tip`;\n }\n return `Process Payment ($${(totalCents / 100).toFixed(2)})`;\n}\n\nfunction buildCheckoutContact({\n catalog,\n customFieldValues,\n email,\n memberId,\n merchSize,\n phone,\n phoneCountry,\n shippingMatchesBilling,\n}: {\n catalog: LockerverseCatalog;\n customFieldValues: Record<string, string | string[]>;\n email: string;\n memberId: string;\n merchSize: string;\n phone: string;\n phoneCountry: string;\n shippingMatchesBilling: boolean;\n}): Parameters<CheckoutContextValue[\"confirm\"]>[0] {\n return {\n customFieldAnswers: catalog.widget.customFields.map((field) => ({\n fieldId: field.id,\n value: customFieldValues[field.id] ?? null,\n })) as LockerverseCustomFieldAnswer[],\n email,\n ...(memberId ? { memberId } : {}),\n ...(merchSize\n ? {\n merchSize: merchSize as\n | \"XS\"\n | \"S\"\n | \"M\"\n | \"L\"\n | \"XL\"\n | \"XXL\"\n | \"XXXL\",\n }\n : {}),\n ...(phone ? { phone: getInternationalPhone(phone, phoneCountry) } : {}),\n ...(catalog.widget.fields.shipping ? { shippingMatchesBilling } : {}),\n };\n}\n\nexport function LockerverseCheckoutSessionPaymentForm({\n branding,\n onComplete,\n}: {\n branding?: LockerversePaymentBranding;\n onComplete?: (result: LockerversePaymentCompletion) => void;\n}) {\n const {\n applyPromoCode,\n catalog,\n confirm,\n pricing,\n totalCents,\n updatePricing,\n } = useLockerverseCheckoutSession();\n const [email, setEmail] = useState(\"\");\n const [phone, setPhone] = useState(\"\");\n const [phoneCountry, setPhoneCountry] = useState(\"US\");\n const [memberId, setMemberId] = useState(\"\");\n const [merchSize, setMerchSize] = useState(\"M\");\n const [customFieldValues, setCustomFieldValues] = useState<\n Record<string, string | string[]>\n >({});\n const [promoCode, setPromoCode] = useState(\"\");\n const [message, setMessage] = useState<string | null>(null);\n const [busy, setBusy] = useState(false);\n const [pricingBusy, setPricingBusy] = useState(false);\n const [isBillingAddressReady, setIsBillingAddressReady] = useState(false);\n const [isPaymentReady, setIsPaymentReady] = useState(false);\n const [isShippingAddressReady, setIsShippingAddressReady] = useState(false);\n const [shippingMatchesBilling, setShippingMatchesBilling] = useState(true);\n const initialTipOption =\n TIP_OPTIONS.find(\n (option) =>\n option.percent !== null &&\n Math.round((pricing.subtotalCents * option.percent) / 100) ===\n pricing.tipCents\n )?.value ?? \"custom\";\n const [tipOption, setTipOption] = useState(initialTipOption);\n const [tipInput, setTipInput] = useState(\n initialTipOption === \"custom\" && pricing.tipCents > 0\n ? (pricing.tipCents / 100).toFixed(2)\n : \"\"\n );\n const committedPricing = useRef({\n includeServiceFee: pricing.includeServiceFee,\n tipCents: pricing.tipCents,\n });\n const pendingPricing = useRef<Promise<boolean>>(Promise.resolve(true));\n useEffect(() => {\n committedPricing.current = {\n includeServiceFee: pricing.includeServiceFee,\n tipCents: pricing.tipCents,\n };\n }, [pricing.includeServiceFee, pricing.tipCents]);\n\n function savePricing(next: { includeServiceFee: boolean; tipCents: number }) {\n const operation = (async () => {\n setPricingBusy(true);\n setMessage(null);\n try {\n const updated = await updatePricing(next);\n committedPricing.current = {\n includeServiceFee: updated.includeServiceFee,\n tipCents: updated.tipCents,\n };\n return true;\n } catch (error) {\n setMessage(\n error instanceof Error ? error.message : \"Unable to update checkout.\"\n );\n return false;\n } finally {\n setPricingBusy(false);\n }\n })();\n pendingPricing.current = operation;\n return operation;\n }\n\n async function selectTip(option: (typeof TIP_OPTIONS)[number]) {\n if (option.percent === null) {\n setTipOption(option.value);\n return;\n }\n const nextTipCents = Math.round(\n (pricing.subtotalCents * option.percent) / 100\n );\n const updated = await savePricing({\n includeServiceFee: pricing.includeServiceFee,\n tipCents: nextTipCents,\n });\n if (updated) {\n setTipInput(\"\");\n setTipOption(option.value);\n }\n }\n\n function applyCustomTip() {\n const nextTipCents = parseCustomTipCents(tipInput);\n if (nextTipCents === null) {\n setMessage(\"Enter a valid tip with no more than two decimal places.\");\n return;\n }\n return savePricing({\n includeServiceFee: pricing.includeServiceFee,\n tipCents: nextTipCents,\n });\n }\n\n async function changeServiceFee(nextIncludeServiceFee: boolean) {\n await savePricing({\n includeServiceFee: nextIncludeServiceFee,\n tipCents: pricing.tipCents,\n });\n }\n async function updateDiscount() {\n setBusy(true);\n setMessage(null);\n try {\n setMessage(await applyPromoCode(promoCode));\n } catch (error) {\n setMessage(\n error instanceof Error ? error.message : \"Unable to update checkout.\"\n );\n } finally {\n setBusy(false);\n }\n }\n\n async function commitPricingBeforeSubmit() {\n if (!(await pendingPricing.current)) {\n return false;\n }\n if (tipOption !== \"custom\") {\n return true;\n }\n const nextTipCents = parseCustomTipCents(tipInput);\n if (nextTipCents === null) {\n setMessage(\"Enter a valid tip with no more than two decimal places.\");\n return false;\n }\n if (nextTipCents === committedPricing.current.tipCents) {\n return true;\n }\n return savePricing({\n includeServiceFee: committedPricing.current.includeServiceFee,\n tipCents: nextTipCents,\n });\n }\n\n async function submit(event: FormEvent) {\n event.preventDefault();\n setBusy(true);\n setMessage(null);\n try {\n if (!(await commitPricingBeforeSubmit())) {\n return;\n }\n const completion = await confirm(\n buildCheckoutContact({\n catalog,\n customFieldValues,\n email,\n memberId,\n merchSize,\n phone,\n phoneCountry,\n shippingMatchesBilling,\n })\n );\n onComplete?.(completion);\n } catch (error) {\n setMessage(\n error instanceof Error ? error.message : \"Unable to complete checkout.\"\n );\n } finally {\n setBusy(false);\n }\n }\n\n return (\n <form className=\"lockerverse-payment__form\" onSubmit={submit}>\n <header>\n {catalog.widget.showCommunityBranding && branding ? (\n <div className=\"lockerverse-payment__branding\">\n {branding.imageUrl ? (\n <img\n alt={branding.name}\n height=\"48\"\n src={branding.imageUrl}\n width=\"48\"\n />\n ) : null}\n <strong>{branding.name}</strong>\n </div>\n ) : null}\n <h1>{catalog.widget.title ?? catalog.widget.name}</h1>\n {catalog.widget.description ? (\n <p>{catalog.widget.description}</p>\n ) : null}\n </header>\n <TipSelector\n busy={busy || pricingBusy}\n enabled={catalog.widget.fields.tipping}\n onCustomTipBlur={applyCustomTip}\n onCustomTipChange={setTipInput}\n onSelect={selectTip}\n tipInput={tipInput}\n tipOption={tipOption}\n />\n <ContactFields\n email={email}\n fields={catalog.widget.fields}\n onEmailChange={setEmail}\n onPhoneChange={setPhone}\n onPhoneCountryChange={setPhoneCountry}\n phone={phone}\n phoneCountry={phoneCountry}\n />\n <StripeCheckoutFields\n fields={catalog.widget.fields}\n isBillingAddressReady={isBillingAddressReady}\n isPaymentReady={isPaymentReady}\n isShippingAddressReady={isShippingAddressReady}\n onBillingAddressReady={() => setIsBillingAddressReady(true)}\n onPaymentReady={() => setIsPaymentReady(true)}\n onShippingAddressReady={() => setIsShippingAddressReady(true)}\n onShippingMatchesBillingChange={(value) => {\n setShippingMatchesBilling(value);\n if (!value) {\n setIsShippingAddressReady(false);\n }\n }}\n shippingMatchesBilling={shippingMatchesBilling}\n totalCents={totalCents}\n />\n <CustomerFields\n fields={catalog.widget.fields}\n memberId={memberId}\n merchSize={merchSize}\n onMemberIdChange={setMemberId}\n onMerchSizeChange={setMerchSize}\n />\n {catalog.widget.fields.promoCode ? (\n <div className=\"lockerverse-payment__additional-fields\">\n <label>\n <span>Promo code</span>\n <input\n name=\"promoCode\"\n onChange={(event) => setPromoCode(event.currentTarget.value)}\n placeholder=\"Optional\"\n value={promoCode}\n />\n </label>\n <button disabled={busy} onClick={updateDiscount} type=\"button\">\n {promoCode.trim() ? \"Apply code\" : \"Remove code\"}\n </button>\n </div>\n ) : null}\n {catalog.widget.customFields.length ? (\n <div className=\"lockerverse-payment__custom-fields\">\n <LockerverseCustomFields\n fields={catalog.widget.customFields}\n onChange={(fieldId, value) =>\n setCustomFieldValues((current) => ({\n ...current,\n [fieldId]: value,\n }))\n }\n values={customFieldValues}\n />\n </div>\n ) : null}\n {message ? <div role=\"alert\">{message}</div> : null}\n <div className=\"lockerverse-payment__actions\">\n {catalog.widget.fields.serviceFee ? (\n <label className=\"lockerverse-payment__check-row\">\n <input\n checked={pricing.includeServiceFee}\n disabled={busy || pricingBusy}\n name=\"includeServiceFee\"\n onChange={(event) =>\n changeServiceFee(event.currentTarget.checked)\n }\n type=\"checkbox\"\n />\n <span>\n Add {formatMoney(pricing.serviceFeeAmountCents)} to help cover\n processing fees\n </span>\n </label>\n ) : null}\n <button disabled={busy} type=\"submit\">\n {getPaymentButtonLabel(totalCents, pricing.tipCents)}\n </button>\n </div>\n </form>\n );\n}\n\nexport function LockerversePayment(props: LockerversePaymentProps) {\n const selectPortalContainerRef = useRef<HTMLElement | null>(null);\n const {\n apiBaseUrl,\n branding,\n className,\n communitySlug,\n environment,\n fetch,\n includeServiceFee,\n onError,\n onPaymentComplete,\n requestTimeoutMs,\n returnUrl,\n selection,\n sentryDsn,\n unstable_stripeLoader,\n style,\n theme = \"dark\",\n tipCents,\n widgetSlug,\n ...sectionProps\n } = props;\n const destination =\n returnUrl ??\n (typeof globalThis.location === \"undefined\"\n ? \"https://lockerverse.com\"\n : globalThis.location.href);\n const rootClassName = [\"lockerverse-payment\", className]\n .filter(Boolean)\n .join(\" \");\n const clientOptions = apiBaseUrl\n ? { apiBaseUrl, communitySlug, environment, widgetSlug }\n : { communitySlug, environment: \"production\" as const, widgetSlug };\n const accentColor = style?.[\"--lockerverse-accent\"] ?? branding?.accentColor;\n const rootStyle = accentColor\n ? ({\n ...style,\n \"--lockerverse-accent\": accentColor,\n \"--lockerverse-accent-contrast\":\n style?.[\"--lockerverse-accent-contrast\"] ??\n getAccentContrast(accentColor) ??\n \"#08110c\",\n } as const)\n : style;\n\n return (\n <section\n {...sectionProps}\n className={rootClassName}\n data-lockerverse-theme={theme}\n ref={selectPortalContainerRef}\n style={rootStyle}\n >\n <SelectPortalProvider container={selectPortalContainerRef}>\n <LockerverseCheckoutSessionProvider\n {...clientOptions}\n {...(accentColor ? { accentColor } : {})}\n {...(fetch ? { fetch } : {})}\n {...(includeServiceFee === undefined ? {} : { includeServiceFee })}\n {...(onError ? { onError } : {})}\n {...(requestTimeoutMs === undefined ? {} : { requestTimeoutMs })}\n returnUrl={destination}\n selection={selection}\n {...(sentryDsn === undefined ? {} : { sentryDsn })}\n {...(unstable_stripeLoader ? { unstable_stripeLoader } : {})}\n theme={theme}\n {...(tipCents === undefined ? {} : { tipCents })}\n >\n <LockerverseCheckoutSessionPaymentForm\n {...(branding ? { branding } : {})}\n {...(onPaymentComplete ? { onComplete: onPaymentComplete } : {})}\n />\n </LockerverseCheckoutSessionProvider>\n </SelectPortalProvider>\n </section>\n );\n}\n"],"mappings":"ylBAAA,MAAM,EAAY,8BAElB,SAAS,EAAc,EAAe,CACpC,IAAM,EAAQ,EAAU,KAAK,EAAM,KAAK,CAAC,EACzC,GAAI,CAAC,EACH,OAEF,GAAM,EAAG,GAAS,EAClB,GAAI,CAAC,EACH,OAEF,IAAM,EACJ,EAAM,SAAW,EACb,MAAM,KAAK,EAAQ,GAAc,GAAG,IAAY,GAAW,CAAC,CAAC,KAAK,EAAE,EACpE,EACN,MAAO,CAAC,EAAG,EAAG,CAAC,CAAC,CAAC,IAAK,GACpB,OAAO,SAAS,EAAS,MAAM,EAAQ,EAAS,CAAC,EAAG,EAAE,CACxD,CACF,CAEA,SAAS,EAAkB,CAAC,EAAK,EAAO,GAAiB,CACvD,GAAM,CAAC,EAAY,EAAG,EAAc,EAAG,EAAa,GAAK,CACvD,EACA,EACA,CACF,CAAC,CAAC,KAAK,EAAU,IAAM,CACrB,IAAM,EAAa,EAAU,IAC7B,OAAO,GAAc,OACjB,EAAa,QACX,EAAa,MAAS,QAAU,GACx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AkB,EAChE,GAAK,EAAU,CAAE,SAAQ,EAAI,CAAC,EAC9B,GAAK,IAAqB,IAAA,GAAY,CAAC,EAAI,CAAE,kBAAiB,EAC9D,UAAW,EACA,YACX,GAAK,IAAc,IAAA,GAAY,CAAC,EAAI,CAAE,WAAU,EAChD,GAAK,EAAwB,CAAE,uBAAsB,EAAI,CAAC,EACnD,QACP,GAAK,IAAa,IAAA,GAAY,CAAC,EAAI,CAAE,UAAS,EAE9C,SAAA,EAAC,EAAD,CACE,GAAK,EAAW,CAAE,UAAS,EAAI,CAAC,EAChC,GAAK,EAAoB,CAAE,WAAY,CAAkB,EAAI,CAAC,CAC/D,CAAA,CACiC,CAAA,CAChB,CAAA,CACf,CAAA,CAEb"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/accent-contrast.ts","../src/select-control.tsx","../src/checkout-session-form-fields.tsx","../src/checkout-session-loading.tsx","../src/checkout-session-payment.tsx"],"sourcesContent":["const HEX_COLOR = /^#([\\da-f]{3}|[\\da-f]{6})$/i;\n\nfunction parseHexColor(color: string) {\n const match = HEX_COLOR.exec(color.trim());\n if (!match) {\n return;\n }\n const [, value] = match;\n if (!value) {\n return;\n }\n const expanded =\n value.length === 3\n ? Array.from(value, (character) => `${character}${character}`).join(\"\")\n : value;\n return [0, 2, 4].map((offset) =>\n Number.parseInt(expanded.slice(offset, offset + 2), 16)\n );\n}\n\nfunction relativeLuminance([red, green, blue]: number[]) {\n const [linearRed = 0, linearGreen = 0, linearBlue = 0] = [\n red,\n green,\n blue,\n ].map((channel = 0) => {\n const normalized = channel / 255;\n return normalized <= 0.040_45\n ? normalized / 12.92\n : ((normalized + 0.055) / 1.055) ** 2.4;\n });\n return 0.2126 * linearRed + 0.7152 * linearGreen + 0.0722 * linearBlue;\n}\n\nexport function getAccentContrast(color: string) {\n const parsed = parseHexColor(color);\n if (!parsed) {\n return;\n }\n const luminance = relativeLuminance(parsed);\n const blackContrast = (luminance + 0.05) / 0.05;\n const whiteContrast = 1.05 / (luminance + 0.05);\n return blackContrast >= whiteContrast ? \"#000\" : \"#fff\";\n}\n","import { Select } from \"@base-ui/react/select\";\nimport {\n createContext,\n type ReactNode,\n type RefObject,\n useContext,\n} from \"react\";\n\nexport type LockerverseSelectOption = {\n label: string;\n value: string;\n};\n\nconst SelectPortalContext = createContext<\n RefObject<HTMLElement | null> | undefined\n>(undefined);\n\nexport function SelectPortalProvider({\n children,\n container,\n}: {\n children: ReactNode;\n container: RefObject<HTMLElement | null>;\n}) {\n return (\n <SelectPortalContext.Provider value={container}>\n {children}\n </SelectPortalContext.Provider>\n );\n}\n\nfunction SelectIcon() {\n return (\n <svg aria-hidden=\"true\" fill=\"none\" viewBox=\"0 0 16 16\">\n <path d=\"m4 6 4 4 4-4\" />\n </svg>\n );\n}\n\nfunction SelectedIcon() {\n return (\n <svg aria-hidden=\"true\" fill=\"none\" viewBox=\"0 0 16 16\">\n <path d=\"m3 8 3 3 7-7\" />\n </svg>\n );\n}\n\nexport function LockerverseSelect({\n ariaDescribedBy,\n ariaLabel,\n ariaLabelledBy,\n className,\n id,\n invalid = false,\n name,\n onValueChange,\n options,\n required = false,\n value,\n}: {\n ariaDescribedBy?: string;\n ariaLabel?: string;\n ariaLabelledBy?: string;\n className?: string;\n id?: string;\n invalid?: boolean;\n name: string;\n onValueChange: (value: string) => void;\n options: readonly LockerverseSelectOption[];\n required?: boolean;\n value: string;\n}) {\n const portalContainer = useContext(SelectPortalContext);\n const rootClassName = [\"lockerverse-payment__select\", className]\n .filter(Boolean)\n .join(\" \");\n\n return (\n <div className={rootClassName}>\n <Select.Root\n id={id}\n items={options}\n name={name}\n onValueChange={(nextValue) => {\n if (nextValue !== null) {\n onValueChange(nextValue);\n }\n }}\n required={required}\n value={value}\n >\n <Select.Trigger\n aria-describedby={ariaDescribedBy}\n aria-invalid={invalid || undefined}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n className=\"lockerverse-payment__select-trigger\"\n >\n <Select.Value />\n <Select.Icon\n aria-hidden=\"true\"\n className=\"lockerverse-payment__select-icon\"\n >\n <SelectIcon />\n </Select.Icon>\n </Select.Trigger>\n <Select.Portal container={portalContainer}>\n <Select.Positioner\n alignItemWithTrigger={false}\n className=\"lockerverse-payment__select-positioner\"\n sideOffset={6}\n >\n <Select.Popup className=\"lockerverse-payment__select-popup\">\n <Select.List className=\"lockerverse-payment__select-list\">\n {options.map((option) => (\n <Select.Item\n className=\"lockerverse-payment__select-item\"\n key={option.value}\n value={option.value}\n >\n <Select.ItemText>{option.label}</Select.ItemText>\n <Select.ItemIndicator\n aria-hidden=\"true\"\n className=\"lockerverse-payment__select-item-indicator\"\n >\n <SelectedIcon />\n </Select.ItemIndicator>\n </Select.Item>\n ))}\n </Select.List>\n </Select.Popup>\n </Select.Positioner>\n </Select.Portal>\n </Select.Root>\n </div>\n );\n}\n","import type {\n LockerverseCatalog,\n LockerverseCustomField,\n} from \"@lockerverse/sdk/checkout\";\nimport {\n BillingAddressElement,\n PaymentElement,\n ShippingAddressElement,\n} from \"@stripe/react-stripe-js/checkout\";\nimport { LockerverseSelect } from \"./select-control.tsx\";\n\nexport const PHONE_COUNTRIES = [\n { callingCode: \"+1\", label: \"๐บ๐ธ +1\", value: \"US\" },\n { callingCode: \"+52\", label: \"๐ฒ๐ฝ +52\", value: \"MX\" },\n { callingCode: \"+380\", label: \"๐บ๐ฆ +380\", value: \"UA\" },\n { callingCode: \"+48\", label: \"๐ต๐ฑ +48\", value: \"PL\" },\n { callingCode: \"+1\", label: \"๐จ๐ฆ +1\", value: \"CA\" },\n { callingCode: \"+49\", label: \"๐ฉ๐ช +49\", value: \"DE\" },\n { callingCode: \"+44\", label: \"๐ฌ๐ง +44\", value: \"GB\" },\n { callingCode: \"+46\", label: \"๐ธ๐ช +46\", value: \"SE\" },\n { callingCode: \"+358\", label: \"๐ซ๐ฎ +358\", value: \"FI\" },\n { callingCode: \"+1\", label: \"๐ต๐ท +1\", value: \"PR\" },\n] as const;\n\nexport const TIP_OPTIONS = [\n { label: \"15%\", percent: 15, value: \"15\" },\n { label: \"12%\", percent: 12, value: \"12\" },\n { label: \"10%\", percent: 10, value: \"10\" },\n { label: \"5%\", percent: 5, value: \"5\" },\n { label: \"Other\", percent: null, value: \"custom\" },\n] as const;\n\nfunction StripeElementLoader({ label }: { label: string }) {\n return (\n <div className=\"lockerverse-payment__stripe-loader\" role=\"status\">\n <p>{label}</p>\n <div aria-hidden=\"true\">\n <span />\n <span />\n <span />\n </div>\n </div>\n );\n}\n\nexport function LockerverseCustomFields({\n fields,\n onChange,\n values,\n}: {\n fields: LockerverseCustomField[];\n onChange: (fieldId: string, value: string | string[]) => void;\n values: Record<string, string | string[]>;\n}) {\n return fields.map((field) => {\n const value =\n values[field.id] ??\n (field.type.includes(\"multi\") || field.type === \"checkboxes\" ? [] : \"\");\n if (field.type === \"textarea\") {\n return (\n <label key={field.id}>\n <span>{field.label}</span>\n <textarea\n name={field.id}\n onChange={(event) => onChange(field.id, event.currentTarget.value)}\n required={field.required}\n value={String(value)}\n />\n </label>\n );\n }\n if (field.type === \"select\") {\n const labelId = `lockerverse-custom-${field.id}-label`;\n return (\n <div className=\"lockerverse-payment__field\" key={field.id}>\n <span id={labelId}>{field.label}</span>\n <LockerverseSelect\n ariaLabelledBy={labelId}\n name={field.id}\n onValueChange={(nextValue) => onChange(field.id, nextValue)}\n options={[\n { label: \"Selectโฆ\", value: \"\" },\n ...field.options.map((option) => ({\n label: option.label,\n value: option.id,\n })),\n ]}\n required={field.required}\n value={String(value)}\n />\n </div>\n );\n }\n if (\n field.type === \"radio\" ||\n field.type === \"checkboxes\" ||\n field.type === \"multi_select\"\n ) {\n const selected = Array.isArray(value) ? value : [value];\n return (\n <fieldset key={field.id}>\n <legend>{field.label}</legend>\n {field.options.map((option) => {\n const checked = selected.includes(option.id);\n return (\n <label className=\"lockerverse-payment__choice\" key={option.id}>\n <input\n checked={checked}\n name={field.id}\n onChange={() => {\n if (field.type === \"radio\") {\n onChange(field.id, option.id);\n return;\n }\n onChange(\n field.id,\n checked\n ? selected.filter((id) => id !== option.id)\n : [...selected, option.id]\n );\n }}\n required={field.required && selected.length === 0}\n type={field.type === \"radio\" ? \"radio\" : \"checkbox\"}\n value={option.id}\n />\n <span>{option.label}</span>\n </label>\n );\n })}\n </fieldset>\n );\n }\n return (\n <label key={field.id}>\n <span>{field.label}</span>\n <input\n name={field.id}\n onChange={(event) => onChange(field.id, event.currentTarget.value)}\n required={field.required}\n type=\"text\"\n value={String(value)}\n />\n </label>\n );\n });\n}\n\nexport function TipSelector({\n busy,\n enabled,\n onCustomTipBlur,\n onCustomTipChange,\n onSelect,\n tipInput,\n tipOption,\n}: {\n busy: boolean;\n enabled: boolean;\n onCustomTipBlur: () => Promise<unknown> | undefined;\n onCustomTipChange: (value: string) => void;\n onSelect: (option: (typeof TIP_OPTIONS)[number]) => Promise<void>;\n tipInput: string;\n tipOption: string;\n}) {\n if (!enabled) {\n return null;\n }\n return (\n <div className=\"lockerverse-payment__tip\">\n <strong>Add a tip to support the Lockerverse platform</strong>\n <div aria-label=\"Tip amount\" role=\"radiogroup\">\n {TIP_OPTIONS.map((option) => (\n <button\n aria-pressed={tipOption === option.value}\n disabled={busy}\n key={option.value}\n onClick={() => onSelect(option)}\n type=\"button\"\n >\n {option.label}\n </button>\n ))}\n </div>\n {tipOption === \"custom\" ? (\n <label>\n <span>Custom tip</span>\n <div className=\"lockerverse-payment__money-input\">\n <span aria-hidden=\"true\">$</span>\n <input\n inputMode=\"decimal\"\n name=\"customTip\"\n onBlur={onCustomTipBlur}\n onChange={(event) => onCustomTipChange(event.currentTarget.value)}\n placeholder=\"0.00\"\n value={tipInput}\n />\n </div>\n </label>\n ) : null}\n </div>\n );\n}\n\nexport function ContactFields({\n email,\n fields,\n onEmailChange,\n onPhoneChange,\n onPhoneCountryChange,\n phone,\n phoneCountry,\n}: {\n email: string;\n fields: LockerverseCatalog[\"widget\"][\"fields\"];\n onEmailChange: (value: string) => void;\n onPhoneChange: (value: string) => void;\n onPhoneCountryChange: (value: string) => void;\n phone: string;\n phoneCountry: string;\n}) {\n return (\n <div className=\"lockerverse-payment__contact\">\n <label>\n <span>Email</span>\n <input\n autoComplete=\"email\"\n inputMode=\"email\"\n name=\"email\"\n onChange={(event) => onEmailChange(event.currentTarget.value)}\n placeholder=\"name@example.com\"\n required\n type=\"email\"\n value={email}\n />\n </label>\n {fields.phone ? (\n <label>\n <span>Phone</span>\n <div className=\"lockerverse-payment__phone-control\">\n <LockerverseSelect\n ariaLabel=\"Phone country\"\n className=\"lockerverse-payment__select--phone-country\"\n name=\"phoneCountry\"\n onValueChange={onPhoneCountryChange}\n options={PHONE_COUNTRIES}\n value={phoneCountry}\n />\n <input\n autoComplete=\"tel\"\n inputMode=\"tel\"\n name=\"phone\"\n onChange={(event) => onPhoneChange(event.currentTarget.value)}\n placeholder=\"(201) 555-0123\"\n required\n type=\"tel\"\n value={phone}\n />\n </div>\n </label>\n ) : null}\n </div>\n );\n}\n\nexport function StripeCheckoutFields({\n fields,\n isBillingAddressReady,\n isPaymentReady,\n isShippingAddressReady,\n onBillingAddressReady,\n onPaymentReady,\n onShippingAddressReady,\n onShippingMatchesBillingChange,\n shippingMatchesBilling,\n totalCents,\n}: {\n fields: LockerverseCatalog[\"widget\"][\"fields\"];\n isBillingAddressReady: boolean;\n isPaymentReady: boolean;\n isShippingAddressReady: boolean;\n onBillingAddressReady: () => void;\n onPaymentReady: () => void;\n onShippingAddressReady: () => void;\n onShippingMatchesBillingChange: (value: boolean) => void;\n shippingMatchesBilling: boolean;\n totalCents: number;\n}) {\n return (\n <>\n <div\n className=\"lockerverse-payment__stripe-element\"\n data-ready={isPaymentReady}\n hidden={totalCents === 0}\n >\n {isPaymentReady ? null : (\n <StripeElementLoader label=\"Loading payment form...\" />\n )}\n <div className=\"lockerverse-payment__stripe-mount\">\n <PaymentElement\n onReady={onPaymentReady}\n options={{\n fields: {\n billingDetails: {\n address: \"never\",\n email: \"never\",\n name: \"never\",\n phone: \"never\",\n },\n },\n layout: \"tabs\",\n paymentMethodOrder: [\"card\", \"apple_pay\", \"paypal\"],\n terms: {\n applePay: \"auto\",\n card: \"always\",\n googlePay: \"never\",\n paypal: \"auto\",\n usBankAccount: \"never\",\n },\n wallets: { applePay: \"auto\", googlePay: \"never\" },\n }}\n />\n </div>\n </div>\n <div className=\"lockerverse-payment__address\">\n <h2>Billing address</h2>\n <div\n className=\"lockerverse-payment__stripe-element lockerverse-payment__stripe-element--address\"\n data-ready={isBillingAddressReady}\n >\n {isBillingAddressReady ? null : (\n <StripeElementLoader label=\"Loading billing address...\" />\n )}\n <div className=\"lockerverse-payment__stripe-mount\">\n <BillingAddressElement onReady={onBillingAddressReady} />\n </div>\n </div>\n </div>\n {fields.shipping ? (\n <div className=\"lockerverse-payment__shipping\">\n <label className=\"lockerverse-payment__check-row\">\n <input\n checked={shippingMatchesBilling}\n name=\"shippingMatchesBilling\"\n onChange={(event) =>\n onShippingMatchesBillingChange(event.currentTarget.checked)\n }\n type=\"checkbox\"\n />\n <span>Shipping is same as billing information</span>\n </label>\n {shippingMatchesBilling ? null : (\n <div className=\"lockerverse-payment__address\">\n <h2>Shipping address</h2>\n <div\n className=\"lockerverse-payment__stripe-element lockerverse-payment__stripe-element--address\"\n data-ready={isShippingAddressReady}\n >\n {isShippingAddressReady ? null : (\n <StripeElementLoader label=\"Loading shipping address...\" />\n )}\n <div className=\"lockerverse-payment__stripe-mount\">\n <ShippingAddressElement onReady={onShippingAddressReady} />\n </div>\n </div>\n </div>\n )}\n </div>\n ) : null}\n </>\n );\n}\n\nexport function CustomerFields({\n fields,\n memberId,\n merchSize,\n onMemberIdChange,\n onMerchSizeChange,\n}: {\n fields: LockerverseCatalog[\"widget\"][\"fields\"];\n memberId: string;\n merchSize: string;\n onMemberIdChange: (value: string) => void;\n onMerchSizeChange: (value: string) => void;\n}) {\n return (\n <>\n {fields.memberId ? (\n <label>\n <span>Member ID</span>\n <input\n name=\"memberId\"\n onChange={(event) => onMemberIdChange(event.currentTarget.value)}\n required\n type=\"text\"\n value={memberId}\n />\n </label>\n ) : null}\n {fields.merchSize ? (\n <div className=\"lockerverse-payment__field\">\n <span id=\"lockerverse-merch-size-label\">Size</span>\n <LockerverseSelect\n ariaLabelledBy=\"lockerverse-merch-size-label\"\n name=\"merchSize\"\n onValueChange={onMerchSizeChange}\n options={[\"XS\", \"S\", \"M\", \"L\", \"XL\", \"XXL\", \"XXXL\"].map((size) => ({\n label: size,\n value: size,\n }))}\n required\n value={merchSize}\n />\n </div>\n ) : null}\n </>\n );\n}\n","function SkeletonLoaderBlock() {\n return (\n <div className=\"lockerverse-payment__skeleton-loader-block\">\n <span className=\"lockerverse-payment__skeleton-loader-label\" />\n <div className=\"lockerverse-payment__skeleton-loader-content\">\n <span className=\"lockerverse-payment__skeleton-loader-full\" />\n <div className=\"lockerverse-payment__skeleton-loader-grid\">\n <span className=\"lockerverse-payment__skeleton-loader-half\" />\n <span className=\"lockerverse-payment__skeleton-loader-half\" />\n </div>\n </div>\n </div>\n );\n}\n\nexport function PaymentSkeleton() {\n return (\n <div className=\"lockerverse-payment__loading\">\n <span className=\"lockerverse-payment__sr-only\" role=\"status\">\n Preparing secure checkoutโฆ\n </span>\n <div aria-hidden=\"true\" className=\"lockerverse-payment__skeleton\">\n <div className=\"lockerverse-payment__skeleton-branding\">\n <span className=\"lockerverse-payment__skeleton-avatar\" />\n <span className=\"lockerverse-payment__skeleton-community\" />\n </div>\n <div className=\"lockerverse-payment__skeleton-contact\">\n <div className=\"lockerverse-payment__skeleton-field\">\n <span className=\"lockerverse-payment__skeleton-label\" />\n <span className=\"lockerverse-payment__skeleton-input\" />\n </div>\n <div className=\"lockerverse-payment__skeleton-field\">\n <span className=\"lockerverse-payment__skeleton-label\" />\n <span className=\"lockerverse-payment__skeleton-input\" />\n </div>\n </div>\n <SkeletonLoaderBlock />\n <SkeletonLoaderBlock />\n <div className=\"lockerverse-payment__skeleton-actions\">\n <span className=\"lockerverse-payment__skeleton-check-line\" />\n <span className=\"lockerverse-payment__skeleton-button\" />\n </div>\n </div>\n </div>\n );\n}\n","import type {\n CreateLockerverseWidgetOptions,\n LockerverseCatalog,\n LockerverseCheckoutClient,\n LockerverseCheckoutItem,\n LockerverseCheckoutSession,\n LockerverseCheckoutSessionPricing,\n LockerverseCustomFieldAnswer,\n} from \"@lockerverse/sdk/checkout\";\nimport { createLockerverseCheckoutClient } from \"@lockerverse/sdk/checkout\";\nimport type { StripeCheckoutElementsValue } from \"@stripe/react-stripe-js/checkout\";\nimport {\n CheckoutElementsProvider,\n useCheckoutElements,\n} from \"@stripe/react-stripe-js/checkout\";\nimport { loadStripe } from \"@stripe/stripe-js/pure\";\nimport {\n createContext,\n type FormEvent,\n type PropsWithChildren,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport { pipe, regex, safeParse, string } from \"valibot\";\nimport { getAccentContrast } from \"./accent-contrast.ts\";\nimport {\n ContactFields,\n CustomerFields,\n LockerverseCustomFields,\n PHONE_COUNTRIES,\n StripeCheckoutFields,\n TIP_OPTIONS,\n TipSelector,\n} from \"./checkout-session-form-fields.tsx\";\nimport { PaymentSkeleton } from \"./checkout-session-loading.tsx\";\nimport { SelectPortalProvider } from \"./select-control.tsx\";\nimport type {\n LockerversePaymentBranding,\n LockerversePaymentCompletion,\n LockerversePaymentProps,\n LockerversePaymentSelectionItem,\n} from \"./types.ts\";\n\ntype CheckoutSessionStripeLoader = typeof loadStripe;\n\nexport type LockerverseCheckoutSessionProviderProps =\n CreateLockerverseWidgetOptions &\n PropsWithChildren<{\n accentColor?: string;\n email?: string;\n includeServiceFee?: boolean;\n metadata?: Record<string, string>;\n returnUrl: string;\n selection: LockerversePaymentSelectionItem[];\n unstable_stripeLoader?: CheckoutSessionStripeLoader;\n theme?: \"dark\" | \"light\";\n tipCents?: number;\n }>;\n\ntype LoadedCheckout = {\n catalog: LockerverseCatalog;\n client: LockerverseCheckoutClient;\n includeServiceFee: boolean;\n returnUrl: string;\n session: LockerverseCheckoutSession;\n subtotalCents: number;\n tipCents: number;\n};\n\ntype CheckoutContextValue = {\n applyPromoCode: (promoCode: string) => Promise<string | null>;\n catalog: LockerverseCatalog;\n confirm: (contact: {\n customFieldAnswers?: LockerverseCustomFieldAnswer[];\n email: string;\n memberId?: string;\n merchSize?: \"XS\" | \"S\" | \"M\" | \"L\" | \"XL\" | \"XXL\" | \"XXXL\";\n phone?: string;\n shippingMatchesBilling?: boolean;\n }) => Promise<LockerversePaymentCompletion>;\n paymentReference: string;\n pricing: {\n includeServiceFee: boolean;\n serviceFeeAmountCents: number;\n subtotalCents: number;\n tipCents: number;\n };\n totalCents: number;\n updatePricing: (input: {\n includeServiceFee: boolean;\n tipCents: number;\n }) => Promise<LockerverseCheckoutSessionPricing>;\n};\n\nconst CheckoutContext = createContext<CheckoutContextValue | null>(null);\n\nconst customTipSchema = pipe(string(), regex(/^\\d+(?:\\.\\d{1,2})?$/));\n\nfunction parseCustomTipCents(value: string) {\n const normalized = value.trim();\n if (!normalized) {\n return 0;\n }\n const parsed = safeParse(customTipSchema, normalized);\n if (!parsed.success) {\n return null;\n }\n const [dollars = \"0\", cents = \"\"] = parsed.output.split(\".\");\n const amount = BigInt(dollars) * 100n + BigInt(cents.padEnd(2, \"0\"));\n return amount <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(amount) : null;\n}\n\nfunction formatMoney(amountCents: number) {\n return new Intl.NumberFormat(\"en-US\", {\n currency: \"USD\",\n style: \"currency\",\n }).format(amountCents / 100);\n}\n\nfunction getInternationalPhone(phone: string, country: string) {\n const normalized = phone.trim();\n const digits = normalized.replace(/\\D/g, \"\");\n if (normalized.startsWith(\"+\")) {\n return `+${digits}`;\n }\n const callingCode =\n PHONE_COUNTRIES.find((option) => option.value === country)?.callingCode ??\n \"+1\";\n return `${callingCode}${digits}`;\n}\n\nfunction resolveItems(\n catalog: LockerverseCatalog,\n selection: LockerversePaymentSelectionItem[]\n) {\n if (!selection.length) {\n throw new Error(\"Select at least one Product before opening checkout.\");\n }\n return selection.map((selected): LockerverseCheckoutItem => {\n const product = catalog.products.find(\n (candidate) => candidate.slug === selected.productSlug\n );\n if (!product) {\n throw new Error(`Product ${selected.productSlug} is unavailable.`);\n }\n return \"amountCents\" in selected\n ? { amountCents: selected.amountCents, productId: product.id }\n : { productId: product.id, quantity: selected.quantity };\n });\n}\n\nfunction getSelectionSubtotalCents(\n catalog: LockerverseCatalog,\n selection: LockerversePaymentSelectionItem[]\n) {\n return selection.reduce((total, selected) => {\n if (\"amountCents\" in selected) {\n return total + selected.amountCents;\n }\n const product = catalog.products.find(\n (candidate) => candidate.slug === selected.productSlug\n );\n if (!product || product.amountCents === null) {\n throw new Error(`Product ${selected.productSlug} has invalid pricing.`);\n }\n return total + product.amountCents * selected.quantity;\n }, 0);\n}\n\nfunction createClientOptions(\n props: LockerverseCheckoutSessionProviderProps\n): CreateLockerverseWidgetOptions {\n const common = {\n communitySlug: props.communitySlug,\n ...(props.fetch ? { fetch: props.fetch } : {}),\n ...(props.onError ? { onError: props.onError } : {}),\n ...(props.requestTimeoutMs === undefined\n ? {}\n : { requestTimeoutMs: props.requestTimeoutMs }),\n ...(props.sentryDsn === undefined ? {} : { sentryDsn: props.sentryDsn }),\n widgetSlug: props.widgetSlug,\n };\n return props.apiBaseUrl\n ? {\n ...common,\n apiBaseUrl: props.apiBaseUrl,\n environment: props.environment,\n }\n : { ...common, environment: \"production\" };\n}\n\nfunction createSessionMetadata(metadata?: Record<string, string>) {\n return metadata ? { metadata } : {};\n}\n\nfunction createStripeProviderOptions(\n loaded: LoadedCheckout | null,\n accentColor: string | undefined,\n theme: \"dark\" | \"light\" | undefined\n) {\n if (!loaded) {\n return null;\n }\n const accent = accentColor ?? \"#38d77a\";\n const light = theme === \"light\";\n return {\n clientSecret: loaded.session.clientSecret,\n elementsOptions: {\n appearance: {\n rules: {\n \".Input:focus\": {\n borderColor: accent,\n boxShadow: `0 0 0 1px ${accent}`,\n outline: \"none\",\n },\n },\n theme: light ? (\"stripe\" as const) : (\"night\" as const),\n variables: {\n borderRadius: \"10px\",\n colorBackground: light ? \"#f5f6f7\" : \"#121212\",\n colorDanger: light ? \"#c52b3e\" : \"#f08a98\",\n colorPrimary: accent,\n colorText: light ? \"#121416\" : \"#ffffff\",\n colorTextPlaceholder: light ? \"#72767d\" : \"#6b6b6b\",\n colorTextSecondary: light ? \"#62666d\" : \"#a1a1aa\",\n focusBoxShadow: \"none\",\n focusOutline: \"none\",\n fontSizeBase: \"16px\",\n },\n },\n syncAddressCheckbox: \"none\" as const,\n },\n };\n}\n\nfunction CheckoutBridge({\n children,\n loaded,\n}: PropsWithChildren<{ loaded: LoadedCheckout }>) {\n const result = useCheckoutElements();\n if (result.type === \"loading\") {\n return <PaymentSkeleton />;\n }\n if (result.type === \"error\") {\n return <div role=\"alert\">{result.error.message}</div>;\n }\n return (\n <ReadyCheckoutBridge checkout={result.checkout} loaded={loaded}>\n {children}\n </ReadyCheckoutBridge>\n );\n}\n\nfunction initialPricing(loaded: LoadedCheckout) {\n return {\n includeServiceFee: loaded.includeServiceFee,\n serviceFeeAmountCents: Math.round(\n (loaded.subtotalCents *\n loaded.catalog.pricingPolicy.serviceFeeRateBasisPoints) /\n 10_000\n ),\n subtotalCents: loaded.subtotalCents,\n tipCents: loaded.tipCents,\n };\n}\n\nfunction ReadyCheckoutBridge({\n checkout,\n children,\n loaded,\n}: PropsWithChildren<{\n checkout: StripeCheckoutElementsValue;\n loaded: LoadedCheckout;\n}>) {\n const [pricing, setPricing] = useState(() => initialPricing(loaded));\n useEffect(() => {\n setPricing(initialPricing(loaded));\n }, [loaded]);\n const value: CheckoutContextValue = {\n async applyPromoCode(promoCode) {\n const update = await checkout.runServerUpdate(() =>\n loaded.client.updateSessionDiscount({\n paymentReference: loaded.session.paymentReference,\n ...(promoCode.trim() ? { promoCode: promoCode.trim() } : {}),\n })\n );\n return update.type === \"error\" ? update.error.message : null;\n },\n catalog: loaded.catalog,\n async confirm(contact) {\n if (contact.shippingMatchesBilling) {\n if (!checkout.billingAddress) {\n throw new Error(\"Billing address is required.\");\n }\n const addressUpdate = await checkout.updateShippingAddress(\n checkout.billingAddress\n );\n if (addressUpdate.type === \"error\") {\n throw new Error(addressUpdate.error.message);\n }\n }\n const detailsUpdate = await checkout.runServerUpdate(() =>\n loaded.client.updateSessionDetails({\n ...(contact.customFieldAnswers\n ? { customFieldAnswers: contact.customFieldAnswers }\n : {}),\n email: contact.email,\n ...(contact.memberId ? { memberId: contact.memberId } : {}),\n ...(contact.merchSize ? { merchSize: contact.merchSize } : {}),\n paymentReference: loaded.session.paymentReference,\n ...(contact.phone ? { phone: contact.phone } : {}),\n })\n );\n if (detailsUpdate.type === \"error\") {\n throw new Error(detailsUpdate.error.message);\n }\n const prepared = await prepareCheckoutContact(\n checkout,\n contact.email,\n contact.phone ?? \"\",\n checkout.total.total.minorUnitsAmount > 0\n );\n if (\"error\" in prepared) {\n throw new Error(prepared.error);\n }\n const confirmation = await checkout.confirm({\n email: prepared.email,\n ...(prepared.phone ? { phoneNumber: prepared.phone } : {}),\n redirect: \"if_required\",\n });\n if (confirmation.type === \"error\") {\n throw new Error(confirmation.error.message);\n }\n return {\n paymentReference: loaded.session.paymentReference,\n sessionId: loaded.session.sessionId,\n };\n },\n paymentReference: loaded.session.paymentReference,\n pricing,\n totalCents: checkout.total.total.minorUnitsAmount,\n async updatePricing(input) {\n let updatedPricing: LockerverseCheckoutSessionPricing | undefined;\n const update = await checkout.runServerUpdate(() =>\n loaded.client\n .updateSessionPricing({\n ...input,\n paymentReference: loaded.session.paymentReference,\n })\n .then((response) => {\n updatedPricing = response;\n return response;\n })\n );\n if (update.type === \"error\") {\n throw new Error(update.error.message);\n }\n if (!updatedPricing) {\n throw new Error(\"Lockerverse returned no updated pricing.\");\n }\n const nextPricing = updatedPricing;\n setPricing((current) => ({\n ...current,\n includeServiceFee: nextPricing.includeServiceFee,\n tipCents: nextPricing.tipCents,\n }));\n return nextPricing;\n },\n };\n return (\n <CheckoutContext.Provider value={value}>\n {children}\n </CheckoutContext.Provider>\n );\n}\n\nexport function LockerverseCheckoutSessionProvider(\n props: LockerverseCheckoutSessionProviderProps\n) {\n const [loaded, setLoaded] = useState<LoadedCheckout | null>(null);\n const [failure, setFailure] = useState<string | null>(null);\n const [revision, setRevision] = useState(0);\n const preparation = useRef<{\n clientOptions: CreateLockerverseWidgetOptions;\n promise: Promise<LoadedCheckout>;\n } | null>(null);\n const currentCheckoutKey = JSON.stringify({\n email: props.email,\n includeServiceFee: props.includeServiceFee,\n metadata: props.metadata,\n returnUrl: props.returnUrl,\n selection: props.selection,\n tipCents: props.tipCents,\n });\n const initialCheckout = useRef({\n email: props.email,\n includeServiceFee: props.includeServiceFee,\n key: currentCheckoutKey,\n metadata: props.metadata,\n requestKey: globalThis.crypto.randomUUID(),\n returnUrl: props.returnUrl,\n selection: props.selection,\n tipCents: props.tipCents,\n });\n const clientOptions = useMemo(\n () => createClientOptions(props),\n [\n props.apiBaseUrl,\n props.communitySlug,\n props.environment,\n props.fetch,\n props.onError,\n props.requestTimeoutMs,\n props.sentryDsn,\n props.widgetSlug,\n ]\n );\n\n useEffect(() => {\n let active = true;\n if (preparation.current?.clientOptions !== clientOptions || revision > 0) {\n const client = createLockerverseCheckoutClient(clientOptions);\n const checkoutInput = initialCheckout.current;\n preparation.current = {\n clientOptions,\n promise: (async () => {\n const catalog = await client.load();\n const items = resolveItems(catalog, checkoutInput.selection);\n const subtotalCents = getSelectionSubtotalCents(\n catalog,\n checkoutInput.selection\n );\n const includeServiceFee =\n checkoutInput.includeServiceFee ?? catalog.widget.fields.serviceFee;\n const tipCents =\n checkoutInput.tipCents ??\n (catalog.widget.fields.tipping\n ? Math.round(subtotalCents * 0.1)\n : 0);\n const session = await client.createSession({\n ...(checkoutInput.email ? { email: checkoutInput.email } : {}),\n ...(catalog.widget.fields.serviceFee ? { includeServiceFee } : {}),\n items,\n ...createSessionMetadata(checkoutInput.metadata),\n requestKey: checkoutInput.requestKey,\n returnUrl: checkoutInput.returnUrl,\n ...(catalog.widget.fields.tipping ? { tipCents } : {}),\n });\n return {\n catalog,\n client,\n includeServiceFee,\n returnUrl: checkoutInput.returnUrl,\n session,\n subtotalCents,\n tipCents,\n };\n })(),\n };\n }\n setLoaded(null);\n setFailure(null);\n preparation.current.promise\n .then((next) => {\n if (active) {\n setLoaded(next);\n }\n })\n .catch((error: unknown) => {\n if (active) {\n setFailure(\n error instanceof Error ? error.message : \"Unable to load checkout.\"\n );\n }\n });\n return () => {\n active = false;\n };\n }, [clientOptions, revision]);\n\n const stripe = useMemo(() => {\n if (!loaded) {\n return null;\n }\n const stripeLoader = props.unstable_stripeLoader ?? loadStripe;\n return stripeLoader(loaded.catalog.payment.publishableKey, {\n betas: [\"custom_checkout_server_updates_1\"],\n ...(loaded.session.connectedAccountId\n ? { stripeAccount: loaded.session.connectedAccountId }\n : {}),\n });\n }, [loaded, props.unstable_stripeLoader]);\n const providerOptions = useMemo(\n () =>\n createStripeProviderOptions(\n loaded,\n props.accentColor ??\n loaded?.catalog.community?.accentColor ??\n undefined,\n props.theme\n ),\n [loaded, props.accentColor, props.theme]\n );\n\n if (currentCheckoutKey !== initialCheckout.current.key) {\n return (\n <div className=\"lockerverse-payment__payment-status\" role=\"alert\">\n Checkout selection changed. Remount this payment component for the new\n selection.\n </div>\n );\n }\n if (failure) {\n return (\n <div className=\"lockerverse-payment__payment-status\" role=\"alert\">\n <p>{failure}</p>\n <button onClick={() => setRevision((value) => value + 1)} type=\"button\">\n Try again\n </button>\n </div>\n );\n }\n if (!(loaded && providerOptions)) {\n return <PaymentSkeleton />;\n }\n\n return (\n <CheckoutElementsProvider options={providerOptions} stripe={stripe}>\n <CheckoutBridge loaded={loaded}>{props.children}</CheckoutBridge>\n </CheckoutElementsProvider>\n );\n}\n\nexport function useLockerverseCheckoutSession() {\n const value = useContext(CheckoutContext);\n if (!value) {\n throw new Error(\n \"useLockerverseCheckoutSession must be used inside LockerverseCheckoutSessionProvider.\"\n );\n }\n return value;\n}\n\nasync function prepareCheckoutContact(\n checkout: StripeCheckoutElementsValue,\n email: string,\n phone: string,\n requirePaymentDetails: boolean\n) {\n const normalizedEmail = email.trim().toLowerCase();\n if (!normalizedEmail) {\n return { error: \"Email is required.\" } as const;\n }\n const emailResult = await checkout.updateEmail(normalizedEmail);\n if (emailResult.type === \"error\") {\n return { error: emailResult.error.message } as const;\n }\n const normalizedPhone = phone.trim();\n if (normalizedPhone) {\n const phoneResult = await checkout.updatePhoneNumber(normalizedPhone);\n if (phoneResult.type === \"error\") {\n return { error: \"Phone number is invalid.\" } as const;\n }\n }\n if (requirePaymentDetails) {\n const validation = await checkout.validateElements();\n if (validation.type === \"error\") {\n return { error: validation.error.message } as const;\n }\n }\n return { email: normalizedEmail, phone: normalizedPhone } as const;\n}\n\nfunction getPaymentButtonLabel(totalCents: number, tipCents: number) {\n if (totalCents === 0) {\n return \"Complete free order\";\n }\n if (tipCents > 0) {\n return `Process Payment ($${((totalCents - tipCents) / 100).toFixed(2)}) + $${(tipCents / 100).toFixed(2)} tip`;\n }\n return `Process Payment ($${(totalCents / 100).toFixed(2)})`;\n}\n\nfunction buildCheckoutContact({\n catalog,\n customFieldValues,\n email,\n memberId,\n merchSize,\n phone,\n phoneCountry,\n shippingMatchesBilling,\n}: {\n catalog: LockerverseCatalog;\n customFieldValues: Record<string, string | string[]>;\n email: string;\n memberId: string;\n merchSize: string;\n phone: string;\n phoneCountry: string;\n shippingMatchesBilling: boolean;\n}): Parameters<CheckoutContextValue[\"confirm\"]>[0] {\n return {\n customFieldAnswers: catalog.widget.customFields.map((field) => ({\n fieldId: field.id,\n value: customFieldValues[field.id] ?? null,\n })) as LockerverseCustomFieldAnswer[],\n email,\n ...(memberId ? { memberId } : {}),\n ...(merchSize\n ? {\n merchSize: merchSize as\n | \"XS\"\n | \"S\"\n | \"M\"\n | \"L\"\n | \"XL\"\n | \"XXL\"\n | \"XXXL\",\n }\n : {}),\n ...(phone ? { phone: getInternationalPhone(phone, phoneCountry) } : {}),\n ...(catalog.widget.fields.shipping ? { shippingMatchesBilling } : {}),\n };\n}\n\nexport function LockerverseCheckoutSessionPaymentForm({\n branding,\n onComplete,\n}: {\n branding?: LockerversePaymentBranding;\n onComplete?: (result: LockerversePaymentCompletion) => void;\n}) {\n const {\n applyPromoCode,\n catalog,\n confirm,\n pricing,\n totalCents,\n updatePricing,\n } = useLockerverseCheckoutSession();\n const resolvedBranding = catalog.community\n ? {\n accentColor: catalog.community.accentColor ?? undefined,\n imageUrl: catalog.community.imageUrl,\n name: catalog.community.name,\n ...branding,\n }\n : branding;\n const [email, setEmail] = useState(\"\");\n const [phone, setPhone] = useState(\"\");\n const [phoneCountry, setPhoneCountry] = useState(\"US\");\n const [memberId, setMemberId] = useState(\"\");\n const [merchSize, setMerchSize] = useState(\"M\");\n const [customFieldValues, setCustomFieldValues] = useState<\n Record<string, string | string[]>\n >({});\n const [promoCode, setPromoCode] = useState(\"\");\n const [message, setMessage] = useState<string | null>(null);\n const [busy, setBusy] = useState(false);\n const [pricingBusy, setPricingBusy] = useState(false);\n const [isBillingAddressReady, setIsBillingAddressReady] = useState(false);\n const [isPaymentReady, setIsPaymentReady] = useState(false);\n const [isShippingAddressReady, setIsShippingAddressReady] = useState(false);\n const [shippingMatchesBilling, setShippingMatchesBilling] = useState(true);\n const initialTipOption =\n TIP_OPTIONS.find(\n (option) =>\n option.percent !== null &&\n Math.round((pricing.subtotalCents * option.percent) / 100) ===\n pricing.tipCents\n )?.value ?? \"custom\";\n const [tipOption, setTipOption] = useState(initialTipOption);\n const [tipInput, setTipInput] = useState(\n initialTipOption === \"custom\" && pricing.tipCents > 0\n ? (pricing.tipCents / 100).toFixed(2)\n : \"\"\n );\n const committedPricing = useRef({\n includeServiceFee: pricing.includeServiceFee,\n tipCents: pricing.tipCents,\n });\n const pendingPricing = useRef<Promise<boolean>>(Promise.resolve(true));\n useEffect(() => {\n committedPricing.current = {\n includeServiceFee: pricing.includeServiceFee,\n tipCents: pricing.tipCents,\n };\n }, [pricing.includeServiceFee, pricing.tipCents]);\n\n function savePricing(next: { includeServiceFee: boolean; tipCents: number }) {\n const operation = (async () => {\n setPricingBusy(true);\n setMessage(null);\n try {\n const updated = await updatePricing(next);\n committedPricing.current = {\n includeServiceFee: updated.includeServiceFee,\n tipCents: updated.tipCents,\n };\n return true;\n } catch (error) {\n setMessage(\n error instanceof Error ? error.message : \"Unable to update checkout.\"\n );\n return false;\n } finally {\n setPricingBusy(false);\n }\n })();\n pendingPricing.current = operation;\n return operation;\n }\n\n async function selectTip(option: (typeof TIP_OPTIONS)[number]) {\n if (option.percent === null) {\n setTipOption(option.value);\n return;\n }\n const nextTipCents = Math.round(\n (pricing.subtotalCents * option.percent) / 100\n );\n const updated = await savePricing({\n includeServiceFee: pricing.includeServiceFee,\n tipCents: nextTipCents,\n });\n if (updated) {\n setTipInput(\"\");\n setTipOption(option.value);\n }\n }\n\n function applyCustomTip() {\n const nextTipCents = parseCustomTipCents(tipInput);\n if (nextTipCents === null) {\n setMessage(\"Enter a valid tip with no more than two decimal places.\");\n return;\n }\n return savePricing({\n includeServiceFee: pricing.includeServiceFee,\n tipCents: nextTipCents,\n });\n }\n\n async function changeServiceFee(nextIncludeServiceFee: boolean) {\n await savePricing({\n includeServiceFee: nextIncludeServiceFee,\n tipCents: pricing.tipCents,\n });\n }\n async function updateDiscount() {\n setBusy(true);\n setMessage(null);\n try {\n setMessage(await applyPromoCode(promoCode));\n } catch (error) {\n setMessage(\n error instanceof Error ? error.message : \"Unable to update checkout.\"\n );\n } finally {\n setBusy(false);\n }\n }\n\n async function commitPricingBeforeSubmit() {\n if (!(await pendingPricing.current)) {\n return false;\n }\n if (tipOption !== \"custom\") {\n return true;\n }\n const nextTipCents = parseCustomTipCents(tipInput);\n if (nextTipCents === null) {\n setMessage(\"Enter a valid tip with no more than two decimal places.\");\n return false;\n }\n if (nextTipCents === committedPricing.current.tipCents) {\n return true;\n }\n return savePricing({\n includeServiceFee: committedPricing.current.includeServiceFee,\n tipCents: nextTipCents,\n });\n }\n\n async function submit(event: FormEvent) {\n event.preventDefault();\n setBusy(true);\n setMessage(null);\n try {\n if (!(await commitPricingBeforeSubmit())) {\n return;\n }\n const completion = await confirm(\n buildCheckoutContact({\n catalog,\n customFieldValues,\n email,\n memberId,\n merchSize,\n phone,\n phoneCountry,\n shippingMatchesBilling,\n })\n );\n onComplete?.(completion);\n } catch (error) {\n setMessage(\n error instanceof Error ? error.message : \"Unable to complete checkout.\"\n );\n } finally {\n setBusy(false);\n }\n }\n\n return (\n <form className=\"lockerverse-payment__form\" onSubmit={submit}>\n <header>\n {catalog.widget.showCommunityBranding && resolvedBranding ? (\n <div className=\"lockerverse-payment__branding\">\n {resolvedBranding.imageUrl ? (\n <img\n alt={resolvedBranding.name}\n height=\"48\"\n src={resolvedBranding.imageUrl}\n width=\"48\"\n />\n ) : null}\n <strong>{resolvedBranding.name}</strong>\n </div>\n ) : null}\n <h1>{catalog.widget.title ?? catalog.widget.name}</h1>\n {catalog.widget.description ? (\n <p>{catalog.widget.description}</p>\n ) : null}\n </header>\n <TipSelector\n busy={busy || pricingBusy}\n enabled={catalog.widget.fields.tipping}\n onCustomTipBlur={applyCustomTip}\n onCustomTipChange={setTipInput}\n onSelect={selectTip}\n tipInput={tipInput}\n tipOption={tipOption}\n />\n <ContactFields\n email={email}\n fields={catalog.widget.fields}\n onEmailChange={setEmail}\n onPhoneChange={setPhone}\n onPhoneCountryChange={setPhoneCountry}\n phone={phone}\n phoneCountry={phoneCountry}\n />\n <StripeCheckoutFields\n fields={catalog.widget.fields}\n isBillingAddressReady={isBillingAddressReady}\n isPaymentReady={isPaymentReady}\n isShippingAddressReady={isShippingAddressReady}\n onBillingAddressReady={() => setIsBillingAddressReady(true)}\n onPaymentReady={() => setIsPaymentReady(true)}\n onShippingAddressReady={() => setIsShippingAddressReady(true)}\n onShippingMatchesBillingChange={(value) => {\n setShippingMatchesBilling(value);\n if (!value) {\n setIsShippingAddressReady(false);\n }\n }}\n shippingMatchesBilling={shippingMatchesBilling}\n totalCents={totalCents}\n />\n <CustomerFields\n fields={catalog.widget.fields}\n memberId={memberId}\n merchSize={merchSize}\n onMemberIdChange={setMemberId}\n onMerchSizeChange={setMerchSize}\n />\n {catalog.widget.fields.promoCode ? (\n <div className=\"lockerverse-payment__additional-fields\">\n <label>\n <span>Promo code</span>\n <input\n name=\"promoCode\"\n onChange={(event) => setPromoCode(event.currentTarget.value)}\n placeholder=\"Optional\"\n value={promoCode}\n />\n </label>\n <button disabled={busy} onClick={updateDiscount} type=\"button\">\n {promoCode.trim() ? \"Apply code\" : \"Remove code\"}\n </button>\n </div>\n ) : null}\n {catalog.widget.customFields.length ? (\n <div className=\"lockerverse-payment__custom-fields\">\n <LockerverseCustomFields\n fields={catalog.widget.customFields}\n onChange={(fieldId, value) =>\n setCustomFieldValues((current) => ({\n ...current,\n [fieldId]: value,\n }))\n }\n values={customFieldValues}\n />\n </div>\n ) : null}\n {message ? <div role=\"alert\">{message}</div> : null}\n <div className=\"lockerverse-payment__actions\">\n {catalog.widget.fields.serviceFee ? (\n <label className=\"lockerverse-payment__check-row\">\n <input\n checked={pricing.includeServiceFee}\n disabled={busy || pricingBusy}\n name=\"includeServiceFee\"\n onChange={(event) =>\n changeServiceFee(event.currentTarget.checked)\n }\n type=\"checkbox\"\n />\n <span>\n Add {formatMoney(pricing.serviceFeeAmountCents)} to help cover\n processing fees\n </span>\n </label>\n ) : null}\n <button disabled={busy} type=\"submit\">\n {getPaymentButtonLabel(totalCents, pricing.tipCents)}\n </button>\n </div>\n </form>\n );\n}\n\nexport function LockerversePayment(props: LockerversePaymentProps) {\n const selectPortalContainerRef = useRef<HTMLElement | null>(null);\n const {\n apiBaseUrl,\n branding,\n className,\n communitySlug,\n environment,\n fetch,\n includeServiceFee,\n metadata,\n onError,\n onPaymentComplete,\n requestTimeoutMs,\n returnUrl,\n selection,\n sentryDsn,\n unstable_stripeLoader,\n style,\n theme = \"dark\",\n tipCents,\n widgetSlug,\n ...sectionProps\n } = props;\n const destination =\n returnUrl ??\n (typeof globalThis.location === \"undefined\"\n ? \"https://lockerverse.com\"\n : globalThis.location.href);\n const rootClassName = [\"lockerverse-payment\", className]\n .filter(Boolean)\n .join(\" \");\n const clientOptions = apiBaseUrl\n ? { apiBaseUrl, communitySlug, environment, widgetSlug }\n : { communitySlug, environment: \"production\" as const, widgetSlug };\n const accentColor = style?.[\"--lockerverse-accent\"] ?? branding?.accentColor;\n const rootStyle = accentColor\n ? ({\n ...style,\n \"--lockerverse-accent\": accentColor,\n \"--lockerverse-accent-contrast\":\n style?.[\"--lockerverse-accent-contrast\"] ??\n getAccentContrast(accentColor) ??\n \"#08110c\",\n } as const)\n : style;\n\n return (\n <section\n {...sectionProps}\n className={rootClassName}\n data-lockerverse-theme={theme}\n ref={selectPortalContainerRef}\n style={rootStyle}\n >\n <SelectPortalProvider container={selectPortalContainerRef}>\n <LockerverseCheckoutSessionProvider\n {...clientOptions}\n {...(accentColor ? { accentColor } : {})}\n {...(fetch ? { fetch } : {})}\n {...(includeServiceFee === undefined ? {} : { includeServiceFee })}\n {...(metadata ? { metadata } : {})}\n {...(onError ? { onError } : {})}\n {...(requestTimeoutMs === undefined ? {} : { requestTimeoutMs })}\n returnUrl={destination}\n selection={selection}\n {...(sentryDsn === undefined ? {} : { sentryDsn })}\n {...(unstable_stripeLoader ? { unstable_stripeLoader } : {})}\n theme={theme}\n {...(tipCents === undefined ? {} : { tipCents })}\n >\n <LockerverseCheckoutSessionPaymentForm\n {...(branding ? { branding } : {})}\n {...(onPaymentComplete ? { onComplete: onPaymentComplete } : {})}\n />\n </LockerverseCheckoutSessionProvider>\n </SelectPortalProvider>\n </section>\n );\n}\n"],"mappings":"ylBAAA,MAAM,EAAY,8BAElB,SAAS,EAAc,EAAe,CACpC,IAAM,EAAQ,EAAU,KAAK,EAAM,KAAK,CAAC,EACzC,GAAI,CAAC,EACH,OAEF,GAAM,EAAG,GAAS,EAClB,GAAI,CAAC,EACH,OAEF,IA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AAA,CACiC,CAAA,CAChB,CAAA,CACf,CAAA,CAEb"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lockerverse/react",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.27",
|
|
4
4
|
"description": "React payment UI for Lockerverse",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@base-ui/react": "1.6.0",
|
|
33
33
|
"valibot": "1.4.2",
|
|
34
|
-
"@lockerverse/sdk": "0.2.
|
|
34
|
+
"@lockerverse/sdk": "0.2.27"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@size-limit/file": "13.0.3",
|