@lockerverse/react 0.2.209 → 0.2.210
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/MIGRATIONS.md +17 -0
- package/dist/auction-payment-view.js +1 -1
- package/dist/auction-payment-view.js.map +1 -1
- package/dist/lockerverse-payment.js +1 -1
- package/dist/lockerverse-payment.js.map +1 -1
- package/guides/auctions.md +1 -1
- package/guides/events.md +1 -1
- package/guides/integration.md +1 -1
- package/guides/payment-widgets.md +7 -2
- package/guides/signup.md +1 -1
- package/package.json +2 -2
package/MIGRATIONS.md
CHANGED
|
@@ -36,6 +36,23 @@ If it cannot be found, report that limit and use the baseline review below. Do n
|
|
|
36
36
|
claim that every historical migration was applied. Read this file even if the
|
|
37
37
|
version already matches: a previous upgrade may have missed host adoption steps.
|
|
38
38
|
|
|
39
|
+
## 0.2.210 — Apple Pay and Google Pay
|
|
40
|
+
|
|
41
|
+
- **Affected:** React payment widgets, donate launchers, and auction checkout,
|
|
42
|
+
including bid payment-method setup.
|
|
43
|
+
- **Automatic:** allows Apple Pay and Google Pay when Stripe reports that the
|
|
44
|
+
wallet is available. Existing card, ACH, and off-session setup rules remain.
|
|
45
|
+
- **Required:** upgrade matching SDK/React packages and deploy each host. Enable
|
|
46
|
+
both wallets in Stripe and register every checkout domain and subdomain on
|
|
47
|
+
the account that takes the charge, including connected accounts for direct
|
|
48
|
+
charges. For cross-origin embeds, register both the host and iframe domains
|
|
49
|
+
and set `allow="payment *"` on every containing iframe. A restrictive
|
|
50
|
+
`Permissions-Policy` header must also permit payment for these origins.
|
|
51
|
+
- **Check:** use HTTPS and an eligible browser with a configured wallet. Check
|
|
52
|
+
direct checkout and embedded checkout on desktop and mobile. Stripe controls
|
|
53
|
+
wallet availability; unsupported devices can continue to use card entry.
|
|
54
|
+
No SDK prop changes or live transactions are required for this check.
|
|
55
|
+
|
|
39
56
|
## 0.2.209 — slightly stronger ticket tint
|
|
40
57
|
|
|
41
58
|
- **Affected:** React donate launcher ticket products with community branding.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as e}from"./use-auction-boundary.js";import{a as t,i as n,n as r,o as i,r as a,s as o,t as s}from"./auction-payment.js";import{t as c}from"./host-callback.js";import{d as l,n as u,p as d,r as f,t as p,u as m}from"./phone-field.js";import{i as h,n as g,t as _}from"./stripe-loader.js";import{ArrowRight as v,ChevronLeft as y}from"lucide-react";import{useEffect as b,useId as x,useRef as S,useState as C}from"react";import{Fragment as w,jsx as T,jsxs as E}from"react/jsx-runtime";import{LockerverseSdkError as D}from"@lockerverse/sdk/auctions";import{AddressElement as O,Elements as k,PaymentElement as A,useElements as ee,useStripe as te}from"@stripe/react-stripe-js";function j(e){return{business:{name:`Lockerverse`},fields:{billingDetails:{address:`never`,email:`never`,name:`never`,phone:`never`}},terms:{applePay:e?`auto`:`never`,auBecsDebit:`never`,bancontact:`never`,card:`always`,cashapp:`never`,googlePay:`never`,ideal:`never`,paypal:e?`auto`:`never`,sepaDebit:`never`,sofort:`never`,usBankAccount:`never`},wallets:{applePay:e?`auto`:`never`,googlePay:`never`}}}function ne(e){let{isPurchase:t,isMaximumBid:n,item:r,id:i}=e;return E(`form`,{className:`lockerverse-auctions__checkout`,noValidate:!0,onSubmit:e.onSubmit,children:[E(`div`,{className:`lockerverse-auctions__checkout-header`,children:[E(`div`,{className:`lockerverse-auctions__checkout-navigation`,children:[T(`button`,{"aria-label":`Back`,className:`lockerverse-auctions__checkout-back`,disabled:!e.onBack,onClick:e.onBack,type:`button`,children:T(y,{"aria-hidden":`true`,size:20})}),E(`div`,{children:[T(`p`,{className:`lockerverse-auctions__checkout-eyebrow`,children:`Step 2 of 2`}),T(`p`,{children:t?`Secure checkout`:`Secure payment method`})]})]}),T(`p`,{className:`lockerverse-auctions__checkout-eyebrow`,children:e.communityName}),T(`h2`,{children:t?`Finalize your purchase.`:`Finalize your bid authorization.`}),T(P,{...e}),r.collectShippingAddress&&E(`div`,{className:`lockerverse-auctions__checkout-physical`,children:[T(`p`,{className:`lockerverse-auctions__checkout-eyebrow`,children:`Physical item`}),T(`p`,{children:`This item requires a delivery address. Billing details are used by default, and you can switch to a separate delivery address below if needed.`})]})]}),E(`div`,{className:`lockerverse-auctions__checkout-body`,children:[e.showFields&&E(`fieldset`,{disabled:e.locked,children:[E(`div`,{className:`lockerverse-auctions__checkout-contact`,children:[T(l,{error:e.contactErrors.email,id:`${i}-email`,label:`Email`,name:`email`,onChange:t=>e.onEmailChange(t.target.value),required:!0,value:e.email}),T(d,{error:e.contactErrors.phone,id:`${i}-phone`,label:`Phone`,children:T(p,{country:e.phoneCountry,error:e.contactErrors.phone,errorId:`${i}-phone-error`,id:`${i}-phone`,name:`phone`,onChange:e.onPhoneChange,required:!0,value:e.phone})})]}),E(`section`,{"aria-label":`Payment Information`,className:`lockerverse-auctions__checkout-section`,children:[E(`div`,{className:`lockerverse-auctions__checkout-section-heading`,children:[T(`h3`,{children:`Payment Information`}),T(`p`,{children:t?`Processed securely and charged immediately for this purchase.`:`Stored securely and charged only if your bid finishes on top.`})]}),T(A,{onLoadError:e.onPaymentLoadError,options:j(t)})]}),E(`section`,{"aria-label":`Billing Details`,className:`lockerverse-auctions__checkout-section`,children:[T(`h3`,{children:`Billing Details`}),T(O,{onChange:e.onBillingChange,options:{mode:`billing`}}),T(`p`,{children:t?`Use your full name here. We use the email and phone above for purchase confirmation and fulfillment updates.`:`Use the bidder's full name here. We use the email and phone above to contact you if this bid is outbid or wins.`})]}),r.collectShippingAddress&&E(`section`,{"aria-label":`Delivery Details`,className:`lockerverse-auctions__checkout-section`,children:[E(`label`,{className:`lockerverse-auctions__checkout-checkbox lockerverse-auctions__checkout-delivery`,htmlFor:`${i}-delivery-same-as-billing`,children:[T(m,{checked:e.sameAsBilling,id:`${i}-delivery-same-as-billing`,onChange:t=>e.onSameAsBillingChange(t.target.checked)}),E(`span`,{children:[T(`strong`,{children:`Delivery address is the same as billing`}),T(`span`,{children:`Leave this on for the fastest flow. Turn it off only if the delivery address should differ from the billing details above.`})]})]}),!e.sameAsBilling&&E(w,{children:[T(`h3`,{children:`Delivery Address`}),T(O,{onChange:e.onShippingChange,options:{mode:`shipping`}})]})]}),T(N,{isMaximumBid:n,isPurchase:t,pricing:e.pricing}),e.serviceFeeEnabled&&T(M,{...e})]}),e.message&&T(`p`,{"aria-live":`polite`,className:`lockerverse-auctions__notice`,role:`status`,children:e.message}),!e.isTerminal&&E(`div`,{className:`lockerverse-auctions__checkout-footer`,children:[E(`p`,{children:[t?`By continuing, you agree to be charged for this purchase.`:`By continuing, you agree to have this payment method stored for item settlement if your bid is the winning offer.`,r.collectShippingAddress?` Your delivery details are stored with the ${t?`order`:`bid`} so the seller can fulfill the item after payment.`:``]}),E(`button`,{className:`lockerverse-auctions__button lockerverse-auctions__checkout-submit`,disabled:e.submitDisabled,type:`submit`,children:[e.buttonText,T(v,{"aria-hidden":`true`,size:16})]})]})]})]})}function M(t){let{isPurchase:n,isMaximumBid:r,pricing:i}=t,a=F(n,r);return T(`section`,{"aria-label":`Processing fees`,className:`lockerverse-auctions__checkout-section`,children:t.onIncludeServiceFeeChange?E(`label`,{className:`lockerverse-auctions__checkout-checkbox`,htmlFor:`${t.id}-service-fee`,children:[T(m,{checked:t.includeServiceFee,id:`${t.id}-service-fee`,onChange:e=>t.onIncludeServiceFeeChange?.(e.target.checked)}),E(`span`,{children:[E(`strong`,{children:[a.fee,` `,e(t.serviceFeeCents),` to help cover processing fees`]}),E(`span`,{children:[a.total,`: `,e(i.totalCents)]})]})]}):E(`p`,{children:[a.total,`: `,e(i.totalCents)]})})}function N({pricing:t,isPurchase:n,isMaximumBid:r}){let i=F(n,r);return t.additionalCharge?E(`section`,{"aria-label":`Order amounts`,className:`lockerverse-auctions__checkout-section`,children:[E(`p`,{children:[i.amount,`: `,e(t.subtotalCents)]}),E(`p`,{children:[t.additionalCharge.name,`:`,` `,e(t.additionalChargeCents??0)]}),E(`p`,{children:[i.total,`: `,e(t.totalCents)]})]}):null}function P(t){let{isPurchase:n,isMaximumBid:r,item:i,pricing:a}=t;return T(`p`,{className:`lockerverse-auctions__checkout-summary`,children:n?E(w,{children:[`Pay `,T(`strong`,{children:e(a.totalCents)}),` for`,` `,t.quantity,` `,t.quantity===1?`item`:`items`,` of`,` `,T(`strong`,{children:i.name}),`. Your card is charged immediately once checkout succeeds.`]}):E(w,{children:[`Authorize a payment method for your`,` `,r?`maximum bid`:`bid`,` of`,` `,T(`strong`,{children:e(a.subtotalCents)}),` on`,` `,T(`strong`,{children:i.name}),`. Your card is only charged if this bid wins the item.`,r?` You pay the final winning price, up to your maximum, plus any agreed fees and additional charges. Your maximum stays private.`:``]})})}function F(e,t){return e?{amount:`Subtotal`,fee:`Add`,total:`Total`}:t?{amount:`Maximum bid`,fee:`If I win, add up to`,total:`Maximum total if I win`}:{amount:`Bid amount`,fee:`If I win, add`,total:`Total if I win`}}function re(e,t,n){return e===`busy`?n?`Processing...`:`Authorizing...`:e===`retry`?`Retry original purchase`:t?`Check purchase status`:n?`Buy Now`:`Authorize Bid`}function I(e){let{auction:l,item:d,selection:p,client:m,onReview:g,onBack:_}=e,v=te(),y=ee(),w=x(),[E,O]=C(e.contact?.email??``),[k,A]=C(e.contact?.phone??``),[j,M]=C(()=>f(e.contact?.phone??``)),[N,P]=C({}),[F,I]=C(!0),[L,ie]=C(null),[ae,oe]=C(null),[R,se]=C(e.resumePurchase??null),[z,ce]=C(e.resumePurchase?`pending`:`ready`),[le,ue]=C(null),B=S(e.resumePurchase?.submission.clientRequestId??null),V=z===`complete`||z===`uncertain`,H=S(!1),U=S(!0),W=S(e);W.current=e;let G=S(!1);function K(e){U.current&&ce(e),c(W.current.onInteractionLockChange,e!==`ready`&&e!==`complete`)}function q(e){U.current&&ue(e)}function J(e){K(e===`bid`?`uncertain`:`pending`),q(e===`bid`?`We could not confirm your bid. Do not submit another bid until you check your email or contact the auction organizer.`:`We could not confirm the purchase result. Check its status using the same purchase request.`),G.current||(G.current=!0,c(W.current.onUncertain,e))}b(()=>(U.current=!0,()=>{U.current=!1}),[]);let Y=!!(R??e.resumePurchase)||d.saleMode===`buy_now`,X=R?.pricing??e.resumePurchase?.pricing??t(l,d,p),de=R?.payment??e.resumePurchase?.payment??l.payment;function Z(e){U.current&&se(e),c(W.current.onPurchaseRecoveryChange,e)}function fe(e){e.status===`paid`?(B.current=null,Z(null),K(`complete`),c(W.current.onResult,{additionalCharge:e.additionalCharge??null,additionalChargeCents:e.additionalChargeCents??0,kind:`purchase`,purchaseId:e.purchaseId,quantity:e.quantity,serviceFeeCents:e.serviceFeeCents,status:`paid`,subtotalCents:e.subtotalCents,totalCents:e.totalCents,unitAmountCents:e.subtotalCents/e.quantity}),G.current||(G.current=!0,c(W.current.onPurchaseComplete,e))):e.status===`pending_payment`?(K(`pending`),q(`Your purchase is pending. Check its status before making another payment.`)):(B.current=null,Z(null),K(`ready`),q(`This purchase is ${e.status.replaceAll(`_`,` `)}. You can start a new purchase.`))}function pe(){let e=u(k,j),t=h({email:E,phone:e},!0);return P(t.errors),t.value?{email:t.value.email,phone:e}:(document.getElementById(`${w}-${t.errors.email?`email`:`phone`}`)?.focus(),null)}function me(){let e=W.current.selection;if(p.quantity!==e.quantity||p.amount!==e.amount||p.bidType!==e.bidType||p.includeServiceFee!==e.includeServiceFee)throw Error(`Your selection changed. Review the total before continuing.`)}async function he(e){if(!(Y&&d.additionalCharge))return!0;let t=await m.getPurchaseQuote(l.slug,d.id,{includeServiceFee:p.includeServiceFee,quantity:p.quantity});return U.current?t.subtotalCents!==X.subtotalCents||(t.additionalChargeCents??0)!==(X.additionalChargeCents??0)||t.serviceFeeCents!==X.serviceFeeCents||t.totalCents!==X.totalCents||!o(t.additionalCharge,X.additionalCharge)?(g(e,`The checkout details changed. Review them before continuing.`),!1):!0:!1}async function ge(e){if(!e)throw Error(`Check the contact fields below.`);if(!(v&&y&&l.payment))throw Error(`Payment details are still loading.`);let t=await m.load(l.slug);if(!U.current)return null;let r=t.items.find(e=>e.id===d.id);if(!r)return g(t,`This item is no longer available.`),null;let o=n(t,r,p);if(o||i(l,t,d,r,p))return g(t,o??`The checkout details changed. Review them before continuing.`),null;if(!await he(t))return null;let c=await a({billing:L,collectShippingAddress:d.collectShippingAddress,elements:y,email:e.email,phone:e.phone,shipping:F?L:ae,stripe:v});return U.current?(me(),{confirmationToken:c,email:e.email,includeServiceFee:p.includeServiceFee,phone:e.phone,...s(X)}):null}async function _e(e){let t={...e,amount:p.amount};p.bidType===`maximum`&&(t.bidType=`maximum`);let n=await m.createBid(l.slug,d.id,t);if(n.requiresAction){if(!(U.current&&v)){J(`bid`);return}await r(v,n)}K(`complete`),c(W.current.onResult,{additionalCharge:n.additionalCharge??null,additionalChargeCents:n.additionalChargeCents??0,amountCents:n.subtotalCents,bidType:p.bidType??`fixed`,kind:`bid`,serviceFeeCents:n.serviceFeeCents,totalCents:n.totalCents}),G.current||(G.current=!0,c(W.current.onBidSubmitted,n))}async function Q(e,t){if(e.requiresAction){if(!(U.current&&v)){J(`purchase`);return}await r(v,e);let n=await m.getPurchaseStatus(l.slug,d.id,t.submission.clientRequestId);n?fe(n):(K(`pending`),q(`Payment status is not available yet. Check again shortly.`));return}fe(e),!U.current&&e.status===`pending_payment`&&J(`purchase`)}async function ve(e){let t=await m.getPurchaseStatus(l.slug,d.id,e.submission.clientRequestId);if(t)await Q(t,e);else{if(!U.current){J(`purchase`);return}K(`retry`),q(`No purchase is recorded yet. You can retry the original purchase with the same request ID.`)}}async function ye(e,t){let n=await m.getPurchaseStatus(l.slug,d.id,t.submission.clientRequestId);if(n){await Q(n,t);return}Z(null),K(`ready`),q(`The purchase was rejected. Review the item and payment details before trying again. (${e.status??`validation`})`)}async function be(e,t,n,r){let i=t&&(!(e instanceof D)||e.recoveryRecommended);if(q(e instanceof Error?e.message:`Unable to complete this request.`),Y&&n){if(!r&&e instanceof D&&!e.recoveryRecommended)try{await ye(e,n);return}catch{}J(`purchase`)}else i?J(`bid`):K(`ready`)}function xe(){return B.current??=globalThis.crypto.randomUUID(),B.current}function Se(){return U.current?!0:(R||(Z(null),K(`ready`)),!1)}async function Ce(e,t){if(t){await ve(e);return}Se()&&await Q(await m.createPurchase(l.slug,d.id,e.submission),e)}let $=v&&y&&de;function we(){if(H.current||V)return null;if(!$)return q(`Payment details are still loading.`),null;let e=R?null:pe();return R||e?{checkoutPayment:$,contact:e,retryOriginal:z===`retry`}:null}async function Te(e){e.preventDefault();let t=we();if(!t)return;let{contact:n,checkoutPayment:r,retryOriginal:i}=t;H.current=!0,G.current=!1,K(`busy`),q(null);let a=!1,o=R;try{if(!o){let e=await ge(n);if(!(e&&U.current)){K(`ready`);return}if(!Y){a=!0,await _e(e);return}o=Object.freeze({auctionId:l.id,item:d,itemId:d.id,payment:Object.freeze({...r}),pricing:X,submission:Object.freeze({...e,clientRequestId:xe(),paymentMethodTypes:Object.freeze([`card`]),quantity:p.quantity})}),Z(o)}a=!0,await Ce(o,!!R&&!i)}catch(e){await be(e,a,o,R!==null&&!i)}finally{H.current=!1}}let Ee=re(z,R!==null,Y),De=z!==`ready`;return T(ne,{buttonText:Ee,communityName:e.communityName??l.name,contactErrors:N,email:E,id:w,includeServiceFee:p.includeServiceFee,isMaximumBid:!Y&&p.bidType===`maximum`,isPurchase:Y,isTerminal:V,item:d,locked:De,message:le,onBack:z===`ready`?_:void 0,onBillingChange:ie,onEmailChange:t=>{O(t),e.onContactChange?.({email:t,phone:u(k,j)})},onIncludeServiceFeeChange:e.onIncludeServiceFeeChange,onPaymentLoadError:()=>q(`Unable to load payment form.`),onPhoneChange:({value:t,country:n})=>{A(t),M(n),e.onContactChange?.({email:E,phone:u(t,n)})},onSameAsBillingChange:I,onShippingChange:oe,onSubmit:Te,phone:k,phoneCountry:j,pricing:X,quantity:p.quantity,sameAsBilling:F,serviceFeeCents:R?X.serviceFeeCents:t(l,d,{...p,includeServiceFee:l.serviceFeeEnabled}).serviceFeeCents,serviceFeeEnabled:l.serviceFeeEnabled,showFields:!(R||V),submitDisabled:z===`busy`||!v||!y})}function L(e){let{auction:n,item:r,selection:i,theme:a=`dark`,stripeLoader:o=_,style:s,onBack:c,resumePurchase:l}=e,[u,d]=C(null),[f,p]=C(!1),[m,h]=C(0),v=g(e.appearanceRoot,a,s,e.interactionLocked),y=l?.payment??n.payment;if(b(()=>{let e=!0;if(!y){p(!0);return}return Promise.resolve().then(()=>o(y.publishableKey,y.connectedAccountId?{stripeAccount:y.connectedAccountId}:void 0)).then(t=>{e&&(d(t),p(!t))},()=>{e&&p(!0)}),()=>{e=!1}},[y,o,m]),f)return E(`div`,{children:[T(`p`,{role:`alert`,children:`Payment details could not load.`}),l?null:T(`button`,{onClick:c,type:`button`,children:`Back to item`}),T(`button`,{onClick:()=>{p(!1),d(null),h(e=>e+1)},type:`button`,children:`Try again`})]});if(!(u&&v))return E(`div`,{children:[T(`p`,{role:`status`,children:`Loading secure payment details…`}),l?null:T(`button`,{onClick:c,type:`button`,children:`Back to item`})]});let x={mode:`setup`};l?x={amount:l.pricing.totalCents,currency:`usd`,mode:`payment`}:r.saleMode===`buy_now`&&(x={amount:t(n,r,i).totalCents,currency:`usd`,mode:`payment`});let S={...x,appearance:v,currency:`usd`,paymentMethodTypes:[`card`],setupFutureUsage:`off_session`,syncAddressCheckbox:`none`};return T(k,{options:S,stripe:u,children:T(I,{...e})})}export{L as AuctionPayment};
|
|
1
|
+
import{i as e}from"./use-auction-boundary.js";import{a as t,i as n,n as r,o as i,r as a,s as o,t as s}from"./auction-payment.js";import{t as c}from"./host-callback.js";import{d as l,n as u,p as d,r as f,t as p,u as m}from"./phone-field.js";import{i as h,n as g,t as _}from"./stripe-loader.js";import{ArrowRight as v,ChevronLeft as y}from"lucide-react";import{useEffect as b,useId as x,useRef as S,useState as C}from"react";import{Fragment as w,jsx as T,jsxs as E}from"react/jsx-runtime";import{LockerverseSdkError as D}from"@lockerverse/sdk/auctions";import{AddressElement as O,Elements as k,PaymentElement as A,useElements as ee,useStripe as te}from"@stripe/react-stripe-js";function j(e){return{business:{name:`Lockerverse`},fields:{billingDetails:{address:`never`,email:`never`,name:`never`,phone:`never`}},terms:{applePay:`auto`,auBecsDebit:`never`,bancontact:`never`,card:`always`,cashapp:`never`,googlePay:`auto`,ideal:`never`,paypal:e?`auto`:`never`,sepaDebit:`never`,sofort:`never`,usBankAccount:`never`},wallets:{applePay:`auto`,googlePay:`auto`}}}function ne(e){let{isPurchase:t,isMaximumBid:n,item:r,id:i}=e;return E(`form`,{className:`lockerverse-auctions__checkout`,noValidate:!0,onSubmit:e.onSubmit,children:[E(`div`,{className:`lockerverse-auctions__checkout-header`,children:[E(`div`,{className:`lockerverse-auctions__checkout-navigation`,children:[T(`button`,{"aria-label":`Back`,className:`lockerverse-auctions__checkout-back`,disabled:!e.onBack,onClick:e.onBack,type:`button`,children:T(y,{"aria-hidden":`true`,size:20})}),E(`div`,{children:[T(`p`,{className:`lockerverse-auctions__checkout-eyebrow`,children:`Step 2 of 2`}),T(`p`,{children:t?`Secure checkout`:`Secure payment method`})]})]}),T(`p`,{className:`lockerverse-auctions__checkout-eyebrow`,children:e.communityName}),T(`h2`,{children:t?`Finalize your purchase.`:`Finalize your bid authorization.`}),T(P,{...e}),r.collectShippingAddress&&E(`div`,{className:`lockerverse-auctions__checkout-physical`,children:[T(`p`,{className:`lockerverse-auctions__checkout-eyebrow`,children:`Physical item`}),T(`p`,{children:`This item requires a delivery address. Billing details are used by default, and you can switch to a separate delivery address below if needed.`})]})]}),E(`div`,{className:`lockerverse-auctions__checkout-body`,children:[e.showFields&&E(`fieldset`,{disabled:e.locked,children:[E(`div`,{className:`lockerverse-auctions__checkout-contact`,children:[T(l,{error:e.contactErrors.email,id:`${i}-email`,label:`Email`,name:`email`,onChange:t=>e.onEmailChange(t.target.value),required:!0,value:e.email}),T(d,{error:e.contactErrors.phone,id:`${i}-phone`,label:`Phone`,children:T(p,{country:e.phoneCountry,error:e.contactErrors.phone,errorId:`${i}-phone-error`,id:`${i}-phone`,name:`phone`,onChange:e.onPhoneChange,required:!0,value:e.phone})})]}),E(`section`,{"aria-label":`Payment Information`,className:`lockerverse-auctions__checkout-section`,children:[E(`div`,{className:`lockerverse-auctions__checkout-section-heading`,children:[T(`h3`,{children:`Payment Information`}),T(`p`,{children:t?`Processed securely and charged immediately for this purchase.`:`Stored securely and charged only if your bid finishes on top.`})]}),T(A,{onLoadError:e.onPaymentLoadError,options:j(t)})]}),E(`section`,{"aria-label":`Billing Details`,className:`lockerverse-auctions__checkout-section`,children:[T(`h3`,{children:`Billing Details`}),T(O,{onChange:e.onBillingChange,options:{mode:`billing`}}),T(`p`,{children:t?`Use your full name here. We use the email and phone above for purchase confirmation and fulfillment updates.`:`Use the bidder's full name here. We use the email and phone above to contact you if this bid is outbid or wins.`})]}),r.collectShippingAddress&&E(`section`,{"aria-label":`Delivery Details`,className:`lockerverse-auctions__checkout-section`,children:[E(`label`,{className:`lockerverse-auctions__checkout-checkbox lockerverse-auctions__checkout-delivery`,htmlFor:`${i}-delivery-same-as-billing`,children:[T(m,{checked:e.sameAsBilling,id:`${i}-delivery-same-as-billing`,onChange:t=>e.onSameAsBillingChange(t.target.checked)}),E(`span`,{children:[T(`strong`,{children:`Delivery address is the same as billing`}),T(`span`,{children:`Leave this on for the fastest flow. Turn it off only if the delivery address should differ from the billing details above.`})]})]}),!e.sameAsBilling&&E(w,{children:[T(`h3`,{children:`Delivery Address`}),T(O,{onChange:e.onShippingChange,options:{mode:`shipping`}})]})]}),T(N,{isMaximumBid:n,isPurchase:t,pricing:e.pricing}),e.serviceFeeEnabled&&T(M,{...e})]}),e.message&&T(`p`,{"aria-live":`polite`,className:`lockerverse-auctions__notice`,role:`status`,children:e.message}),!e.isTerminal&&E(`div`,{className:`lockerverse-auctions__checkout-footer`,children:[E(`p`,{children:[t?`By continuing, you agree to be charged for this purchase.`:`By continuing, you agree to have this payment method stored for item settlement if your bid is the winning offer.`,r.collectShippingAddress?` Your delivery details are stored with the ${t?`order`:`bid`} so the seller can fulfill the item after payment.`:``]}),E(`button`,{className:`lockerverse-auctions__button lockerverse-auctions__checkout-submit`,disabled:e.submitDisabled,type:`submit`,children:[e.buttonText,T(v,{"aria-hidden":`true`,size:16})]})]})]})]})}function M(t){let{isPurchase:n,isMaximumBid:r,pricing:i}=t,a=F(n,r);return T(`section`,{"aria-label":`Processing fees`,className:`lockerverse-auctions__checkout-section`,children:t.onIncludeServiceFeeChange?E(`label`,{className:`lockerverse-auctions__checkout-checkbox`,htmlFor:`${t.id}-service-fee`,children:[T(m,{checked:t.includeServiceFee,id:`${t.id}-service-fee`,onChange:e=>t.onIncludeServiceFeeChange?.(e.target.checked)}),E(`span`,{children:[E(`strong`,{children:[a.fee,` `,e(t.serviceFeeCents),` to help cover processing fees`]}),E(`span`,{children:[a.total,`: `,e(i.totalCents)]})]})]}):E(`p`,{children:[a.total,`: `,e(i.totalCents)]})})}function N({pricing:t,isPurchase:n,isMaximumBid:r}){let i=F(n,r);return t.additionalCharge?E(`section`,{"aria-label":`Order amounts`,className:`lockerverse-auctions__checkout-section`,children:[E(`p`,{children:[i.amount,`: `,e(t.subtotalCents)]}),E(`p`,{children:[t.additionalCharge.name,`:`,` `,e(t.additionalChargeCents??0)]}),E(`p`,{children:[i.total,`: `,e(t.totalCents)]})]}):null}function P(t){let{isPurchase:n,isMaximumBid:r,item:i,pricing:a}=t;return T(`p`,{className:`lockerverse-auctions__checkout-summary`,children:n?E(w,{children:[`Pay `,T(`strong`,{children:e(a.totalCents)}),` for`,` `,t.quantity,` `,t.quantity===1?`item`:`items`,` of`,` `,T(`strong`,{children:i.name}),`. Your card is charged immediately once checkout succeeds.`]}):E(w,{children:[`Authorize a payment method for your`,` `,r?`maximum bid`:`bid`,` of`,` `,T(`strong`,{children:e(a.subtotalCents)}),` on`,` `,T(`strong`,{children:i.name}),`. Your card is only charged if this bid wins the item.`,r?` You pay the final winning price, up to your maximum, plus any agreed fees and additional charges. Your maximum stays private.`:``]})})}function F(e,t){return e?{amount:`Subtotal`,fee:`Add`,total:`Total`}:t?{amount:`Maximum bid`,fee:`If I win, add up to`,total:`Maximum total if I win`}:{amount:`Bid amount`,fee:`If I win, add`,total:`Total if I win`}}function re(e,t,n){return e===`busy`?n?`Processing...`:`Authorizing...`:e===`retry`?`Retry original purchase`:t?`Check purchase status`:n?`Buy Now`:`Authorize Bid`}function I(e){let{auction:l,item:d,selection:p,client:m,onReview:g,onBack:_}=e,v=te(),y=ee(),w=x(),[E,O]=C(e.contact?.email??``),[k,A]=C(e.contact?.phone??``),[j,M]=C(()=>f(e.contact?.phone??``)),[N,P]=C({}),[F,I]=C(!0),[L,ie]=C(null),[ae,oe]=C(null),[R,se]=C(e.resumePurchase??null),[z,ce]=C(e.resumePurchase?`pending`:`ready`),[le,ue]=C(null),B=S(e.resumePurchase?.submission.clientRequestId??null),V=z===`complete`||z===`uncertain`,H=S(!1),U=S(!0),W=S(e);W.current=e;let G=S(!1);function K(e){U.current&&ce(e),c(W.current.onInteractionLockChange,e!==`ready`&&e!==`complete`)}function q(e){U.current&&ue(e)}function J(e){K(e===`bid`?`uncertain`:`pending`),q(e===`bid`?`We could not confirm your bid. Do not submit another bid until you check your email or contact the auction organizer.`:`We could not confirm the purchase result. Check its status using the same purchase request.`),G.current||(G.current=!0,c(W.current.onUncertain,e))}b(()=>(U.current=!0,()=>{U.current=!1}),[]);let Y=!!(R??e.resumePurchase)||d.saleMode===`buy_now`,X=R?.pricing??e.resumePurchase?.pricing??t(l,d,p),de=R?.payment??e.resumePurchase?.payment??l.payment;function Z(e){U.current&&se(e),c(W.current.onPurchaseRecoveryChange,e)}function fe(e){e.status===`paid`?(B.current=null,Z(null),K(`complete`),c(W.current.onResult,{additionalCharge:e.additionalCharge??null,additionalChargeCents:e.additionalChargeCents??0,kind:`purchase`,purchaseId:e.purchaseId,quantity:e.quantity,serviceFeeCents:e.serviceFeeCents,status:`paid`,subtotalCents:e.subtotalCents,totalCents:e.totalCents,unitAmountCents:e.subtotalCents/e.quantity}),G.current||(G.current=!0,c(W.current.onPurchaseComplete,e))):e.status===`pending_payment`?(K(`pending`),q(`Your purchase is pending. Check its status before making another payment.`)):(B.current=null,Z(null),K(`ready`),q(`This purchase is ${e.status.replaceAll(`_`,` `)}. You can start a new purchase.`))}function pe(){let e=u(k,j),t=h({email:E,phone:e},!0);return P(t.errors),t.value?{email:t.value.email,phone:e}:(document.getElementById(`${w}-${t.errors.email?`email`:`phone`}`)?.focus(),null)}function me(){let e=W.current.selection;if(p.quantity!==e.quantity||p.amount!==e.amount||p.bidType!==e.bidType||p.includeServiceFee!==e.includeServiceFee)throw Error(`Your selection changed. Review the total before continuing.`)}async function he(e){if(!(Y&&d.additionalCharge))return!0;let t=await m.getPurchaseQuote(l.slug,d.id,{includeServiceFee:p.includeServiceFee,quantity:p.quantity});return U.current?t.subtotalCents!==X.subtotalCents||(t.additionalChargeCents??0)!==(X.additionalChargeCents??0)||t.serviceFeeCents!==X.serviceFeeCents||t.totalCents!==X.totalCents||!o(t.additionalCharge,X.additionalCharge)?(g(e,`The checkout details changed. Review them before continuing.`),!1):!0:!1}async function ge(e){if(!e)throw Error(`Check the contact fields below.`);if(!(v&&y&&l.payment))throw Error(`Payment details are still loading.`);let t=await m.load(l.slug);if(!U.current)return null;let r=t.items.find(e=>e.id===d.id);if(!r)return g(t,`This item is no longer available.`),null;let o=n(t,r,p);if(o||i(l,t,d,r,p))return g(t,o??`The checkout details changed. Review them before continuing.`),null;if(!await he(t))return null;let c=await a({billing:L,collectShippingAddress:d.collectShippingAddress,elements:y,email:e.email,phone:e.phone,shipping:F?L:ae,stripe:v});return U.current?(me(),{confirmationToken:c,email:e.email,includeServiceFee:p.includeServiceFee,phone:e.phone,...s(X)}):null}async function _e(e){let t={...e,amount:p.amount};p.bidType===`maximum`&&(t.bidType=`maximum`);let n=await m.createBid(l.slug,d.id,t);if(n.requiresAction){if(!(U.current&&v)){J(`bid`);return}await r(v,n)}K(`complete`),c(W.current.onResult,{additionalCharge:n.additionalCharge??null,additionalChargeCents:n.additionalChargeCents??0,amountCents:n.subtotalCents,bidType:p.bidType??`fixed`,kind:`bid`,serviceFeeCents:n.serviceFeeCents,totalCents:n.totalCents}),G.current||(G.current=!0,c(W.current.onBidSubmitted,n))}async function Q(e,t){if(e.requiresAction){if(!(U.current&&v)){J(`purchase`);return}await r(v,e);let n=await m.getPurchaseStatus(l.slug,d.id,t.submission.clientRequestId);n?fe(n):(K(`pending`),q(`Payment status is not available yet. Check again shortly.`));return}fe(e),!U.current&&e.status===`pending_payment`&&J(`purchase`)}async function ve(e){let t=await m.getPurchaseStatus(l.slug,d.id,e.submission.clientRequestId);if(t)await Q(t,e);else{if(!U.current){J(`purchase`);return}K(`retry`),q(`No purchase is recorded yet. You can retry the original purchase with the same request ID.`)}}async function ye(e,t){let n=await m.getPurchaseStatus(l.slug,d.id,t.submission.clientRequestId);if(n){await Q(n,t);return}Z(null),K(`ready`),q(`The purchase was rejected. Review the item and payment details before trying again. (${e.status??`validation`})`)}async function be(e,t,n,r){let i=t&&(!(e instanceof D)||e.recoveryRecommended);if(q(e instanceof Error?e.message:`Unable to complete this request.`),Y&&n){if(!r&&e instanceof D&&!e.recoveryRecommended)try{await ye(e,n);return}catch{}J(`purchase`)}else i?J(`bid`):K(`ready`)}function xe(){return B.current??=globalThis.crypto.randomUUID(),B.current}function Se(){return U.current?!0:(R||(Z(null),K(`ready`)),!1)}async function Ce(e,t){if(t){await ve(e);return}Se()&&await Q(await m.createPurchase(l.slug,d.id,e.submission),e)}let $=v&&y&&de;function we(){if(H.current||V)return null;if(!$)return q(`Payment details are still loading.`),null;let e=R?null:pe();return R||e?{checkoutPayment:$,contact:e,retryOriginal:z===`retry`}:null}async function Te(e){e.preventDefault();let t=we();if(!t)return;let{contact:n,checkoutPayment:r,retryOriginal:i}=t;H.current=!0,G.current=!1,K(`busy`),q(null);let a=!1,o=R;try{if(!o){let e=await ge(n);if(!(e&&U.current)){K(`ready`);return}if(!Y){a=!0,await _e(e);return}o=Object.freeze({auctionId:l.id,item:d,itemId:d.id,payment:Object.freeze({...r}),pricing:X,submission:Object.freeze({...e,clientRequestId:xe(),paymentMethodTypes:Object.freeze([`card`]),quantity:p.quantity})}),Z(o)}a=!0,await Ce(o,!!R&&!i)}catch(e){await be(e,a,o,R!==null&&!i)}finally{H.current=!1}}let Ee=re(z,R!==null,Y),De=z!==`ready`;return T(ne,{buttonText:Ee,communityName:e.communityName??l.name,contactErrors:N,email:E,id:w,includeServiceFee:p.includeServiceFee,isMaximumBid:!Y&&p.bidType===`maximum`,isPurchase:Y,isTerminal:V,item:d,locked:De,message:le,onBack:z===`ready`?_:void 0,onBillingChange:ie,onEmailChange:t=>{O(t),e.onContactChange?.({email:t,phone:u(k,j)})},onIncludeServiceFeeChange:e.onIncludeServiceFeeChange,onPaymentLoadError:()=>q(`Unable to load payment form.`),onPhoneChange:({value:t,country:n})=>{A(t),M(n),e.onContactChange?.({email:E,phone:u(t,n)})},onSameAsBillingChange:I,onShippingChange:oe,onSubmit:Te,phone:k,phoneCountry:j,pricing:X,quantity:p.quantity,sameAsBilling:F,serviceFeeCents:R?X.serviceFeeCents:t(l,d,{...p,includeServiceFee:l.serviceFeeEnabled}).serviceFeeCents,serviceFeeEnabled:l.serviceFeeEnabled,showFields:!(R||V),submitDisabled:z===`busy`||!v||!y})}function L(e){let{auction:n,item:r,selection:i,theme:a=`dark`,stripeLoader:o=_,style:s,onBack:c,resumePurchase:l}=e,[u,d]=C(null),[f,p]=C(!1),[m,h]=C(0),v=g(e.appearanceRoot,a,s,e.interactionLocked),y=l?.payment??n.payment;if(b(()=>{let e=!0;if(!y){p(!0);return}return Promise.resolve().then(()=>o(y.publishableKey,y.connectedAccountId?{stripeAccount:y.connectedAccountId}:void 0)).then(t=>{e&&(d(t),p(!t))},()=>{e&&p(!0)}),()=>{e=!1}},[y,o,m]),f)return E(`div`,{children:[T(`p`,{role:`alert`,children:`Payment details could not load.`}),l?null:T(`button`,{onClick:c,type:`button`,children:`Back to item`}),T(`button`,{onClick:()=>{p(!1),d(null),h(e=>e+1)},type:`button`,children:`Try again`})]});if(!(u&&v))return E(`div`,{children:[T(`p`,{role:`status`,children:`Loading secure payment details…`}),l?null:T(`button`,{onClick:c,type:`button`,children:`Back to item`})]});let x={mode:`setup`};l?x={amount:l.pricing.totalCents,currency:`usd`,mode:`payment`}:r.saleMode===`buy_now`&&(x={amount:t(n,r,i).totalCents,currency:`usd`,mode:`payment`});let S={...x,appearance:v,currency:`usd`,paymentMethodTypes:[`card`],setupFutureUsage:`off_session`,syncAddressCheckbox:`none`};return T(k,{options:S,stripe:u,children:T(I,{...e})})}export{L as AuctionPayment};
|
|
2
2
|
//# sourceMappingURL=auction-payment-view.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auction-payment-view.js","names":["formatMoney"],"sources":["../src/auction-checkout-view.tsx","../src/auction-checkout.tsx","../src/auction-payment-view.tsx"],"sourcesContent":["import type {\n LockerverseAuctionItem,\n LockerverseAuctionPricing,\n} from \"@lockerverse/sdk/auctions\";\nimport { AddressElement, PaymentElement } from \"@stripe/react-stripe-js\";\nimport type {\n StripeAddressElementChangeEvent,\n StripePaymentElementOptions,\n} from \"@stripe/stripe-js\";\nimport { ArrowRight, ChevronLeft } from \"lucide-react\";\nimport type { FormEventHandler } from \"react\";\nimport { formatAuctionMoney as formatMoney } from \"./auction-display.ts\";\nimport { Checkbox, EmailField, FormField } from \"./form-field.tsx\";\nimport type { PhoneInputValue } from \"./phone-field.tsx\";\nimport { PhoneInput } from \"./phone-field.tsx\";\n\ntype AuctionCheckoutViewProps = {\n buttonText: string;\n communityName: string;\n email: string;\n contactErrors: { email?: string; phone?: string };\n phoneCountry: string;\n id: string;\n includeServiceFee: boolean;\n isPurchase: boolean;\n isMaximumBid: boolean;\n isTerminal: boolean;\n item: LockerverseAuctionItem;\n locked: boolean;\n message: string | null;\n onBack?: (() => void) | undefined;\n onBillingChange: (event: StripeAddressElementChangeEvent) => void;\n onEmailChange: (value: string) => void;\n onIncludeServiceFeeChange?: ((value: boolean) => void) | undefined;\n onPaymentLoadError: () => void;\n onPhoneChange: (value: PhoneInputValue) => void;\n onSameAsBillingChange: (value: boolean) => void;\n onShippingChange: (event: StripeAddressElementChangeEvent) => void;\n onSubmit: FormEventHandler<HTMLFormElement>;\n phone: string;\n pricing: LockerverseAuctionPricing;\n quantity: number;\n sameAsBilling: boolean;\n serviceFeeCents: number;\n serviceFeeEnabled: boolean;\n showFields: boolean;\n submitDisabled: boolean;\n};\n\nfunction getPaymentOptions(isPurchase: boolean): StripePaymentElementOptions {\n return {\n business: { name: \"Lockerverse\" },\n fields: {\n billingDetails: {\n address: \"never\",\n email: \"never\",\n name: \"never\",\n phone: \"never\",\n },\n },\n terms: {\n applePay: isPurchase ? \"auto\" : \"never\",\n auBecsDebit: \"never\",\n bancontact: \"never\",\n card: \"always\",\n cashapp: \"never\",\n googlePay: \"never\",\n ideal: \"never\",\n paypal: isPurchase ? \"auto\" : \"never\",\n sepaDebit: \"never\",\n sofort: \"never\",\n usBankAccount: \"never\",\n },\n wallets: { applePay: isPurchase ? \"auto\" : \"never\", googlePay: \"never\" },\n };\n}\n\nexport function AuctionCheckoutView(props: AuctionCheckoutViewProps) {\n const { isPurchase, isMaximumBid, item, id } = props;\n return (\n <form\n className=\"lockerverse-auctions__checkout\"\n noValidate\n onSubmit={props.onSubmit}\n >\n <div className=\"lockerverse-auctions__checkout-header\">\n <div className=\"lockerverse-auctions__checkout-navigation\">\n <button\n aria-label=\"Back\"\n className=\"lockerverse-auctions__checkout-back\"\n disabled={!props.onBack}\n onClick={props.onBack}\n type=\"button\"\n >\n <ChevronLeft aria-hidden=\"true\" size={20} />\n </button>\n <div>\n <p className=\"lockerverse-auctions__checkout-eyebrow\">\n Step 2 of 2\n </p>\n <p>{isPurchase ? \"Secure checkout\" : \"Secure payment method\"}</p>\n </div>\n </div>\n <p className=\"lockerverse-auctions__checkout-eyebrow\">\n {props.communityName}\n </p>\n <h2>\n {isPurchase\n ? \"Finalize your purchase.\"\n : \"Finalize your bid authorization.\"}\n </h2>\n <CheckoutSummary {...props} />\n {item.collectShippingAddress && (\n <div className=\"lockerverse-auctions__checkout-physical\">\n <p className=\"lockerverse-auctions__checkout-eyebrow\">\n Physical item\n </p>\n <p>\n This item requires a delivery address. Billing details are used by\n default, and you can switch to a separate delivery address below\n if needed.\n </p>\n </div>\n )}\n </div>\n <div className=\"lockerverse-auctions__checkout-body\">\n {props.showFields && (\n <fieldset disabled={props.locked}>\n <div className=\"lockerverse-auctions__checkout-contact\">\n <EmailField\n error={props.contactErrors.email}\n id={`${id}-email`}\n label=\"Email\"\n name=\"email\"\n onChange={(event) => props.onEmailChange(event.target.value)}\n required\n value={props.email}\n />\n <FormField\n error={props.contactErrors.phone}\n id={`${id}-phone`}\n label=\"Phone\"\n >\n <PhoneInput\n country={props.phoneCountry}\n error={props.contactErrors.phone}\n errorId={`${id}-phone-error`}\n id={`${id}-phone`}\n name=\"phone\"\n onChange={props.onPhoneChange}\n required\n value={props.phone}\n />\n </FormField>\n </div>\n <section\n aria-label=\"Payment Information\"\n className=\"lockerverse-auctions__checkout-section\"\n >\n <div className=\"lockerverse-auctions__checkout-section-heading\">\n <h3>Payment Information</h3>\n <p>\n {isPurchase\n ? \"Processed securely and charged immediately for this purchase.\"\n : \"Stored securely and charged only if your bid finishes on top.\"}\n </p>\n </div>\n <PaymentElement\n onLoadError={props.onPaymentLoadError}\n options={getPaymentOptions(isPurchase)}\n />\n </section>\n <section\n aria-label=\"Billing Details\"\n className=\"lockerverse-auctions__checkout-section\"\n >\n <h3>Billing Details</h3>\n <AddressElement\n onChange={props.onBillingChange}\n options={{ mode: \"billing\" }}\n />\n <p>\n {isPurchase\n ? \"Use your full name here. We use the email and phone above for purchase confirmation and fulfillment updates.\"\n : \"Use the bidder's full name here. We use the email and phone above to contact you if this bid is outbid or wins.\"}\n </p>\n </section>\n {item.collectShippingAddress && (\n <section\n aria-label=\"Delivery Details\"\n className=\"lockerverse-auctions__checkout-section\"\n >\n <label\n className=\"lockerverse-auctions__checkout-checkbox lockerverse-auctions__checkout-delivery\"\n htmlFor={`${id}-delivery-same-as-billing`}\n >\n <Checkbox\n checked={props.sameAsBilling}\n id={`${id}-delivery-same-as-billing`}\n onChange={(event) =>\n props.onSameAsBillingChange(event.target.checked)\n }\n />\n <span>\n <strong>Delivery address is the same as billing</strong>\n <span>\n Leave this on for the fastest flow. Turn it off only if\n the delivery address should differ from the billing\n details above.\n </span>\n </span>\n </label>\n {!props.sameAsBilling && (\n <>\n <h3>Delivery Address</h3>\n <AddressElement\n onChange={props.onShippingChange}\n options={{ mode: \"shipping\" }}\n />\n </>\n )}\n </section>\n )}\n <CheckoutAdditionalCharge\n isMaximumBid={isMaximumBid}\n isPurchase={isPurchase}\n pricing={props.pricing}\n />\n {props.serviceFeeEnabled && <CheckoutServiceFee {...props} />}\n </fieldset>\n )}\n {props.message && (\n <p\n aria-live=\"polite\"\n className=\"lockerverse-auctions__notice\"\n role=\"status\"\n >\n {props.message}\n </p>\n )}\n {!props.isTerminal && (\n <div className=\"lockerverse-auctions__checkout-footer\">\n <p>\n {isPurchase\n ? \"By continuing, you agree to be charged for this purchase.\"\n : \"By continuing, you agree to have this payment method stored for item settlement if your bid is the winning offer.\"}\n {item.collectShippingAddress\n ? ` Your delivery details are stored with the ${isPurchase ? \"order\" : \"bid\"} so the seller can fulfill the item after payment.`\n : \"\"}\n </p>\n <button\n className=\"lockerverse-auctions__button lockerverse-auctions__checkout-submit\"\n disabled={props.submitDisabled}\n type=\"submit\"\n >\n {props.buttonText}\n <ArrowRight aria-hidden=\"true\" size={16} />\n </button>\n </div>\n )}\n </div>\n </form>\n );\n}\n\nfunction CheckoutServiceFee(props: AuctionCheckoutViewProps) {\n const { isPurchase, isMaximumBid, pricing } = props;\n const labels = checkoutAmountLabels(isPurchase, isMaximumBid);\n return (\n <section\n aria-label=\"Processing fees\"\n className=\"lockerverse-auctions__checkout-section\"\n >\n {props.onIncludeServiceFeeChange ? (\n <label\n className=\"lockerverse-auctions__checkout-checkbox\"\n htmlFor={`${props.id}-service-fee`}\n >\n <Checkbox\n checked={props.includeServiceFee}\n id={`${props.id}-service-fee`}\n onChange={(event) =>\n props.onIncludeServiceFeeChange?.(event.target.checked)\n }\n />\n <span>\n <strong>\n {labels.fee} {formatMoney(props.serviceFeeCents)} to help cover\n processing fees\n </strong>\n <span>\n {labels.total}: {formatMoney(pricing.totalCents)}\n </span>\n </span>\n </label>\n ) : (\n <p>\n {labels.total}: {formatMoney(pricing.totalCents)}\n </p>\n )}\n </section>\n );\n}\n\nfunction CheckoutAdditionalCharge({\n pricing,\n isPurchase,\n isMaximumBid,\n}: {\n pricing: LockerverseAuctionPricing;\n isPurchase: boolean;\n isMaximumBid: boolean;\n}) {\n const labels = checkoutAmountLabels(isPurchase, isMaximumBid);\n if (!pricing.additionalCharge) {\n return null;\n }\n return (\n <section\n aria-label=\"Order amounts\"\n className=\"lockerverse-auctions__checkout-section\"\n >\n <p>\n {labels.amount}: {formatMoney(pricing.subtotalCents)}\n </p>\n <p>\n {pricing.additionalCharge.name}:{\" \"}\n {formatMoney(pricing.additionalChargeCents ?? 0)}\n </p>\n <p>\n {labels.total}: {formatMoney(pricing.totalCents)}\n </p>\n </section>\n );\n}\n\nfunction CheckoutSummary(props: AuctionCheckoutViewProps) {\n const { isPurchase, isMaximumBid, item, pricing } = props;\n return (\n <p className=\"lockerverse-auctions__checkout-summary\">\n {isPurchase ? (\n <>\n Pay <strong>{formatMoney(pricing.totalCents)}</strong> for{\" \"}\n {props.quantity} {props.quantity === 1 ? \"item\" : \"items\"} of{\" \"}\n <strong>{item.name}</strong>. Your card is charged immediately once\n checkout succeeds.\n </>\n ) : (\n <>\n Authorize a payment method for your{\" \"}\n {isMaximumBid ? \"maximum bid\" : \"bid\"} of{\" \"}\n <strong>{formatMoney(pricing.subtotalCents)}</strong> on{\" \"}\n <strong>{item.name}</strong>. Your card is only charged if this bid\n wins the item.\n {isMaximumBid\n ? \" You pay the final winning price, up to your maximum, plus any agreed fees and additional charges. Your maximum stays private.\"\n : \"\"}\n </>\n )}\n </p>\n );\n}\n\nfunction checkoutAmountLabels(isPurchase: boolean, isMaximumBid: boolean) {\n if (isPurchase) {\n return { amount: \"Subtotal\", fee: \"Add\", total: \"Total\" };\n }\n if (isMaximumBid) {\n return {\n amount: \"Maximum bid\",\n fee: \"If I win, add up to\",\n total: \"Maximum total if I win\",\n };\n }\n return {\n amount: \"Bid amount\",\n fee: \"If I win, add\",\n total: \"Total if I win\",\n };\n}\n","// biome-ignore-all lint/suspicious/noUnnecessaryConditions: React refs change in effect cleanup and event handlers outside this static control flow.\nimport {\n type LockerverseAuction,\n type LockerverseAuctionItem,\n type LockerverseAuctionPurchaseResult,\n LockerverseSdkError,\n} from \"@lockerverse/sdk/auctions\";\nimport { useElements, useStripe } from \"@stripe/react-stripe-js\";\nimport type { StripeAddressElementChangeEvent } from \"@stripe/stripe-js\";\nimport { type FormEvent, useEffect, useId, useRef, useState } from \"react\";\nimport { AuctionCheckoutView } from \"./auction-checkout-view.tsx\";\nimport type {\n LockerverseAuctionItemProps,\n LockerverseAuctionPurchaseRecovery,\n} from \"./auction-item-types.ts\";\nimport {\n type AuctionSelection,\n auctionExpectedPricing,\n completeAuctionAction,\n createAuctionConfirmationToken,\n getAuctionSelectionError,\n getAuctionSelectionPricing,\n hasAuctionCheckoutChanged,\n sameAuctionAdditionalCharge,\n} from \"./auction-payment.ts\";\nimport type { LockerverseAuctionOutcome } from \"./auction-result.tsx\";\nimport { notifyHostCallback } from \"./host-callback.ts\";\nimport { type ContactErrors, validateContact } from \"./payment-validation.ts\";\nimport { getInternationalPhone, resolvePhoneCountry } from \"./phone.ts\";\n\ntype AuctionCheckoutProps = LockerverseAuctionItemProps & {\n item: LockerverseAuctionItem;\n selection: AuctionSelection;\n onReview: (auction: LockerverseAuction, message: string) => void;\n onBack: () => void;\n contact?: { email: string; phone: string };\n onContactChange?: (contact: { email: string; phone: string }) => void;\n onIncludeServiceFeeChange?: (value: boolean) => void;\n onInteractionLockChange?: (locked: boolean) => void;\n onResult: (outcome: LockerverseAuctionOutcome) => void;\n};\n\ntype CheckoutState =\n | \"ready\"\n | \"busy\"\n | \"pending\"\n | \"retry\"\n | \"complete\"\n | \"uncertain\";\n\nfunction getSubmitLabel(\n state: CheckoutState,\n hasRecovery: boolean,\n isPurchase: boolean\n) {\n if (state === \"busy\") {\n return isPurchase ? \"Processing...\" : \"Authorizing...\";\n }\n if (state === \"retry\") {\n return \"Retry original purchase\";\n }\n if (hasRecovery) {\n return \"Check purchase status\";\n }\n return isPurchase ? \"Buy Now\" : \"Authorize Bid\";\n}\n\nexport function AuctionCheckout(props: AuctionCheckoutProps) {\n const { auction, item, selection, client, onReview, onBack } = props;\n const stripe = useStripe();\n const elements = useElements();\n const id = useId();\n const [email, setEmail] = useState(props.contact?.email ?? \"\");\n const [phone, setPhone] = useState(props.contact?.phone ?? \"\");\n const [phoneCountry, setPhoneCountry] = useState<string>(() =>\n resolvePhoneCountry(props.contact?.phone ?? \"\")\n );\n const [contactErrors, setContactErrors] = useState<ContactErrors>({});\n const [sameAsBilling, setSameAsBilling] = useState(true);\n const [billing, setBilling] =\n useState<StripeAddressElementChangeEvent | null>(null);\n const [shipping, setShipping] =\n useState<StripeAddressElementChangeEvent | null>(null);\n const [recovery, setRecovery] = useState(props.resumePurchase ?? null);\n const [state, setState] = useState<CheckoutState>(\n props.resumePurchase ? \"pending\" : \"ready\"\n );\n const [message, setMessage] = useState<string | null>(null);\n const purchaseRequestId = useRef<string | null>(\n props.resumePurchase?.submission.clientRequestId ?? null\n );\n const isTerminal = state === \"complete\" || state === \"uncertain\";\n const busy = useRef<boolean>(false);\n const mounted = useRef<boolean>(true);\n const callbacks = useRef(props);\n callbacks.current = props;\n const outcomeReported = useRef(false);\n\n function transition(next: CheckoutState) {\n if (mounted.current) {\n setState(next);\n }\n notifyHostCallback(\n callbacks.current.onInteractionLockChange,\n next !== \"ready\" && next !== \"complete\"\n );\n }\n function showMessage(value: string | null) {\n if (mounted.current) {\n setMessage(value);\n }\n }\n function reportUncertain(kind: \"bid\" | \"purchase\") {\n transition(kind === \"bid\" ? \"uncertain\" : \"pending\");\n showMessage(\n kind === \"bid\"\n ? \"We could not confirm your bid. Do not submit another bid until you check your email or contact the auction organizer.\"\n : \"We could not confirm the purchase result. Check its status using the same purchase request.\"\n );\n if (!outcomeReported.current) {\n outcomeReported.current = true;\n notifyHostCallback(callbacks.current.onUncertain, kind);\n }\n }\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n };\n }, []);\n const isPurchase =\n Boolean(recovery ?? props.resumePurchase) || item.saleMode === \"buy_now\";\n const pricing =\n recovery?.pricing ??\n props.resumePurchase?.pricing ??\n getAuctionSelectionPricing(auction, item, selection);\n\n const payment =\n recovery?.payment ?? props.resumePurchase?.payment ?? auction.payment;\n\n function rememberPurchase(value: LockerverseAuctionPurchaseRecovery | null) {\n if (mounted.current) {\n setRecovery(value);\n }\n notifyHostCallback(callbacks.current.onPurchaseRecoveryChange, value);\n }\n\n function finishPurchase(result: LockerverseAuctionPurchaseResult) {\n if (result.status === \"paid\") {\n purchaseRequestId.current = null;\n rememberPurchase(null);\n transition(\"complete\");\n notifyHostCallback(callbacks.current.onResult, {\n additionalCharge: result.additionalCharge ?? null,\n additionalChargeCents: result.additionalChargeCents ?? 0,\n kind: \"purchase\",\n purchaseId: result.purchaseId,\n quantity: result.quantity,\n serviceFeeCents: result.serviceFeeCents,\n status: \"paid\",\n subtotalCents: result.subtotalCents,\n totalCents: result.totalCents,\n unitAmountCents: result.subtotalCents / result.quantity,\n });\n if (!outcomeReported.current) {\n outcomeReported.current = true;\n notifyHostCallback(callbacks.current.onPurchaseComplete, result);\n }\n } else if (result.status === \"pending_payment\") {\n transition(\"pending\");\n showMessage(\n \"Your purchase is pending. Check its status before making another payment.\"\n );\n } else {\n purchaseRequestId.current = null;\n rememberPurchase(null);\n transition(\"ready\");\n showMessage(\n `This purchase is ${result.status.replaceAll(\"_\", \" \")}. You can start a new purchase.`\n );\n }\n }\n\n function readContact() {\n const phoneNumber = getInternationalPhone(phone, phoneCountry);\n const contact = validateContact({ email, phone: phoneNumber }, true);\n setContactErrors(contact.errors);\n if (!contact.value) {\n document\n .getElementById(`${id}-${contact.errors.email ? \"email\" : \"phone\"}`)\n ?.focus();\n return null;\n }\n return { email: contact.value.email, phone: phoneNumber };\n }\n\n function requireCurrentSelection() {\n const latest = callbacks.current.selection;\n if (\n selection.quantity !== latest.quantity ||\n selection.amount !== latest.amount ||\n selection.bidType !== latest.bidType ||\n selection.includeServiceFee !== latest.includeServiceFee\n ) {\n throw new Error(\n \"Your selection changed. Review the total before continuing.\"\n );\n }\n }\n\n async function verifyPurchaseQuote(current: LockerverseAuction) {\n if (!(isPurchase && item.additionalCharge)) {\n return true;\n }\n const quote = await client.getPurchaseQuote(auction.slug, item.id, {\n includeServiceFee: selection.includeServiceFee,\n quantity: selection.quantity,\n });\n if (!mounted.current) {\n return false;\n }\n if (\n quote.subtotalCents !== pricing.subtotalCents ||\n (quote.additionalChargeCents ?? 0) !==\n (pricing.additionalChargeCents ?? 0) ||\n quote.serviceFeeCents !== pricing.serviceFeeCents ||\n quote.totalCents !== pricing.totalCents ||\n !sameAuctionAdditionalCharge(\n quote.additionalCharge,\n pricing.additionalCharge\n )\n ) {\n onReview(\n current,\n \"The checkout details changed. Review them before continuing.\"\n );\n return false;\n }\n return true;\n }\n\n async function prepareSubmission(\n contact: { email: string; phone: string } | null\n ) {\n if (!contact) {\n throw new Error(\"Check the contact fields below.\");\n }\n if (!(stripe && elements && auction.payment)) {\n throw new Error(\"Payment details are still loading.\");\n }\n const current = await client.load(auction.slug);\n if (!mounted.current) {\n return null;\n }\n const currentItem = current.items.find(\n (candidate) => candidate.id === item.id\n );\n if (!currentItem) {\n onReview(current, \"This item is no longer available.\");\n return null;\n }\n const selectionError = getAuctionSelectionError(\n current,\n currentItem,\n selection\n );\n if (\n selectionError ||\n hasAuctionCheckoutChanged(auction, current, item, currentItem, selection)\n ) {\n onReview(\n current,\n selectionError ??\n \"The checkout details changed. Review them before continuing.\"\n );\n return null;\n }\n if (!(await verifyPurchaseQuote(current))) {\n return null;\n }\n const confirmationToken = await createAuctionConfirmationToken({\n billing,\n collectShippingAddress: item.collectShippingAddress,\n elements,\n email: contact.email,\n phone: contact.phone,\n shipping: sameAsBilling ? billing : shipping,\n stripe,\n });\n if (!mounted.current) {\n return null;\n }\n requireCurrentSelection();\n return {\n confirmationToken,\n email: contact.email,\n includeServiceFee: selection.includeServiceFee,\n phone: contact.phone,\n ...auctionExpectedPricing(pricing),\n };\n }\n\n async function sendBid(\n submission: NonNullable<Awaited<ReturnType<typeof prepareSubmission>>>\n ) {\n const bidSubmission: Parameters<typeof client.createBid>[2] = {\n ...submission,\n amount: selection.amount,\n };\n if (selection.bidType === \"maximum\") {\n bidSubmission.bidType = \"maximum\";\n }\n const result = await client.createBid(auction.slug, item.id, bidSubmission);\n if (result.requiresAction) {\n if (!(mounted.current && stripe)) {\n reportUncertain(\"bid\");\n return;\n }\n await completeAuctionAction(stripe, result);\n }\n transition(\"complete\");\n notifyHostCallback(callbacks.current.onResult, {\n additionalCharge: result.additionalCharge ?? null,\n additionalChargeCents: result.additionalChargeCents ?? 0,\n amountCents: result.subtotalCents,\n bidType: selection.bidType ?? \"fixed\",\n kind: \"bid\",\n serviceFeeCents: result.serviceFeeCents,\n totalCents: result.totalCents,\n });\n if (!outcomeReported.current) {\n outcomeReported.current = true;\n notifyHostCallback(callbacks.current.onBidSubmitted, result);\n }\n }\n\n async function resolvePurchase(\n result: LockerverseAuctionPurchaseResult,\n active: LockerverseAuctionPurchaseRecovery\n ) {\n if (result.requiresAction) {\n if (!(mounted.current && stripe)) {\n reportUncertain(\"purchase\");\n return;\n }\n await completeAuctionAction(stripe, result);\n const updated = await client.getPurchaseStatus(\n auction.slug,\n item.id,\n active.submission.clientRequestId\n );\n if (updated) {\n finishPurchase(updated);\n } else {\n transition(\"pending\");\n showMessage(\n \"Payment status is not available yet. Check again shortly.\"\n );\n }\n return;\n }\n finishPurchase(result);\n if (!mounted.current && result.status === \"pending_payment\") {\n reportUncertain(\"purchase\");\n }\n }\n\n async function checkPurchase(active: LockerverseAuctionPurchaseRecovery) {\n const result = await client.getPurchaseStatus(\n auction.slug,\n item.id,\n active.submission.clientRequestId\n );\n if (result) {\n await resolvePurchase(result, active);\n } else {\n if (!mounted.current) {\n reportUncertain(\"purchase\");\n return;\n }\n transition(\"retry\");\n showMessage(\n \"No purchase is recorded yet. You can retry the original purchase with the same request ID.\"\n );\n }\n }\n\n async function clearRejectedPurchase(\n error: LockerverseSdkError,\n active: LockerverseAuctionPurchaseRecovery\n ) {\n const result = await client.getPurchaseStatus(\n auction.slug,\n item.id,\n active.submission.clientRequestId\n );\n if (result) {\n await resolvePurchase(result, active);\n return;\n }\n rememberPurchase(null);\n transition(\"ready\");\n showMessage(\n `The purchase was rejected. Review the item and payment details before trying again. (${error.status ?? \"validation\"})`\n );\n }\n\n async function handleFailure<Failure>(\n error: Failure,\n requestSent: boolean,\n active: LockerverseAuctionPurchaseRecovery | null,\n wasRecovery: boolean\n ) {\n const uncertain =\n requestSent &&\n (!(error instanceof LockerverseSdkError) || error.recoveryRecommended);\n showMessage(\n error instanceof Error\n ? error.message\n : \"Unable to complete this request.\"\n );\n if (isPurchase && active) {\n if (\n !wasRecovery &&\n error instanceof LockerverseSdkError &&\n !error.recoveryRecommended\n ) {\n try {\n await clearRejectedPurchase(error, active);\n return;\n } catch {\n /* Keep the original request when status cannot be established. */\n }\n }\n reportUncertain(\"purchase\");\n } else if (uncertain) {\n reportUncertain(\"bid\");\n } else {\n transition(\"ready\");\n }\n }\n\n function getPurchaseRequestId() {\n purchaseRequestId.current ??= globalThis.crypto.randomUUID();\n return purchaseRequestId.current;\n }\n\n function canSendPurchase() {\n if (mounted.current) {\n return true;\n }\n if (!recovery) {\n rememberPurchase(null);\n transition(\"ready\");\n }\n return false;\n }\n\n async function sendOrCheckPurchase(\n active: LockerverseAuctionPurchaseRecovery,\n statusOnly: boolean\n ) {\n if (statusOnly) {\n await checkPurchase(active);\n return;\n }\n if (!canSendPurchase()) {\n return;\n }\n const result = await client.createPurchase(\n auction.slug,\n item.id,\n active.submission\n );\n await resolvePurchase(result, active);\n }\n\n const checkoutPayment = stripe && elements && payment;\n\n function startSubmission() {\n if (busy.current || isTerminal) {\n return null;\n }\n if (!checkoutPayment) {\n showMessage(\"Payment details are still loading.\");\n return null;\n }\n const contact = recovery ? null : readContact();\n if (!(recovery || contact)) {\n return null;\n }\n return { checkoutPayment, contact, retryOriginal: state === \"retry\" };\n }\n\n async function submit(event: FormEvent<HTMLFormElement>) {\n event.preventDefault();\n const start = startSubmission();\n if (!start) {\n return;\n }\n const { contact, checkoutPayment: readyPayment, retryOriginal } = start;\n busy.current = true;\n outcomeReported.current = false;\n transition(\"busy\");\n showMessage(null);\n let requestSent = false;\n let activeRecovery = recovery;\n try {\n if (!activeRecovery) {\n const submission = await prepareSubmission(contact);\n if (!(submission && mounted.current)) {\n transition(\"ready\");\n return;\n }\n if (!isPurchase) {\n requestSent = true;\n await sendBid(submission);\n return;\n }\n activeRecovery = Object.freeze({\n auctionId: auction.id,\n item,\n itemId: item.id,\n payment: Object.freeze({ ...readyPayment }),\n pricing,\n submission: Object.freeze({\n ...submission,\n clientRequestId: getPurchaseRequestId(),\n paymentMethodTypes: Object.freeze([\"card\"] as const),\n quantity: selection.quantity,\n }),\n });\n rememberPurchase(activeRecovery);\n }\n requestSent = true;\n await sendOrCheckPurchase(\n activeRecovery,\n Boolean(recovery) && !retryOriginal\n );\n } catch (error) {\n await handleFailure(\n error,\n requestSent,\n activeRecovery,\n recovery !== null && !retryOriginal\n );\n } finally {\n busy.current = false;\n }\n }\n\n const buttonText = getSubmitLabel(state, recovery !== null, isPurchase);\n\n const locked = state !== \"ready\";\n return (\n <AuctionCheckoutView\n buttonText={buttonText}\n communityName={props.communityName ?? auction.name}\n contactErrors={contactErrors}\n email={email}\n id={id}\n includeServiceFee={selection.includeServiceFee}\n isMaximumBid={!isPurchase && selection.bidType === \"maximum\"}\n isPurchase={isPurchase}\n isTerminal={isTerminal}\n item={item}\n locked={locked}\n message={message}\n onBack={state === \"ready\" ? onBack : undefined}\n onBillingChange={setBilling}\n onEmailChange={(value) => {\n setEmail(value);\n props.onContactChange?.({\n email: value,\n phone: getInternationalPhone(phone, phoneCountry),\n });\n }}\n onIncludeServiceFeeChange={props.onIncludeServiceFeeChange}\n onPaymentLoadError={() => showMessage(\"Unable to load payment form.\")}\n onPhoneChange={({ value, country }) => {\n setPhone(value);\n setPhoneCountry(country);\n props.onContactChange?.({\n email,\n phone: getInternationalPhone(value, country),\n });\n }}\n onSameAsBillingChange={setSameAsBilling}\n onShippingChange={setShipping}\n onSubmit={submit}\n phone={phone}\n phoneCountry={phoneCountry}\n pricing={pricing}\n quantity={selection.quantity}\n sameAsBilling={sameAsBilling}\n serviceFeeCents={\n recovery\n ? pricing.serviceFeeCents\n : getAuctionSelectionPricing(auction, item, {\n ...selection,\n includeServiceFee: auction.serviceFeeEnabled,\n }).serviceFeeCents\n }\n serviceFeeEnabled={auction.serviceFeeEnabled}\n showFields={!(recovery || isTerminal)}\n submitDisabled={state === \"busy\" || !stripe || !elements}\n />\n );\n}\n","import type {\n LockerverseAuctionItem as AuctionItem,\n LockerverseAuction,\n} from \"@lockerverse/sdk/auctions\";\nimport { Elements } from \"@stripe/react-stripe-js\";\nimport type {\n StripeElementsOptions,\n StripeElementsOptionsMode,\n} from \"@stripe/stripe-js\";\nimport { type RefObject, useEffect, useState } from \"react\";\nimport { AuctionCheckout } from \"./auction-checkout.tsx\";\nimport type { LockerverseAuctionItemProps } from \"./auction-item-types.ts\";\nimport {\n type AuctionSelection,\n getAuctionSelectionPricing,\n} from \"./auction-payment.ts\";\nimport type { LockerverseAuctionOutcome } from \"./auction-result.tsx\";\nimport { useStripeAppearance } from \"./stripe-appearance.ts\";\nimport { defaultLockerverseStripeLoader } from \"./stripe-loader.ts\";\n\nexport type AuctionPaymentProps = LockerverseAuctionItemProps & {\n appearanceRoot: RefObject<HTMLElement | null>;\n interactionLocked: boolean;\n item: AuctionItem;\n selection: AuctionSelection;\n onReview: (auction: LockerverseAuction, message: string) => void;\n onBack: () => void;\n contact: { email: string; phone: string };\n onContactChange: (contact: { email: string; phone: string }) => void;\n onIncludeServiceFeeChange: (value: boolean) => void;\n onInteractionLockChange: (locked: boolean) => void;\n onResult: (outcome: LockerverseAuctionOutcome) => void;\n};\n\nexport function AuctionPayment(props: AuctionPaymentProps) {\n const {\n auction,\n item,\n selection,\n theme = \"dark\",\n stripeLoader = defaultLockerverseStripeLoader,\n style,\n onBack,\n resumePurchase,\n } = props;\n const [stripe, setStripe] =\n useState<Awaited<ReturnType<typeof defaultLockerverseStripeLoader>>>(null);\n const [failed, setFailed] = useState(false);\n const [revision, setRevision] = useState(0);\n const appearance = useStripeAppearance(\n props.appearanceRoot,\n theme,\n style,\n props.interactionLocked\n );\n const payment = resumePurchase?.payment ?? auction.payment;\n useEffect(() => {\n let active = true;\n if (!payment) {\n setFailed(true);\n return;\n }\n Promise.resolve()\n .then(() =>\n stripeLoader(\n payment.publishableKey,\n payment.connectedAccountId\n ? { stripeAccount: payment.connectedAccountId }\n : undefined\n )\n )\n .then(\n (loaded) => {\n if (active) {\n setStripe(loaded);\n setFailed(!loaded);\n }\n },\n () => {\n if (active) {\n setFailed(true);\n }\n }\n );\n return () => {\n active = false;\n };\n }, [payment, stripeLoader, revision]);\n if (failed) {\n return (\n <div>\n <p role=\"alert\">Payment details could not load.</p>\n {resumePurchase ? null : (\n <button onClick={onBack} type=\"button\">\n Back to item\n </button>\n )}\n <button\n onClick={() => {\n setFailed(false);\n setStripe(null);\n setRevision((value) => value + 1);\n }}\n type=\"button\"\n >\n Try again\n </button>\n </div>\n );\n }\n if (!(stripe && appearance)) {\n return (\n <div>\n <p role=\"status\">Loading secure payment details…</p>\n {resumePurchase ? null : (\n <button onClick={onBack} type=\"button\">\n Back to item\n </button>\n )}\n </div>\n );\n }\n let paymentOptions: StripeElementsOptionsMode = {\n mode: \"setup\",\n };\n if (resumePurchase) {\n paymentOptions = {\n amount: resumePurchase.pricing.totalCents,\n currency: \"usd\",\n mode: \"payment\",\n };\n } else if (item.saleMode === \"buy_now\") {\n paymentOptions = {\n amount: getAuctionSelectionPricing(auction, item, selection).totalCents,\n currency: \"usd\",\n mode: \"payment\",\n };\n }\n const options: StripeElementsOptions = {\n ...paymentOptions,\n appearance,\n currency: \"usd\",\n paymentMethodTypes: [\"card\"],\n setupFutureUsage: \"off_session\" as const,\n syncAddressCheckbox: \"none\",\n };\n return (\n <Elements options={options} stripe={stripe}>\n <AuctionCheckout {...props} />\n </Elements>\n );\n}\n"],"mappings":"oqBAiDA,SAAS,EAAkB,EAAkD,CAC3E,MAAO,CACL,SAAU,CAAE,KAAM,aAAc,EAChC,OAAQ,CACN,eAAgB,CACd,QAAS,QACT,MAAO,QACP,KAAM,QACN,MAAO,OACT,CACF,EACA,MAAO,CACL,SAAU,EAAa,OAAS,QAChC,YAAa,QACb,WAAY,QACZ,KAAM,SACN,QAAS,QACT,UAAW,QACX,MAAO,QACP,OAAQ,EAAa,OAAS,QAC9B,UAAW,QACX,OAAQ,QACR,cAAe,OACjB,EACA,QAAS,CAAE,SAAU,EAAa,OAAS,QAAS,UAAW,OAAQ,CACzE,CACF,CAEA,SAAgB,GAAoB,EAAiC,CACnE,GAAM,CAAE,aAAY,eAAc,OAAM,MAAO,EAC/C,OACE,EAAC,OAAD,CACE,UAAU,iCACV,WAAA,GACA,SAAU,EAAM,SAHlB,SAAA,CAKE,EAAC,MAAD,CAAK,UAAU,wCAAf,SAAA,CACE,EAAC,MAAD,CAAK,UAAU,4CAAf,SAAA,CACE,EAAC,SAAD,CACE,aAAW,OACX,UAAU,sCACV,SAAU,CAAC,EAAM,OACjB,QAAS,EAAM,OACf,KAAK,SAEL,SAAA,EAAC,EAAD,CAAa,cAAY,OAAO,KAAM,EAAK,CAAA,CACrC,CAAA,EACR,EAAC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,CACN,IACF,EAAU,CAAM,EAChB,EAAU,CAAC,CAAM,EAErB,MACM,CACA,GACF,EAAU,EAAI,CAElB,CACF,MACW,CACX,EAAS,EACX,CACF,EAAG,CAAC,EAAS,EAAc,CAAQ,CAAC,EAChC,EACF,OACE,EAAC,MAAD,CAAA,SAAA,CACE,EAAC,IAAD,CAAG,KAAK,QAAQ,SAAA,iCAAkC,CAAA,EACjD,EAAiB,KAChB,EAAC,SAAD,CAAQ,QAAS,EAAQ,KAAK,SAAS,SAAA,cAE/B,CAAA,EAEV,EAAC,SAAD,CACE,YAAe,CACb,EAAU,EAAK,EACf,EAAU,IAAI,EACd,EAAa,GAAU,EAAQ,CAAC,CAClC,EACA,KAAK,SACN,SAAA,WAEO,CAAA,CACL,CAAA,CAAA,EAGT,GAAI,EAAE,GAAU,GACd,OACE,EAAC,MAAD,CAAA,SAAA,CACE,EAAC,IAAD,CAAG,KAAK,SAAS,SAAA,iCAAkC,CAAA,EAClD,EAAiB,KAChB,EAAC,SAAD,CAAQ,QAAS,EAAQ,KAAK,SAAS,SAAA,cAE/B,CAAA,CAEP,CAAA,CAAA,EAGT,IAAI,EAA4C,CAC9C,KAAM,OACR,EACI,EACF,EAAiB,CACf,OAAQ,EAAe,QAAQ,WAC/B,SAAU,MACV,KAAM,SACR,EACS,EAAK,WAAa,YAC3B,EAAiB,CACf,OAAQ,EAA2B,EAAS,EAAM,CAAS,CAAC,CAAC,WAC7D,SAAU,MACV,KAAM,SACR,GAEF,IAAM,EAAiC,CACrC,GAAG,EACH,aACA,SAAU,MACV,mBAAoB,CAAC,MAAM,EAC3B,iBAAkB,cAClB,oBAAqB,MACvB,EACA,OACE,EAAC,EAAD,CAAmB,UAAiB,SAClC,SAAA,EAAC,EAAD,CAAiB,GAAI,CAAQ,CAAA,CACrB,CAAA,CAEd"}
|
|
1
|
+
{"version":3,"file":"auction-payment-view.js","names":["formatMoney"],"sources":["../src/auction-checkout-view.tsx","../src/auction-checkout.tsx","../src/auction-payment-view.tsx"],"sourcesContent":["import type {\n LockerverseAuctionItem,\n LockerverseAuctionPricing,\n} from \"@lockerverse/sdk/auctions\";\nimport { AddressElement, PaymentElement } from \"@stripe/react-stripe-js\";\nimport type {\n StripeAddressElementChangeEvent,\n StripePaymentElementOptions,\n} from \"@stripe/stripe-js\";\nimport { ArrowRight, ChevronLeft } from \"lucide-react\";\nimport type { FormEventHandler } from \"react\";\nimport { formatAuctionMoney as formatMoney } from \"./auction-display.ts\";\nimport { Checkbox, EmailField, FormField } from \"./form-field.tsx\";\nimport type { PhoneInputValue } from \"./phone-field.tsx\";\nimport { PhoneInput } from \"./phone-field.tsx\";\n\ntype AuctionCheckoutViewProps = {\n buttonText: string;\n communityName: string;\n email: string;\n contactErrors: { email?: string; phone?: string };\n phoneCountry: string;\n id: string;\n includeServiceFee: boolean;\n isPurchase: boolean;\n isMaximumBid: boolean;\n isTerminal: boolean;\n item: LockerverseAuctionItem;\n locked: boolean;\n message: string | null;\n onBack?: (() => void) | undefined;\n onBillingChange: (event: StripeAddressElementChangeEvent) => void;\n onEmailChange: (value: string) => void;\n onIncludeServiceFeeChange?: ((value: boolean) => void) | undefined;\n onPaymentLoadError: () => void;\n onPhoneChange: (value: PhoneInputValue) => void;\n onSameAsBillingChange: (value: boolean) => void;\n onShippingChange: (event: StripeAddressElementChangeEvent) => void;\n onSubmit: FormEventHandler<HTMLFormElement>;\n phone: string;\n pricing: LockerverseAuctionPricing;\n quantity: number;\n sameAsBilling: boolean;\n serviceFeeCents: number;\n serviceFeeEnabled: boolean;\n showFields: boolean;\n submitDisabled: boolean;\n};\n\nfunction getPaymentOptions(isPurchase: boolean): StripePaymentElementOptions {\n return {\n business: { name: \"Lockerverse\" },\n fields: {\n billingDetails: {\n address: \"never\",\n email: \"never\",\n name: \"never\",\n phone: \"never\",\n },\n },\n terms: {\n applePay: \"auto\",\n auBecsDebit: \"never\",\n bancontact: \"never\",\n card: \"always\",\n cashapp: \"never\",\n googlePay: \"auto\",\n ideal: \"never\",\n paypal: isPurchase ? \"auto\" : \"never\",\n sepaDebit: \"never\",\n sofort: \"never\",\n usBankAccount: \"never\",\n },\n wallets: { applePay: \"auto\", googlePay: \"auto\" },\n };\n}\n\nexport function AuctionCheckoutView(props: AuctionCheckoutViewProps) {\n const { isPurchase, isMaximumBid, item, id } = props;\n return (\n <form\n className=\"lockerverse-auctions__checkout\"\n noValidate\n onSubmit={props.onSubmit}\n >\n <div className=\"lockerverse-auctions__checkout-header\">\n <div className=\"lockerverse-auctions__checkout-navigation\">\n <button\n aria-label=\"Back\"\n className=\"lockerverse-auctions__checkout-back\"\n disabled={!props.onBack}\n onClick={props.onBack}\n type=\"button\"\n >\n <ChevronLeft aria-hidden=\"true\" size={20} />\n </button>\n <div>\n <p className=\"lockerverse-auctions__checkout-eyebrow\">\n Step 2 of 2\n </p>\n <p>{isPurchase ? \"Secure checkout\" : \"Secure payment method\"}</p>\n </div>\n </div>\n <p className=\"lockerverse-auctions__checkout-eyebrow\">\n {props.communityName}\n </p>\n <h2>\n {isPurchase\n ? \"Finalize your purchase.\"\n : \"Finalize your bid authorization.\"}\n </h2>\n <CheckoutSummary {...props} />\n {item.collectShippingAddress && (\n <div className=\"lockerverse-auctions__checkout-physical\">\n <p className=\"lockerverse-auctions__checkout-eyebrow\">\n Physical item\n </p>\n <p>\n This item requires a delivery address. Billing details are used by\n default, and you can switch to a separate delivery address below\n if needed.\n </p>\n </div>\n )}\n </div>\n <div className=\"lockerverse-auctions__checkout-body\">\n {props.showFields && (\n <fieldset disabled={props.locked}>\n <div className=\"lockerverse-auctions__checkout-contact\">\n <EmailField\n error={props.contactErrors.email}\n id={`${id}-email`}\n label=\"Email\"\n name=\"email\"\n onChange={(event) => props.onEmailChange(event.target.value)}\n required\n value={props.email}\n />\n <FormField\n error={props.contactErrors.phone}\n id={`${id}-phone`}\n label=\"Phone\"\n >\n <PhoneInput\n country={props.phoneCountry}\n error={props.contactErrors.phone}\n errorId={`${id}-phone-error`}\n id={`${id}-phone`}\n name=\"phone\"\n onChange={props.onPhoneChange}\n required\n value={props.phone}\n />\n </FormField>\n </div>\n <section\n aria-label=\"Payment Information\"\n className=\"lockerverse-auctions__checkout-section\"\n >\n <div className=\"lockerverse-auctions__checkout-section-heading\">\n <h3>Payment Information</h3>\n <p>\n {isPurchase\n ? \"Processed securely and charged immediately for this purchase.\"\n : \"Stored securely and charged only if your bid finishes on top.\"}\n </p>\n </div>\n <PaymentElement\n onLoadError={props.onPaymentLoadError}\n options={getPaymentOptions(isPurchase)}\n />\n </section>\n <section\n aria-label=\"Billing Details\"\n className=\"lockerverse-auctions__checkout-section\"\n >\n <h3>Billing Details</h3>\n <AddressElement\n onChange={props.onBillingChange}\n options={{ mode: \"billing\" }}\n />\n <p>\n {isPurchase\n ? \"Use your full name here. We use the email and phone above for purchase confirmation and fulfillment updates.\"\n : \"Use the bidder's full name here. We use the email and phone above to contact you if this bid is outbid or wins.\"}\n </p>\n </section>\n {item.collectShippingAddress && (\n <section\n aria-label=\"Delivery Details\"\n className=\"lockerverse-auctions__checkout-section\"\n >\n <label\n className=\"lockerverse-auctions__checkout-checkbox lockerverse-auctions__checkout-delivery\"\n htmlFor={`${id}-delivery-same-as-billing`}\n >\n <Checkbox\n checked={props.sameAsBilling}\n id={`${id}-delivery-same-as-billing`}\n onChange={(event) =>\n props.onSameAsBillingChange(event.target.checked)\n }\n />\n <span>\n <strong>Delivery address is the same as billing</strong>\n <span>\n Leave this on for the fastest flow. Turn it off only if\n the delivery address should differ from the billing\n details above.\n </span>\n </span>\n </label>\n {!props.sameAsBilling && (\n <>\n <h3>Delivery Address</h3>\n <AddressElement\n onChange={props.onShippingChange}\n options={{ mode: \"shipping\" }}\n />\n </>\n )}\n </section>\n )}\n <CheckoutAdditionalCharge\n isMaximumBid={isMaximumBid}\n isPurchase={isPurchase}\n pricing={props.pricing}\n />\n {props.serviceFeeEnabled && <CheckoutServiceFee {...props} />}\n </fieldset>\n )}\n {props.message && (\n <p\n aria-live=\"polite\"\n className=\"lockerverse-auctions__notice\"\n role=\"status\"\n >\n {props.message}\n </p>\n )}\n {!props.isTerminal && (\n <div className=\"lockerverse-auctions__checkout-footer\">\n <p>\n {isPurchase\n ? \"By continuing, you agree to be charged for this purchase.\"\n : \"By continuing, you agree to have this payment method stored for item settlement if your bid is the winning offer.\"}\n {item.collectShippingAddress\n ? ` Your delivery details are stored with the ${isPurchase ? \"order\" : \"bid\"} so the seller can fulfill the item after payment.`\n : \"\"}\n </p>\n <button\n className=\"lockerverse-auctions__button lockerverse-auctions__checkout-submit\"\n disabled={props.submitDisabled}\n type=\"submit\"\n >\n {props.buttonText}\n <ArrowRight aria-hidden=\"true\" size={16} />\n </button>\n </div>\n )}\n </div>\n </form>\n );\n}\n\nfunction CheckoutServiceFee(props: AuctionCheckoutViewProps) {\n const { isPurchase, isMaximumBid, pricing } = props;\n const labels = checkoutAmountLabels(isPurchase, isMaximumBid);\n return (\n <section\n aria-label=\"Processing fees\"\n className=\"lockerverse-auctions__checkout-section\"\n >\n {props.onIncludeServiceFeeChange ? (\n <label\n className=\"lockerverse-auctions__checkout-checkbox\"\n htmlFor={`${props.id}-service-fee`}\n >\n <Checkbox\n checked={props.includeServiceFee}\n id={`${props.id}-service-fee`}\n onChange={(event) =>\n props.onIncludeServiceFeeChange?.(event.target.checked)\n }\n />\n <span>\n <strong>\n {labels.fee} {formatMoney(props.serviceFeeCents)} to help cover\n processing fees\n </strong>\n <span>\n {labels.total}: {formatMoney(pricing.totalCents)}\n </span>\n </span>\n </label>\n ) : (\n <p>\n {labels.total}: {formatMoney(pricing.totalCents)}\n </p>\n )}\n </section>\n );\n}\n\nfunction CheckoutAdditionalCharge({\n pricing,\n isPurchase,\n isMaximumBid,\n}: {\n pricing: LockerverseAuctionPricing;\n isPurchase: boolean;\n isMaximumBid: boolean;\n}) {\n const labels = checkoutAmountLabels(isPurchase, isMaximumBid);\n if (!pricing.additionalCharge) {\n return null;\n }\n return (\n <section\n aria-label=\"Order amounts\"\n className=\"lockerverse-auctions__checkout-section\"\n >\n <p>\n {labels.amount}: {formatMoney(pricing.subtotalCents)}\n </p>\n <p>\n {pricing.additionalCharge.name}:{\" \"}\n {formatMoney(pricing.additionalChargeCents ?? 0)}\n </p>\n <p>\n {labels.total}: {formatMoney(pricing.totalCents)}\n </p>\n </section>\n );\n}\n\nfunction CheckoutSummary(props: AuctionCheckoutViewProps) {\n const { isPurchase, isMaximumBid, item, pricing } = props;\n return (\n <p className=\"lockerverse-auctions__checkout-summary\">\n {isPurchase ? (\n <>\n Pay <strong>{formatMoney(pricing.totalCents)}</strong> for{\" \"}\n {props.quantity} {props.quantity === 1 ? \"item\" : \"items\"} of{\" \"}\n <strong>{item.name}</strong>. Your card is charged immediately once\n checkout succeeds.\n </>\n ) : (\n <>\n Authorize a payment method for your{\" \"}\n {isMaximumBid ? \"maximum bid\" : \"bid\"} of{\" \"}\n <strong>{formatMoney(pricing.subtotalCents)}</strong> on{\" \"}\n <strong>{item.name}</strong>. Your card is only charged if this bid\n wins the item.\n {isMaximumBid\n ? \" You pay the final winning price, up to your maximum, plus any agreed fees and additional charges. Your maximum stays private.\"\n : \"\"}\n </>\n )}\n </p>\n );\n}\n\nfunction checkoutAmountLabels(isPurchase: boolean, isMaximumBid: boolean) {\n if (isPurchase) {\n return { amount: \"Subtotal\", fee: \"Add\", total: \"Total\" };\n }\n if (isMaximumBid) {\n return {\n amount: \"Maximum bid\",\n fee: \"If I win, add up to\",\n total: \"Maximum total if I win\",\n };\n }\n return {\n amount: \"Bid amount\",\n fee: \"If I win, add\",\n total: \"Total if I win\",\n };\n}\n","// biome-ignore-all lint/suspicious/noUnnecessaryConditions: React refs change in effect cleanup and event handlers outside this static control flow.\nimport {\n type LockerverseAuction,\n type LockerverseAuctionItem,\n type LockerverseAuctionPurchaseResult,\n LockerverseSdkError,\n} from \"@lockerverse/sdk/auctions\";\nimport { useElements, useStripe } from \"@stripe/react-stripe-js\";\nimport type { StripeAddressElementChangeEvent } from \"@stripe/stripe-js\";\nimport { type FormEvent, useEffect, useId, useRef, useState } from \"react\";\nimport { AuctionCheckoutView } from \"./auction-checkout-view.tsx\";\nimport type {\n LockerverseAuctionItemProps,\n LockerverseAuctionPurchaseRecovery,\n} from \"./auction-item-types.ts\";\nimport {\n type AuctionSelection,\n auctionExpectedPricing,\n completeAuctionAction,\n createAuctionConfirmationToken,\n getAuctionSelectionError,\n getAuctionSelectionPricing,\n hasAuctionCheckoutChanged,\n sameAuctionAdditionalCharge,\n} from \"./auction-payment.ts\";\nimport type { LockerverseAuctionOutcome } from \"./auction-result.tsx\";\nimport { notifyHostCallback } from \"./host-callback.ts\";\nimport { type ContactErrors, validateContact } from \"./payment-validation.ts\";\nimport { getInternationalPhone, resolvePhoneCountry } from \"./phone.ts\";\n\ntype AuctionCheckoutProps = LockerverseAuctionItemProps & {\n item: LockerverseAuctionItem;\n selection: AuctionSelection;\n onReview: (auction: LockerverseAuction, message: string) => void;\n onBack: () => void;\n contact?: { email: string; phone: string };\n onContactChange?: (contact: { email: string; phone: string }) => void;\n onIncludeServiceFeeChange?: (value: boolean) => void;\n onInteractionLockChange?: (locked: boolean) => void;\n onResult: (outcome: LockerverseAuctionOutcome) => void;\n};\n\ntype CheckoutState =\n | \"ready\"\n | \"busy\"\n | \"pending\"\n | \"retry\"\n | \"complete\"\n | \"uncertain\";\n\nfunction getSubmitLabel(\n state: CheckoutState,\n hasRecovery: boolean,\n isPurchase: boolean\n) {\n if (state === \"busy\") {\n return isPurchase ? \"Processing...\" : \"Authorizing...\";\n }\n if (state === \"retry\") {\n return \"Retry original purchase\";\n }\n if (hasRecovery) {\n return \"Check purchase status\";\n }\n return isPurchase ? \"Buy Now\" : \"Authorize Bid\";\n}\n\nexport function AuctionCheckout(props: AuctionCheckoutProps) {\n const { auction, item, selection, client, onReview, onBack } = props;\n const stripe = useStripe();\n const elements = useElements();\n const id = useId();\n const [email, setEmail] = useState(props.contact?.email ?? \"\");\n const [phone, setPhone] = useState(props.contact?.phone ?? \"\");\n const [phoneCountry, setPhoneCountry] = useState<string>(() =>\n resolvePhoneCountry(props.contact?.phone ?? \"\")\n );\n const [contactErrors, setContactErrors] = useState<ContactErrors>({});\n const [sameAsBilling, setSameAsBilling] = useState(true);\n const [billing, setBilling] =\n useState<StripeAddressElementChangeEvent | null>(null);\n const [shipping, setShipping] =\n useState<StripeAddressElementChangeEvent | null>(null);\n const [recovery, setRecovery] = useState(props.resumePurchase ?? null);\n const [state, setState] = useState<CheckoutState>(\n props.resumePurchase ? \"pending\" : \"ready\"\n );\n const [message, setMessage] = useState<string | null>(null);\n const purchaseRequestId = useRef<string | null>(\n props.resumePurchase?.submission.clientRequestId ?? null\n );\n const isTerminal = state === \"complete\" || state === \"uncertain\";\n const busy = useRef<boolean>(false);\n const mounted = useRef<boolean>(true);\n const callbacks = useRef(props);\n callbacks.current = props;\n const outcomeReported = useRef(false);\n\n function transition(next: CheckoutState) {\n if (mounted.current) {\n setState(next);\n }\n notifyHostCallback(\n callbacks.current.onInteractionLockChange,\n next !== \"ready\" && next !== \"complete\"\n );\n }\n function showMessage(value: string | null) {\n if (mounted.current) {\n setMessage(value);\n }\n }\n function reportUncertain(kind: \"bid\" | \"purchase\") {\n transition(kind === \"bid\" ? \"uncertain\" : \"pending\");\n showMessage(\n kind === \"bid\"\n ? \"We could not confirm your bid. Do not submit another bid until you check your email or contact the auction organizer.\"\n : \"We could not confirm the purchase result. Check its status using the same purchase request.\"\n );\n if (!outcomeReported.current) {\n outcomeReported.current = true;\n notifyHostCallback(callbacks.current.onUncertain, kind);\n }\n }\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n };\n }, []);\n const isPurchase =\n Boolean(recovery ?? props.resumePurchase) || item.saleMode === \"buy_now\";\n const pricing =\n recovery?.pricing ??\n props.resumePurchase?.pricing ??\n getAuctionSelectionPricing(auction, item, selection);\n\n const payment =\n recovery?.payment ?? props.resumePurchase?.payment ?? auction.payment;\n\n function rememberPurchase(value: LockerverseAuctionPurchaseRecovery | null) {\n if (mounted.current) {\n setRecovery(value);\n }\n notifyHostCallback(callbacks.current.onPurchaseRecoveryChange, value);\n }\n\n function finishPurchase(result: LockerverseAuctionPurchaseResult) {\n if (result.status === \"paid\") {\n purchaseRequestId.current = null;\n rememberPurchase(null);\n transition(\"complete\");\n notifyHostCallback(callbacks.current.onResult, {\n additionalCharge: result.additionalCharge ?? null,\n additionalChargeCents: result.additionalChargeCents ?? 0,\n kind: \"purchase\",\n purchaseId: result.purchaseId,\n quantity: result.quantity,\n serviceFeeCents: result.serviceFeeCents,\n status: \"paid\",\n subtotalCents: result.subtotalCents,\n totalCents: result.totalCents,\n unitAmountCents: result.subtotalCents / result.quantity,\n });\n if (!outcomeReported.current) {\n outcomeReported.current = true;\n notifyHostCallback(callbacks.current.onPurchaseComplete, result);\n }\n } else if (result.status === \"pending_payment\") {\n transition(\"pending\");\n showMessage(\n \"Your purchase is pending. Check its status before making another payment.\"\n );\n } else {\n purchaseRequestId.current = null;\n rememberPurchase(null);\n transition(\"ready\");\n showMessage(\n `This purchase is ${result.status.replaceAll(\"_\", \" \")}. You can start a new purchase.`\n );\n }\n }\n\n function readContact() {\n const phoneNumber = getInternationalPhone(phone, phoneCountry);\n const contact = validateContact({ email, phone: phoneNumber }, true);\n setContactErrors(contact.errors);\n if (!contact.value) {\n document\n .getElementById(`${id}-${contact.errors.email ? \"email\" : \"phone\"}`)\n ?.focus();\n return null;\n }\n return { email: contact.value.email, phone: phoneNumber };\n }\n\n function requireCurrentSelection() {\n const latest = callbacks.current.selection;\n if (\n selection.quantity !== latest.quantity ||\n selection.amount !== latest.amount ||\n selection.bidType !== latest.bidType ||\n selection.includeServiceFee !== latest.includeServiceFee\n ) {\n throw new Error(\n \"Your selection changed. Review the total before continuing.\"\n );\n }\n }\n\n async function verifyPurchaseQuote(current: LockerverseAuction) {\n if (!(isPurchase && item.additionalCharge)) {\n return true;\n }\n const quote = await client.getPurchaseQuote(auction.slug, item.id, {\n includeServiceFee: selection.includeServiceFee,\n quantity: selection.quantity,\n });\n if (!mounted.current) {\n return false;\n }\n if (\n quote.subtotalCents !== pricing.subtotalCents ||\n (quote.additionalChargeCents ?? 0) !==\n (pricing.additionalChargeCents ?? 0) ||\n quote.serviceFeeCents !== pricing.serviceFeeCents ||\n quote.totalCents !== pricing.totalCents ||\n !sameAuctionAdditionalCharge(\n quote.additionalCharge,\n pricing.additionalCharge\n )\n ) {\n onReview(\n current,\n \"The checkout details changed. Review them before continuing.\"\n );\n return false;\n }\n return true;\n }\n\n async function prepareSubmission(\n contact: { email: string; phone: string } | null\n ) {\n if (!contact) {\n throw new Error(\"Check the contact fields below.\");\n }\n if (!(stripe && elements && auction.payment)) {\n throw new Error(\"Payment details are still loading.\");\n }\n const current = await client.load(auction.slug);\n if (!mounted.current) {\n return null;\n }\n const currentItem = current.items.find(\n (candidate) => candidate.id === item.id\n );\n if (!currentItem) {\n onReview(current, \"This item is no longer available.\");\n return null;\n }\n const selectionError = getAuctionSelectionError(\n current,\n currentItem,\n selection\n );\n if (\n selectionError ||\n hasAuctionCheckoutChanged(auction, current, item, currentItem, selection)\n ) {\n onReview(\n current,\n selectionError ??\n \"The checkout details changed. Review them before continuing.\"\n );\n return null;\n }\n if (!(await verifyPurchaseQuote(current))) {\n return null;\n }\n const confirmationToken = await createAuctionConfirmationToken({\n billing,\n collectShippingAddress: item.collectShippingAddress,\n elements,\n email: contact.email,\n phone: contact.phone,\n shipping: sameAsBilling ? billing : shipping,\n stripe,\n });\n if (!mounted.current) {\n return null;\n }\n requireCurrentSelection();\n return {\n confirmationToken,\n email: contact.email,\n includeServiceFee: selection.includeServiceFee,\n phone: contact.phone,\n ...auctionExpectedPricing(pricing),\n };\n }\n\n async function sendBid(\n submission: NonNullable<Awaited<ReturnType<typeof prepareSubmission>>>\n ) {\n const bidSubmission: Parameters<typeof client.createBid>[2] = {\n ...submission,\n amount: selection.amount,\n };\n if (selection.bidType === \"maximum\") {\n bidSubmission.bidType = \"maximum\";\n }\n const result = await client.createBid(auction.slug, item.id, bidSubmission);\n if (result.requiresAction) {\n if (!(mounted.current && stripe)) {\n reportUncertain(\"bid\");\n return;\n }\n await completeAuctionAction(stripe, result);\n }\n transition(\"complete\");\n notifyHostCallback(callbacks.current.onResult, {\n additionalCharge: result.additionalCharge ?? null,\n additionalChargeCents: result.additionalChargeCents ?? 0,\n amountCents: result.subtotalCents,\n bidType: selection.bidType ?? \"fixed\",\n kind: \"bid\",\n serviceFeeCents: result.serviceFeeCents,\n totalCents: result.totalCents,\n });\n if (!outcomeReported.current) {\n outcomeReported.current = true;\n notifyHostCallback(callbacks.current.onBidSubmitted, result);\n }\n }\n\n async function resolvePurchase(\n result: LockerverseAuctionPurchaseResult,\n active: LockerverseAuctionPurchaseRecovery\n ) {\n if (result.requiresAction) {\n if (!(mounted.current && stripe)) {\n reportUncertain(\"purchase\");\n return;\n }\n await completeAuctionAction(stripe, result);\n const updated = await client.getPurchaseStatus(\n auction.slug,\n item.id,\n active.submission.clientRequestId\n );\n if (updated) {\n finishPurchase(updated);\n } else {\n transition(\"pending\");\n showMessage(\n \"Payment status is not available yet. Check again shortly.\"\n );\n }\n return;\n }\n finishPurchase(result);\n if (!mounted.current && result.status === \"pending_payment\") {\n reportUncertain(\"purchase\");\n }\n }\n\n async function checkPurchase(active: LockerverseAuctionPurchaseRecovery) {\n const result = await client.getPurchaseStatus(\n auction.slug,\n item.id,\n active.submission.clientRequestId\n );\n if (result) {\n await resolvePurchase(result, active);\n } else {\n if (!mounted.current) {\n reportUncertain(\"purchase\");\n return;\n }\n transition(\"retry\");\n showMessage(\n \"No purchase is recorded yet. You can retry the original purchase with the same request ID.\"\n );\n }\n }\n\n async function clearRejectedPurchase(\n error: LockerverseSdkError,\n active: LockerverseAuctionPurchaseRecovery\n ) {\n const result = await client.getPurchaseStatus(\n auction.slug,\n item.id,\n active.submission.clientRequestId\n );\n if (result) {\n await resolvePurchase(result, active);\n return;\n }\n rememberPurchase(null);\n transition(\"ready\");\n showMessage(\n `The purchase was rejected. Review the item and payment details before trying again. (${error.status ?? \"validation\"})`\n );\n }\n\n async function handleFailure<Failure>(\n error: Failure,\n requestSent: boolean,\n active: LockerverseAuctionPurchaseRecovery | null,\n wasRecovery: boolean\n ) {\n const uncertain =\n requestSent &&\n (!(error instanceof LockerverseSdkError) || error.recoveryRecommended);\n showMessage(\n error instanceof Error\n ? error.message\n : \"Unable to complete this request.\"\n );\n if (isPurchase && active) {\n if (\n !wasRecovery &&\n error instanceof LockerverseSdkError &&\n !error.recoveryRecommended\n ) {\n try {\n await clearRejectedPurchase(error, active);\n return;\n } catch {\n /* Keep the original request when status cannot be established. */\n }\n }\n reportUncertain(\"purchase\");\n } else if (uncertain) {\n reportUncertain(\"bid\");\n } else {\n transition(\"ready\");\n }\n }\n\n function getPurchaseRequestId() {\n purchaseRequestId.current ??= globalThis.crypto.randomUUID();\n return purchaseRequestId.current;\n }\n\n function canSendPurchase() {\n if (mounted.current) {\n return true;\n }\n if (!recovery) {\n rememberPurchase(null);\n transition(\"ready\");\n }\n return false;\n }\n\n async function sendOrCheckPurchase(\n active: LockerverseAuctionPurchaseRecovery,\n statusOnly: boolean\n ) {\n if (statusOnly) {\n await checkPurchase(active);\n return;\n }\n if (!canSendPurchase()) {\n return;\n }\n const result = await client.createPurchase(\n auction.slug,\n item.id,\n active.submission\n );\n await resolvePurchase(result, active);\n }\n\n const checkoutPayment = stripe && elements && payment;\n\n function startSubmission() {\n if (busy.current || isTerminal) {\n return null;\n }\n if (!checkoutPayment) {\n showMessage(\"Payment details are still loading.\");\n return null;\n }\n const contact = recovery ? null : readContact();\n if (!(recovery || contact)) {\n return null;\n }\n return { checkoutPayment, contact, retryOriginal: state === \"retry\" };\n }\n\n async function submit(event: FormEvent<HTMLFormElement>) {\n event.preventDefault();\n const start = startSubmission();\n if (!start) {\n return;\n }\n const { contact, checkoutPayment: readyPayment, retryOriginal } = start;\n busy.current = true;\n outcomeReported.current = false;\n transition(\"busy\");\n showMessage(null);\n let requestSent = false;\n let activeRecovery = recovery;\n try {\n if (!activeRecovery) {\n const submission = await prepareSubmission(contact);\n if (!(submission && mounted.current)) {\n transition(\"ready\");\n return;\n }\n if (!isPurchase) {\n requestSent = true;\n await sendBid(submission);\n return;\n }\n activeRecovery = Object.freeze({\n auctionId: auction.id,\n item,\n itemId: item.id,\n payment: Object.freeze({ ...readyPayment }),\n pricing,\n submission: Object.freeze({\n ...submission,\n clientRequestId: getPurchaseRequestId(),\n paymentMethodTypes: Object.freeze([\"card\"] as const),\n quantity: selection.quantity,\n }),\n });\n rememberPurchase(activeRecovery);\n }\n requestSent = true;\n await sendOrCheckPurchase(\n activeRecovery,\n Boolean(recovery) && !retryOriginal\n );\n } catch (error) {\n await handleFailure(\n error,\n requestSent,\n activeRecovery,\n recovery !== null && !retryOriginal\n );\n } finally {\n busy.current = false;\n }\n }\n\n const buttonText = getSubmitLabel(state, recovery !== null, isPurchase);\n\n const locked = state !== \"ready\";\n return (\n <AuctionCheckoutView\n buttonText={buttonText}\n communityName={props.communityName ?? auction.name}\n contactErrors={contactErrors}\n email={email}\n id={id}\n includeServiceFee={selection.includeServiceFee}\n isMaximumBid={!isPurchase && selection.bidType === \"maximum\"}\n isPurchase={isPurchase}\n isTerminal={isTerminal}\n item={item}\n locked={locked}\n message={message}\n onBack={state === \"ready\" ? onBack : undefined}\n onBillingChange={setBilling}\n onEmailChange={(value) => {\n setEmail(value);\n props.onContactChange?.({\n email: value,\n phone: getInternationalPhone(phone, phoneCountry),\n });\n }}\n onIncludeServiceFeeChange={props.onIncludeServiceFeeChange}\n onPaymentLoadError={() => showMessage(\"Unable to load payment form.\")}\n onPhoneChange={({ value, country }) => {\n setPhone(value);\n setPhoneCountry(country);\n props.onContactChange?.({\n email,\n phone: getInternationalPhone(value, country),\n });\n }}\n onSameAsBillingChange={setSameAsBilling}\n onShippingChange={setShipping}\n onSubmit={submit}\n phone={phone}\n phoneCountry={phoneCountry}\n pricing={pricing}\n quantity={selection.quantity}\n sameAsBilling={sameAsBilling}\n serviceFeeCents={\n recovery\n ? pricing.serviceFeeCents\n : getAuctionSelectionPricing(auction, item, {\n ...selection,\n includeServiceFee: auction.serviceFeeEnabled,\n }).serviceFeeCents\n }\n serviceFeeEnabled={auction.serviceFeeEnabled}\n showFields={!(recovery || isTerminal)}\n submitDisabled={state === \"busy\" || !stripe || !elements}\n />\n );\n}\n","import type {\n LockerverseAuctionItem as AuctionItem,\n LockerverseAuction,\n} from \"@lockerverse/sdk/auctions\";\nimport { Elements } from \"@stripe/react-stripe-js\";\nimport type {\n StripeElementsOptions,\n StripeElementsOptionsMode,\n} from \"@stripe/stripe-js\";\nimport { type RefObject, useEffect, useState } from \"react\";\nimport { AuctionCheckout } from \"./auction-checkout.tsx\";\nimport type { LockerverseAuctionItemProps } from \"./auction-item-types.ts\";\nimport {\n type AuctionSelection,\n getAuctionSelectionPricing,\n} from \"./auction-payment.ts\";\nimport type { LockerverseAuctionOutcome } from \"./auction-result.tsx\";\nimport { useStripeAppearance } from \"./stripe-appearance.ts\";\nimport { defaultLockerverseStripeLoader } from \"./stripe-loader.ts\";\n\nexport type AuctionPaymentProps = LockerverseAuctionItemProps & {\n appearanceRoot: RefObject<HTMLElement | null>;\n interactionLocked: boolean;\n item: AuctionItem;\n selection: AuctionSelection;\n onReview: (auction: LockerverseAuction, message: string) => void;\n onBack: () => void;\n contact: { email: string; phone: string };\n onContactChange: (contact: { email: string; phone: string }) => void;\n onIncludeServiceFeeChange: (value: boolean) => void;\n onInteractionLockChange: (locked: boolean) => void;\n onResult: (outcome: LockerverseAuctionOutcome) => void;\n};\n\nexport function AuctionPayment(props: AuctionPaymentProps) {\n const {\n auction,\n item,\n selection,\n theme = \"dark\",\n stripeLoader = defaultLockerverseStripeLoader,\n style,\n onBack,\n resumePurchase,\n } = props;\n const [stripe, setStripe] =\n useState<Awaited<ReturnType<typeof defaultLockerverseStripeLoader>>>(null);\n const [failed, setFailed] = useState(false);\n const [revision, setRevision] = useState(0);\n const appearance = useStripeAppearance(\n props.appearanceRoot,\n theme,\n style,\n props.interactionLocked\n );\n const payment = resumePurchase?.payment ?? auction.payment;\n useEffect(() => {\n let active = true;\n if (!payment) {\n setFailed(true);\n return;\n }\n Promise.resolve()\n .then(() =>\n stripeLoader(\n payment.publishableKey,\n payment.connectedAccountId\n ? { stripeAccount: payment.connectedAccountId }\n : undefined\n )\n )\n .then(\n (loaded) => {\n if (active) {\n setStripe(loaded);\n setFailed(!loaded);\n }\n },\n () => {\n if (active) {\n setFailed(true);\n }\n }\n );\n return () => {\n active = false;\n };\n }, [payment, stripeLoader, revision]);\n if (failed) {\n return (\n <div>\n <p role=\"alert\">Payment details could not load.</p>\n {resumePurchase ? null : (\n <button onClick={onBack} type=\"button\">\n Back to item\n </button>\n )}\n <button\n onClick={() => {\n setFailed(false);\n setStripe(null);\n setRevision((value) => value + 1);\n }}\n type=\"button\"\n >\n Try again\n </button>\n </div>\n );\n }\n if (!(stripe && appearance)) {\n return (\n <div>\n <p role=\"status\">Loading secure payment details…</p>\n {resumePurchase ? null : (\n <button onClick={onBack} type=\"button\">\n Back to item\n </button>\n )}\n </div>\n );\n }\n let paymentOptions: StripeElementsOptionsMode = {\n mode: \"setup\",\n };\n if (resumePurchase) {\n paymentOptions = {\n amount: resumePurchase.pricing.totalCents,\n currency: \"usd\",\n mode: \"payment\",\n };\n } else if (item.saleMode === \"buy_now\") {\n paymentOptions = {\n amount: getAuctionSelectionPricing(auction, item, selection).totalCents,\n currency: \"usd\",\n mode: \"payment\",\n };\n }\n const options: StripeElementsOptions = {\n ...paymentOptions,\n appearance,\n currency: \"usd\",\n paymentMethodTypes: [\"card\"],\n setupFutureUsage: \"off_session\" as const,\n syncAddressCheckbox: \"none\",\n };\n return (\n <Elements options={options} stripe={stripe}>\n <AuctionCheckout {...props} />\n </Elements>\n );\n}\n"],"mappings":"oqBAiDA,SAAS,EAAkB,EAAkD,CAC3E,MAAO,CACL,SAAU,CAAE,KAAM,aAAc,EAChC,OAAQ,CACN,eAAgB,CACd,QAAS,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A,iCAAkC,CAAA,EAClD,EAAiB,KAChB,EAAC,SAAD,CAAQ,QAAS,EAAQ,KAAK,SAAS,SAAA,cAE/B,CAAA,CAEP,CAAA,CAAA,EAGT,IAAI,EAA4C,CAC9C,KAAM,OACR,EACI,EACF,EAAiB,CACf,OAAQ,EAAe,QAAQ,WAC/B,SAAU,MACV,KAAM,SACR,EACS,EAAK,WAAa,YAC3B,EAAiB,CACf,OAAQ,EAA2B,EAAS,EAAM,CAAS,CAAC,CAAC,WAC7D,SAAU,MACV,KAAM,SACR,GAEF,IAAM,EAAiC,CACrC,GAAG,EACH,aACA,SAAU,MACV,mBAAoB,CAAC,MAAM,EAC3B,iBAAkB,cAClB,oBAAqB,MACvB,EACA,OACE,EAAC,EAAD,CAAmB,UAAiB,SAClC,SAAA,EAAC,EAAD,CAAiB,GAAI,CAAQ,CAAA,CACrB,CAAA,CAEd"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t as e}from"./format-money.js";import{t}from"./host-callback.js";import{n,t as r}from"./accent-contrast.js";import{d as i,i as a,n as o,p as s,t as c,u as l}from"./phone-field.js";import{a as u,i as d,n as f,r as p,s as m}from"./custom-fields.js";import{t as h}from"./form-skeleton.js";import{t as g}from"./payment-summary.js";import{i as _,n as v,r as y,t as b}from"./stripe-loader.js";import{useCallback as x,useEffect as S,useId as C,useLayoutEffect as w,useMemo as T,useReducer as E,useRef as D,useState as O}from"react";import{Fragment as k,jsx as A,jsxs as j}from"react/jsx-runtime";import{LockerverseSdkError as M,estimateLockerverseCheckout as N}from"@lockerverse/sdk/checkout";import{AddressElement as P,Elements as F,PaymentElement as I,useElements as L,useStripe as R}from"@stripe/react-stripe-js";import{array as z,literal as B,minLength as V,minValue as ee,nonEmpty as H,nullable as te,number as ne,object as re,optional as U,pipe as W,regex as ie,safeInteger as G,safeParse as ae,strictObject as oe,string as K,trim as q,union as se}from"valibot";function ce({ariaDescribedBy:e,ariaLabel:t,ariaLabelledBy:n,className:r,id:i,invalid:a=!1,name:o,onValueChange:s,options:c,value:l}){return A(`select`,{"aria-describedby":e,"aria-invalid":a||void 0,"aria-label":t,"aria-labelledby":n,className:[`lockerverse-form__control`,`lockerverse-form__select`,r].filter(Boolean).join(` `),id:i,name:o,onChange:e=>s(e.currentTarget.value),value:l,children:c.map(e=>A(`option`,{value:e.value,children:e.label},e.value))})}const le=[`XS`,`S`,`M`,`L`,`XL`,`XXL`,`XXXL`],ue=[`15`,`12`,`10`,`5`],J=[...ue,`custom`];function de({enabled:e,error:t,errorId:n,onChange:r,values:i}){if(!e)return null;let a=e=>r({...i,...e}),o=(e,t)=>{let n=J.indexOf(t),r;switch(e.key){case`ArrowDown`:case`ArrowRight`:r=(n+1)%J.length;break;case`ArrowLeft`:case`ArrowUp`:r=(n-1+J.length)%J.length;break;case`Home`:r=0;break;case`End`:r=J.length-1;break;default:return}e.preventDefault();let i=J[r];i&&((e.currentTarget.closest(`[role="radiogroup"]`)?.querySelectorAll(`input[type="radio"]`))?.[r]?.focus(),a({tipPercent:i}))};return j(`div`,{className:`lockerverse-payment__tip-box`,children:[A(`p`,{children:`Add a tip to support the Lockerverse platform`}),j(`div`,{"aria-label":`Tip amount`,role:`radiogroup`,children:[ue.map(e=>j(`label`,{className:`lockerverse-payment__tip-choice`,children:[A(`input`,{checked:i.tipPercent===e,name:`tipPercent`,onChange:()=>a({tipPercent:e}),onKeyDown:t=>o(t,e),tabIndex:i.tipPercent===e?0:-1,type:`radio`,value:e}),j(`span`,{children:[e,`%`]})]},e)),j(`label`,{className:`lockerverse-payment__tip-choice`,children:[A(`input`,{checked:i.tipPercent===`custom`,name:`tipPercent`,onChange:()=>a({tipPercent:`custom`}),onKeyDown:e=>o(e,`custom`),tabIndex:i.tipPercent===`custom`?0:-1,type:`radio`,value:`custom`}),A(`span`,{children:`Other`})]})]}),i.tipPercent===`custom`?j(`label`,{children:[A(`span`,{children:`Custom tip`}),j(`span`,{className:`lockerverse-payment__money-input`,children:[A(`span`,{"aria-hidden":`true`,children:`$`}),A(`input`,{"aria-describedby":t?n:void 0,"aria-invalid":t?`true`:void 0,inputMode:`decimal`,name:`tip`,onChange:e=>a({customTip:e.currentTarget.value}),placeholder:`0.00`,value:i.customTip})]}),t?A(`span`,{className:`lockerverse-payment__field-message`,id:n,children:t}):null]}):A(`input`,{name:`tip`,type:`hidden`,value:i.tipPercent})]})}function fe({checked:e,children:t,name:n,onChange:r}){let i=C();return j(`label`,{className:`lockerverse-payment__check-row`,htmlFor:i,children:[A(l,{checked:e,id:i,name:n,onChange:e=>r(e.currentTarget.checked)}),A(`span`,{children:t})]})}function pe({customFields:e,errors:t,fields:n,idPrefix:r,isPromoApplying:i,memberIdLabel:a,onChange:o,onApplyPromo:s,promoError:c,values:l}){let u=e=>o({...l,...e});return j(`div`,{className:`lockerverse-payment__additional-fields`,children:[n.memberId?j(`label`,{children:[A(`span`,{children:a?.trim()||`Member ID`}),A(`input`,{name:`memberId`,onChange:e=>u({memberId:e.currentTarget.value}),placeholder:`Optional`,value:l.memberId})]}):null,n.merchSize?j(`div`,{className:`lockerverse-payment__field`,children:[A(`span`,{id:`${r}-merch-size-label`,children:`Size`}),A(ce,{ariaLabelledBy:`${r}-merch-size-label`,name:`merchSize`,onValueChange:e=>{let t=le.find(t=>t===e);t&&u({merchSize:t})},options:le.map(e=>({label:e,value:e})),value:l.merchSize})]}):null,n.promoCode?j(`div`,{className:`lockerverse-payment__field`,children:[A(`span`,{id:`${r}-promo-code-label`,children:`Promo code`}),j(`div`,{className:`lockerverse-payment__promo-control`,children:[A(`input`,{"aria-describedby":c?`${r}-promo-code-error`:void 0,"aria-invalid":c?`true`:void 0,"aria-labelledby":`${r}-promo-code-label`,name:`promoCode`,onChange:e=>u({promoCode:e.currentTarget.value}),placeholder:`Optional`,value:l.promoCode}),A(`button`,{disabled:!l.promoCode.trim()||i,onClick:s,type:`button`,children:i?`Applying…`:`Apply`})]}),c?A(`p`,{className:`lockerverse-payment__field-message`,id:`${r}-promo-code-error`,role:`alert`,children:c}):null]}):null,A(f,{choiceClassName:`lockerverse-payment__check-row`,errorClassName:`lockerverse-payment__field-message`,errors:t,fields:e,idPrefix:r,onChange:e=>u({customFields:e}),values:l.customFields})]})}function Y({amountCents:t,enabled:n,onChange:r,values:i}){return n?j(fe,{checked:i.includeServiceFee,name:`includeServiceFee`,onChange:e=>r({...i,includeServiceFee:e}),children:[`Add `,e(t),` to help cover processing fees`]}):null}function X(e){return{error:void 0,message:void 0,status:e?`recovering`:`editing`}}function Z(e,t,n){return t.includes(e.status)?{...e,...n}:e}function me(e,t){if(t.type===`recovery_started`&&e.status===`unresolved`)return{...e,message:void 0,status:`recovering`};if(e.status===`sold_out`||e.status===`succeeded`||e.status===`unresolved`)return e;switch(t.type){case`field_changed`:return Z(e,[`editing`,`invalid`,`refreshing_quote`],{error:void 0,status:`editing`});case`validation_failed`:return Z(e,[`editing`],{status:`invalid`});case`quote_refresh_started`:return Z(e,[`editing`,`invalid`],{status:`refreshing_quote`});case`quote_refresh_succeeded`:return Z(e,[`refreshing_quote`],{error:void 0,status:`editing`});case`quote_refresh_failed`:return Z(e,[`refreshing_quote`],{error:t.error??e.error,status:`editing`});case`submission_started`:return Z(e,[`editing`,`invalid`,`refreshing_quote`],{error:void 0,status:`submitting`});case`submission_validation_failed`:return Z(e,[`submitting`],{error:void 0,status:`invalid`});case`quote_changed`:return Z(e,[`submitting`],{status:`editing`});case`retryable_failure`:return Z(e,[`editing`,`invalid`,`submitting`],{error:t.error,status:`editing`});case`recovery_failed`:return Z(e,[`recovering`],{error:t.error,retryUrl:void 0,status:`editing`});case`sold_out`:return{error:void 0,message:void 0,status:`sold_out`};case`succeeded`:return Z(e,[`recovering`,`submitting`],{message:t.message,retryUrl:void 0,status:`succeeded`});case`unresolved`:return Z(e,[`recovering`,`submitting`],{message:t.message,retryUrl:t.retryUrl,status:`unresolved`});default:return e}}function he(e){return e.status===`editing`||e.status===`invalid`||e.status===`refreshing_quote`?e.error:void 0}function Q(e){return e.status===`sold_out`?`sold_out`:e.status===`succeeded`?`success`:e.status===`unresolved`?`unresolved`:e.status===`submitting`||e.status===`recovering`?`submitting`:e.status===`invalid`?`invalid`:he(e)?`error`:`idle`}function $(e){return e.status===`submitting`}const ge=[`amountCents`,`discountableSubtotalCents`,`discountCents`,`serviceFeeCents`,`subtotalCents`,`tipCents`,`totalCents`],_e=[`discountableSubtotalCents`,`discountCents`,`subtotalCents`];function ve(e,t,n,r){return(n===t.totalCents?_e:ge).some(n=>e[n]!==t[n])||r!==t.payment.connectedAccountId||e.authoritative&&(e.payment.connectedAccountId!==r||e.payment.currency!==t.payment.currency)||JSON.stringify(e.appliedDiscount)!==JSON.stringify(t.appliedDiscount)||JSON.stringify(e.lineItems)!==JSON.stringify(t.lineItems)}function ye(e){if(e.checkoutStatus===`success`)return{kind:`success`,payment:e};if(e.checkoutStatus===`failed`)return{kind:`failed`,payment:e};let t={kind:`unresolved`,paymentReference:e.paymentReference,reason:e.checkoutStatus===`action_required`?`action_required`:`pending`};return e.retryUrl&&(t.retryUrl=e.retryUrl),t}async function be(e,t,n){if(t.checkoutStatus!==`action_required`||!t.requiresAction)return ye(t);if(!n)return{kind:`unresolved`,paymentReference:t.paymentReference,reason:`action_required`};if(t.clientSecret)try{await n.handleNextAction({clientSecret:t.clientSecret})}catch{}try{return ye(await e.getPaymentStatus(t.paymentReference))}catch{return{kind:`unresolved`,paymentReference:t.paymentReference,reason:`action_required`}}}async function xe(e,t,n){let r;try{r=await e.submitPayment(t)}catch(n){if(!(n instanceof M&&n.recoveryRecommended))throw n;try{r=await e.getPaymentStatus(t.checkout.paymentReference)}catch{return{kind:`unresolved`,paymentReference:t.checkout.paymentReference,reason:`recovery_failed`}}}return be(e,r,n)}async function Se(e,t,n){try{return be(e,await e.getPaymentStatus(t),n)}catch{return{kind:`unresolved`,paymentReference:t,reason:`recovery_failed`}}}const Ce=W(K(),q(),H()),we=W(ne(),G(),ee(1)),Te=W(z(se([oe({amountCents:we,productSlug:Ce}),oe({productSlug:Ce,quantity:we}),oe({productSlug:Ce})])),V(1)),Ee=W(K(),q(),ie(/^(?:0|[1-9]\d*)(?:\.\d{1,2})?$/,`Enter a valid tip amount.`));function De(e){let t=ae(Ee,e);if(!t.success)return{message:t.issues[0]?.message??`Enter a valid tip amount.`,success:!1};let[n=`0`,r=``]=t.output.split(`.`),i=BigInt(n)*100n+BigInt(r.padEnd(2,`0`));return i>BigInt(2**53-1)?{message:`Enter a valid tip amount.`,success:!1}:{cents:Number(i),success:!0}}function Oe(e){let t=ae(Te,e);return t.success?{success:!0,value:t.output}:{message:`Lockerverse payment configuration is invalid.`,success:!1}}const ke=`This promo code is invalid or cannot be applied.`;function Ae(e,t){return t.tipPercent===`custom`?t.customTip.trim()?De(t.customTip):{cents:0,success:!0}:{cents:Math.round(e*Number(t.tipPercent)/100),success:!0}}function je(e,t,n,r){let i={};return n&&(i.email=n),e.widget.fields.serviceFee&&(i.includeServiceFee=t.includeServiceFee),e.widget.fields.promoCode&&t.promoCode.trim()&&(i.promoCode=t.promoCode.trim()),e.widget.fields.tipping&&(i.tipCents=r),i}function Me(e,t,n){let r=e.widget.fields.tipping?Ae(n.subtotalCents,t):{cents:0,success:!0};if(!r.success)return{parsedTip:r,totalCents:null};let i=e.widget.fields.serviceFee&&t.includeServiceFee?n.serviceFeeCents||Math.round(n.subtotalCents*e.pricingPolicy.serviceFeeRateBasisPoints/1e4):0;return{parsedTip:r,totalCents:n.totalCents-n.serviceFeeCents-n.tipCents+i+r.cents}}function Ne(e,t){return{displayedTotalCents:e.totalCents,promoError:t&&e.appliedDiscount?.source!==`promo_code`?ke:void 0}}function Pe(e,t){let n;return t||(n=e instanceof Error?e.message:`The order total could not be updated.`),{paymentError:n,promoError:t?ke:void 0}}function Fe(e,t){if(!e?.complete)throw Error(`${t} address is required.`);return e.value}function Ie(e,t,n,r){if(e.widget.fields.shipping)return t.shippingMatchesBilling?n:Fe(r.shipping,`Shipping`)}function Le({billingAddress:e,catalog:t,email:n,phone:r,shippingAddress:i}){let a={payment_method_data:{billing_details:t.widget.fields.phone?{address:e.address,email:n,name:e.name,phone:r}:{address:e.address,email:n,name:e.name}}};return i?{...a,shipping:{address:i.address,name:i.name,phone:t.widget.fields.phone?r:i.phone??null}}:a}function Re({catalog:e,checkoutItems:t,confirmationToken:n,email:r,fieldValues:i,metadata:a,phone:o,shippingAddress:s}){let c={customFieldAnswers:p(u(e,t),i.customFields),email:r};if(n&&(c.confirmationToken=n,c.paymentMethodConfiguration=`explicit`),a&&(c.metadata=a),e.widget.fields.memberId&&i.memberId.trim()&&(c.memberId=i.memberId.trim()),e.widget.fields.merchSize&&(c.merchSize=i.merchSize),e.widget.fields.phone&&(c.phone=o),s){let e={city:s.address.city??``,country:s.address.country,line1:s.address.line1??``,postal_code:s.address.postal_code??``,state:s.address.state??``};s.address.line2&&(e.line2=s.address.line2),c.shipping={address:e,name:s.name}}return c}function ze(e){if(!e())throw Error(`Payment component is no longer active.`)}function Be(e,n){t(e,n)}function Ve(e,t,n,r){return e.kind===`failed`?{kind:`payment_failed`,message:r}:e.kind===`unresolved`?{kind:`payment_unresolved`,paymentReference:e.paymentReference,reason:e.reason,retryUrl:e.retryUrl}:{email:n,kind:`payment`,payment:e.payment,quote:t}}async function He({addresses:e,catalog:t,checkoutItems:n,client:r,elements:i,email:a,fieldValues:o,isAttemptActive:s,locallyPreviewedTotalCents:c,metadata:l,onPaymentRecoveryChange:u,phone:d,quote:f,stripe:p,stripeConnectedAccountId:m}){let h=a.trim().toLowerCase(),g=y(d),_=Ae(f.subtotalCents,o);if(!_.success)throw Error(_.message);let v=await r.calculateTotal({...je(t,o,h,_.cents),catalog:t,items:n});if(ze(s),v.totalCents>0&&ve(f,v,c,m))return{kind:`quote_changed`,quote:v};let b,x;if(v.totalCents===0)t.widget.fields.shipping&&(b=Ie(t,o,Fe(e.billing,`Billing`),e));else{if(!(i&&p))throw Error(`Payment form is still loading.`);await i.update({amount:v.totalCents}),ze(s);let n=await i.submit();if(ze(s),n.error)throw Error(n.error.message);let r=Fe(e.billing,`Billing`);b=Ie(t,o,r,e);let a=await p.createConfirmationToken({elements:i,params:Le({billingAddress:r,catalog:t,email:h,phone:g,shippingAddress:b})});if(ze(s),a.error)throw Error(a.error.message);x=a.confirmationToken.id}Be(u,{connectedAccountId:v.payment.connectedAccountId,paymentReference:v.paymentReference});let S=await xe(r,{checkout:v,submission:Re({catalog:t,checkoutItems:n,confirmationToken:x,email:h,fieldValues:o,metadata:l,phone:g,shippingAddress:b})},p);return ze(s),Ve(S,v,h,v.totalCents===0?`Order could not be completed. Review the details and try again.`:`Payment was declined. Check your payment details and try again.`)}function Ue(e,n){t(e,n)}function We(e,n){t(e,n)}function Ge(e,t){return{...e,...t}}function Ke(e){let t={message:e.reason===`action_required`?`Payment needs your attention. Keep this checkout open.`:`Payment is not complete. Check its status before you try again.`,type:`unresolved`};return e.retryUrl&&(t.retryUrl=e.retryUrl),t}function qe(e,t,n){return e.kind===`unresolved`&&e.reason===`action_required`&&!e.retryUrl&&!t&&!n}function Je(e){return e instanceof M&&e.serverCode===`PAYMENT_WIDGET_SALES_LIMIT_REACHED`}function Ye({nextQuote:e,onQuoteChange:t,setDisplayedTotalCents:n,setPromoError:r,updateState:i,validatePromo:a}){let o=Ne(e,a);i({type:`quote_refresh_succeeded`}),n(o.displayedTotalCents),t(e),a&&r(o.promoError)}function Xe({error:e,setPromoError:t,updateState:n,validatePromo:r}){let i=Pe(e,r);r&&t(i.promoError),n(i.paymentError===void 0?{type:`quote_refresh_failed`}:{error:i.paymentError,type:`quote_refresh_failed`})}function Ze({onPaymentComplete:n,onPaymentRecoveryChange:r,onPaymentUncertain:i,onQuoteChange:a,result:o,setDisplayedTotalCents:s,dispatchState:c,unresolvedReferenceRef:l}){if(o.kind===`quote_changed`){let t=`The total changed to ${e(o.quote.totalCents)}. Review it and pay again.`;a(o.quote,t),s(o.quote.totalCents),c({type:`quote_changed`});return}if(o.kind===`payment_failed`){Ue(r,null),c({error:o.message,type:`retryable_failure`});return}if(o.kind===`payment_unresolved`){l.current=o.paymentReference,c(Ke(o)),We(i,{paymentReference:o.paymentReference,reason:o.reason});return}a(o.quote),Ue(r,null),c({message:o.payment.paymentRequired?`Payment completed successfully.`:`Order confirmed. No payment was required.`,type:`succeeded`}),t(n,Ge(o.payment,{email:o.email,lineItems:o.quote.lineItems}))}function Qe(e){let{catalog:n,checkoutItems:r,client:i,elements:o,email:s,fieldValues:c,metadata:l,onPaymentComplete:u,onResumePaymentFailed:d,onPaymentRecoveryChange:f,onPaymentUncertain:p,onQuoteChange:m,onStateChange:h,quote:g,resumePayment:v,stripe:y,stripeConnectedAccountId:b,stripeLoadFailed:C,paymentState:w,updateState:T}=e,[E,k]=O(g.totalCents),[A,j]=O(),N=D(!1),P=D(void 0),F=D(0),I=D(0),L=x(e=>T(e,!0),[T]),R=x(()=>{let e=I.current+1;return I.current=e,()=>I.current===e},[]);S(()=>()=>{I.current+=1,F.current+=1},[]);let{parsedTip:z,totalCents:B}=Me(n,c,g);S(()=>{B!==null&&(k(B),B>0&&o?.update({amount:B}))},[n.pricingPolicy.serviceFeeRateBasisPoints,n.widget.fields.serviceFee,o,c.includeServiceFee,B,g.serviceFeeCents,g.tipCents,g.totalCents,g.subtotalCents]),S(()=>{let e=v?.paymentReference??P.current;if(!e||N.current||w.status!==`recovering`)return;N.current=!0;let n=R();return h(Q(w)),Se(i,e,y).then(e=>{if(n()&&!qe(e,y,C)){if(e.kind===`failed`){Ue(f,null),d(),L({error:`The previous payment failed. Check your details and try again.`,type:`recovery_failed`});return}if(e.kind===`unresolved`){L(Ke(e)),We(p,{paymentReference:e.paymentReference,reason:e.reason});return}Ue(f,null),L({message:e.payment.paymentRequired?`Payment completed successfully.`:`Order confirmed. No payment was required.`,type:`succeeded`}),t(u,Ge(e.payment,{email:null,lineItems:null}))}}),()=>{n()&&(I.current+=1),N.current=!1}},[i,u,d,f,p,h,v,y,C,R,L,w]);let V=x((e=!1,t=!1)=>{t||(F.current+=1),e&&j(void 0),T({type:`field_changed`})},[T]);async function ee(e=!1,t=!1){let a=s.trim().toLowerCase(),o=_({email:a,phone:``},!1);if(!(z.success&&(o.value||e)))return;F.current+=1;let l=F.current;T({type:`quote_refresh_started`});try{let e=await i.calculateTotal({...je(n,c,o.value?.email??``,z.cents),catalog:n,items:r});if(l!==F.current)return;Ye({nextQuote:e,onQuoteChange:m,setDisplayedTotalCents:k,setPromoError:j,updateState:T,validatePromo:t})}catch(e){if(l!==F.current)return;if(Je(e)){T({type:`sold_out`});return}Xe({error:e,setPromoError:j,updateState:T,validatePromo:t})}}async function H(){j(void 0),await ee(!0,!0)}async function te({addresses:e,phone:t}){L({type:`submission_started`});let d=R();try{let a=await He({addresses:e,catalog:n,checkoutItems:r,client:i,elements:o,email:s,fieldValues:c,isAttemptActive:d,locallyPreviewedTotalCents:E,metadata:l,onPaymentRecoveryChange:f,phone:t,quote:g,stripe:y,stripeConnectedAccountId:b});if(!d())return;Ze({dispatchState:L,onPaymentComplete:u,onPaymentRecoveryChange:f,onPaymentUncertain:p,onQuoteChange:m,result:a,setDisplayedTotalCents:k,unresolvedReferenceRef:P})}catch(e){if(!d())return;if(Ue(f,null),Je(e)){L({type:`sold_out`});return}let t=e instanceof M?a(e.serverCode):void 0;if(t)return L({type:`submission_validation_failed`}),{phoneError:t};L({error:e instanceof Error?e.message:`Payment could not be completed.`,type:`retryable_failure`})}}let ne=w.status===`succeeded`||w.status===`unresolved`?w.message:void 0;return{commands:{applyPromo:H,checkPaymentStatus:()=>L({type:`recovery_started`}),fieldChanged:V,refreshAuthoritativeTotal:ee,reportValidationFailure:()=>L({type:`validation_failed`}),submit:te},state:{displayedTotalCents:E,isRecovering:w.status===`recovering`,isRefreshingQuote:w.status===`refreshing_quote`,isSubmitting:$(w),isUnresolved:w.status===`unresolved`,parsedTip:z,paymentError:he(w),promoError:A,retryUrl:w.retryUrl,terminalMessage:ne}}}const $e=b;function et(e){let{connectedAccountId:t,publishableKey:n}=e.payment;return $e(n,t?{stripeAccount:t}:void 0)}function tt(e){return e===`monthly`?{interval:`month`,label:`Monthly`}:e===`annually`?{interval:`year`,label:`Annual`}:e===`every-six-months`?{interval:`6 months`,label:`Every 6 months`}:null}function nt(e,t,n){if(n){let{connectedAccountId:e}=n;return e}if(`payment`in t){let{connectedAccountId:e}=t.payment;return e}let{connectedAccountId:r}=e.payment;return r}function rt({accentColor:e,catalog:t,checkoutItems:n,client:r,appearanceRoot:i,initialCustomFieldValues:a,paymentSummaryPosition:o,metadata:s,onPaymentComplete:c,onResumePaymentFailed:l,onPaymentRecoveryChange:u,onPaymentUncertain:d,onQuoteChange:f,quote:p,resumePayment:m,onStateChange:g,stripeLoader:_,theme:y,visualStyle:b}){let[C,w]=O(()=>X(!!m)),E=D(C);E.current=C;let k=x((e,t=!1)=>{let n=me(E.current,e);n!==E.current&&(E.current=n,w(n),t&&g(Q(n)))},[g]),j=nt(t,p,m),M=D({connectedAccountId:j,paymentOption:p.paymentOption});C.status!==`submitting`&&C.status!==`recovering`&&(M.current={connectedAccountId:j,paymentOption:p.paymentOption});let{connectedAccountId:N,paymentOption:P}=M.current,I=T(()=>_(t.payment.publishableKey,N?{stripeAccount:N}:void 0).catch(()=>null),[t.payment.publishableKey,N,_]),[L,R]=O(!1);S(()=>{let e=!0;return R(!1),I.then(t=>{e&&t===null&&R(!0)}),()=>{e=!1}},[I]);let z=v(i,y,b,C.status===`submitting`||C.status===`recovering`,e);return z?A(F,{options:{amount:Math.max(p.totalCents,100),appearance:z,currency:t.payment.currency,mode:P===`one-time`?`payment`:`subscription`,paymentMethodTypes:t.community?.widgetAchEnabled?[`card`,`us_bank_account`]:[`card`],setupFutureUsage:`off_session`,syncAddressCheckbox:`none`},stripe:I,children:A(gt,{catalog:t,checkoutItems:n,client:r,initialCustomFieldValues:a,metadata:s,onPaymentComplete:c,onPaymentRecoveryChange:u,onPaymentUncertain:d,onQuoteChange:f,onResumePaymentFailed:l,onStateChange:g,paymentState:C,paymentSummaryPosition:o,quote:p,resumePayment:m,stripeConnectedAccountId:N,stripeLoadFailed:L,updateState:k})},`${t.payment.publishableKey}:${N??`platform`}:${P}`):A(h,{fieldCount:3,label:`Loading payment form`})}function it({label:e}){return j(`div`,{className:`lockerverse-payment__stripe-loader`,role:`status`,children:[A(`p`,{children:e}),j(`div`,{"aria-hidden":`true`,children:[A(`span`,{}),A(`span`,{}),A(`span`,{})]})]})}function at({onError:e,onReady:t,ready:n}){return j(`div`,{className:`lockerverse-payment__stripe-element`,"data-ready":n,children:[n?null:A(it,{label:`Loading payment form...`}),A(`div`,{className:`lockerverse-payment__stripe-mount`,children:A(I,{onLoadError:({error:t})=>e(t.message??`Payment form failed to load.`),onReady:t,options:{business:{name:`Lockerverse`},fields:{billingDetails:{address:`never`,email:`never`,name:`never`,phone:`never`}},layout:`tabs`,terms:{applePay:`auto`,card:`always`,usBankAccount:`auto`},wallets:{applePay:`auto`,googlePay:`never`}}})})]})}function ot({label:e,mode:t,onChange:n,onError:r,onReady:i,ready:a}){return j(`div`,{className:`lockerverse-payment__address`,children:[A(`h2`,{children:e}),j(`div`,{className:`lockerverse-payment__stripe-element lockerverse-payment__stripe-element--address`,"data-ready":a,children:[a?null:A(it,{label:`Loading ${e.toLowerCase()}...`}),A(`div`,{className:`lockerverse-payment__stripe-mount`,children:A(P,{onChange:n,onLoadError:({error:t})=>r(t.message??`${e} failed to load.`),onReady:i,options:{autocomplete:{mode:`automatic`},mode:t}})})]})]})}function st({message:e}){return e?A(`p`,{className:`lockerverse-payment__field-message`,role:`alert`,children:e}):null}function ct({catalog:e,displayedTotalCents:t,fieldValues:n,isBillingAddressReady:r,isPaymentReady:i,isShippingAddressReady:a,onAddressChange:o,onFieldValuesChange:s,onStripeLoadError:c,setIsBillingAddressReady:l,setIsPaymentReady:u,setIsShippingAddressReady:d}){let f=t>0;return j(k,{children:[f?A(at,{onError:c,onReady:()=>u(!0),ready:i}):null,f||e.widget.fields.shipping?A(ot,{label:f?`Billing address`:`Shipping address`,mode:`billing`,onChange:e=>o(`billing`,e),onError:c,onReady:()=>l(!0),ready:r}):null,e.widget.fields.shipping?j(`div`,{className:`lockerverse-payment__shipping`,children:[A(fe,{checked:n.shippingMatchesBilling,name:`shippingMatchesBilling`,onChange:e=>{s({...n,shippingMatchesBilling:e}),e?o(`shipping`,null):d(!1)},children:`Shipping is same as billing information`}),n.shippingMatchesBilling?null:A(ot,{label:`Shipping address`,mode:`shipping`,onChange:e=>o(`shipping`,e),onError:c,onReady:()=>d(!0),ready:a})]}):null]})}function lt({catalog:t,displayedTotalCents:n,fieldValues:r,isBillingAddressReady:i,isPaymentReady:a,isRequiredShippingReady:o,isSubmitting:s,onFieldValuesChange:c,quote:l}){let u=n===0,d=u?!t.widget.fields.shipping||i&&o:a&&i&&o,f=tt(l.paymentOption),p=u?`Complete order`:`Pay ${e(n)}`;!u&&f&&(p=`Subscribe for ${e(n)}/${f.interval}`),s&&(p=u?`Completing…`:`Processing…`);let m=`Process payment for ${e(n)} total`;return u?m=`Complete order`:f&&(m=`Start ${f.label.toLowerCase()} subscription for ${e(n)}`),j(`div`,{className:`lockerverse-payment__actions`,children:[A(Y,{amountCents:l.serviceFeeCents||Math.round(l.subtotalCents*t.pricingPolicy.serviceFeeRateBasisPoints/1e4),enabled:t.widget.fields.serviceFee,onChange:c,values:r}),A(`button`,{"aria-busy":s,"aria-label":m,disabled:s||!d,type:`submit`,children:p})]})}function ut(e,t){let n=e.elements.namedItem(t);if(n instanceof HTMLElement){n.focus();return}n instanceof RadioNodeList&&Array.from(n).find(e=>e instanceof HTMLElement)?.focus()}function dt({customFieldErrors:e,emailRef:t,form:n,parsedTipSuccess:r,phoneRef:i,validationErrors:a}){if(a.email){t.current?.focus();return}if(a.phone){i.current?.focus();return}if(!r){n.querySelector(`[name="tip"]`)?.focus();return}let[o]=Object.keys(e);o&&ut(n,`custom:${o}`)}function ft(t){let n=t.appliedDiscount;if(n?.source!==`email_list`)return;let r=n.percentageOff===void 0?e(t.discountCents):`${n.percentageOff}%`;return n.message??`Your email qualifies for ${r} off.`}function pt({email:e,emailDiscountMessage:t,emailErrorId:n,emailId:r,emailRef:a,errors:o,onEmailBlur:l,onEmailChange:u,onPhoneChange:d,phone:f,phoneCountry:p,phoneEnabled:m,phoneErrorId:h,phoneId:g,phoneRef:_}){return j(`div`,{className:`lockerverse-payment__contact`,children:[A(i,{error:o.email,errorId:n,id:r,label:`Email`,name:`email`,onBlur:l,onChange:e=>u(e.currentTarget.value),ref:a,required:!0,value:e}),t===void 0?null:A(`p`,{className:`lockerverse-payment__discount-message`,role:`status`,children:t}),m?A(s,{error:o.phone,errorId:h,id:g,label:`Phone`,children:A(c,{country:p,error:o.phone,errorId:h,id:g,inputRef:_,name:`phone`,onChange:d,required:!0,value:f})}):null]})}function mt({message:e}){return e?j(`div`,{className:`lockerverse-payment__actions`,children:[A(`p`,{className:`lockerverse-payment__field-message`,role:`alert`,children:e}),A(`button`,{className:`lockerverse-payment__status-check`,onClick:()=>window.location.reload(),type:`button`,children:`Reload checkout`})]}):null}function ht({paymentRequired:e,shippingRequired:t,isPaymentReady:n,isBillingAddressReady:r,isRequiredShippingReady:i,isSubmitting:a,scriptFailed:o,elementError:s,clearElementError:c}){let[l,u]=O(!1),d=e||t,f=(!e||n)&&(!d||r)&&i;if(S(()=>{if(u(!1),f&&c(void 0),!d||f||a)return;let e=window.setTimeout(()=>u(!0),3e4);return()=>window.clearTimeout(e)},[d,f,a,c]),!(!d||f||a)){if(o||s)return`The secure checkout fields could not load. Check your connection, then reload the checkout.`;if(l)return`The secure checkout fields are taking longer than expected. You can wait or reload the checkout.`}}function gt({catalog:e,checkoutItems:t,client:n,initialCustomFieldValues:r,paymentSummaryPosition:i,metadata:a,onPaymentComplete:s,onResumePaymentFailed:c,onPaymentRecoveryChange:l,onPaymentUncertain:f,onQuoteChange:p,onStateChange:h,quote:v,resumePayment:y,stripeConnectedAccountId:b,stripeLoadFailed:x,paymentState:w,updateState:T}){let E=u(e,t),[M,N]=O(``),[P,F]=O(``),[I,z]=O(`US`),[B,V]=O({}),[ee,H]=O({}),[te,ne]=O(),[re,U]=O(),[W,ie]=O(!1),[G,ae]=O(!1),[oe,K]=O(!1),[q,se]=O(()=>({customFields:d(E,r),customTip:``,includeServiceFee:e.widget.fields.serviceFee,memberId:``,merchSize:`M`,promoCode:``,shippingMatchesBilling:!0,tipPercent:`10`})),ce=D({billing:null,shipping:null}),le=D(null),ue=D(null),J=D(null),fe=D(v.totalCents>0),Y=Qe({catalog:e,checkoutItems:t,client:n,elements:L(),email:M,fieldValues:q,metadata:a,onPaymentComplete:s,onPaymentRecoveryChange:l,onPaymentUncertain:f,onQuoteChange:p,onResumePaymentFailed:c,onStateChange:h,paymentState:w,quote:v,resumePayment:y,stripe:R(),stripeConnectedAccountId:b,stripeLoadFailed:x,updateState:T}),{displayedTotalCents:X,isRecovering:Z,isUnresolved:me,isRefreshingQuote:he,isSubmitting:Q,parsedTip:$,paymentError:ge,promoError:_e,terminalMessage:ve,retryUrl:ye}=Y.state,be=`lockerverse-${C()}`,xe=`${be}-email`,Se=`${xe}-error`,Ce=`${be}-phone`,we=`${Ce}-error`,Te=`${be}-tip-error`,Ee=($.success?$.cents:null)??0,De=X-Ee,Oe=!e.widget.fields.shipping||q.shippingMatchesBilling||oe,ke=ht({clearElementError:U,elementError:re,isBillingAddressReady:G,isPaymentReady:W,isRequiredShippingReady:Oe,isSubmitting:Q,paymentRequired:X>0,scriptFailed:x,shippingRequired:e.widget.fields.shipping});S(()=>{Q&&J.current?.focus({preventScroll:!0})},[Q]),S(()=>{Q||B.email||!B.phone||ue.current?.focus()},[B.email,B.phone,Q]),S(()=>{let e=X>0;e&&!fe.current&&(ie(!1),ae(!1)),fe.current=e},[X]);function Ae(e){Y.commands.fieldChanged(!1,e!==`email`),V(t=>{let n={...t};return delete n[e],n})}function je(e){let t=e.promoCode!==q.promoCode,n=e.includeServiceFee!==q.includeServiceFee;Y.commands.fieldChanged(t,!(t||n)),se(e),H({}),ne(void 0)}async function Me(t){t.preventDefault();let n=e.widget.fields.phone?o(P,I):``,r=_({email:M,phone:n},e.widget.fields.phone),i=m(E,q.customFields);if(!(r.value&&$.success)||Object.keys(i).length>0){V(r.errors),H(i),ne($.success?void 0:$.message),Y.commands.reportValidationFailure();let e=t.currentTarget;queueMicrotask(()=>{dt({customFieldErrors:i,emailRef:le,form:e,parsedTipSuccess:$.success,phoneRef:ue,validationErrors:r.errors})});return}V({}),H({});let a=await Y.commands.submit({addresses:ce.current,phone:n});a?.phoneError&&V({phone:a.phoneError})}if(ve||Z)return j(`div`,{className:`lockerverse-payment__actions`,children:[j(`p`,{className:`lockerverse-payment__payment-status`,ref:J,role:`status`,tabIndex:-1,children:[Z?`Recovering payment…`:ve,ye?j(k,{children:[` `,A(`a`,{href:ye,rel:`noopener noreferrer`,target:`_blank`,children:`Complete payment`})]}):null]}),me||Z?A(`button`,{"aria-busy":Z,className:`lockerverse-payment__status-check`,disabled:Z,onClick:Y.commands.checkPaymentStatus,type:`button`,children:Z?`Checking payment status…`:`Check payment status`}):null]});let Ne=A(g,{displayedBaseCents:De,displayedTipCents:Ee,displayedTotalCents:X,quote:v}),Pe=A(de,{enabled:e.widget.fields.tipping,error:te,errorId:Te,onChange:je,values:q}),Fe={bottom:{afterFields:j(k,{children:[Pe,Ne]}),beforeFields:null},hidden:{afterFields:Pe,beforeFields:null},top:{afterFields:null,beforeFields:j(k,{children:[Ne,Pe]})}}[i??`top`];return j(`form`,{"aria-busy":Q,className:`lockerverse-payment__form`,noValidate:!0,onSubmit:Me,children:[A(`div`,{"data-lockerverse-input-region":``,inert:Q?!0:void 0,children:j(`fieldset`,{className:`lockerverse-payment__input-fieldset`,disabled:Q,children:[Fe.beforeFields,A(pt,{email:M,emailDiscountMessage:ft(v),emailErrorId:Se,emailId:xe,emailRef:le,errors:B,onEmailBlur:()=>Y.commands.refreshAuthoritativeTotal(),onEmailChange:e=>{N(e),Ae(`email`)},onPhoneChange:({value:e,country:t})=>{F(e),z(t),Ae(`phone`)},phone:P,phoneCountry:I,phoneEnabled:e.widget.fields.phone,phoneErrorId:we,phoneId:Ce,phoneRef:ue}),A(mt,{message:ke}),A(ct,{catalog:e,displayedTotalCents:X,fieldValues:q,isBillingAddressReady:G,isPaymentReady:W,isShippingAddressReady:oe,onAddressChange:(e,t)=>{ce.current[e]=t},onFieldValuesChange:je,onStripeLoadError:U,setIsBillingAddressReady:ae,setIsPaymentReady:ie,setIsShippingAddressReady:K}),A(pe,{customFields:E,errors:ee,fields:e.widget.fields,idPrefix:be,isPromoApplying:he,memberIdLabel:e.community?.memberIdLabel,onApplyPromo:Y.commands.applyPromo,onChange:je,promoError:_e,values:q}),Fe.afterFields,A(lt,{catalog:e,displayedTotalCents:X,fieldValues:q,isBillingAddressReady:G,isPaymentReady:W,isRequiredShippingReady:Oe,isSubmitting:Q,onFieldValuesChange:je,quote:v})]})}),Q?A(`p`,{className:`lockerverse-payment__sr-only`,ref:J,role:`status`,tabIndex:-1,children:X===0?`Completing order…`:`Processing payment…`}):null,A(st,{message:ge})]})}function _t(){return A(h,{fieldCount:2,label:`Loading payment…`,sectionCount:2,showCheckbox:!0})}function vt(e,t){switch(t.type){case`loading`:return{phase:`loading`,revision:e.revision};case`ready`:return St(t.displayedQuote,e.revision+1);case`error`:return{failure:t.failure,phase:`error`,revision:e.revision};case`checkout`:return e.phase===`ready`?{...e,displayedQuote:t.checkout,quoteFailure:void 0}:e;case`quote-error`:return e.phase===`ready`?{...e,quoteFailure:t.failure}:e;default:return e}}function yt(e,t,n){return e?.catalog===t&&e.selectionKey===n}function bt({checkout:e}){return{displayedQuote:e,type:`ready`}}function xt(e){return e instanceof Error?e.message:`Lockerverse payment could not load.`}function St(e,t){return{checkoutItems:[...e.items],displayedQuote:e,phase:`ready`,quoteFailure:void 0,revision:t}}function Ct(e,t){let n=e.widget.fields.serviceFee;return N(e,{includeServiceFee:n,selection:t})}function wt(e,t){try{return St(Ct(e,t),1)}catch(e){return{failure:xt(e),phase:`error`,revision:0}}}function Tt({catalog:e,client:t,paymentState:n,selection:r}){let i=Oe(r),a=i.success?JSON.stringify(i.value):`invalid-selection`,o=T(()=>i.success?i.value:[],[i.success,a]),[s,c]=E(vt,void 0,()=>i.success?wt(e,o):{phase:`loading`,revision:0}),l=D(void 0),u=D(0),d=D(s.phase===`ready`?{catalog:e,selectionKey:a}:void 0),f=D(s.phase===`error`?{catalog:e,selectionKey:a}:void 0),p=n===`submitting`||n===`success`||n===`unresolved`;S(()=>{if(!i.success||p||yt(f.current,e,a)||yt(l.current,e,a))return;let n=!0;l.current={catalog:e,selectionKey:a};let r=yt(d.current,e,a);r||c({type:`loading`});function s(e){n&&c(e)}function m(){n&&(l.current=void 0,f.current={catalog:e,selectionKey:a})}let h;function g(t){if(!n||(l.current=void 0,f.current={catalog:e,selectionKey:a},r&&h!==void 0&&u.current!==h))return;let i=xt(t);if(i===`This option is sold out.`){c({failure:i,type:`error`});return}c(r?{failure:i,type:`quote-error`}:{failure:i,type:`error`})}async function _(){try{h=u.current;let n=e.widget.fields.serviceFee;if(!r){let t=Ct(e,o);r=!0,d.current={catalog:e,selectionKey:a},s(bt({checkout:t}))}let i=await t.calculateTotal({catalog:e,includeServiceFee:n,selection:o});m(),u.current===h&&s({checkout:i,type:`checkout`})}catch(e){g(e)}}return _(),()=>{n=!1,yt(l.current,e,a)&&(l.current=void 0)}},[e,t,i.success,p,a,o]);let m=yt(d.current,e,a)||yt(f.current,e,a)||yt(l.current,e,a),h=p||m?s:{phase:`loading`,revision:s.revision};return{selectionError:i.success?void 0:i.message,session:h,updateCheckout:e=>{u.current+=1,c({checkout:e,type:`checkout`})}}}const Et=re({recovery:re({connectedAccountId:te(K()),paymentReference:W(K(),q(),H())}),selectionFingerprint:K(),version:se([B(1),B(2)]),widgetId:U(K())});function Dt(e){let t=Oe(e);return t.success?JSON.stringify(t.value.map(e=>{let t=e.productSlug.trim();return`quantity`in e?[`quantity`,t,e.quantity]:`amountCents`in e?[`amount`,t,e.amountCents]:[`product`,t]})):null}const Ot=`A previous payment uses different checkout details. Return to its original checkout to check the payment before you pay again.`;function kt(e,t,n){let r;try{r=window.sessionStorage.getItem(e)}catch{return{recovery:null}}if(!r)return{recovery:null};try{let e=ae(Et,JSON.parse(r));if(!e.success)throw Error(`Invalid recovery record`);let i=e.output;return i.selectionFingerprint!==t||i.version===2&&i.widgetId!==n?{error:Ot,recovery:null}:{recovery:{connectedAccountId:i.recovery.connectedAccountId,paymentReference:i.recovery.paymentReference}}}catch{return{error:`The saved payment could not be read. Contact support to check it before you pay again.`,recovery:null}}}function At({selection:e,storageKey:t,widgetId:n}){let r=Dt(e),i=JSON.stringify([t,r,n]),[a,o]=O(null),s=D(null);S(()=>{if(!t)return;let e=s.current,a={recovery:null};e?.recovery?a=e.identity===i?{recovery:e.recovery}:{error:Ot,recovery:null}:r!==null&&(a=kt(t,r,n)),a.recovery&&(s.current={identity:i,recovery:a.recovery}),o({identity:i,...a})},[r,i,t,n]);let c=x(e=>{if(!(!t||r===null)){s.current=e?{identity:i,recovery:e}:null;try{e?window.sessionStorage.setItem(t,JSON.stringify({recovery:e,selectionFingerprint:r,version:2,widgetId:n})):window.sessionStorage.removeItem(t)}catch{}}},[r,i,t,n]);return{error:t&&a?.identity===i?a.error:void 0,ready:!t||a?.identity===i,recovery:t&&a?.identity===i?a.recovery:null,remember:c}}const jt={annually:`/year`,"every-six-months":` every 6 months`,monthly:`/month`,"one-time":``};function Mt({branding:e,catalog:t}){return j(`header`,{children:[t.widget.showCommunityBranding&&e?j(`div`,{className:`lockerverse-payment__branding`,children:[e.imageUrl?A(`img`,{alt:e.name,height:`48`,src:e.imageUrl,width:`48`}):null,A(`strong`,{children:e.name})]}):null,A(`h1`,{children:t.widget.title??t.widget.name}),t.widget.description?A(`p`,{children:t.widget.description}):null]})}function Nt({catalog:t,selection:n}){let r=n?.length?t.products.filter(e=>n.some(t=>t.productSlug===e.slug)):t.products.filter(e=>e.id!==t.widget.requiredShipping?.productId);return r.length===0?null:j(`div`,{className:`lockerverse-payment__payment-summary`,children:[A(`h2`,{children:`Products`}),A(`div`,{className:`lockerverse-payment__payment-summary-items`,children:r.map(t=>{let n=t.pricingMode===`fixed`?t.amountCents:t.minimumAmountCents,r=jt[t.paymentOption];return j(`div`,{className:`lockerverse-payment__payment-summary-row`,children:[A(`span`,{children:t.name}),A(`strong`,{children:n===null?`Choose amount`:`${t.pricingMode===`custom`?`From `:``}${e(n)}${r}`})]},t.id)})}),A(`p`,{children:`Base prices. Final total is checked at checkout.`})]})}function Pt(e,t){let i=n(e?.[`--lockerverse-accent`]??t?.accentColor??`#38d77a`),a=r(i),o={...e};return(e?.[`--lockerverse-accent`]!==void 0||t?.accentColor)&&(o[`--lockerverse-accent`]=i),a&&e?.[`--lockerverse-accent-contrast`]===void 0&&(o[`--lockerverse-accent-contrast`]=a),{accent:i,rootStyle:o}}function Ft({catalog:e,client:n,loadError:r,onRetry:i,...a}){let{branding:o,className:s,completionView:c,paymentSummaryPosition:l=`top`,recoveryStorageKey:u,initialCustomFieldValues:d,metadata:f,onPaymentComplete:p,onPaymentRecoveryChange:m,onPaymentUncertain:h,resumePayment:g,selection:_,style:v,stripeLoader:y=$e,theme:b=`dark`,...C}=a,[T,E]=O(g),k=D(null),[M,N]=O(null),P=x(e=>{N(e),t(p,e)},[p]),[F,I]=O(),[L,R]=O(`idle`),z=D(void 0),{selectionError:B,session:V,updateCheckout:ee}=Tt({catalog:e,client:n,paymentState:L,selection:_}),H=V.phase===`ready`?V.revision:void 0,te=x(e=>{H!==void 0&&(z.current=H),R(e)},[H]),ne=x(e=>m?.(e),[m]),re=x(()=>{E(void 0)},[]);S(()=>{V.phase===`loading`&&I(void 0)},[V.phase]),w(()=>{V.phase===`ready`&&z.current!==V.revision&&R(e=>e===`success`||e===`unresolved`?e:`idle`)},[V.phase,V.revision]);let U=[`lockerverse-payment`,s].filter(Boolean).join(` `),W=o??e.community,{accent:ie,rootStyle:G}=Pt(v,W);return M&&c===`summary`?A(`section`,{...C,className:U,"data-lockerverse-theme":b,"data-payment-state":`success`,style:G,children:j(`div`,{className:`lockerverse-payment__completion`,role:`status`,children:[A(`span`,{"aria-hidden":`true`,className:`lockerverse-payment__completion-icon`,children:A(`svg`,{"aria-hidden":`true`,fill:`none`,height:`28`,stroke:`currentColor`,strokeWidth:`2`,viewBox:`0 0 24 24`,width:`28`,children:A(`path`,{d:`m5 12 4 4L19 6`})})}),A(`h1`,{children:M.paymentRequired?`Thank you`:`Order confirmed`}),A(`p`,{children:M.paymentRequired?`Your payment has been received.`:`Your order is confirmed. No payment was required.`})]})}):B?A(`section`,{...C,className:U,"data-lockerverse-theme":b,role:`alert`,style:G,children:B}):V.phase===`error`&&V.failure===`This option is sold out.`||L===`sold_out`?j(`section`,{...C,className:U,"data-lockerverse-theme":b,role:`alert`,style:G,children:[A(`h1`,{children:`Sold out`}),A(`p`,{children:`This option is sold out.`})]}):V.phase===`error`?A(`section`,{...C,className:U,"data-lockerverse-theme":b,style:G,children:A(`p`,{role:`alert`,children:V.failure})}):V.phase===`ready`?j(`section`,{...C,"aria-label":`Payment`,className:U,"data-lockerverse-theme":b,"data-payment-state":L,ref:k,style:G,children:[A(Mt,{branding:W,catalog:e}),r?j(`div`,{role:`alert`,children:[A(`p`,{children:r.message}),A(`button`,{onClick:i,type:`button`,children:`Retry`})]}):null,F?A(`p`,{className:`lockerverse-payment__payment-status`,role:`status`,children:F}):null,V.quoteFailure?j(`div`,{className:`lockerverse-payment__payment-status`,role:`alert`,children:[A(`span`,{children:V.quoteFailure}),A(`span`,{children:` The final total will be checked when you submit.`})]}):null,A(rt,{accentColor:ie,appearanceRoot:k,catalog:e,checkoutItems:V.checkoutItems,client:n,initialCustomFieldValues:d,metadata:f,onPaymentComplete:P,onPaymentRecoveryChange:ne,onPaymentUncertain:h,onQuoteChange:(e,t)=>{I(t),ee(e)},onResumePaymentFailed:re,onStateChange:te,paymentSummaryPosition:l,quote:V.displayedQuote,resumePayment:T,stripeLoader:y,theme:b,visualStyle:G},V.revision)]}):j(`section`,{...C,"aria-busy":`true`,"aria-label":`Payment`,className:U,"data-lockerverse-theme":b,style:G,children:[A(Mt,{branding:W,catalog:e}),r?j(`div`,{role:`alert`,children:[A(`p`,{children:r.message}),A(`button`,{onClick:i,type:`button`,children:`Retry`})]}):null,A(_t,{})]})}function It({children:e,loading:t=!1,viewProps:i}){let{branding:a,className:o,completionView:s,paymentSummaryPosition:c,recoveryStorageKey:l,initialCustomFieldValues:u,metadata:d,onPaymentComplete:f,onPaymentRecoveryChange:p,onPaymentUncertain:m,resumePayment:h,selection:g,stripeLoader:_,style:v,theme:y=`dark`,...b}=i,x=n(v?.[`--lockerverse-accent`]??a?.accentColor??`#38d77a`),S=r(x),C={...v};return(v?.[`--lockerverse-accent`]!==void 0||a?.accentColor)&&(C[`--lockerverse-accent`]=x),S&&v?.[`--lockerverse-accent-contrast`]===void 0&&(C[`--lockerverse-accent-contrast`]=S),A(`section`,{...b,...t?{"aria-busy":!0,"aria-label":`Payment`}:{},className:[`lockerverse-payment`,o].filter(Boolean).join(` `),"data-lockerverse-theme":y,style:C,children:e})}function Lt(e){let{catalog:n,client:r,loadError:i,onRetry:a,...o}=e,{onPaymentRecoveryChange:s,recoveryStorageKey:c,resumePayment:l,selection:u}=o,d=At({selection:u,storageKey:c,widgetId:n.widget.id}),f=x(e=>{d.remember(e),t(s,e)},[s,d.remember]);return!d.ready||d.error?A(It,{loading:!d.ready,viewProps:o,children:d.error?A(`p`,{role:`alert`,children:d.error}):A(_t,{})}):A(Ft,{...e,onPaymentRecoveryChange:f,resumePayment:l??d.recovery})}function Rt({widget:e,...t}){return e.error&&!e.catalog?j(It,{viewProps:t,children:[A(`p`,{role:`alert`,children:e.error.message}),A(`button`,{onClick:e.refresh,type:`button`,children:`Retry`})]}):e.loading?j(It,{loading:!0,viewProps:t,children:[e.catalog?j(k,{children:[A(Mt,{branding:t.branding??e.catalog.community,catalog:e.catalog}),(t.paymentSummaryPosition??`top`)===`top`?A(Nt,{catalog:e.catalog,selection:t.selection}):null]}):null,A(_t,{})]}):e.catalog?A(Lt,{catalog:e.catalog,client:e.client,loadError:e.error,onRetry:e.refresh,...t}):A(It,{loading:!0,viewProps:t,children:A(_t,{})})}export{et as n,Rt as t};
|
|
1
|
+
import{t as e}from"./format-money.js";import{t}from"./host-callback.js";import{n,t as r}from"./accent-contrast.js";import{d as i,i as a,n as o,p as s,t as c,u as l}from"./phone-field.js";import{a as u,i as d,n as f,r as p,s as m}from"./custom-fields.js";import{t as h}from"./form-skeleton.js";import{t as g}from"./payment-summary.js";import{i as _,n as v,r as y,t as b}from"./stripe-loader.js";import{useCallback as x,useEffect as S,useId as C,useLayoutEffect as w,useMemo as T,useReducer as E,useRef as D,useState as O}from"react";import{Fragment as k,jsx as A,jsxs as j}from"react/jsx-runtime";import{LockerverseSdkError as M,estimateLockerverseCheckout as N}from"@lockerverse/sdk/checkout";import{AddressElement as P,Elements as F,PaymentElement as I,useElements as L,useStripe as R}from"@stripe/react-stripe-js";import{array as z,literal as B,minLength as V,minValue as ee,nonEmpty as H,nullable as te,number as ne,object as re,optional as U,pipe as W,regex as ie,safeInteger as G,safeParse as ae,strictObject as oe,string as K,trim as q,union as se}from"valibot";function ce({ariaDescribedBy:e,ariaLabel:t,ariaLabelledBy:n,className:r,id:i,invalid:a=!1,name:o,onValueChange:s,options:c,value:l}){return A(`select`,{"aria-describedby":e,"aria-invalid":a||void 0,"aria-label":t,"aria-labelledby":n,className:[`lockerverse-form__control`,`lockerverse-form__select`,r].filter(Boolean).join(` `),id:i,name:o,onChange:e=>s(e.currentTarget.value),value:l,children:c.map(e=>A(`option`,{value:e.value,children:e.label},e.value))})}const le=[`XS`,`S`,`M`,`L`,`XL`,`XXL`,`XXXL`],ue=[`15`,`12`,`10`,`5`],J=[...ue,`custom`];function de({enabled:e,error:t,errorId:n,onChange:r,values:i}){if(!e)return null;let a=e=>r({...i,...e}),o=(e,t)=>{let n=J.indexOf(t),r;switch(e.key){case`ArrowDown`:case`ArrowRight`:r=(n+1)%J.length;break;case`ArrowLeft`:case`ArrowUp`:r=(n-1+J.length)%J.length;break;case`Home`:r=0;break;case`End`:r=J.length-1;break;default:return}e.preventDefault();let i=J[r];i&&((e.currentTarget.closest(`[role="radiogroup"]`)?.querySelectorAll(`input[type="radio"]`))?.[r]?.focus(),a({tipPercent:i}))};return j(`div`,{className:`lockerverse-payment__tip-box`,children:[A(`p`,{children:`Add a tip to support the Lockerverse platform`}),j(`div`,{"aria-label":`Tip amount`,role:`radiogroup`,children:[ue.map(e=>j(`label`,{className:`lockerverse-payment__tip-choice`,children:[A(`input`,{checked:i.tipPercent===e,name:`tipPercent`,onChange:()=>a({tipPercent:e}),onKeyDown:t=>o(t,e),tabIndex:i.tipPercent===e?0:-1,type:`radio`,value:e}),j(`span`,{children:[e,`%`]})]},e)),j(`label`,{className:`lockerverse-payment__tip-choice`,children:[A(`input`,{checked:i.tipPercent===`custom`,name:`tipPercent`,onChange:()=>a({tipPercent:`custom`}),onKeyDown:e=>o(e,`custom`),tabIndex:i.tipPercent===`custom`?0:-1,type:`radio`,value:`custom`}),A(`span`,{children:`Other`})]})]}),i.tipPercent===`custom`?j(`label`,{children:[A(`span`,{children:`Custom tip`}),j(`span`,{className:`lockerverse-payment__money-input`,children:[A(`span`,{"aria-hidden":`true`,children:`$`}),A(`input`,{"aria-describedby":t?n:void 0,"aria-invalid":t?`true`:void 0,inputMode:`decimal`,name:`tip`,onChange:e=>a({customTip:e.currentTarget.value}),placeholder:`0.00`,value:i.customTip})]}),t?A(`span`,{className:`lockerverse-payment__field-message`,id:n,children:t}):null]}):A(`input`,{name:`tip`,type:`hidden`,value:i.tipPercent})]})}function fe({checked:e,children:t,name:n,onChange:r}){let i=C();return j(`label`,{className:`lockerverse-payment__check-row`,htmlFor:i,children:[A(l,{checked:e,id:i,name:n,onChange:e=>r(e.currentTarget.checked)}),A(`span`,{children:t})]})}function pe({customFields:e,errors:t,fields:n,idPrefix:r,isPromoApplying:i,memberIdLabel:a,onChange:o,onApplyPromo:s,promoError:c,values:l}){let u=e=>o({...l,...e});return j(`div`,{className:`lockerverse-payment__additional-fields`,children:[n.memberId?j(`label`,{children:[A(`span`,{children:a?.trim()||`Member ID`}),A(`input`,{name:`memberId`,onChange:e=>u({memberId:e.currentTarget.value}),placeholder:`Optional`,value:l.memberId})]}):null,n.merchSize?j(`div`,{className:`lockerverse-payment__field`,children:[A(`span`,{id:`${r}-merch-size-label`,children:`Size`}),A(ce,{ariaLabelledBy:`${r}-merch-size-label`,name:`merchSize`,onValueChange:e=>{let t=le.find(t=>t===e);t&&u({merchSize:t})},options:le.map(e=>({label:e,value:e})),value:l.merchSize})]}):null,n.promoCode?j(`div`,{className:`lockerverse-payment__field`,children:[A(`span`,{id:`${r}-promo-code-label`,children:`Promo code`}),j(`div`,{className:`lockerverse-payment__promo-control`,children:[A(`input`,{"aria-describedby":c?`${r}-promo-code-error`:void 0,"aria-invalid":c?`true`:void 0,"aria-labelledby":`${r}-promo-code-label`,name:`promoCode`,onChange:e=>u({promoCode:e.currentTarget.value}),placeholder:`Optional`,value:l.promoCode}),A(`button`,{disabled:!l.promoCode.trim()||i,onClick:s,type:`button`,children:i?`Applying…`:`Apply`})]}),c?A(`p`,{className:`lockerverse-payment__field-message`,id:`${r}-promo-code-error`,role:`alert`,children:c}):null]}):null,A(f,{choiceClassName:`lockerverse-payment__check-row`,errorClassName:`lockerverse-payment__field-message`,errors:t,fields:e,idPrefix:r,onChange:e=>u({customFields:e}),values:l.customFields})]})}function Y({amountCents:t,enabled:n,onChange:r,values:i}){return n?j(fe,{checked:i.includeServiceFee,name:`includeServiceFee`,onChange:e=>r({...i,includeServiceFee:e}),children:[`Add `,e(t),` to help cover processing fees`]}):null}function X(e){return{error:void 0,message:void 0,status:e?`recovering`:`editing`}}function Z(e,t,n){return t.includes(e.status)?{...e,...n}:e}function me(e,t){if(t.type===`recovery_started`&&e.status===`unresolved`)return{...e,message:void 0,status:`recovering`};if(e.status===`sold_out`||e.status===`succeeded`||e.status===`unresolved`)return e;switch(t.type){case`field_changed`:return Z(e,[`editing`,`invalid`,`refreshing_quote`],{error:void 0,status:`editing`});case`validation_failed`:return Z(e,[`editing`],{status:`invalid`});case`quote_refresh_started`:return Z(e,[`editing`,`invalid`],{status:`refreshing_quote`});case`quote_refresh_succeeded`:return Z(e,[`refreshing_quote`],{error:void 0,status:`editing`});case`quote_refresh_failed`:return Z(e,[`refreshing_quote`],{error:t.error??e.error,status:`editing`});case`submission_started`:return Z(e,[`editing`,`invalid`,`refreshing_quote`],{error:void 0,status:`submitting`});case`submission_validation_failed`:return Z(e,[`submitting`],{error:void 0,status:`invalid`});case`quote_changed`:return Z(e,[`submitting`],{status:`editing`});case`retryable_failure`:return Z(e,[`editing`,`invalid`,`submitting`],{error:t.error,status:`editing`});case`recovery_failed`:return Z(e,[`recovering`],{error:t.error,retryUrl:void 0,status:`editing`});case`sold_out`:return{error:void 0,message:void 0,status:`sold_out`};case`succeeded`:return Z(e,[`recovering`,`submitting`],{message:t.message,retryUrl:void 0,status:`succeeded`});case`unresolved`:return Z(e,[`recovering`,`submitting`],{message:t.message,retryUrl:t.retryUrl,status:`unresolved`});default:return e}}function he(e){return e.status===`editing`||e.status===`invalid`||e.status===`refreshing_quote`?e.error:void 0}function Q(e){return e.status===`sold_out`?`sold_out`:e.status===`succeeded`?`success`:e.status===`unresolved`?`unresolved`:e.status===`submitting`||e.status===`recovering`?`submitting`:e.status===`invalid`?`invalid`:he(e)?`error`:`idle`}function $(e){return e.status===`submitting`}const ge=[`amountCents`,`discountableSubtotalCents`,`discountCents`,`serviceFeeCents`,`subtotalCents`,`tipCents`,`totalCents`],_e=[`discountableSubtotalCents`,`discountCents`,`subtotalCents`];function ve(e,t,n,r){return(n===t.totalCents?_e:ge).some(n=>e[n]!==t[n])||r!==t.payment.connectedAccountId||e.authoritative&&(e.payment.connectedAccountId!==r||e.payment.currency!==t.payment.currency)||JSON.stringify(e.appliedDiscount)!==JSON.stringify(t.appliedDiscount)||JSON.stringify(e.lineItems)!==JSON.stringify(t.lineItems)}function ye(e){if(e.checkoutStatus===`success`)return{kind:`success`,payment:e};if(e.checkoutStatus===`failed`)return{kind:`failed`,payment:e};let t={kind:`unresolved`,paymentReference:e.paymentReference,reason:e.checkoutStatus===`action_required`?`action_required`:`pending`};return e.retryUrl&&(t.retryUrl=e.retryUrl),t}async function be(e,t,n){if(t.checkoutStatus!==`action_required`||!t.requiresAction)return ye(t);if(!n)return{kind:`unresolved`,paymentReference:t.paymentReference,reason:`action_required`};if(t.clientSecret)try{await n.handleNextAction({clientSecret:t.clientSecret})}catch{}try{return ye(await e.getPaymentStatus(t.paymentReference))}catch{return{kind:`unresolved`,paymentReference:t.paymentReference,reason:`action_required`}}}async function xe(e,t,n){let r;try{r=await e.submitPayment(t)}catch(n){if(!(n instanceof M&&n.recoveryRecommended))throw n;try{r=await e.getPaymentStatus(t.checkout.paymentReference)}catch{return{kind:`unresolved`,paymentReference:t.checkout.paymentReference,reason:`recovery_failed`}}}return be(e,r,n)}async function Se(e,t,n){try{return be(e,await e.getPaymentStatus(t),n)}catch{return{kind:`unresolved`,paymentReference:t,reason:`recovery_failed`}}}const Ce=W(K(),q(),H()),we=W(ne(),G(),ee(1)),Te=W(z(se([oe({amountCents:we,productSlug:Ce}),oe({productSlug:Ce,quantity:we}),oe({productSlug:Ce})])),V(1)),Ee=W(K(),q(),ie(/^(?:0|[1-9]\d*)(?:\.\d{1,2})?$/,`Enter a valid tip amount.`));function De(e){let t=ae(Ee,e);if(!t.success)return{message:t.issues[0]?.message??`Enter a valid tip amount.`,success:!1};let[n=`0`,r=``]=t.output.split(`.`),i=BigInt(n)*100n+BigInt(r.padEnd(2,`0`));return i>BigInt(2**53-1)?{message:`Enter a valid tip amount.`,success:!1}:{cents:Number(i),success:!0}}function Oe(e){let t=ae(Te,e);return t.success?{success:!0,value:t.output}:{message:`Lockerverse payment configuration is invalid.`,success:!1}}const ke=`This promo code is invalid or cannot be applied.`;function Ae(e,t){return t.tipPercent===`custom`?t.customTip.trim()?De(t.customTip):{cents:0,success:!0}:{cents:Math.round(e*Number(t.tipPercent)/100),success:!0}}function je(e,t,n,r){let i={};return n&&(i.email=n),e.widget.fields.serviceFee&&(i.includeServiceFee=t.includeServiceFee),e.widget.fields.promoCode&&t.promoCode.trim()&&(i.promoCode=t.promoCode.trim()),e.widget.fields.tipping&&(i.tipCents=r),i}function Me(e,t,n){let r=e.widget.fields.tipping?Ae(n.subtotalCents,t):{cents:0,success:!0};if(!r.success)return{parsedTip:r,totalCents:null};let i=e.widget.fields.serviceFee&&t.includeServiceFee?n.serviceFeeCents||Math.round(n.subtotalCents*e.pricingPolicy.serviceFeeRateBasisPoints/1e4):0;return{parsedTip:r,totalCents:n.totalCents-n.serviceFeeCents-n.tipCents+i+r.cents}}function Ne(e,t){return{displayedTotalCents:e.totalCents,promoError:t&&e.appliedDiscount?.source!==`promo_code`?ke:void 0}}function Pe(e,t){let n;return t||(n=e instanceof Error?e.message:`The order total could not be updated.`),{paymentError:n,promoError:t?ke:void 0}}function Fe(e,t){if(!e?.complete)throw Error(`${t} address is required.`);return e.value}function Ie(e,t,n,r){if(e.widget.fields.shipping)return t.shippingMatchesBilling?n:Fe(r.shipping,`Shipping`)}function Le({billingAddress:e,catalog:t,email:n,phone:r,shippingAddress:i}){let a={payment_method_data:{billing_details:t.widget.fields.phone?{address:e.address,email:n,name:e.name,phone:r}:{address:e.address,email:n,name:e.name}}};return i?{...a,shipping:{address:i.address,name:i.name,phone:t.widget.fields.phone?r:i.phone??null}}:a}function Re({catalog:e,checkoutItems:t,confirmationToken:n,email:r,fieldValues:i,metadata:a,phone:o,shippingAddress:s}){let c={customFieldAnswers:p(u(e,t),i.customFields),email:r};if(n&&(c.confirmationToken=n,c.paymentMethodConfiguration=`explicit`),a&&(c.metadata=a),e.widget.fields.memberId&&i.memberId.trim()&&(c.memberId=i.memberId.trim()),e.widget.fields.merchSize&&(c.merchSize=i.merchSize),e.widget.fields.phone&&(c.phone=o),s){let e={city:s.address.city??``,country:s.address.country,line1:s.address.line1??``,postal_code:s.address.postal_code??``,state:s.address.state??``};s.address.line2&&(e.line2=s.address.line2),c.shipping={address:e,name:s.name}}return c}function ze(e){if(!e())throw Error(`Payment component is no longer active.`)}function Be(e,n){t(e,n)}function Ve(e,t,n,r){return e.kind===`failed`?{kind:`payment_failed`,message:r}:e.kind===`unresolved`?{kind:`payment_unresolved`,paymentReference:e.paymentReference,reason:e.reason,retryUrl:e.retryUrl}:{email:n,kind:`payment`,payment:e.payment,quote:t}}async function He({addresses:e,catalog:t,checkoutItems:n,client:r,elements:i,email:a,fieldValues:o,isAttemptActive:s,locallyPreviewedTotalCents:c,metadata:l,onPaymentRecoveryChange:u,phone:d,quote:f,stripe:p,stripeConnectedAccountId:m}){let h=a.trim().toLowerCase(),g=y(d),_=Ae(f.subtotalCents,o);if(!_.success)throw Error(_.message);let v=await r.calculateTotal({...je(t,o,h,_.cents),catalog:t,items:n});if(ze(s),v.totalCents>0&&ve(f,v,c,m))return{kind:`quote_changed`,quote:v};let b,x;if(v.totalCents===0)t.widget.fields.shipping&&(b=Ie(t,o,Fe(e.billing,`Billing`),e));else{if(!(i&&p))throw Error(`Payment form is still loading.`);await i.update({amount:v.totalCents}),ze(s);let n=await i.submit();if(ze(s),n.error)throw Error(n.error.message);let r=Fe(e.billing,`Billing`);b=Ie(t,o,r,e);let a=await p.createConfirmationToken({elements:i,params:Le({billingAddress:r,catalog:t,email:h,phone:g,shippingAddress:b})});if(ze(s),a.error)throw Error(a.error.message);x=a.confirmationToken.id}Be(u,{connectedAccountId:v.payment.connectedAccountId,paymentReference:v.paymentReference});let S=await xe(r,{checkout:v,submission:Re({catalog:t,checkoutItems:n,confirmationToken:x,email:h,fieldValues:o,metadata:l,phone:g,shippingAddress:b})},p);return ze(s),Ve(S,v,h,v.totalCents===0?`Order could not be completed. Review the details and try again.`:`Payment was declined. Check your payment details and try again.`)}function Ue(e,n){t(e,n)}function We(e,n){t(e,n)}function Ge(e,t){return{...e,...t}}function Ke(e){let t={message:e.reason===`action_required`?`Payment needs your attention. Keep this checkout open.`:`Payment is not complete. Check its status before you try again.`,type:`unresolved`};return e.retryUrl&&(t.retryUrl=e.retryUrl),t}function qe(e,t,n){return e.kind===`unresolved`&&e.reason===`action_required`&&!e.retryUrl&&!t&&!n}function Je(e){return e instanceof M&&e.serverCode===`PAYMENT_WIDGET_SALES_LIMIT_REACHED`}function Ye({nextQuote:e,onQuoteChange:t,setDisplayedTotalCents:n,setPromoError:r,updateState:i,validatePromo:a}){let o=Ne(e,a);i({type:`quote_refresh_succeeded`}),n(o.displayedTotalCents),t(e),a&&r(o.promoError)}function Xe({error:e,setPromoError:t,updateState:n,validatePromo:r}){let i=Pe(e,r);r&&t(i.promoError),n(i.paymentError===void 0?{type:`quote_refresh_failed`}:{error:i.paymentError,type:`quote_refresh_failed`})}function Ze({onPaymentComplete:n,onPaymentRecoveryChange:r,onPaymentUncertain:i,onQuoteChange:a,result:o,setDisplayedTotalCents:s,dispatchState:c,unresolvedReferenceRef:l}){if(o.kind===`quote_changed`){let t=`The total changed to ${e(o.quote.totalCents)}. Review it and pay again.`;a(o.quote,t),s(o.quote.totalCents),c({type:`quote_changed`});return}if(o.kind===`payment_failed`){Ue(r,null),c({error:o.message,type:`retryable_failure`});return}if(o.kind===`payment_unresolved`){l.current=o.paymentReference,c(Ke(o)),We(i,{paymentReference:o.paymentReference,reason:o.reason});return}a(o.quote),Ue(r,null),c({message:o.payment.paymentRequired?`Payment completed successfully.`:`Order confirmed. No payment was required.`,type:`succeeded`}),t(n,Ge(o.payment,{email:o.email,lineItems:o.quote.lineItems}))}function Qe(e){let{catalog:n,checkoutItems:r,client:i,elements:o,email:s,fieldValues:c,metadata:l,onPaymentComplete:u,onResumePaymentFailed:d,onPaymentRecoveryChange:f,onPaymentUncertain:p,onQuoteChange:m,onStateChange:h,quote:g,resumePayment:v,stripe:y,stripeConnectedAccountId:b,stripeLoadFailed:C,paymentState:w,updateState:T}=e,[E,k]=O(g.totalCents),[A,j]=O(),N=D(!1),P=D(void 0),F=D(0),I=D(0),L=x(e=>T(e,!0),[T]),R=x(()=>{let e=I.current+1;return I.current=e,()=>I.current===e},[]);S(()=>()=>{I.current+=1,F.current+=1},[]);let{parsedTip:z,totalCents:B}=Me(n,c,g);S(()=>{B!==null&&(k(B),B>0&&o?.update({amount:B}))},[n.pricingPolicy.serviceFeeRateBasisPoints,n.widget.fields.serviceFee,o,c.includeServiceFee,B,g.serviceFeeCents,g.tipCents,g.totalCents,g.subtotalCents]),S(()=>{let e=v?.paymentReference??P.current;if(!e||N.current||w.status!==`recovering`)return;N.current=!0;let n=R();return h(Q(w)),Se(i,e,y).then(e=>{if(n()&&!qe(e,y,C)){if(e.kind===`failed`){Ue(f,null),d(),L({error:`The previous payment failed. Check your details and try again.`,type:`recovery_failed`});return}if(e.kind===`unresolved`){L(Ke(e)),We(p,{paymentReference:e.paymentReference,reason:e.reason});return}Ue(f,null),L({message:e.payment.paymentRequired?`Payment completed successfully.`:`Order confirmed. No payment was required.`,type:`succeeded`}),t(u,Ge(e.payment,{email:null,lineItems:null}))}}),()=>{n()&&(I.current+=1),N.current=!1}},[i,u,d,f,p,h,v,y,C,R,L,w]);let V=x((e=!1,t=!1)=>{t||(F.current+=1),e&&j(void 0),T({type:`field_changed`})},[T]);async function ee(e=!1,t=!1){let a=s.trim().toLowerCase(),o=_({email:a,phone:``},!1);if(!(z.success&&(o.value||e)))return;F.current+=1;let l=F.current;T({type:`quote_refresh_started`});try{let e=await i.calculateTotal({...je(n,c,o.value?.email??``,z.cents),catalog:n,items:r});if(l!==F.current)return;Ye({nextQuote:e,onQuoteChange:m,setDisplayedTotalCents:k,setPromoError:j,updateState:T,validatePromo:t})}catch(e){if(l!==F.current)return;if(Je(e)){T({type:`sold_out`});return}Xe({error:e,setPromoError:j,updateState:T,validatePromo:t})}}async function H(){j(void 0),await ee(!0,!0)}async function te({addresses:e,phone:t}){L({type:`submission_started`});let d=R();try{let a=await He({addresses:e,catalog:n,checkoutItems:r,client:i,elements:o,email:s,fieldValues:c,isAttemptActive:d,locallyPreviewedTotalCents:E,metadata:l,onPaymentRecoveryChange:f,phone:t,quote:g,stripe:y,stripeConnectedAccountId:b});if(!d())return;Ze({dispatchState:L,onPaymentComplete:u,onPaymentRecoveryChange:f,onPaymentUncertain:p,onQuoteChange:m,result:a,setDisplayedTotalCents:k,unresolvedReferenceRef:P})}catch(e){if(!d())return;if(Ue(f,null),Je(e)){L({type:`sold_out`});return}let t=e instanceof M?a(e.serverCode):void 0;if(t)return L({type:`submission_validation_failed`}),{phoneError:t};L({error:e instanceof Error?e.message:`Payment could not be completed.`,type:`retryable_failure`})}}let ne=w.status===`succeeded`||w.status===`unresolved`?w.message:void 0;return{commands:{applyPromo:H,checkPaymentStatus:()=>L({type:`recovery_started`}),fieldChanged:V,refreshAuthoritativeTotal:ee,reportValidationFailure:()=>L({type:`validation_failed`}),submit:te},state:{displayedTotalCents:E,isRecovering:w.status===`recovering`,isRefreshingQuote:w.status===`refreshing_quote`,isSubmitting:$(w),isUnresolved:w.status===`unresolved`,parsedTip:z,paymentError:he(w),promoError:A,retryUrl:w.retryUrl,terminalMessage:ne}}}const $e=b;function et(e){let{connectedAccountId:t,publishableKey:n}=e.payment;return $e(n,t?{stripeAccount:t}:void 0)}function tt(e){return e===`monthly`?{interval:`month`,label:`Monthly`}:e===`annually`?{interval:`year`,label:`Annual`}:e===`every-six-months`?{interval:`6 months`,label:`Every 6 months`}:null}function nt(e,t,n){if(n){let{connectedAccountId:e}=n;return e}if(`payment`in t){let{connectedAccountId:e}=t.payment;return e}let{connectedAccountId:r}=e.payment;return r}function rt({accentColor:e,catalog:t,checkoutItems:n,client:r,appearanceRoot:i,initialCustomFieldValues:a,paymentSummaryPosition:o,metadata:s,onPaymentComplete:c,onResumePaymentFailed:l,onPaymentRecoveryChange:u,onPaymentUncertain:d,onQuoteChange:f,quote:p,resumePayment:m,onStateChange:g,stripeLoader:_,theme:y,visualStyle:b}){let[C,w]=O(()=>X(!!m)),E=D(C);E.current=C;let k=x((e,t=!1)=>{let n=me(E.current,e);n!==E.current&&(E.current=n,w(n),t&&g(Q(n)))},[g]),j=nt(t,p,m),M=D({connectedAccountId:j,paymentOption:p.paymentOption});C.status!==`submitting`&&C.status!==`recovering`&&(M.current={connectedAccountId:j,paymentOption:p.paymentOption});let{connectedAccountId:N,paymentOption:P}=M.current,I=T(()=>_(t.payment.publishableKey,N?{stripeAccount:N}:void 0).catch(()=>null),[t.payment.publishableKey,N,_]),[L,R]=O(!1);S(()=>{let e=!0;return R(!1),I.then(t=>{e&&t===null&&R(!0)}),()=>{e=!1}},[I]);let z=v(i,y,b,C.status===`submitting`||C.status===`recovering`,e);return z?A(F,{options:{amount:Math.max(p.totalCents,100),appearance:z,currency:t.payment.currency,mode:P===`one-time`?`payment`:`subscription`,paymentMethodTypes:t.community?.widgetAchEnabled?[`card`,`us_bank_account`]:[`card`],setupFutureUsage:`off_session`,syncAddressCheckbox:`none`},stripe:I,children:A(gt,{catalog:t,checkoutItems:n,client:r,initialCustomFieldValues:a,metadata:s,onPaymentComplete:c,onPaymentRecoveryChange:u,onPaymentUncertain:d,onQuoteChange:f,onResumePaymentFailed:l,onStateChange:g,paymentState:C,paymentSummaryPosition:o,quote:p,resumePayment:m,stripeConnectedAccountId:N,stripeLoadFailed:L,updateState:k})},`${t.payment.publishableKey}:${N??`platform`}:${P}`):A(h,{fieldCount:3,label:`Loading payment form`})}function it({label:e}){return j(`div`,{className:`lockerverse-payment__stripe-loader`,role:`status`,children:[A(`p`,{children:e}),j(`div`,{"aria-hidden":`true`,children:[A(`span`,{}),A(`span`,{}),A(`span`,{})]})]})}function at({onError:e,onReady:t,ready:n}){return j(`div`,{className:`lockerverse-payment__stripe-element`,"data-ready":n,children:[n?null:A(it,{label:`Loading payment form...`}),A(`div`,{className:`lockerverse-payment__stripe-mount`,children:A(I,{onLoadError:({error:t})=>e(t.message??`Payment form failed to load.`),onReady:t,options:{business:{name:`Lockerverse`},fields:{billingDetails:{address:`never`,email:`never`,name:`never`,phone:`never`}},layout:`tabs`,terms:{applePay:`auto`,card:`always`,googlePay:`auto`,usBankAccount:`auto`},wallets:{applePay:`auto`,googlePay:`auto`}}})})]})}function ot({label:e,mode:t,onChange:n,onError:r,onReady:i,ready:a}){return j(`div`,{className:`lockerverse-payment__address`,children:[A(`h2`,{children:e}),j(`div`,{className:`lockerverse-payment__stripe-element lockerverse-payment__stripe-element--address`,"data-ready":a,children:[a?null:A(it,{label:`Loading ${e.toLowerCase()}...`}),A(`div`,{className:`lockerverse-payment__stripe-mount`,children:A(P,{onChange:n,onLoadError:({error:t})=>r(t.message??`${e} failed to load.`),onReady:i,options:{autocomplete:{mode:`automatic`},mode:t}})})]})]})}function st({message:e}){return e?A(`p`,{className:`lockerverse-payment__field-message`,role:`alert`,children:e}):null}function ct({catalog:e,displayedTotalCents:t,fieldValues:n,isBillingAddressReady:r,isPaymentReady:i,isShippingAddressReady:a,onAddressChange:o,onFieldValuesChange:s,onStripeLoadError:c,setIsBillingAddressReady:l,setIsPaymentReady:u,setIsShippingAddressReady:d}){let f=t>0;return j(k,{children:[f?A(at,{onError:c,onReady:()=>u(!0),ready:i}):null,f||e.widget.fields.shipping?A(ot,{label:f?`Billing address`:`Shipping address`,mode:`billing`,onChange:e=>o(`billing`,e),onError:c,onReady:()=>l(!0),ready:r}):null,e.widget.fields.shipping?j(`div`,{className:`lockerverse-payment__shipping`,children:[A(fe,{checked:n.shippingMatchesBilling,name:`shippingMatchesBilling`,onChange:e=>{s({...n,shippingMatchesBilling:e}),e?o(`shipping`,null):d(!1)},children:`Shipping is same as billing information`}),n.shippingMatchesBilling?null:A(ot,{label:`Shipping address`,mode:`shipping`,onChange:e=>o(`shipping`,e),onError:c,onReady:()=>d(!0),ready:a})]}):null]})}function lt({catalog:t,displayedTotalCents:n,fieldValues:r,isBillingAddressReady:i,isPaymentReady:a,isRequiredShippingReady:o,isSubmitting:s,onFieldValuesChange:c,quote:l}){let u=n===0,d=u?!t.widget.fields.shipping||i&&o:a&&i&&o,f=tt(l.paymentOption),p=u?`Complete order`:`Pay ${e(n)}`;!u&&f&&(p=`Subscribe for ${e(n)}/${f.interval}`),s&&(p=u?`Completing…`:`Processing…`);let m=`Process payment for ${e(n)} total`;return u?m=`Complete order`:f&&(m=`Start ${f.label.toLowerCase()} subscription for ${e(n)}`),j(`div`,{className:`lockerverse-payment__actions`,children:[A(Y,{amountCents:l.serviceFeeCents||Math.round(l.subtotalCents*t.pricingPolicy.serviceFeeRateBasisPoints/1e4),enabled:t.widget.fields.serviceFee,onChange:c,values:r}),A(`button`,{"aria-busy":s,"aria-label":m,disabled:s||!d,type:`submit`,children:p})]})}function ut(e,t){let n=e.elements.namedItem(t);if(n instanceof HTMLElement){n.focus();return}n instanceof RadioNodeList&&Array.from(n).find(e=>e instanceof HTMLElement)?.focus()}function dt({customFieldErrors:e,emailRef:t,form:n,parsedTipSuccess:r,phoneRef:i,validationErrors:a}){if(a.email){t.current?.focus();return}if(a.phone){i.current?.focus();return}if(!r){n.querySelector(`[name="tip"]`)?.focus();return}let[o]=Object.keys(e);o&&ut(n,`custom:${o}`)}function ft(t){let n=t.appliedDiscount;if(n?.source!==`email_list`)return;let r=n.percentageOff===void 0?e(t.discountCents):`${n.percentageOff}%`;return n.message??`Your email qualifies for ${r} off.`}function pt({email:e,emailDiscountMessage:t,emailErrorId:n,emailId:r,emailRef:a,errors:o,onEmailBlur:l,onEmailChange:u,onPhoneChange:d,phone:f,phoneCountry:p,phoneEnabled:m,phoneErrorId:h,phoneId:g,phoneRef:_}){return j(`div`,{className:`lockerverse-payment__contact`,children:[A(i,{error:o.email,errorId:n,id:r,label:`Email`,name:`email`,onBlur:l,onChange:e=>u(e.currentTarget.value),ref:a,required:!0,value:e}),t===void 0?null:A(`p`,{className:`lockerverse-payment__discount-message`,role:`status`,children:t}),m?A(s,{error:o.phone,errorId:h,id:g,label:`Phone`,children:A(c,{country:p,error:o.phone,errorId:h,id:g,inputRef:_,name:`phone`,onChange:d,required:!0,value:f})}):null]})}function mt({message:e}){return e?j(`div`,{className:`lockerverse-payment__actions`,children:[A(`p`,{className:`lockerverse-payment__field-message`,role:`alert`,children:e}),A(`button`,{className:`lockerverse-payment__status-check`,onClick:()=>window.location.reload(),type:`button`,children:`Reload checkout`})]}):null}function ht({paymentRequired:e,shippingRequired:t,isPaymentReady:n,isBillingAddressReady:r,isRequiredShippingReady:i,isSubmitting:a,scriptFailed:o,elementError:s,clearElementError:c}){let[l,u]=O(!1),d=e||t,f=(!e||n)&&(!d||r)&&i;if(S(()=>{if(u(!1),f&&c(void 0),!d||f||a)return;let e=window.setTimeout(()=>u(!0),3e4);return()=>window.clearTimeout(e)},[d,f,a,c]),!(!d||f||a)){if(o||s)return`The secure checkout fields could not load. Check your connection, then reload the checkout.`;if(l)return`The secure checkout fields are taking longer than expected. You can wait or reload the checkout.`}}function gt({catalog:e,checkoutItems:t,client:n,initialCustomFieldValues:r,paymentSummaryPosition:i,metadata:a,onPaymentComplete:s,onResumePaymentFailed:c,onPaymentRecoveryChange:l,onPaymentUncertain:f,onQuoteChange:p,onStateChange:h,quote:v,resumePayment:y,stripeConnectedAccountId:b,stripeLoadFailed:x,paymentState:w,updateState:T}){let E=u(e,t),[M,N]=O(``),[P,F]=O(``),[I,z]=O(`US`),[B,V]=O({}),[ee,H]=O({}),[te,ne]=O(),[re,U]=O(),[W,ie]=O(!1),[G,ae]=O(!1),[oe,K]=O(!1),[q,se]=O(()=>({customFields:d(E,r),customTip:``,includeServiceFee:e.widget.fields.serviceFee,memberId:``,merchSize:`M`,promoCode:``,shippingMatchesBilling:!0,tipPercent:`10`})),ce=D({billing:null,shipping:null}),le=D(null),ue=D(null),J=D(null),fe=D(v.totalCents>0),Y=Qe({catalog:e,checkoutItems:t,client:n,elements:L(),email:M,fieldValues:q,metadata:a,onPaymentComplete:s,onPaymentRecoveryChange:l,onPaymentUncertain:f,onQuoteChange:p,onResumePaymentFailed:c,onStateChange:h,paymentState:w,quote:v,resumePayment:y,stripe:R(),stripeConnectedAccountId:b,stripeLoadFailed:x,updateState:T}),{displayedTotalCents:X,isRecovering:Z,isUnresolved:me,isRefreshingQuote:he,isSubmitting:Q,parsedTip:$,paymentError:ge,promoError:_e,terminalMessage:ve,retryUrl:ye}=Y.state,be=`lockerverse-${C()}`,xe=`${be}-email`,Se=`${xe}-error`,Ce=`${be}-phone`,we=`${Ce}-error`,Te=`${be}-tip-error`,Ee=($.success?$.cents:null)??0,De=X-Ee,Oe=!e.widget.fields.shipping||q.shippingMatchesBilling||oe,ke=ht({clearElementError:U,elementError:re,isBillingAddressReady:G,isPaymentReady:W,isRequiredShippingReady:Oe,isSubmitting:Q,paymentRequired:X>0,scriptFailed:x,shippingRequired:e.widget.fields.shipping});S(()=>{Q&&J.current?.focus({preventScroll:!0})},[Q]),S(()=>{Q||B.email||!B.phone||ue.current?.focus()},[B.email,B.phone,Q]),S(()=>{let e=X>0;e&&!fe.current&&(ie(!1),ae(!1)),fe.current=e},[X]);function Ae(e){Y.commands.fieldChanged(!1,e!==`email`),V(t=>{let n={...t};return delete n[e],n})}function je(e){let t=e.promoCode!==q.promoCode,n=e.includeServiceFee!==q.includeServiceFee;Y.commands.fieldChanged(t,!(t||n)),se(e),H({}),ne(void 0)}async function Me(t){t.preventDefault();let n=e.widget.fields.phone?o(P,I):``,r=_({email:M,phone:n},e.widget.fields.phone),i=m(E,q.customFields);if(!(r.value&&$.success)||Object.keys(i).length>0){V(r.errors),H(i),ne($.success?void 0:$.message),Y.commands.reportValidationFailure();let e=t.currentTarget;queueMicrotask(()=>{dt({customFieldErrors:i,emailRef:le,form:e,parsedTipSuccess:$.success,phoneRef:ue,validationErrors:r.errors})});return}V({}),H({});let a=await Y.commands.submit({addresses:ce.current,phone:n});a?.phoneError&&V({phone:a.phoneError})}if(ve||Z)return j(`div`,{className:`lockerverse-payment__actions`,children:[j(`p`,{className:`lockerverse-payment__payment-status`,ref:J,role:`status`,tabIndex:-1,children:[Z?`Recovering payment…`:ve,ye?j(k,{children:[` `,A(`a`,{href:ye,rel:`noopener noreferrer`,target:`_blank`,children:`Complete payment`})]}):null]}),me||Z?A(`button`,{"aria-busy":Z,className:`lockerverse-payment__status-check`,disabled:Z,onClick:Y.commands.checkPaymentStatus,type:`button`,children:Z?`Checking payment status…`:`Check payment status`}):null]});let Ne=A(g,{displayedBaseCents:De,displayedTipCents:Ee,displayedTotalCents:X,quote:v}),Pe=A(de,{enabled:e.widget.fields.tipping,error:te,errorId:Te,onChange:je,values:q}),Fe={bottom:{afterFields:j(k,{children:[Pe,Ne]}),beforeFields:null},hidden:{afterFields:Pe,beforeFields:null},top:{afterFields:null,beforeFields:j(k,{children:[Ne,Pe]})}}[i??`top`];return j(`form`,{"aria-busy":Q,className:`lockerverse-payment__form`,noValidate:!0,onSubmit:Me,children:[A(`div`,{"data-lockerverse-input-region":``,inert:Q?!0:void 0,children:j(`fieldset`,{className:`lockerverse-payment__input-fieldset`,disabled:Q,children:[Fe.beforeFields,A(pt,{email:M,emailDiscountMessage:ft(v),emailErrorId:Se,emailId:xe,emailRef:le,errors:B,onEmailBlur:()=>Y.commands.refreshAuthoritativeTotal(),onEmailChange:e=>{N(e),Ae(`email`)},onPhoneChange:({value:e,country:t})=>{F(e),z(t),Ae(`phone`)},phone:P,phoneCountry:I,phoneEnabled:e.widget.fields.phone,phoneErrorId:we,phoneId:Ce,phoneRef:ue}),A(mt,{message:ke}),A(ct,{catalog:e,displayedTotalCents:X,fieldValues:q,isBillingAddressReady:G,isPaymentReady:W,isShippingAddressReady:oe,onAddressChange:(e,t)=>{ce.current[e]=t},onFieldValuesChange:je,onStripeLoadError:U,setIsBillingAddressReady:ae,setIsPaymentReady:ie,setIsShippingAddressReady:K}),A(pe,{customFields:E,errors:ee,fields:e.widget.fields,idPrefix:be,isPromoApplying:he,memberIdLabel:e.community?.memberIdLabel,onApplyPromo:Y.commands.applyPromo,onChange:je,promoError:_e,values:q}),Fe.afterFields,A(lt,{catalog:e,displayedTotalCents:X,fieldValues:q,isBillingAddressReady:G,isPaymentReady:W,isRequiredShippingReady:Oe,isSubmitting:Q,onFieldValuesChange:je,quote:v})]})}),Q?A(`p`,{className:`lockerverse-payment__sr-only`,ref:J,role:`status`,tabIndex:-1,children:X===0?`Completing order…`:`Processing payment…`}):null,A(st,{message:ge})]})}function _t(){return A(h,{fieldCount:2,label:`Loading payment…`,sectionCount:2,showCheckbox:!0})}function vt(e,t){switch(t.type){case`loading`:return{phase:`loading`,revision:e.revision};case`ready`:return St(t.displayedQuote,e.revision+1);case`error`:return{failure:t.failure,phase:`error`,revision:e.revision};case`checkout`:return e.phase===`ready`?{...e,displayedQuote:t.checkout,quoteFailure:void 0}:e;case`quote-error`:return e.phase===`ready`?{...e,quoteFailure:t.failure}:e;default:return e}}function yt(e,t,n){return e?.catalog===t&&e.selectionKey===n}function bt({checkout:e}){return{displayedQuote:e,type:`ready`}}function xt(e){return e instanceof Error?e.message:`Lockerverse payment could not load.`}function St(e,t){return{checkoutItems:[...e.items],displayedQuote:e,phase:`ready`,quoteFailure:void 0,revision:t}}function Ct(e,t){let n=e.widget.fields.serviceFee;return N(e,{includeServiceFee:n,selection:t})}function wt(e,t){try{return St(Ct(e,t),1)}catch(e){return{failure:xt(e),phase:`error`,revision:0}}}function Tt({catalog:e,client:t,paymentState:n,selection:r}){let i=Oe(r),a=i.success?JSON.stringify(i.value):`invalid-selection`,o=T(()=>i.success?i.value:[],[i.success,a]),[s,c]=E(vt,void 0,()=>i.success?wt(e,o):{phase:`loading`,revision:0}),l=D(void 0),u=D(0),d=D(s.phase===`ready`?{catalog:e,selectionKey:a}:void 0),f=D(s.phase===`error`?{catalog:e,selectionKey:a}:void 0),p=n===`submitting`||n===`success`||n===`unresolved`;S(()=>{if(!i.success||p||yt(f.current,e,a)||yt(l.current,e,a))return;let n=!0;l.current={catalog:e,selectionKey:a};let r=yt(d.current,e,a);r||c({type:`loading`});function s(e){n&&c(e)}function m(){n&&(l.current=void 0,f.current={catalog:e,selectionKey:a})}let h;function g(t){if(!n||(l.current=void 0,f.current={catalog:e,selectionKey:a},r&&h!==void 0&&u.current!==h))return;let i=xt(t);if(i===`This option is sold out.`){c({failure:i,type:`error`});return}c(r?{failure:i,type:`quote-error`}:{failure:i,type:`error`})}async function _(){try{h=u.current;let n=e.widget.fields.serviceFee;if(!r){let t=Ct(e,o);r=!0,d.current={catalog:e,selectionKey:a},s(bt({checkout:t}))}let i=await t.calculateTotal({catalog:e,includeServiceFee:n,selection:o});m(),u.current===h&&s({checkout:i,type:`checkout`})}catch(e){g(e)}}return _(),()=>{n=!1,yt(l.current,e,a)&&(l.current=void 0)}},[e,t,i.success,p,a,o]);let m=yt(d.current,e,a)||yt(f.current,e,a)||yt(l.current,e,a),h=p||m?s:{phase:`loading`,revision:s.revision};return{selectionError:i.success?void 0:i.message,session:h,updateCheckout:e=>{u.current+=1,c({checkout:e,type:`checkout`})}}}const Et=re({recovery:re({connectedAccountId:te(K()),paymentReference:W(K(),q(),H())}),selectionFingerprint:K(),version:se([B(1),B(2)]),widgetId:U(K())});function Dt(e){let t=Oe(e);return t.success?JSON.stringify(t.value.map(e=>{let t=e.productSlug.trim();return`quantity`in e?[`quantity`,t,e.quantity]:`amountCents`in e?[`amount`,t,e.amountCents]:[`product`,t]})):null}const Ot=`A previous payment uses different checkout details. Return to its original checkout to check the payment before you pay again.`;function kt(e,t,n){let r;try{r=window.sessionStorage.getItem(e)}catch{return{recovery:null}}if(!r)return{recovery:null};try{let e=ae(Et,JSON.parse(r));if(!e.success)throw Error(`Invalid recovery record`);let i=e.output;return i.selectionFingerprint!==t||i.version===2&&i.widgetId!==n?{error:Ot,recovery:null}:{recovery:{connectedAccountId:i.recovery.connectedAccountId,paymentReference:i.recovery.paymentReference}}}catch{return{error:`The saved payment could not be read. Contact support to check it before you pay again.`,recovery:null}}}function At({selection:e,storageKey:t,widgetId:n}){let r=Dt(e),i=JSON.stringify([t,r,n]),[a,o]=O(null),s=D(null);S(()=>{if(!t)return;let e=s.current,a={recovery:null};e?.recovery?a=e.identity===i?{recovery:e.recovery}:{error:Ot,recovery:null}:r!==null&&(a=kt(t,r,n)),a.recovery&&(s.current={identity:i,recovery:a.recovery}),o({identity:i,...a})},[r,i,t,n]);let c=x(e=>{if(!(!t||r===null)){s.current=e?{identity:i,recovery:e}:null;try{e?window.sessionStorage.setItem(t,JSON.stringify({recovery:e,selectionFingerprint:r,version:2,widgetId:n})):window.sessionStorage.removeItem(t)}catch{}}},[r,i,t,n]);return{error:t&&a?.identity===i?a.error:void 0,ready:!t||a?.identity===i,recovery:t&&a?.identity===i?a.recovery:null,remember:c}}const jt={annually:`/year`,"every-six-months":` every 6 months`,monthly:`/month`,"one-time":``};function Mt({branding:e,catalog:t}){return j(`header`,{children:[t.widget.showCommunityBranding&&e?j(`div`,{className:`lockerverse-payment__branding`,children:[e.imageUrl?A(`img`,{alt:e.name,height:`48`,src:e.imageUrl,width:`48`}):null,A(`strong`,{children:e.name})]}):null,A(`h1`,{children:t.widget.title??t.widget.name}),t.widget.description?A(`p`,{children:t.widget.description}):null]})}function Nt({catalog:t,selection:n}){let r=n?.length?t.products.filter(e=>n.some(t=>t.productSlug===e.slug)):t.products.filter(e=>e.id!==t.widget.requiredShipping?.productId);return r.length===0?null:j(`div`,{className:`lockerverse-payment__payment-summary`,children:[A(`h2`,{children:`Products`}),A(`div`,{className:`lockerverse-payment__payment-summary-items`,children:r.map(t=>{let n=t.pricingMode===`fixed`?t.amountCents:t.minimumAmountCents,r=jt[t.paymentOption];return j(`div`,{className:`lockerverse-payment__payment-summary-row`,children:[A(`span`,{children:t.name}),A(`strong`,{children:n===null?`Choose amount`:`${t.pricingMode===`custom`?`From `:``}${e(n)}${r}`})]},t.id)})}),A(`p`,{children:`Base prices. Final total is checked at checkout.`})]})}function Pt(e,t){let i=n(e?.[`--lockerverse-accent`]??t?.accentColor??`#38d77a`),a=r(i),o={...e};return(e?.[`--lockerverse-accent`]!==void 0||t?.accentColor)&&(o[`--lockerverse-accent`]=i),a&&e?.[`--lockerverse-accent-contrast`]===void 0&&(o[`--lockerverse-accent-contrast`]=a),{accent:i,rootStyle:o}}function Ft({catalog:e,client:n,loadError:r,onRetry:i,...a}){let{branding:o,className:s,completionView:c,paymentSummaryPosition:l=`top`,recoveryStorageKey:u,initialCustomFieldValues:d,metadata:f,onPaymentComplete:p,onPaymentRecoveryChange:m,onPaymentUncertain:h,resumePayment:g,selection:_,style:v,stripeLoader:y=$e,theme:b=`dark`,...C}=a,[T,E]=O(g),k=D(null),[M,N]=O(null),P=x(e=>{N(e),t(p,e)},[p]),[F,I]=O(),[L,R]=O(`idle`),z=D(void 0),{selectionError:B,session:V,updateCheckout:ee}=Tt({catalog:e,client:n,paymentState:L,selection:_}),H=V.phase===`ready`?V.revision:void 0,te=x(e=>{H!==void 0&&(z.current=H),R(e)},[H]),ne=x(e=>m?.(e),[m]),re=x(()=>{E(void 0)},[]);S(()=>{V.phase===`loading`&&I(void 0)},[V.phase]),w(()=>{V.phase===`ready`&&z.current!==V.revision&&R(e=>e===`success`||e===`unresolved`?e:`idle`)},[V.phase,V.revision]);let U=[`lockerverse-payment`,s].filter(Boolean).join(` `),W=o??e.community,{accent:ie,rootStyle:G}=Pt(v,W);return M&&c===`summary`?A(`section`,{...C,className:U,"data-lockerverse-theme":b,"data-payment-state":`success`,style:G,children:j(`div`,{className:`lockerverse-payment__completion`,role:`status`,children:[A(`span`,{"aria-hidden":`true`,className:`lockerverse-payment__completion-icon`,children:A(`svg`,{"aria-hidden":`true`,fill:`none`,height:`28`,stroke:`currentColor`,strokeWidth:`2`,viewBox:`0 0 24 24`,width:`28`,children:A(`path`,{d:`m5 12 4 4L19 6`})})}),A(`h1`,{children:M.paymentRequired?`Thank you`:`Order confirmed`}),A(`p`,{children:M.paymentRequired?`Your payment has been received.`:`Your order is confirmed. No payment was required.`})]})}):B?A(`section`,{...C,className:U,"data-lockerverse-theme":b,role:`alert`,style:G,children:B}):V.phase===`error`&&V.failure===`This option is sold out.`||L===`sold_out`?j(`section`,{...C,className:U,"data-lockerverse-theme":b,role:`alert`,style:G,children:[A(`h1`,{children:`Sold out`}),A(`p`,{children:`This option is sold out.`})]}):V.phase===`error`?A(`section`,{...C,className:U,"data-lockerverse-theme":b,style:G,children:A(`p`,{role:`alert`,children:V.failure})}):V.phase===`ready`?j(`section`,{...C,"aria-label":`Payment`,className:U,"data-lockerverse-theme":b,"data-payment-state":L,ref:k,style:G,children:[A(Mt,{branding:W,catalog:e}),r?j(`div`,{role:`alert`,children:[A(`p`,{children:r.message}),A(`button`,{onClick:i,type:`button`,children:`Retry`})]}):null,F?A(`p`,{className:`lockerverse-payment__payment-status`,role:`status`,children:F}):null,V.quoteFailure?j(`div`,{className:`lockerverse-payment__payment-status`,role:`alert`,children:[A(`span`,{children:V.quoteFailure}),A(`span`,{children:` The final total will be checked when you submit.`})]}):null,A(rt,{accentColor:ie,appearanceRoot:k,catalog:e,checkoutItems:V.checkoutItems,client:n,initialCustomFieldValues:d,metadata:f,onPaymentComplete:P,onPaymentRecoveryChange:ne,onPaymentUncertain:h,onQuoteChange:(e,t)=>{I(t),ee(e)},onResumePaymentFailed:re,onStateChange:te,paymentSummaryPosition:l,quote:V.displayedQuote,resumePayment:T,stripeLoader:y,theme:b,visualStyle:G},V.revision)]}):j(`section`,{...C,"aria-busy":`true`,"aria-label":`Payment`,className:U,"data-lockerverse-theme":b,style:G,children:[A(Mt,{branding:W,catalog:e}),r?j(`div`,{role:`alert`,children:[A(`p`,{children:r.message}),A(`button`,{onClick:i,type:`button`,children:`Retry`})]}):null,A(_t,{})]})}function It({children:e,loading:t=!1,viewProps:i}){let{branding:a,className:o,completionView:s,paymentSummaryPosition:c,recoveryStorageKey:l,initialCustomFieldValues:u,metadata:d,onPaymentComplete:f,onPaymentRecoveryChange:p,onPaymentUncertain:m,resumePayment:h,selection:g,stripeLoader:_,style:v,theme:y=`dark`,...b}=i,x=n(v?.[`--lockerverse-accent`]??a?.accentColor??`#38d77a`),S=r(x),C={...v};return(v?.[`--lockerverse-accent`]!==void 0||a?.accentColor)&&(C[`--lockerverse-accent`]=x),S&&v?.[`--lockerverse-accent-contrast`]===void 0&&(C[`--lockerverse-accent-contrast`]=S),A(`section`,{...b,...t?{"aria-busy":!0,"aria-label":`Payment`}:{},className:[`lockerverse-payment`,o].filter(Boolean).join(` `),"data-lockerverse-theme":y,style:C,children:e})}function Lt(e){let{catalog:n,client:r,loadError:i,onRetry:a,...o}=e,{onPaymentRecoveryChange:s,recoveryStorageKey:c,resumePayment:l,selection:u}=o,d=At({selection:u,storageKey:c,widgetId:n.widget.id}),f=x(e=>{d.remember(e),t(s,e)},[s,d.remember]);return!d.ready||d.error?A(It,{loading:!d.ready,viewProps:o,children:d.error?A(`p`,{role:`alert`,children:d.error}):A(_t,{})}):A(Ft,{...e,onPaymentRecoveryChange:f,resumePayment:l??d.recovery})}function Rt({widget:e,...t}){return e.error&&!e.catalog?j(It,{viewProps:t,children:[A(`p`,{role:`alert`,children:e.error.message}),A(`button`,{onClick:e.refresh,type:`button`,children:`Retry`})]}):e.loading?j(It,{loading:!0,viewProps:t,children:[e.catalog?j(k,{children:[A(Mt,{branding:t.branding??e.catalog.community,catalog:e.catalog}),(t.paymentSummaryPosition??`top`)===`top`?A(Nt,{catalog:e.catalog,selection:t.selection}):null]}):null,A(_t,{})]}):e.catalog?A(Lt,{catalog:e.catalog,client:e.client,loadError:e.error,onRetry:e.refresh,...t}):A(It,{loading:!0,viewProps:t,children:A(_t,{})})}export{et as n,Rt as t};
|
|
2
2
|
//# sourceMappingURL=lockerverse-payment.js.map
|