@lockerverse/react 0.2.194 → 0.2.197
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 +47 -0
- package/README.md +34 -2
- package/dist/auction-payment-view.js +1 -1
- package/dist/auction-payment-view.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/lockerverse-donate-launcher.d.ts +1 -1
- package/dist/lockerverse-donate-launcher.d.ts.map +1 -1
- package/dist/lockerverse-donate-launcher.js +1 -1
- package/dist/lockerverse-donate-launcher.js.map +1 -1
- package/dist/lockerverse-payment.js +1 -1
- package/dist/lockerverse-payment.js.map +1 -1
- package/dist/styles.css +200 -0
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.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 +45 -3
- package/guides/signup.md +1 -1
- package/package.json +2 -2
package/MIGRATIONS.md
CHANGED
|
@@ -36,6 +36,53 @@ 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.197 — disable Stripe Link in React widget checkout
|
|
40
|
+
|
|
41
|
+
New React widget checkout forms request card payments, plus US bank account
|
|
42
|
+
payments when the community enables ACH. They no longer request Stripe Link.
|
|
43
|
+
This applies to the launcher and fixed payment component, for both one-time and
|
|
44
|
+
subscription checkout. It does not change existing subscriptions or payments,
|
|
45
|
+
Stripe account settings, or payment flows in hosts that have not upgraded.
|
|
46
|
+
No host prop change is required.
|
|
47
|
+
|
|
48
|
+
## 0.2.197 — hosted donate launcher presentation
|
|
49
|
+
|
|
50
|
+
- **Affected:** React donate launcher integrations that need a hosted product picker.
|
|
51
|
+
- **Automatic:** Dialog remains the default presentation. Fixed-price one-time
|
|
52
|
+
products configured with a maximum quantity of one use an on/off switch.
|
|
53
|
+
Products that allow larger quantities retain quantity controls. Fixed checkout
|
|
54
|
+
has no product-selection change.
|
|
55
|
+
- **Optional:** Set `presentation="page"` for the same selection and payment steps
|
|
56
|
+
inline. Use `productIds` to limit selectable catalog products and
|
|
57
|
+
`initialSelection` for editable starting choices. Use catalog IDs for the filter
|
|
58
|
+
and product slugs for selection. Omitted filter means all; empty means none.
|
|
59
|
+
Required shipping remains automatic. These properties are initial mount
|
|
60
|
+
configuration; remount for another link. Filtering is not server authorization.
|
|
61
|
+
- **Optional:** Use `showDescription={false}` and the public page root class,
|
|
62
|
+
`className`, `style`, and existing theme tokens for minimal branded pages.
|
|
63
|
+
- **Hosted URL:** `/checkout?community=<slug>&widget=<slug>` defaults to dark.
|
|
64
|
+
Optional `include` lists purchasable product slugs; `q.<slug>` prefills quantities.
|
|
65
|
+
Use `theme=light` for light mode. Dev branch uses the development backend;
|
|
66
|
+
production uses production. Explicit `env=development` or `env=production`
|
|
67
|
+
selects a backend. The fixed checkout remains separate.
|
|
68
|
+
- **Verification:** Check both themes, mobile width, excluded prefill, quantity
|
|
69
|
+
limits, Continue, and Edit order without submitting a live payment.
|
|
70
|
+
|
|
71
|
+
## 0.2.196 — save reusable payment methods
|
|
72
|
+
|
|
73
|
+
- **Affected:** React one-time payments, subscriptions, auction Buy Now, and
|
|
74
|
+
purchase recovery. Deferred Stripe Elements now requests `off_session` setup
|
|
75
|
+
so its configuration matches the backend PaymentIntent and saves supported
|
|
76
|
+
reusable methods, including Link, to the customer.
|
|
77
|
+
- **Required:** update the matching SDK/React packages and deploy the host with
|
|
78
|
+
the backend payment-saving change. No host prop changes are required.
|
|
79
|
+
- **Unchanged:** existing purchases are not converted into reusable methods.
|
|
80
|
+
Future charges can still require customer authentication. Methods without
|
|
81
|
+
off-session support cannot be made reusable by this setting.
|
|
82
|
+
- **Check:** in Stripe test mode, complete supported payment methods and verify
|
|
83
|
+
the successful PaymentIntent and customer payment-method attachment. Verify
|
|
84
|
+
auction Buy Now and purchase recovery with the same backend configuration.
|
|
85
|
+
|
|
39
86
|
## 0.2.194 — sharper large auction gallery photos
|
|
40
87
|
|
|
41
88
|
- **Affected:** React auction item gallery responsive images.
|
package/README.md
CHANGED
|
@@ -268,8 +268,40 @@ branding, themes, metadata, and recovery properties are the same as
|
|
|
268
268
|
`LockerversePayment`. API and transport options belong to
|
|
269
269
|
`useLockerverseWidget`.
|
|
270
270
|
|
|
271
|
-
|
|
272
|
-
|
|
271
|
+
For a hosted two-step page, use the same launcher without a trigger or dialog:
|
|
272
|
+
|
|
273
|
+
```tsx
|
|
274
|
+
<LockerverseDonateLauncher
|
|
275
|
+
widget={widget}
|
|
276
|
+
presentation="page"
|
|
277
|
+
theme="light"
|
|
278
|
+
showDescription={false}
|
|
279
|
+
productIds={["configured-product-id"]}
|
|
280
|
+
initialSelection={[{ productSlug: "configured-product-slug", quantity: 2 }]}
|
|
281
|
+
/>
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
`productIds` limits the products visitors can choose. Omit it to show all widget
|
|
285
|
+
products; an empty array shows none. Use IDs from the catalog, not slugs. Required
|
|
286
|
+
shipping remains automatic even when its product ID is not in this list. This is
|
|
287
|
+
a presentation filter, not a server authorization rule.
|
|
288
|
+
|
|
289
|
+
`initialSelection` uses the existing payment selection format and is editable.
|
|
290
|
+
It waits for the catalog, ignores unknown or excluded products, clamps fixed
|
|
291
|
+
quantities to configured limits and inventory, and ignores invalid custom
|
|
292
|
+
amounts. The first valid recurring selection takes precedence over one-time
|
|
293
|
+
choices, since subscriptions cannot be combined with a one-time cart. Both link
|
|
294
|
+
properties are read once per mount; use a React `key` to load a different link.
|
|
295
|
+
|
|
296
|
+
`showDescription={false}` hides the widget description on both steps. The page
|
|
297
|
+
uses the configured widget title and community branding. `className` and `style`
|
|
298
|
+
can style the page root; `.lockerverse-launcher__page` is the supported root
|
|
299
|
+
class. Use the existing theme tokens or a host wrapper for page backgrounds;
|
|
300
|
+
do not target internal control selectors. The default dialog and fixed payment
|
|
301
|
+
component are unchanged.
|
|
302
|
+
|
|
303
|
+
The dialog starts loading Stripe when the visitor opens it. Page presentation
|
|
304
|
+
loads payment when the visitor continues. Catalog-only pages do not load Stripe.
|
|
273
305
|
|
|
274
306
|
## Signup
|
|
275
307
|
|
|
@@ -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(t){let{isPurchase:n,item:r,pricing:i,id:a}=t;return E(`form`,{className:`lockerverse-auctions__checkout`,noValidate:!0,onSubmit:t.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:!t.onBack,onClick:t.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:n?`Secure checkout`:`Secure payment method`})]})]}),T(`p`,{className:`lockerverse-auctions__checkout-eyebrow`,children:t.communityName}),T(`h2`,{children:n?`Finalize your purchase.`:`Finalize your bid authorization.`}),T(`p`,{className:`lockerverse-auctions__checkout-summary`,children:n?E(w,{children:[`Pay `,T(`strong`,{children:e(i.totalCents)}),` for`,` `,t.quantity,` `,t.quantity===1?`item`:`items`,` of`,` `,T(`strong`,{children:r.name}),`. Your card is charged immediately once checkout succeeds.`]}):E(w,{children:[`Authorize a payment method for your bid of`,` `,T(`strong`,{children:e(i.subtotalCents)}),` on`,` `,T(`strong`,{children:r.name}),`. Your card is only charged if this bid wins the item.`]})}),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:[t.showFields&&E(`fieldset`,{disabled:t.locked,children:[E(`div`,{className:`lockerverse-auctions__checkout-contact`,children:[T(l,{error:t.contactErrors.email,id:`${a}-email`,label:`Email`,name:`email`,onChange:e=>t.onEmailChange(e.target.value),required:!0,value:t.email}),T(d,{error:t.contactErrors.phone,id:`${a}-phone`,label:`Phone`,children:T(p,{country:t.phoneCountry,error:t.contactErrors.phone,errorId:`${a}-phone-error`,id:`${a}-phone`,name:`phone`,onChange:t.onPhoneChange,required:!0,value:t.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:n?`Processed securely and charged immediately for this purchase.`:`Stored securely and charged only if your bid finishes on top.`})]}),T(A,{onLoadError:t.onPaymentLoadError,options:j(n)})]}),E(`section`,{"aria-label":`Billing Details`,className:`lockerverse-auctions__checkout-section`,children:[T(`h3`,{children:`Billing Details`}),T(O,{onChange:t.onBillingChange,options:{mode:`billing`}}),T(`p`,{children:n?`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:`${a}-delivery-same-as-billing`,children:[T(m,{checked:t.sameAsBilling,id:`${a}-delivery-same-as-billing`,onChange:e=>t.onSameAsBillingChange(e.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.`})]})]}),!t.sameAsBilling&&E(w,{children:[T(`h3`,{children:`Delivery Address`}),T(O,{onChange:t.onShippingChange,options:{mode:`shipping`}})]})]}),T(N,{isPurchase:n,pricing:i}),t.serviceFeeEnabled&&T(M,{...t})]}),t.message&&T(`p`,{"aria-live":`polite`,className:`lockerverse-auctions__notice`,role:`status`,children:t.message}),!t.isTerminal&&E(`div`,{className:`lockerverse-auctions__checkout-footer`,children:[E(`p`,{children:[n?`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 ${n?`order`:`bid`} so the seller can fulfill the item after payment.`:``]}),E(`button`,{className:`lockerverse-auctions__button lockerverse-auctions__checkout-submit`,disabled:t.submitDisabled,type:`submit`,children:[t.buttonText,T(v,{"aria-hidden":`true`,size:16})]})]})]})]})}function M(t){let{isPurchase:n,pricing:r}=t;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:[n?`Add`:`If I win, add`,` `,e(t.serviceFeeCents),` to help cover processing fees`]}),E(`span`,{children:[n?`Total`:`Total if I win`,`:`,` `,e(r.totalCents)]})]})]}):E(`p`,{children:[n?`Total`:`Total if I win`,`:`,` `,e(r.totalCents)]})})}function N({pricing:t,isPurchase:n}){return t.additionalCharge?E(`section`,{"aria-label":`Order amounts`,className:`lockerverse-auctions__checkout-section`,children:[E(`p`,{children:[n?`Subtotal`:`Bid amount`,`:`,` `,e(t.subtotalCents)]}),E(`p`,{children:[t.additionalCharge.name,`:`,` `,e(t.additionalChargeCents??0)]}),E(`p`,{children:[n?`Total`:`Total if I win`,`:`,` `,e(t.totalCents)]})]}):null}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 P(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,ie]=C(!0),[I,ae]=C(null),[oe,se]=C(null),[L,ce]=C(e.resumePurchase??null),[R,le]=C(e.resumePurchase?`pending`:`ready`),[ue,de]=C(null),z=S(e.resumePurchase?.submission.clientRequestId??null),B=R===`complete`||R===`uncertain`,V=S(!1),H=S(!0),U=S(e);U.current=e;let W=S(!1);function G(e){H.current&&le(e),c(U.current.onInteractionLockChange,e!==`ready`&&e!==`complete`)}function K(e){H.current&&de(e)}function q(e){G(e===`bid`?`uncertain`:`pending`),K(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.`),W.current||(W.current=!0,c(U.current.onUncertain,e))}b(()=>(H.current=!0,()=>{H.current=!1}),[]);let J=!!(L??e.resumePurchase)||d.saleMode===`buy_now`,Y=L?.pricing??e.resumePurchase?.pricing??t(l,d,p),fe=L?.payment??e.resumePurchase?.payment??l.payment;function X(e){H.current&&ce(e),c(U.current.onPurchaseRecoveryChange,e)}function Z(e){e.status===`paid`?(z.current=null,X(null),G(`complete`),c(U.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}),W.current||(W.current=!0,c(U.current.onPurchaseComplete,e))):e.status===`pending_payment`?(G(`pending`),K(`Your purchase is pending. Check its status before making another payment.`)):(z.current=null,X(null),G(`ready`),K(`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=U.current.selection;if(p.quantity!==e.quantity||p.amount!==e.amount||p.includeServiceFee!==e.includeServiceFee)throw Error(`Your selection changed. Review the total before continuing.`)}async function he(e){if(!(J&&d.additionalCharge))return!0;let t=await m.getPurchaseQuote(l.slug,d.id,{includeServiceFee:p.includeServiceFee,quantity:p.quantity});return H.current?t.subtotalCents!==Y.subtotalCents||(t.additionalChargeCents??0)!==(Y.additionalChargeCents??0)||t.serviceFeeCents!==Y.serviceFeeCents||t.totalCents!==Y.totalCents||!o(t.additionalCharge,Y.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(!H.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:I,collectShippingAddress:d.collectShippingAddress,elements:y,email:e.email,phone:e.phone,shipping:F?I:oe,stripe:v});return H.current?(me(),{confirmationToken:c,email:e.email,includeServiceFee:p.includeServiceFee,phone:e.phone,...s(Y)}):null}async function _e(e){let t=await m.createBid(l.slug,d.id,{...e,amount:p.amount});if(t.requiresAction){if(!(H.current&&v)){q(`bid`);return}await r(v,t)}G(`complete`),c(U.current.onResult,{additionalCharge:t.additionalCharge??null,additionalChargeCents:t.additionalChargeCents??0,amountCents:t.subtotalCents,kind:`bid`,serviceFeeCents:t.serviceFeeCents,totalCents:t.totalCents}),W.current||(W.current=!0,c(U.current.onBidSubmitted,t))}async function Q(e,t){if(e.requiresAction){if(!(H.current&&v)){q(`purchase`);return}await r(v,e);let n=await m.getPurchaseStatus(l.slug,d.id,t.submission.clientRequestId);n?Z(n):(G(`pending`),K(`Payment status is not available yet. Check again shortly.`));return}Z(e),!H.current&&e.status===`pending_payment`&&q(`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(!H.current){q(`purchase`);return}G(`retry`),K(`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}X(null),G(`ready`),K(`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(K(e instanceof Error?e.message:`Unable to complete this request.`),J&&n){if(!r&&e instanceof D&&!e.recoveryRecommended)try{await ye(e,n);return}catch{}q(`purchase`)}else i?q(`bid`):G(`ready`)}function xe(){return z.current??=globalThis.crypto.randomUUID(),z.current}function Se(){return H.current?!0:(L||(X(null),G(`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&&fe;function we(){if(V.current||B)return null;if(!$)return K(`Payment details are still loading.`),null;let e=L?null:pe();return L||e?{checkoutPayment:$,contact:e,retryOriginal:R===`retry`}:null}async function Te(e){e.preventDefault();let t=we();if(!t)return;let{contact:n,checkoutPayment:r,retryOriginal:i}=t;V.current=!0,W.current=!1,G(`busy`),K(null);let a=!1,o=L;try{if(!o){let e=await ge(n);if(!(e&&H.current)){G(`ready`);return}if(!J){a=!0,await _e(e);return}o=Object.freeze({auctionId:l.id,item:d,itemId:d.id,payment:Object.freeze({...r}),pricing:Y,submission:Object.freeze({...e,clientRequestId:xe(),paymentMethodTypes:Object.freeze([`card`]),quantity:p.quantity})}),X(o)}a=!0,await Ce(o,!!L&&!i)}catch(e){await be(e,a,o,L!==null&&!i)}finally{V.current=!1}}let Ee=re(R,L!==null,J),De=R!==`ready`;return T(ne,{buttonText:Ee,communityName:e.communityName??l.name,contactErrors:N,email:E,id:w,includeServiceFee:p.includeServiceFee,isPurchase:J,isTerminal:B,item:d,locked:De,message:ue,onBack:R===`ready`?_:void 0,onBillingChange:ae,onEmailChange:t=>{O(t),e.onContactChange?.({email:t,phone:u(k,j)})},onIncludeServiceFeeChange:e.onIncludeServiceFeeChange,onPaymentLoadError:()=>K(`Unable to load payment form.`),onPhoneChange:({value:t,country:n})=>{A(t),M(n),e.onContactChange?.({email:E,phone:u(t,n)})},onSameAsBillingChange:ie,onShippingChange:se,onSubmit:Te,phone:k,phoneCountry:j,pricing:Y,quantity:p.quantity,sameAsBilling:F,serviceFeeCents:L?Y.serviceFeeCents:t(l,d,{...p,includeServiceFee:l.serviceFeeEnabled}).serviceFeeCents,serviceFeeEnabled:l.serviceFeeEnabled,showFields:!(L||B),submitDisabled:R===`busy`||!v||!y})}function F(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`,setupFutureUsage:`off_session`};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`],syncAddressCheckbox:`none`};return T(k,{options:S,stripe:u,children:T(P,{...e})})}export{F 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: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(t){let{isPurchase:n,item:r,pricing:i,id:a}=t;return E(`form`,{className:`lockerverse-auctions__checkout`,noValidate:!0,onSubmit:t.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:!t.onBack,onClick:t.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:n?`Secure checkout`:`Secure payment method`})]})]}),T(`p`,{className:`lockerverse-auctions__checkout-eyebrow`,children:t.communityName}),T(`h2`,{children:n?`Finalize your purchase.`:`Finalize your bid authorization.`}),T(`p`,{className:`lockerverse-auctions__checkout-summary`,children:n?E(w,{children:[`Pay `,T(`strong`,{children:e(i.totalCents)}),` for`,` `,t.quantity,` `,t.quantity===1?`item`:`items`,` of`,` `,T(`strong`,{children:r.name}),`. Your card is charged immediately once checkout succeeds.`]}):E(w,{children:[`Authorize a payment method for your bid of`,` `,T(`strong`,{children:e(i.subtotalCents)}),` on`,` `,T(`strong`,{children:r.name}),`. Your card is only charged if this bid wins the item.`]})}),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:[t.showFields&&E(`fieldset`,{disabled:t.locked,children:[E(`div`,{className:`lockerverse-auctions__checkout-contact`,children:[T(l,{error:t.contactErrors.email,id:`${a}-email`,label:`Email`,name:`email`,onChange:e=>t.onEmailChange(e.target.value),required:!0,value:t.email}),T(d,{error:t.contactErrors.phone,id:`${a}-phone`,label:`Phone`,children:T(p,{country:t.phoneCountry,error:t.contactErrors.phone,errorId:`${a}-phone-error`,id:`${a}-phone`,name:`phone`,onChange:t.onPhoneChange,required:!0,value:t.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:n?`Processed securely and charged immediately for this purchase.`:`Stored securely and charged only if your bid finishes on top.`})]}),T(A,{onLoadError:t.onPaymentLoadError,options:j(n)})]}),E(`section`,{"aria-label":`Billing Details`,className:`lockerverse-auctions__checkout-section`,children:[T(`h3`,{children:`Billing Details`}),T(O,{onChange:t.onBillingChange,options:{mode:`billing`}}),T(`p`,{children:n?`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:`${a}-delivery-same-as-billing`,children:[T(m,{checked:t.sameAsBilling,id:`${a}-delivery-same-as-billing`,onChange:e=>t.onSameAsBillingChange(e.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.`})]})]}),!t.sameAsBilling&&E(w,{children:[T(`h3`,{children:`Delivery Address`}),T(O,{onChange:t.onShippingChange,options:{mode:`shipping`}})]})]}),T(N,{isPurchase:n,pricing:i}),t.serviceFeeEnabled&&T(M,{...t})]}),t.message&&T(`p`,{"aria-live":`polite`,className:`lockerverse-auctions__notice`,role:`status`,children:t.message}),!t.isTerminal&&E(`div`,{className:`lockerverse-auctions__checkout-footer`,children:[E(`p`,{children:[n?`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 ${n?`order`:`bid`} so the seller can fulfill the item after payment.`:``]}),E(`button`,{className:`lockerverse-auctions__button lockerverse-auctions__checkout-submit`,disabled:t.submitDisabled,type:`submit`,children:[t.buttonText,T(v,{"aria-hidden":`true`,size:16})]})]})]})]})}function M(t){let{isPurchase:n,pricing:r}=t;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:[n?`Add`:`If I win, add`,` `,e(t.serviceFeeCents),` to help cover processing fees`]}),E(`span`,{children:[n?`Total`:`Total if I win`,`:`,` `,e(r.totalCents)]})]})]}):E(`p`,{children:[n?`Total`:`Total if I win`,`:`,` `,e(r.totalCents)]})})}function N({pricing:t,isPurchase:n}){return t.additionalCharge?E(`section`,{"aria-label":`Order amounts`,className:`lockerverse-auctions__checkout-section`,children:[E(`p`,{children:[n?`Subtotal`:`Bid amount`,`:`,` `,e(t.subtotalCents)]}),E(`p`,{children:[t.additionalCharge.name,`:`,` `,e(t.additionalChargeCents??0)]}),E(`p`,{children:[n?`Total`:`Total if I win`,`:`,` `,e(t.totalCents)]})]}):null}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 P(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,ie]=C(!0),[I,ae]=C(null),[oe,se]=C(null),[L,ce]=C(e.resumePurchase??null),[R,le]=C(e.resumePurchase?`pending`:`ready`),[ue,de]=C(null),z=S(e.resumePurchase?.submission.clientRequestId??null),B=R===`complete`||R===`uncertain`,V=S(!1),H=S(!0),U=S(e);U.current=e;let W=S(!1);function G(e){H.current&&le(e),c(U.current.onInteractionLockChange,e!==`ready`&&e!==`complete`)}function K(e){H.current&&de(e)}function q(e){G(e===`bid`?`uncertain`:`pending`),K(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.`),W.current||(W.current=!0,c(U.current.onUncertain,e))}b(()=>(H.current=!0,()=>{H.current=!1}),[]);let J=!!(L??e.resumePurchase)||d.saleMode===`buy_now`,Y=L?.pricing??e.resumePurchase?.pricing??t(l,d,p),fe=L?.payment??e.resumePurchase?.payment??l.payment;function X(e){H.current&&ce(e),c(U.current.onPurchaseRecoveryChange,e)}function Z(e){e.status===`paid`?(z.current=null,X(null),G(`complete`),c(U.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}),W.current||(W.current=!0,c(U.current.onPurchaseComplete,e))):e.status===`pending_payment`?(G(`pending`),K(`Your purchase is pending. Check its status before making another payment.`)):(z.current=null,X(null),G(`ready`),K(`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=U.current.selection;if(p.quantity!==e.quantity||p.amount!==e.amount||p.includeServiceFee!==e.includeServiceFee)throw Error(`Your selection changed. Review the total before continuing.`)}async function he(e){if(!(J&&d.additionalCharge))return!0;let t=await m.getPurchaseQuote(l.slug,d.id,{includeServiceFee:p.includeServiceFee,quantity:p.quantity});return H.current?t.subtotalCents!==Y.subtotalCents||(t.additionalChargeCents??0)!==(Y.additionalChargeCents??0)||t.serviceFeeCents!==Y.serviceFeeCents||t.totalCents!==Y.totalCents||!o(t.additionalCharge,Y.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(!H.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:I,collectShippingAddress:d.collectShippingAddress,elements:y,email:e.email,phone:e.phone,shipping:F?I:oe,stripe:v});return H.current?(me(),{confirmationToken:c,email:e.email,includeServiceFee:p.includeServiceFee,phone:e.phone,...s(Y)}):null}async function _e(e){let t=await m.createBid(l.slug,d.id,{...e,amount:p.amount});if(t.requiresAction){if(!(H.current&&v)){q(`bid`);return}await r(v,t)}G(`complete`),c(U.current.onResult,{additionalCharge:t.additionalCharge??null,additionalChargeCents:t.additionalChargeCents??0,amountCents:t.subtotalCents,kind:`bid`,serviceFeeCents:t.serviceFeeCents,totalCents:t.totalCents}),W.current||(W.current=!0,c(U.current.onBidSubmitted,t))}async function Q(e,t){if(e.requiresAction){if(!(H.current&&v)){q(`purchase`);return}await r(v,e);let n=await m.getPurchaseStatus(l.slug,d.id,t.submission.clientRequestId);n?Z(n):(G(`pending`),K(`Payment status is not available yet. Check again shortly.`));return}Z(e),!H.current&&e.status===`pending_payment`&&q(`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(!H.current){q(`purchase`);return}G(`retry`),K(`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}X(null),G(`ready`),K(`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(K(e instanceof Error?e.message:`Unable to complete this request.`),J&&n){if(!r&&e instanceof D&&!e.recoveryRecommended)try{await ye(e,n);return}catch{}q(`purchase`)}else i?q(`bid`):G(`ready`)}function xe(){return z.current??=globalThis.crypto.randomUUID(),z.current}function Se(){return H.current?!0:(L||(X(null),G(`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&&fe;function we(){if(V.current||B)return null;if(!$)return K(`Payment details are still loading.`),null;let e=L?null:pe();return L||e?{checkoutPayment:$,contact:e,retryOriginal:R===`retry`}:null}async function Te(e){e.preventDefault();let t=we();if(!t)return;let{contact:n,checkoutPayment:r,retryOriginal:i}=t;V.current=!0,W.current=!1,G(`busy`),K(null);let a=!1,o=L;try{if(!o){let e=await ge(n);if(!(e&&H.current)){G(`ready`);return}if(!J){a=!0,await _e(e);return}o=Object.freeze({auctionId:l.id,item:d,itemId:d.id,payment:Object.freeze({...r}),pricing:Y,submission:Object.freeze({...e,clientRequestId:xe(),paymentMethodTypes:Object.freeze([`card`]),quantity:p.quantity})}),X(o)}a=!0,await Ce(o,!!L&&!i)}catch(e){await be(e,a,o,L!==null&&!i)}finally{V.current=!1}}let Ee=re(R,L!==null,J),De=R!==`ready`;return T(ne,{buttonText:Ee,communityName:e.communityName??l.name,contactErrors:N,email:E,id:w,includeServiceFee:p.includeServiceFee,isPurchase:J,isTerminal:B,item:d,locked:De,message:ue,onBack:R===`ready`?_:void 0,onBillingChange:ae,onEmailChange:t=>{O(t),e.onContactChange?.({email:t,phone:u(k,j)})},onIncludeServiceFeeChange:e.onIncludeServiceFeeChange,onPaymentLoadError:()=>K(`Unable to load payment form.`),onPhoneChange:({value:t,country:n})=>{A(t),M(n),e.onContactChange?.({email:E,phone:u(t,n)})},onSameAsBillingChange:ie,onShippingChange:se,onSubmit:Te,phone:k,phoneCountry:j,pricing:Y,quantity:p.quantity,sameAsBilling:F,serviceFeeCents:L?Y.serviceFeeCents:t(l,d,{...p,includeServiceFee:l.serviceFeeEnabled}).serviceFeeCents,serviceFeeEnabled:l.serviceFeeEnabled,showFields:!(L||B),submitDisabled:R===`busy`||!v||!y})}function F(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(P,{...e})})}export{F 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 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, item, pricing, 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 <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\n once checkout succeeds.\n </>\n ) : (\n <>\n Authorize a payment method for your bid of{\" \"}\n <strong>{formatMoney(pricing.subtotalCents)}</strong> on{\" \"}\n <strong>{item.name}</strong>. Your card is only charged if this\n bid wins the item.\n </>\n )}\n </p>\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 isPurchase={isPurchase}\n pricing={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, pricing } = props;\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 {isPurchase ? \"Add\" : \"If I win, add\"}{\" \"}\n {formatMoney(props.serviceFeeCents)} to help cover processing fees\n </strong>\n <span>\n {isPurchase ? \"Total\" : \"Total if I win\"}:{\" \"}\n {formatMoney(pricing.totalCents)}\n </span>\n </span>\n </label>\n ) : (\n <p>\n {isPurchase ? \"Total\" : \"Total if I win\"}:{\" \"}\n {formatMoney(pricing.totalCents)}\n </p>\n )}\n </section>\n );\n}\n\nfunction CheckoutAdditionalCharge({\n pricing,\n isPurchase,\n}: {\n pricing: LockerverseAuctionPricing;\n isPurchase: boolean;\n}) {\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 {isPurchase ? \"Subtotal\" : \"Bid amount\"}:{\" \"}\n {formatMoney(pricing.subtotalCents)}\n </p>\n <p>\n {pricing.additionalCharge.name}:{\" \"}\n {formatMoney(pricing.additionalChargeCents ?? 0)}\n </p>\n <p>\n {isPurchase ? \"Total\" : \"Total if I win\"}:{\" \"}\n {formatMoney(pricing.totalCents)}\n </p>\n </section>\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.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 result = await client.createBid(auction.slug, item.id, {\n ...submission,\n amount: selection.amount,\n });\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 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 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 setupFutureUsage: \"off_session\",\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 syncAddressCheckbox: \"none\",\n };\n return (\n <Elements options={options} stripe={stripe}>\n <AuctionCheckout {...props} />\n </Elements>\n );\n}\n"],"mappings":"oqBAgDA,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,OAAM,UAAS,MAAO,EAC1C,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,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AAC,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,QACN,iBAAkB,aACpB,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,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 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, item, pricing, 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 <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\n once checkout succeeds.\n </>\n ) : (\n <>\n Authorize a payment method for your bid of{\" \"}\n <strong>{formatMoney(pricing.subtotalCents)}</strong> on{\" \"}\n <strong>{item.name}</strong>. Your card is only charged if this\n bid wins the item.\n </>\n )}\n </p>\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 isPurchase={isPurchase}\n pricing={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, pricing } = props;\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 {isPurchase ? \"Add\" : \"If I win, add\"}{\" \"}\n {formatMoney(props.serviceFeeCents)} to help cover processing fees\n </strong>\n <span>\n {isPurchase ? \"Total\" : \"Total if I win\"}:{\" \"}\n {formatMoney(pricing.totalCents)}\n </span>\n </span>\n </label>\n ) : (\n <p>\n {isPurchase ? \"Total\" : \"Total if I win\"}:{\" \"}\n {formatMoney(pricing.totalCents)}\n </p>\n )}\n </section>\n );\n}\n\nfunction CheckoutAdditionalCharge({\n pricing,\n isPurchase,\n}: {\n pricing: LockerverseAuctionPricing;\n isPurchase: boolean;\n}) {\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 {isPurchase ? \"Subtotal\" : \"Bid amount\"}:{\" \"}\n {formatMoney(pricing.subtotalCents)}\n </p>\n <p>\n {pricing.additionalCharge.name}:{\" \"}\n {formatMoney(pricing.additionalChargeCents ?? 0)}\n </p>\n <p>\n {isPurchase ? \"Total\" : \"Total if I win\"}:{\" \"}\n {formatMoney(pricing.totalCents)}\n </p>\n </section>\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.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 result = await client.createBid(auction.slug, item.id, {\n ...submission,\n amount: selection.amount,\n });\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 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 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":"oqBAgDA,SAAS,EAAkB,EAAkD,CAC3E,MAAO,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,CAAmB,UAAiB,SAClC,SAAA,EAAC,EAAD,CAAiB,GAAI,CAAQ,CAAA,CACrB,CAAA,CAEd"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{t as e}from"./lockerverse-donate-launcher.js";import{n as t,t as n}from"./lockerverse-payment.js";import{t as r}from"./use-lockerverse-widget.js";export{e as LockerverseDonateLauncher,n as LockerversePayment,t as preloadLockerversePayment,r as useLockerverseWidget};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as LockerverseDonateLauncherProps } from "./types.js";
|
|
2
2
|
//#region src/lockerverse-donate-launcher.d.ts
|
|
3
|
-
declare function LockerverseDonateLauncher({ buttonLabel, position, widget, ...paymentProps }: LockerverseDonateLauncherProps): import("react").JSX.Element;
|
|
3
|
+
declare function LockerverseDonateLauncher({ buttonLabel, position, presentation, initialSelection, productIds, showDescription, widget, ...paymentProps }: LockerverseDonateLauncherProps): import("react").JSX.Element;
|
|
4
4
|
//#endregion
|
|
5
5
|
export { LockerverseDonateLauncher as t };
|
|
6
6
|
//# sourceMappingURL=lockerverse-donate-launcher.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lockerverse-donate-launcher.d.ts","names":[],"sources":["../src/lockerverse-donate-launcher.tsx"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"lockerverse-donate-launcher.d.ts","names":[],"sources":["../src/lockerverse-donate-launcher.tsx"],"mappings":";;iBA6oBgB,4BACd,aACA,UACA,cACA,kBACA,YACA,iBACA,WACG,gBACF,iDAA8B,IAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n as e,t}from"./accent-contrast.js";import{n,t as r}from"./lockerverse-payment.js";import{createElement as i,useState as a}from"react";import{Fragment as o,jsx as s,jsxs as c}from"react/jsx-runtime";import{Dialog as l}from"@base-ui/react/dialog";import{getLockerverseMinimumCustomAmountCents as u}from"@lockerverse/sdk/checkout";const d=new Intl.NumberFormat(`en-US`,{currency:`USD`,style:`currency`}),f=/^(?:0|[1-9]\d*)(?:\.\d{1,2})?$/,p=[1e3,2500,5e3,1e4];function m(e){if(!f.test(e))return null;let t=Math.round(Number(e)*100);return Number.isSafeInteger(t)&&t>0?t:null}function h(e,t){let n=``;return t===`monthly`&&(n=`/month`),t===`annually`&&(n=`/year`),t===`every-six-months`&&(n=` every 6 months`),`${d.format(e/100)}${n}`}function g({customAmounts:e,product:t,quantities:n,recurringProductId:r,setCustomAmounts:i,setQuantities:a,setRecurringProductId:o}){let l=n[t.id]??0;if(t.pricingMode===`fixed`&&t.paymentOption===`one-time`){let e=t.minimumQuantity??1,n=Math.min(t.maximumQuantity??1/0,t.inventoryQuantity??1/0);return c(`span`,{className:`lockerverse-launcher__quantity`,children:[s(`button`,{"aria-label":`Decrease ${t.name} quantity`,disabled:l===0,onClick:()=>{o(null),a(n=>{let r=n[t.id]??0;return{...n,[t.id]:r<=e?0:r-1}})},type:`button`,children:`−`}),s(`output`,{"aria-label":`${t.name} quantity`,children:l}),s(`button`,{"aria-label":`Increase ${t.name} quantity`,disabled:n<e||l>=n,onClick:()=>{o(null),a(n=>{let r=n[t.id]??0;return{...n,[t.id]:r===0?e:r+1}})},type:`button`,children:`+`})]})}return t.pricingMode===`custom`&&t.paymentOption===`one-time`?c(`span`,{className:`lockerverse-launcher__custom-amount`,children:[s(`span`,{"aria-hidden":`true`,children:`$`}),s(`input`,{"aria-label":`${t.name} amount`,min:u(t)/100,name:`amount-${t.slug}`,onChange:e=>{o(null),i(n=>({...n,[t.id]:e.target.value}))},placeholder:`0.00`,step:`0.01`,type:`number`,value:e[t.id]??``}),t.minimumAmountCents===null?null:c(`small`,{children:[`Minimum `,d.format(t.minimumAmountCents/100)]})]}):s(`button`,{"aria-label":`Select ${t.name}`,"aria-pressed":r===t.id,className:`lockerverse-launcher__select`,onClick:()=>{a({}),i({}),o(e=>e===t.id?null:t.id)},type:`button`,children:`Select`})}function _({variant:e=`default`,...t}){let{customAmounts:n,product:r,quantities:i,recurringProductId:a}=t,o=m(n[r.id]??``),l=a===r.id||r.paymentOption===`one-time`&&(r.pricingMode===`fixed`&&(i[r.id]??0)>0||r.pricingMode===`custom`&&o!==null&&o>=u(r));return c(`article`,{className:`lockerverse-launcher__product lockerverse-launcher__product--${e}`,"data-selected":l||void 0,children:[c(`span`,{className:`lockerverse-launcher__product-copy`,children:[s(`strong`,{className:`lockerverse-launcher__product-name`,children:r.name}),r.description?s(`small`,{children:r.description}):null,r.amountCents===null?null:s(`span`,{className:`lockerverse-launcher__product-price`,children:h(r.amountCents,r.paymentOption)})]}),s(g,{...t})]})}function v({customAmounts:e,product:t,setCustomAmounts:n,setRecurringProductId:r}){let i=e[t.id]??``,a=m(i),o=p.filter(e=>e>=u(t)),l=o.includes(a??0),f=e=>{r(null),n(n=>({...n,[t.id]:e}))};return s(`div`,{className:`lockerverse-launcher__donation-option`,children:c(`fieldset`,{className:`lockerverse-launcher__donation-choices`,children:[c(`legend`,{className:`lockerverse-launcher__sr-only`,children:[t.name,` amount`]}),s(`button`,{"aria-pressed":i===``,onClick:()=>f(``),type:`button`,children:`No thanks`}),o.map(e=>s(`button`,{"aria-pressed":a===e,onClick:()=>f(String(e/100)),type:`button`,children:d.format(e/100).replace(`.00`,``)},e)),s(`label`,{className:`lockerverse-launcher__donation-other`,"data-selected":i!==``&&!l||void 0,children:s(`input`,{"aria-label":`${t.name} amount`,min:u(t)/100,name:`amount-${t.slug}`,onChange:e=>f(e.target.value),placeholder:`Other $`,step:`0.01`,type:`number`,value:l?``:i})})]})})}function y({products:e,variant:t=`default`,...n}){return s(`div`,{className:`lockerverse-launcher__product-list`,children:e.map(e=>t===`donation`?i(v,{...n,key:e.id,product:e}):i(_,{...n,key:e.id,product:e,variant:t}))})}function b(e,t){let n=0,r=0;for(let i of t){let t=e.products.find(e=>e.slug===i.productSlug);if(t){if(`quantity`in i){n+=i.quantity,r+=(t.amountCents??0)*i.quantity;continue}n+=1,r+=`amountCents`in i?i.amountCents:t.amountCents??0}}let i=e.widget.requiredShipping,a=i?t.reduce((t,n)=>{let r=e.products.find(e=>e.slug===n.productSlug);return r&&i.triggerProductIds.includes(r.id)?t+(`quantity`in n?n.quantity:1):t},0):0,o=a>0;return i&&o&&(r+=(e.products.find(e=>e.id===i.productId)?.amountCents??0)+Math.max(0,a-1)*(i.additionalUnitAmountCents??0)),{amountCents:r,itemCount:n,needsShipping:o}}function x(){return s(`div`,{"aria-label":`Loading donation options`,className:`lockerverse-launcher__loading`,role:`status`,children:[0,1,2].map(e=>s(`span`,{"aria-hidden":`true`,className:`lockerverse-launcher__loading-row`},e))})}function S(e,t,n,r){if(r){let t=e.products.find(e=>e.id===r&&e.paymentOption!==`one-time`);return t?[{productSlug:t.slug}]:[]}return e.products.flatMap(e=>{let r=t[e.id]??0;if(e.pricingMode===`fixed`&&e.paymentOption===`one-time`&&r>0)return[{productSlug:e.slug,quantity:r}];let i=m(n[e.id]??``);return e.pricingMode===`custom`&&e.paymentOption===`one-time`&&i!==null&&i>=u(e)?[{amountCents:i,productSlug:e.slug}]:[]})}function C({catalog:e,onContinue:t,...n}){let r=S(e,n.quantities,n.customAmounts,n.recurringProductId),i=b(e,r),a=e.products.filter(e=>e.paymentOption===`one-time`&&e.pricingMode===`custom`),o=e.products.filter(t=>!a.includes(t)&&t.id!==e.widget.requiredShipping?.productId);return c(`form`,{className:`lockerverse-launcher__products`,onSubmit:e=>{e.preventDefault(),r.length>0&&t(r)},children:[o.length>0?s(`section`,{className:`lockerverse-launcher__section`,children:s(y,{...n,products:o})}):null,a.length>0?c(`section`,{className:`lockerverse-launcher__donation`,children:[c(`header`,{className:`lockerverse-launcher__section-header`,children:[s(`h3`,{children:`Add a donation`}),s(`p`,{children:`Choose an amount to add to this order.`})]}),s(y,{...n,products:a,variant:`donation`})]}):null,e.products.length>0?c(`footer`,{className:`lockerverse-launcher__footer`,children:[c(`p`,{"aria-live":`polite`,className:`lockerverse-launcher__summary`,children:[s(`span`,{children:i.itemCount===0?`No items selected`:`${i.itemCount} ${i.itemCount===1?`item`:`items`} selected`}),i.itemCount===0?null:s(`strong`,{children:d.format(i.amountCents/100)})]}),i.needsShipping?s(`p`,{children:`Shipping is included once per order.`}):null,s(`button`,{className:`lockerverse-launcher__continue`,disabled:r.length===0,type:`submit`,children:`Continue`})]}):null]})}function w({onEdit:e,paymentProps:t,selection:n,style:i,widget:a}){return c(`div`,{className:`lockerverse-launcher__checkout`,children:[s(`header`,{className:`lockerverse-launcher__checkout-toolbar`,children:s(`button`,{className:`lockerverse-launcher__back`,onClick:e,type:`button`,children:`Edit order`})}),s(r,{...t,selection:n,style:i,widget:a})]})}function T({catalog:e,checkout:t}){return t?c(o,{children:[s(l.Title,{className:`lockerverse-launcher__sr-only`,children:`Checkout`}),s(l.Description,{className:`lockerverse-launcher__sr-only`,children:`Review the order and complete payment.`})]}):e?c(`header`,{className:`lockerverse-launcher__header`,children:[e.community?c(`div`,{className:`lockerverse-launcher__brand`,children:[e.community.imageUrl?s(`img`,{alt:`${e.community.name} logo`,height:`28`,src:e.community.imageUrl,width:`28`}):null,s(`span`,{children:e.community.name})]}):null,s(l.Title,{className:`lockerverse-launcher__title`,children:e.widget.title??e.widget.name}),s(l.Description,{className:`lockerverse-launcher__description`,children:e.widget.description??`Choose your options, then continue to checkout.`})]}):c(`header`,{className:`lockerverse-launcher__header`,children:[s(l.Title,{className:`lockerverse-launcher__title`,children:`Donate`}),s(l.Description,{className:`lockerverse-launcher__description`,children:`Choose your options, then continue to checkout.`})]})}function E({buttonLabel:r=`Donate`,position:i=`inline`,widget:o,...u}){let[d,f]=a(null),[p,m]=a({}),[h,g]=a({}),[_,v]=a(null),{catalog:y,error:b,loading:S}=o,E=e(u.style?.[`--lockerverse-accent`]??y?.community?.accentColor??`#38d77a`),D=t(E),O={...u.style};(u.style?.[`--lockerverse-accent`]!==void 0||y?.community?.accentColor)&&(O[`--lockerverse-accent`]=E),D&&u.style?.[`--lockerverse-accent-contrast`]===void 0&&(O[`--lockerverse-accent-contrast`]=D);let k;return k=S?s(x,{}):b?c(`div`,{role:`alert`,children:[s(`p`,{children:`Unable to load donation options.`}),s(`button`,{onClick:o.refresh,type:`button`,children:`Retry`})]}):y?s(C,{catalog:y,customAmounts:p,onContinue:f,quantities:h,recurringProductId:_,setCustomAmounts:m,setQuantities:g,setRecurringProductId:v}):s(x,{}),!(S||b)&&d&&y&&(k=s(w,{onEdit:()=>f(null),paymentProps:u,selection:d,style:O,widget:o})),c(l.Root,{onOpenChange:e=>{e&&y&&u.stripeLoader===void 0&&requestAnimationFrame(()=>{n(y)})},children:[s(l.Trigger,{className:`lockerverse-launcher lockerverse-launcher--${i}`,"data-lockerverse-theme":u.theme??`dark`,style:O,children:r}),c(l.Portal,{children:[s(l.Backdrop,{className:`lockerverse-launcher__backdrop`}),s(l.Viewport,{className:`lockerverse-launcher__viewport`,children:c(l.Popup,{className:`lockerverse-launcher__dialog`,"data-lockerverse-theme":u.theme??`dark`,style:O,children:[s(T,{catalog:y,checkout:d!==null}),s(l.Close,{"aria-label":`Close donation dialog`,className:`lockerverse-launcher__close`,children:s(`span`,{"aria-hidden":`true`,children:`×`})}),k]})})]})]})}export{E as t};
|
|
1
|
+
import{n as e,t}from"./accent-contrast.js";import{n,t as r}from"./lockerverse-payment.js";import{createElement as i,useEffect as a,useMemo as o,useState as s}from"react";import{Fragment as c,jsx as l,jsxs as u}from"react/jsx-runtime";import{Dialog as d}from"@base-ui/react/dialog";import{getLockerverseMinimumCustomAmountCents as f}from"@lockerverse/sdk/checkout";function p(e,t){let n={},r={},i=null;for(let a of t){let t=e.products.find(e=>e.slug===a.productSlug);if(!(!t||t.id===e.widget.requiredShipping?.productId)){if(t.paymentOption!==`one-time`){if(!(`quantity`in a||`amountCents`in a)){i=t.id;break}continue}t.pricingMode===`fixed`&&`quantity`in a&&Number.isSafeInteger(a.quantity)&&a.quantity>0&&(n[t.id]=m(t,a.quantity)),t.pricingMode===`custom`&&`amountCents`in a&&Number.isSafeInteger(a.amountCents)&&a.amountCents>=f(t)&&(r[t.id]=(a.amountCents/100).toFixed(2))}}return i?{customAmounts:{},quantities:{},recurringProductId:i}:{customAmounts:r,quantities:n,recurringProductId:i}}function m(e,t){let n=e.minimumQuantity??1,r=Math.min(e.maximumQuantity??1/0,e.inventoryQuantity??1/0);return r<n?0:Math.min(r,Math.max(n,t))}function h(e,t){return!e||t===void 0?e:{...e,products:e.products.filter(n=>t.includes(n.id)||n.id===e.widget.requiredShipping?.productId)}}function g(e,t){return t||!e?e:{...e,widget:{...e.widget,description:null}}}const _=new Intl.NumberFormat(`en-US`,{currency:`USD`,style:`currency`}),v=/^(?:0|[1-9]\d*)(?:\.\d{1,2})?$/,y=[1e3,2500,5e3,1e4];function b(e){if(!v.test(e))return null;let t=Math.round(Number(e)*100);return Number.isSafeInteger(t)&&t>0?t:null}function x(e,t){let n=``;return t===`monthly`&&(n=`/month`),t===`annually`&&(n=`/year`),t===`every-six-months`&&(n=` every 6 months`),`${_.format(e/100)}${n}`}function S({product:e,quantities:t,setQuantities:n,setRecurringProductId:r}){let i=(t[e.id]??0)>0;return l(`span`,{className:`lockerverse-launcher__optional-control`,children:l(`input`,{"aria-label":e.name,checked:i,className:`lockerverse-launcher__optional-switch`,disabled:!i&&e.inventoryQuantity===0,onChange:()=>{r(null),n(t=>({...t,[e.id]:(t[e.id]??0)>0?0:1}))},type:`checkbox`})})}function C({customAmounts:e,product:t,quantities:n,recurringProductId:r,setCustomAmounts:i,setQuantities:a,setRecurringProductId:o}){let s=n[t.id]??0;if(t.pricingMode===`fixed`&&t.paymentOption===`one-time`){let e=t.minimumQuantity??1,n=Math.min(t.maximumQuantity??1/0,t.inventoryQuantity??1/0);return u(`span`,{className:`lockerverse-launcher__quantity`,children:[l(`button`,{"aria-label":`Decrease ${t.name} quantity`,disabled:s===0,onClick:()=>{o(null),a(n=>{let r=n[t.id]??0;return{...n,[t.id]:r<=e?0:r-1}})},type:`button`,children:`−`}),l(`output`,{"aria-label":`${t.name} quantity`,children:s}),l(`button`,{"aria-label":`Increase ${t.name} quantity`,disabled:n<e||s>=n,onClick:()=>{o(null),a(n=>{let r=n[t.id]??0;return{...n,[t.id]:r===0?e:r+1}})},type:`button`,children:`+`})]})}return t.pricingMode===`custom`&&t.paymentOption===`one-time`?u(`span`,{className:`lockerverse-launcher__custom-amount`,children:[l(`span`,{"aria-hidden":`true`,children:`$`}),l(`input`,{"aria-label":`${t.name} amount`,min:f(t)/100,name:`amount-${t.slug}`,onChange:e=>{o(null),i(n=>({...n,[t.id]:e.target.value}))},placeholder:`0.00`,step:`0.01`,type:`number`,value:e[t.id]??``}),t.minimumAmountCents===null?null:u(`small`,{children:[`Minimum `,_.format(t.minimumAmountCents/100)]})]}):l(`button`,{"aria-label":`Select ${t.name}`,"aria-pressed":r===t.id,className:`lockerverse-launcher__select`,onClick:()=>{a({}),i({}),o(e=>e===t.id?null:t.id)},type:`button`,children:`Select`})}function w({variant:e=`default`,...t}){let{customAmounts:n,product:r,quantities:i,recurringProductId:a}=t,o=b(n[r.id]??``),s=a===r.id||r.paymentOption===`one-time`&&(r.pricingMode===`fixed`&&(i[r.id]??0)>0||r.pricingMode===`custom`&&o!==null&&o>=f(r));return u(`article`,{className:`lockerverse-launcher__product lockerverse-launcher__product--${e}`,"data-selected":s||void 0,children:[u(`span`,{className:`lockerverse-launcher__product-copy`,children:[l(`strong`,{className:`lockerverse-launcher__product-name`,children:r.name}),r.description?l(`small`,{children:r.description}):null,r.amountCents===null?null:l(`span`,{className:`lockerverse-launcher__product-price`,children:x(r.amountCents,r.paymentOption)})]}),r.pricingMode===`fixed`&&r.paymentOption===`one-time`&&r.maximumQuantity===1&&(r.minimumQuantity??1)<=1?l(S,{...t}):l(C,{...t})]})}function T({customAmounts:e,product:t,setCustomAmounts:n,setRecurringProductId:r}){let i=e[t.id]??``,a=b(i),o=y.filter(e=>e>=f(t)),s=o.includes(a??0),c=e=>{r(null),n(n=>({...n,[t.id]:e}))};return l(`div`,{className:`lockerverse-launcher__donation-option`,children:u(`fieldset`,{className:`lockerverse-launcher__donation-choices`,children:[u(`legend`,{className:`lockerverse-launcher__sr-only`,children:[t.name,` amount`]}),l(`button`,{"aria-pressed":i===``,onClick:()=>c(``),type:`button`,children:`No thanks`}),o.map(e=>l(`button`,{"aria-pressed":a===e,onClick:()=>c(String(e/100)),type:`button`,children:_.format(e/100).replace(`.00`,``)},e)),l(`label`,{className:`lockerverse-launcher__donation-other`,"data-selected":i!==``&&!s||void 0,children:l(`input`,{"aria-label":`${t.name} amount`,min:f(t)/100,name:`amount-${t.slug}`,onChange:e=>c(e.target.value),placeholder:`Other $`,step:`0.01`,type:`number`,value:s?``:i})})]})})}function E({products:e,variant:t=`default`,...n}){return l(`div`,{className:`lockerverse-launcher__product-list`,children:e.map(e=>t===`donation`?i(T,{...n,key:e.id,product:e}):i(w,{...n,key:e.id,product:e,variant:t}))})}function D(e,t){let n=0,r=0;for(let i of t){let t=e.products.find(e=>e.slug===i.productSlug);if(t){if(`quantity`in i){n+=i.quantity,r+=(t.amountCents??0)*i.quantity;continue}n+=1,r+=`amountCents`in i?i.amountCents:t.amountCents??0}}let i=e.widget.requiredShipping,a=i?t.reduce((t,n)=>{let r=e.products.find(e=>e.slug===n.productSlug);return r&&i.triggerProductIds.includes(r.id)?t+(`quantity`in n?n.quantity:1):t},0):0,o=a>0;return i&&o&&(r+=(e.products.find(e=>e.id===i.productId)?.amountCents??0)+Math.max(0,a-1)*(i.additionalUnitAmountCents??0)),{amountCents:r,itemCount:n,needsShipping:o}}function O(){return l(`div`,{"aria-label":`Loading donation options`,className:`lockerverse-launcher__loading`,role:`status`,children:[0,1,2].map(e=>l(`span`,{"aria-hidden":`true`,className:`lockerverse-launcher__loading-row`},e))})}function k(e,t,n,r){if(r){let t=e.products.find(e=>e.id===r&&e.paymentOption!==`one-time`);return t?[{productSlug:t.slug}]:[]}return e.products.flatMap(e=>{let r=t[e.id]??0;if(e.pricingMode===`fixed`&&e.paymentOption===`one-time`&&r>0)return[{productSlug:e.slug,quantity:r}];let i=b(n[e.id]??``);return e.pricingMode===`custom`&&e.paymentOption===`one-time`&&i!==null&&i>=f(e)?[{amountCents:i,productSlug:e.slug}]:[]})}function A({catalog:e,onContinue:t,...n}){let r=k(e,n.quantities,n.customAmounts,n.recurringProductId),i=D(e,r),a=e.products.filter(e=>e.paymentOption===`one-time`&&e.pricingMode===`custom`),o=e.products.filter(t=>!a.includes(t)&&t.id!==e.widget.requiredShipping?.productId);return u(`form`,{className:`lockerverse-launcher__products`,onSubmit:e=>{e.preventDefault(),r.length>0&&t(r)},children:[o.length>0?l(`section`,{className:`lockerverse-launcher__section`,children:l(E,{...n,products:o})}):null,a.length>0?u(`section`,{className:`lockerverse-launcher__donation`,children:[u(`header`,{className:`lockerverse-launcher__section-header`,children:[l(`h3`,{children:`Add a donation`}),l(`p`,{children:`Choose an amount to add to this order.`})]}),l(E,{...n,products:a,variant:`donation`})]}):null,o.length+a.length>0?u(`footer`,{className:`lockerverse-launcher__footer`,children:[u(`p`,{"aria-live":`polite`,className:`lockerverse-launcher__summary`,children:[l(`span`,{children:i.itemCount===0?`No items selected`:`${i.itemCount} ${i.itemCount===1?`item`:`items`} selected`}),i.itemCount===0?null:l(`strong`,{children:_.format(i.amountCents/100)})]}),i.needsShipping?l(`p`,{children:`Shipping is included once per order.`}):null,l(`button`,{className:`lockerverse-launcher__continue`,disabled:r.length===0,type:`submit`,children:`Continue`})]}):l(`p`,{children:`No products are available for this link.`})]})}function j({presentation:e,onEdit:t,paymentProps:n,selection:i,style:a,widget:o}){return u(`div`,{className:`lockerverse-launcher__checkout`,children:[l(`header`,{className:`lockerverse-launcher__checkout-toolbar`,children:l(`button`,{className:`lockerverse-launcher__back`,onClick:t,type:`button`,children:`Edit order`})}),l(r,{...n,className:e===`page`?void 0:n.className,selection:i,style:a,widget:o})]})}function M({catalog:e,checkout:t,presentation:n=`dialog`,showDescription:r=!0}){let i=n===`page`?`h1`:d.Title,a=n===`page`?`p`:d.Description;return t&&n===`page`?null:t?u(c,{children:[l(i,{className:`lockerverse-launcher__sr-only`,children:`Checkout`}),l(a,{className:`lockerverse-launcher__sr-only`,children:`Review the order and complete payment.`})]}):e?u(`header`,{className:`lockerverse-launcher__header`,children:[e.community?u(`div`,{className:`lockerverse-launcher__brand`,children:[e.community.imageUrl?l(`img`,{alt:`${e.community.name} logo`,height:`28`,src:e.community.imageUrl,width:`28`}):null,l(`span`,{children:e.community.name})]}):null,l(i,{className:`lockerverse-launcher__title`,children:e.widget.title??e.widget.name}),l(a,{className:`lockerverse-launcher__description`,hidden:!r,children:e.widget.description??`Choose your options, then continue to checkout.`})]}):u(`header`,{className:`lockerverse-launcher__header`,children:[l(i,{className:`lockerverse-launcher__title`,children:`Donate`}),l(a,{className:`lockerverse-launcher__description`,hidden:!r,children:`Choose your options, then continue to checkout.`})]})}function N({buttonLabel:r=`Donate`,position:i=`inline`,presentation:c=`dialog`,initialSelection:f=[],productIds:m,showDescription:_=!0,widget:v,...y}){let[b,x]=s(null),[S,C]=s({}),[w,T]=s({}),[E,D]=s(null),[k]=s(()=>({initialSelection:f.map(e=>({...e})),productIds:m?[...m]:void 0})),[N,P]=s(!1),{error:F,loading:I}=v,L=o(()=>g(v.catalog,_),[v.catalog,_]),R=h(v.catalog,k.productIds);a(()=>{if(N||!v.catalog)return;let e=h(v.catalog,k.productIds);if(!e)return;let t=p(e,k.initialSelection);T(t.quantities),C(t.customAmounts),D(t.recurringProductId),P(!0)},[N,v.catalog,k]);let z=e(y.style?.[`--lockerverse-accent`]??R?.community?.accentColor??`#38d77a`),B=t(z),V={...y.style};(y.style?.[`--lockerverse-accent`]!==void 0||R?.community?.accentColor)&&(V[`--lockerverse-accent`]=z),B&&y.style?.[`--lockerverse-accent-contrast`]===void 0&&(V[`--lockerverse-accent-contrast`]=B);let H;return H=I||!(N||F)?l(O,{}):F?u(`div`,{role:`alert`,children:[l(`p`,{children:`Unable to load donation options.`}),l(`button`,{onClick:v.refresh,type:`button`,children:`Retry`})]}):R?l(A,{catalog:R,customAmounts:S,onContinue:x,quantities:w,recurringProductId:E,setCustomAmounts:C,setQuantities:T,setRecurringProductId:D}):l(O,{}),!(I||F)&&b&&R&&(H=l(j,{onEdit:()=>x(null),paymentProps:y,presentation:c,selection:b,style:V,widget:{...v,catalog:L}})),c===`page`?u(`section`,{className:`lockerverse-launcher__dialog lockerverse-launcher__page ${y.className??``}`,"data-lockerverse-theme":y.theme??`dark`,style:V,children:[l(M,{catalog:R,checkout:b!==null,presentation:`page`,showDescription:_}),H]}):u(d.Root,{onOpenChange:e=>{e&&R&&y.stripeLoader===void 0&&requestAnimationFrame(()=>{n(R)})},children:[l(d.Trigger,{className:`lockerverse-launcher lockerverse-launcher--${i}`,"data-lockerverse-theme":y.theme??`dark`,style:V,children:r}),u(d.Portal,{children:[l(d.Backdrop,{className:`lockerverse-launcher__backdrop`}),l(d.Viewport,{className:`lockerverse-launcher__viewport`,children:u(d.Popup,{className:`lockerverse-launcher__dialog`,"data-lockerverse-theme":y.theme??`dark`,style:V,children:[l(M,{catalog:R,checkout:b!==null,showDescription:_}),l(d.Close,{"aria-label":`Close donation dialog`,className:`lockerverse-launcher__close`,children:l(`span`,{"aria-hidden":`true`,children:`×`})}),H]})})]})]})}export{N as t};
|
|
2
2
|
//# sourceMappingURL=lockerverse-donate-launcher.js.map
|