@commercelayer/react-components 4.25.7-beta.4 → 4.25.8-beta.0
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/lib/cjs/components/orders/PlaceOrderButton.js +1 -1
- package/lib/cjs/components/payment_source/CheckoutComPayment.js +1 -1
- package/lib/cjs/components/payment_source/StripePayment.js +1 -1
- package/lib/esm/components/orders/PlaceOrderButton.js +1 -1
- package/lib/esm/components/payment_source/CheckoutComPayment.js +1 -1
- package/lib/esm/components/payment_source/StripePayment.js +1 -1
- package/lib/tsconfig.prod.esm.tsbuildinfo +1 -1
- package/lib/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +17 -17
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PlaceOrderButton=PlaceOrderButton;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),isFunction_1=tslib_1.__importDefault(require("lodash/isFunction")),react_1=require("react"),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),PaymentMethodContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodContext")),PlaceOrderContext_1=tslib_1.__importDefault(require("../../context/PlaceOrderContext")),useCommerceLayer_1=tslib_1.__importDefault(require("../../hooks/useCommerceLayer")),getCardDetails_1=tslib_1.__importDefault(require("../../utils/getCardDetails")),retrievePaymentIntent_1=require("../../utils/stripe/retrievePaymentIntent"),Parent_1=tslib_1.__importDefault(require("../utils/Parent"));function PlaceOrderButton(props){var _a,_b,_c,_d,_e,_f,_g;const ref=(0,react_1.useRef)(null),{children,label="Place order",loadingLabel="Placing...",autoPlaceOrder=!0,disabled,onClick}=props,p=tslib_1.__rest(props,["children","label","loadingLabel","autoPlaceOrder","disabled","onClick"]),{isPermitted,setPlaceOrder,options,paymentType,setButtonRef,setPlaceOrderStatus,status}=(0,react_1.useContext)(PlaceOrderContext_1.default),[notPermitted,setNotPermitted]=(0,react_1.useState)(!0),[forceDisable,setForceDisable]=(0,react_1.useState)(disabled),[isLoading,setIsLoading]=(0,react_1.useState)(!1),{sdkClient}=(0,useCommerceLayer_1.default)(),{currentPaymentMethodRef,loading,currentPaymentMethodType,paymentSource,setPaymentSource,setPaymentMethodErrors,currentCustomerPaymentSourceId}=(0,react_1.useContext)(PaymentMethodContext_1.default),{order,setOrderErrors,errors}=(0,react_1.useContext)(OrderContext_1.default),isFree=order?.total_amount_with_taxes_cents===0;(0,react_1.useEffect)(()=>{var _a2;if(loading)setNotPermitted(loading);else if(paymentType===currentPaymentMethodType&&paymentType){const card=(0,getCardDetails_1.default)({customerPayment:{payment_source:paymentSource},paymentType});currentCustomerPaymentSourceId!=null&&paymentSource?.id===currentCustomerPaymentSourceId&&card.brand===""&&(card.brand="credit-card"),(isFree&&isPermitted||!((_a2=currentPaymentMethodRef?.current)===null||_a2===void 0)&&_a2.onsubmit||card.brand)&&isPermitted&&setNotPermitted(!1)}else setNotPermitted(!(isFree&&isPermitted));return()=>{setNotPermitted(!0)}},[isPermitted,paymentType!=null,((_a=currentPaymentMethodRef?.current)===null||_a===void 0?void 0:_a.onsubmit)!=null,loading,currentPaymentMethodType,order?.id,paymentSource?.id]),(0,react_1.useEffect)(()=>{errors&&errors.length>0&&(setNotPermitted(!0),setIsLoading(!1),setForceDisable(!1))},[errors]),(0,react_1.useEffect)(()=>{paymentType==="paypal_payments"&&options?.paypalPayerId&&order?.status&&["draft","pending"].includes(order?.status)&&autoPlaceOrder&&handleClick()},[options?.paypalPayerId,paymentType!=null]),(0,react_1.useEffect)(()=>{var _a2,_b2,_c2,_d2;if(paymentType==="stripe_payments"&&(!((_a2=options?.stripe)===null||_a2===void 0)&&_a2.paymentIntentClientSecret)&&(!((_b2=order?.payment_source)===null||_b2===void 0)&&_b2.publishable_key)&&order?.status&&["draft","pending"].includes(order?.status)&&autoPlaceOrder){const publicApiKey=(_c2=order?.payment_source)===null||_c2===void 0?void 0:_c2.publishable_key,paymentIntentClientSecret=(_d2=options?.stripe)===null||_d2===void 0?void 0:_d2.paymentIntentClientSecret,getPaymentIntent=()=>tslib_1.__awaiter(this,void 0,void 0,function*(){const paymentIntentResult=yield(0,retrievePaymentIntent_1.checkPaymentIntent)({publicApiKey,paymentIntentClientSecret});switch(paymentIntentResult.status){case"valid":handleClick();break;case"processing":setTimeout(()=>{getPaymentIntent()},1e3);break;case"invalid":setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:paymentIntentResult.message}]);break}});getPaymentIntent()}},[((_b=options?.stripe)===null||_b===void 0?void 0:_b.paymentIntentClientSecret)!=null,paymentType!=null,order?.payment_source!=null]),(0,react_1.useEffect)(()=>{var _a2,_b2,_c2,_d2,_e2,_f2,_g2,_h,_j,_k;if(order?.status!=null&&["draft","pending"].includes(order?.status)){const isAuthorized=((_b2=(_a2=order?.payment_source)===null||_a2===void 0?void 0:_a2.payment_response)===null||_b2===void 0?void 0:_b2.resultCode)==="Authorised",paymentDetails=((_d2=(_c2=order?.payment_source)===null||_c2===void 0?void 0:_c2.payment_request_details)===null||_d2===void 0?void 0:_d2.details)!=null;if(paymentType==="adyen_payments"&&(!((_e2=options?.adyen)===null||_e2===void 0)&&_e2.redirectResult)&&!paymentDetails){const attributes={payment_request_details:{details:{redirectResult:(_f2=options?.adyen)===null||_f2===void 0?void 0:_f2.redirectResult}},_details:1};setPaymentSource({paymentSourceId:paymentSource?.id,paymentResource:"adyen_payments",attributes}).then(res=>{var _a3,_b3,_c3;const resultCode=(_a3=res?.payment_response)===null||_a3===void 0?void 0:_a3.resultCode,errorCode=(_b3=res?.payment_response)===null||_b3===void 0?void 0:_b3.errorCode,message=(_c3=res?.payment_response)===null||_c3===void 0?void 0:_c3.message;["Authorised","Pending","Received"].includes(resultCode)&&autoPlaceOrder?handleClick():errorCode!=null&&setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message}])})}else paymentType==="adyen_payments"&&isAuthorized&&paymentDetails&&autoPlaceOrder&&status==="standby"&&!(!((_g2=options?.adyen)===null||_g2===void 0)&&_g2.redirectResult)&&!((_k=(_j=(_h=order?.payment_source)===null||_h===void 0?void 0:_h.payment_response)===null||_j===void 0?void 0:_j.merchantReference)===null||_k===void 0)&&_k.includes(order?.number)&&handleClick()}},[((_c=options?.adyen)===null||_c===void 0?void 0:_c.redirectResult)!=null,(_e=(_d=order?.payment_source)===null||_d===void 0?void 0:_d.payment_response)===null||_e===void 0?void 0:_e.resultCode]),(0,react_1.useEffect)(()=>{order?.status==="placed"&&order?.payment_status==="authorized"&&paymentType==="adyen_payments"&&onClick?.({placed:!0,order})},[order?.id,order?.payment_status,order?.status,paymentType!=null]),(0,react_1.useEffect)(()=>{var _a2,_b2,_c2,_d2;if(paymentType==="checkout_com_payments"&&(!((_a2=options?.checkoutCom)===null||_a2===void 0)&&_a2.session_id)&&order?.status&&["draft","pending"].includes(order?.status)&&autoPlaceOrder){const paymentResponse=(_b2=order?.payment_source)===null||_b2===void 0?void 0:_b2.payment_response,paymentStatus=paymentResponse?.status;paymentStatus&&paymentStatus.toLowerCase()==="pending"&&function(){return tslib_1.__awaiter(this,void 0,void 0,function*(){var _a3;const res=yield setPaymentSource({paymentSourceId:paymentSource?.id,paymentResource:"checkout_com_payments",attributes:{_details:1}}),paymentStatus2=(_a3=res?.payment_response)===null||_a3===void 0?void 0:_a3.status,isValidStatus=["authorized","captured"].includes(paymentStatus2?.toLowerCase());paymentStatus2&&isValidStatus?handleClick():(options?.checkoutCom&&(options.checkoutCom.session_id=void 0),setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:paymentStatus2}]))})}()}else if(paymentType==="checkout_com_payments"&&order?.status&&status&&["pending"].includes(order?.status)&&["placing"].includes(status)&&autoPlaceOrder){const paymentSourceStatus=(_d2=(_c2=order?.payment_source)===null||_c2===void 0?void 0:_c2.payment_response)===null||_d2===void 0?void 0:_d2.status;paymentSourceStatus&&["captured","authorized"].includes(paymentSourceStatus.toLowerCase())&&setPlaceOrder?.({paymentSource}).then(placed=>{placed?.placed?(onClick?.(placed),setPlaceOrderStatus?.({status:"placing"})):setPlaceOrderStatus?.({status:"standby"})})}},[(_f=options?.checkoutCom)===null||_f===void 0?void 0:_f.session_id,(_g=order?.payment_source)===null||_g===void 0?void 0:_g.id]),(0,react_1.useEffect)(()=>{ref?.current!=null&&setButtonRef!=null&&setButtonRef(ref)},[ref?.current]),(0,react_1.useEffect)(()=>{switch(status){case"disabled":case"placing":setNotPermitted(!0);break;default:setNotPermitted(!1);break}},[status!=null]);const handleClick=e=>tslib_1.__awaiter(this,void 0,void 0,function*(){var _a2,_b2,_c2,_d2,_e2,_f2,_g2,_h,_j,_k,_l;e?.preventDefault(),e?.stopPropagation();const sdk=sdkClient();if(sdk==null||order==null)return;if(!(paymentType==="stripe_payments")){const{status:status2}=yield sdk.orders.retrieve(order?.id,{fields:["status"]}),isAlreadyPlaced=status2==="placed",isDraftOrder=status2==="draft";if(isAlreadyPlaced){setPlaceOrderStatus?.({status:"placing"}),onClick?.({placed:!0,order});return}if(isDraftOrder){setPlaceOrderStatus?.({status:"standby"}),onClick?.({placed:!1,order,errors:[{code:"VALIDATION_ERROR",resource:"orders",message:"Draft order cannot be placed"}]}),setOrderErrors([{code:"VALIDATION_ERROR",resource:"orders",message:"Draft order cannot be placed"}]);return}}setIsLoading(!0);let isValid=!0;const checkPaymentSource=paymentType!=="stripe_payments"?yield setPaymentSource({paymentResource:paymentType,paymentSourceId:paymentSource?.id}):paymentSource,card=paymentType&&(0,getCardDetails_1.default)({paymentType,customerPayment:{payment_source:checkPaymentSource}});!((_a2=currentPaymentMethodRef?.current)===null||_a2===void 0)&&_a2.onsubmit&&[!options?.paypalPayerId,!(!((_b2=options?.adyen)===null||_b2===void 0)&&_b2.MD),!(!((_c2=options?.checkoutCom)===null||_c2===void 0)&&_c2.session_id)].every(Boolean)?(isValid=yield(_d2=currentPaymentMethodRef.current)===null||_d2===void 0?void 0:_d2.onsubmit({paymentSource:checkPaymentSource,setPlaceOrder,onclickCallback:onClick}),!isValid&&((_e2=checkPaymentSource?.payment_response)===null||_e2===void 0?void 0:_e2.resultCode)==="Authorised"&&(isValid=!0)):!((_f2=currentPaymentMethodRef?.current)===null||_f2===void 0)&&_f2.onsubmit&&(!((_g2=options?.checkoutCom)===null||_g2===void 0)&&_g2.session_id)&&(!((_h=checkPaymentSource?.payment_response)===null||_h===void 0)&&_h.status)&&((_k=(_j=checkPaymentSource?.payment_response)===null||_j===void 0?void 0:_j.status)===null||_k===void 0?void 0:_k.toLowerCase())==="declined"?isValid=yield(_l=currentPaymentMethodRef.current)===null||_l===void 0?void 0:_l.onsubmit({paymentSource:checkPaymentSource,setPlaceOrder,onclickCallback:onClick}):card?.brand&&(isValid=!0),isValid&&setPlaceOrderStatus!=null&&(setPlaceOrderStatus({status:"placing"}),setForceDisable(!0));const placed=isValid&&setPlaceOrder&&(checkPaymentSource||isFree)&&(yield setPlaceOrder({paymentSource:checkPaymentSource,currentCustomerPaymentSourceId}));placed&&setPlaceOrderStatus!=null&&(placed.placed?(setPlaceOrderStatus({status:"placing"}),onClick?.(placed)):(setForceDisable(!1),onClick?.(placed),setIsLoading(!1),setPlaceOrderStatus({status:"standby"})))}),disabledButton=disabled!==void 0?disabled:notPermitted,labelButton=isLoading?loadingLabel:(0,isFunction_1.default)(label)?label():label,parentProps=Object.assign(Object.assign({},p),{label,disabled:disabledButton,handleClick,parentRef:ref,isLoading});return children?(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children})):(0,jsx_runtime_1.jsx)("button",Object.assign({ref,type:"button",disabled:disabledButton||forceDisable,onClick:e=>{handleClick(e)}},p,{children:labelButton}))}exports.default=PlaceOrderButton;
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PlaceOrderButton=PlaceOrderButton;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),isFunction_1=tslib_1.__importDefault(require("lodash/isFunction")),react_1=require("react"),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),PaymentMethodContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodContext")),PlaceOrderContext_1=tslib_1.__importDefault(require("../../context/PlaceOrderContext")),useCommerceLayer_1=tslib_1.__importDefault(require("../../hooks/useCommerceLayer")),getCardDetails_1=tslib_1.__importDefault(require("../../utils/getCardDetails")),retrievePaymentIntent_1=require("../../utils/stripe/retrievePaymentIntent"),Parent_1=tslib_1.__importDefault(require("../utils/Parent"));function PlaceOrderButton(props){var _a,_b,_c,_d,_e,_f,_g;const ref=(0,react_1.useRef)(null),{children,label="Place order",loadingLabel="Placing...",autoPlaceOrder=!0,disabled,onClick}=props,p=tslib_1.__rest(props,["children","label","loadingLabel","autoPlaceOrder","disabled","onClick"]),{isPermitted,setPlaceOrder,options,paymentType,setButtonRef,setPlaceOrderStatus,status}=(0,react_1.useContext)(PlaceOrderContext_1.default),[notPermitted,setNotPermitted]=(0,react_1.useState)(!0),[forceDisable,setForceDisable]=(0,react_1.useState)(disabled),[isLoading,setIsLoading]=(0,react_1.useState)(!1),{sdkClient}=(0,useCommerceLayer_1.default)(),{currentPaymentMethodRef,loading,currentPaymentMethodType,paymentSource,setPaymentSource,setPaymentMethodErrors,currentCustomerPaymentSourceId}=(0,react_1.useContext)(PaymentMethodContext_1.default),{order,setOrderErrors,errors}=(0,react_1.useContext)(OrderContext_1.default),isFree=order?.total_amount_with_taxes_cents===0;(0,react_1.useEffect)(()=>{var _a2;if(loading)setNotPermitted(loading);else if(paymentType===currentPaymentMethodType&&paymentType){const card=(0,getCardDetails_1.default)({customerPayment:{payment_source:paymentSource},paymentType});currentCustomerPaymentSourceId!=null&&paymentSource?.id===currentCustomerPaymentSourceId&&card.brand===""&&(card.brand="credit-card"),(isFree&&isPermitted||!((_a2=currentPaymentMethodRef?.current)===null||_a2===void 0)&&_a2.onsubmit||card.brand)&&isPermitted&&setNotPermitted(!1)}else setNotPermitted(!(isFree&&isPermitted));return()=>{setNotPermitted(!0)}},[isPermitted,paymentType!=null,((_a=currentPaymentMethodRef?.current)===null||_a===void 0?void 0:_a.onsubmit)!=null,loading,currentPaymentMethodType,order?.id,paymentSource?.id]),(0,react_1.useEffect)(()=>{errors&&errors.length>0&&(setNotPermitted(!0),setIsLoading(!1),setForceDisable(!1))},[errors]),(0,react_1.useEffect)(()=>{paymentType==="paypal_payments"&&options?.paypalPayerId&&order?.status&&["draft","pending"].includes(order?.status)&&autoPlaceOrder&&handleClick()},[options?.paypalPayerId,paymentType!=null]),(0,react_1.useEffect)(()=>{var _a2,_b2,_c2,_d2;if(paymentType==="stripe_payments"&&(!((_a2=options?.stripe)===null||_a2===void 0)&&_a2.paymentIntentClientSecret)&&(!((_b2=order?.payment_source)===null||_b2===void 0)&&_b2.publishable_key)&&order?.status&&["draft","pending"].includes(order?.status)&&autoPlaceOrder){console.log("Stripe redirect flow");const publicApiKey=(_c2=order?.payment_source)===null||_c2===void 0?void 0:_c2.publishable_key,paymentIntentClientSecret=(_d2=options?.stripe)===null||_d2===void 0?void 0:_d2.paymentIntentClientSecret,getPaymentIntent=()=>tslib_1.__awaiter(this,void 0,void 0,function*(){const paymentIntentResult=yield(0,retrievePaymentIntent_1.checkPaymentIntent)({publicApiKey,paymentIntentClientSecret});switch(paymentIntentResult.status){case"valid":handleClick();break;case"processing":setTimeout(()=>{getPaymentIntent()},1e3);break;case"invalid":setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:paymentIntentResult.message}]);break}});getPaymentIntent()}},[((_b=options?.stripe)===null||_b===void 0?void 0:_b.paymentIntentClientSecret)!=null,paymentType!=null,order?.payment_source!=null]),(0,react_1.useEffect)(()=>{var _a2,_b2,_c2,_d2,_e2,_f2,_g2,_h,_j,_k;if(order?.status!=null&&["draft","pending"].includes(order?.status)){const isAuthorized=((_b2=(_a2=order?.payment_source)===null||_a2===void 0?void 0:_a2.payment_response)===null||_b2===void 0?void 0:_b2.resultCode)==="Authorised",paymentDetails=((_d2=(_c2=order?.payment_source)===null||_c2===void 0?void 0:_c2.payment_request_details)===null||_d2===void 0?void 0:_d2.details)!=null;if(paymentType==="adyen_payments"&&(!((_e2=options?.adyen)===null||_e2===void 0)&&_e2.redirectResult)&&!paymentDetails){const attributes={payment_request_details:{details:{redirectResult:(_f2=options?.adyen)===null||_f2===void 0?void 0:_f2.redirectResult}},_details:1};setPaymentSource({paymentSourceId:paymentSource?.id,paymentResource:"adyen_payments",attributes}).then(res=>{var _a3,_b3,_c3;const resultCode=(_a3=res?.payment_response)===null||_a3===void 0?void 0:_a3.resultCode,errorCode=(_b3=res?.payment_response)===null||_b3===void 0?void 0:_b3.errorCode,message=(_c3=res?.payment_response)===null||_c3===void 0?void 0:_c3.message;["Authorised","Pending","Received"].includes(resultCode)&&autoPlaceOrder?handleClick():errorCode!=null&&setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message}])})}else paymentType==="adyen_payments"&&isAuthorized&&paymentDetails&&autoPlaceOrder&&status==="standby"&&!(!((_g2=options?.adyen)===null||_g2===void 0)&&_g2.redirectResult)&&!((_k=(_j=(_h=order?.payment_source)===null||_h===void 0?void 0:_h.payment_response)===null||_j===void 0?void 0:_j.merchantReference)===null||_k===void 0)&&_k.includes(order?.number)&&handleClick()}},[((_c=options?.adyen)===null||_c===void 0?void 0:_c.redirectResult)!=null,(_e=(_d=order?.payment_source)===null||_d===void 0?void 0:_d.payment_response)===null||_e===void 0?void 0:_e.resultCode]),(0,react_1.useEffect)(()=>{order?.status==="placed"&&order?.payment_status==="authorized"&&paymentType==="adyen_payments"&&onClick?.({placed:!0,order})},[order?.id,order?.payment_status,order?.status,paymentType!=null]),(0,react_1.useEffect)(()=>{var _a2,_b2,_c2,_d2;if(console.log("Checkout.com redirect flow",{order,status}),paymentType==="checkout_com_payments"&&(!((_a2=options?.checkoutCom)===null||_a2===void 0)&&_a2.session_id)&&order?.status&&["draft","pending"].includes(order?.status)&&autoPlaceOrder){const paymentResponse=(_b2=order?.payment_source)===null||_b2===void 0?void 0:_b2.payment_response,paymentStatus=paymentResponse?.status;paymentStatus&&paymentStatus.toLowerCase()==="pending"&&function(){return tslib_1.__awaiter(this,void 0,void 0,function*(){var _a3;const res=yield setPaymentSource({paymentSourceId:paymentSource?.id,paymentResource:"checkout_com_payments",attributes:{_details:1}}),paymentStatus2=(_a3=res?.payment_response)===null||_a3===void 0?void 0:_a3.status,isValidStatus=["authorized","captured"].includes(paymentStatus2?.toLowerCase());paymentStatus2&&isValidStatus?handleClick():(options?.checkoutCom&&(options.checkoutCom.session_id=void 0),setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:paymentStatus2}]))})}()}else if(paymentType==="checkout_com_payments"&&order?.status&&status&&["pending"].includes(order?.status)&&["placing"].includes(status)&&autoPlaceOrder){console.log("Placing order with Checkout.com express payments");const paymentSourceStatus=(_d2=(_c2=order?.payment_source)===null||_c2===void 0?void 0:_c2.payment_response)===null||_d2===void 0?void 0:_d2.status;console.log("Payment source status:",paymentSourceStatus),paymentSourceStatus&&["captured","authorized"].includes(paymentSourceStatus.toLowerCase())&&setPlaceOrder?.({paymentSource}).then(placed=>{placed?.placed?(onClick?.(placed),setPlaceOrderStatus?.({status:"placing"})):setPlaceOrderStatus?.({status:"standby"})})}},[(_f=options?.checkoutCom)===null||_f===void 0?void 0:_f.session_id,(_g=order?.payment_source)===null||_g===void 0?void 0:_g.id,status]),(0,react_1.useEffect)(()=>{ref?.current!=null&&setButtonRef!=null&&setButtonRef(ref)},[ref?.current]),(0,react_1.useEffect)(()=>{switch(status){case"disabled":case"placing":setNotPermitted(!0);break;default:setNotPermitted(!1);break}},[status!=null]);const handleClick=e=>tslib_1.__awaiter(this,void 0,void 0,function*(){var _a2,_b2,_c2,_d2,_e2,_f2,_g2,_h,_j,_k,_l;e?.preventDefault(),e?.stopPropagation();const sdk=sdkClient();if(sdk==null||order==null)return;if(!(paymentType==="stripe_payments")){const{status:status2}=yield sdk.orders.retrieve(order?.id,{fields:["status"]}),isAlreadyPlaced=status2==="placed",isDraftOrder=status2==="draft";if(isAlreadyPlaced){setPlaceOrderStatus?.({status:"placing"}),onClick?.({placed:!0,order});return}if(isDraftOrder){setPlaceOrderStatus?.({status:"standby"}),onClick?.({placed:!1,order,errors:[{code:"VALIDATION_ERROR",resource:"orders",message:"Draft order cannot be placed"}]}),setOrderErrors([{code:"VALIDATION_ERROR",resource:"orders",message:"Draft order cannot be placed"}]);return}}setIsLoading(!0);let isValid=!0;const checkPaymentSource=paymentType!=="stripe_payments"?yield setPaymentSource({paymentResource:paymentType,paymentSourceId:paymentSource?.id}):paymentSource,card=paymentType&&(0,getCardDetails_1.default)({paymentType,customerPayment:{payment_source:checkPaymentSource}});!((_a2=currentPaymentMethodRef?.current)===null||_a2===void 0)&&_a2.onsubmit&&[!options?.paypalPayerId,!(!((_b2=options?.adyen)===null||_b2===void 0)&&_b2.MD),!(!((_c2=options?.checkoutCom)===null||_c2===void 0)&&_c2.session_id)].every(Boolean)?(isValid=yield(_d2=currentPaymentMethodRef.current)===null||_d2===void 0?void 0:_d2.onsubmit({paymentSource:checkPaymentSource,setPlaceOrder,onclickCallback:onClick}),!isValid&&((_e2=checkPaymentSource?.payment_response)===null||_e2===void 0?void 0:_e2.resultCode)==="Authorised"&&(isValid=!0)):!((_f2=currentPaymentMethodRef?.current)===null||_f2===void 0)&&_f2.onsubmit&&(!((_g2=options?.checkoutCom)===null||_g2===void 0)&&_g2.session_id)&&(!((_h=checkPaymentSource?.payment_response)===null||_h===void 0)&&_h.status)&&((_k=(_j=checkPaymentSource?.payment_response)===null||_j===void 0?void 0:_j.status)===null||_k===void 0?void 0:_k.toLowerCase())==="declined"?isValid=yield(_l=currentPaymentMethodRef.current)===null||_l===void 0?void 0:_l.onsubmit({paymentSource:checkPaymentSource,setPlaceOrder,onclickCallback:onClick}):card?.brand&&(isValid=!0),isValid&&setPlaceOrderStatus!=null&&(setPlaceOrderStatus({status:"placing"}),setForceDisable(!0));const placed=isValid&&setPlaceOrder&&(checkPaymentSource||isFree)&&(yield setPlaceOrder({paymentSource:checkPaymentSource,currentCustomerPaymentSourceId}));placed&&setPlaceOrderStatus!=null&&(placed.placed?(setPlaceOrderStatus({status:"placing"}),onClick?.(placed)):(setForceDisable(!1),onClick?.(placed),setIsLoading(!1),setPlaceOrderStatus({status:"standby"})))}),disabledButton=disabled!==void 0?disabled:notPermitted,labelButton=isLoading?loadingLabel:(0,isFunction_1.default)(label)?label():label,parentProps=Object.assign(Object.assign({},p),{label,disabled:disabledButton,handleClick,parentRef:ref,isLoading});return children?(0,jsx_runtime_1.jsx)(Parent_1.default,Object.assign({},parentProps,{children})):(0,jsx_runtime_1.jsx)("button",Object.assign({ref,type:"button",disabled:disabledButton||forceDisable,onClick:e=>{handleClick(e)}},p,{children:labelButton}))}exports.default=PlaceOrderButton;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CheckoutComPayment=CheckoutComPayment;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),CommerceLayerContext_1=tslib_1.__importDefault(require("../../context/CommerceLayerContext")),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),PaymentMethodContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodContext")),PlaceOrderContext_1=tslib_1.__importDefault(require("../../context/PlaceOrderContext")),useExternalScript_1=tslib_1.__importDefault(require("../../utils/hooks/useExternalScript")),jwt_1=require("../../utils/jwt"),localStorage_1=require("../../utils/localStorage"),scriptUrl="https://checkout-web-components.checkout.com/index.js";function CheckoutComPayment(_a){var _b,{publicKey,options}=_a,p=tslib_1.__rest(_a,["publicKey","options"]);const ref=(0,react_1.useRef)(null),loaded=(0,useExternalScript_1.default)(scriptUrl),{setPaymentRef,setPaymentSource}=(0,react_1.useContext)(PaymentMethodContext_1.default),{accessToken}=(0,react_1.useContext)(CommerceLayerContext_1.default),{order}=(0,react_1.useContext)(OrderContext_1.default),{setPlaceOrderStatus}=(0,react_1.useContext)(PlaceOrderContext_1.default),{containerClassName,templateCustomerSaveToWallet,show}=p,divProps=tslib_1.__rest(p,["containerClassName","templateCustomerSaveToWallet","show"]);return(0,react_1.useEffect)(()=>{var _a2;const ps=order?.payment_source;if(loaded&&window&&ps&&accessToken){const publicKey2=ps.public_key,paymentSession=ps.payment_session;if(window?.CheckoutWebComponents){const environment=(0,jwt_1.jwt)(accessToken).test?"sandbox":"production",locale=(_a2=order?.language_code)!==null&&_a2!==void 0?_a2:"en";tslib_1.__awaiter(this,void 0,void 0,function*(){(yield window.CheckoutWebComponents({appearance:Object.assign({},options?.appearance),showPayButton:!1,publicKey:publicKey2,environment,locale,paymentSession,componentOptions:{card:{displayCardholderName:"hidden"}},onChange:component=>{ref.current&&component.isValid()&&(ref.current.onsubmit=()=>tslib_1.__awaiter(this,void 0,void 0,function*(){var _a3,_b2;const element=(_a3=ref.current)===null||_a3===void 0?void 0:_a3.elements,savePaymentSourceToCustomerWallet=(_b2=element?.save_payment_source_to_customer_wallet)===null||_b2===void 0?void 0:_b2.checked;savePaymentSourceToCustomerWallet&&(0,localStorage_1.setCustomerOrderParam)("_save_payment_source_to_customer_wallet",savePaymentSourceToCustomerWallet);const{data}=yield component.tokenize(),token=data?.token,paymentSource=yield setPaymentSource({paymentSourceId:ps.id,paymentResource:"checkout_com_payments",attributes:{token,_authorize:!0}});if(paymentSource){const response=paymentSource.payment_response,securityRedirect=paymentSource?.redirect_uri;return response?.status.toLowerCase()==="pending"&&securityRedirect?(window.location.href=securityRedirect,!1):!0}return!1}),setPaymentRef?.({ref}))},onError:(component,error)=>{console.error("onError",{error},"Component",component.type)},onPaymentCompleted:(_component,paymentResponse)=>tslib_1.__awaiter(this,void 0,void 0,function*(){paymentResponse.status.toLowerCase()==="approved"&&(yield setPaymentSource({paymentSourceId:ps.id,paymentResource:"checkout_com_payments",attributes:{token:paymentResponse.id,_authorize:!0}}),setPlaceOrderStatus?.({status:"placing"}))})})).create("flow").mount(document.getElementById("flow-container"))})}}},[loaded,(_b=order?.payment_source)===null||_b===void 0?void 0:_b.id,accessToken]),loaded&&show?(0,jsx_runtime_1.jsxs)("form",{ref,children:[(0,jsx_runtime_1.jsx)("div",Object.assign({className:containerClassName},divProps,{children:(0,jsx_runtime_1.jsx)("div",{id:"flow-container"})})),templateCustomerSaveToWallet&&(0,jsx_runtime_1.jsx)(Parent_1.default,{name:"save_payment_source_to_customer_wallet",children:templateCustomerSaveToWallet})]}):null}exports.default=CheckoutComPayment;
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.CheckoutComPayment=CheckoutComPayment;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_1=require("react"),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),CommerceLayerContext_1=tslib_1.__importDefault(require("../../context/CommerceLayerContext")),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),PaymentMethodContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodContext")),PlaceOrderContext_1=tslib_1.__importDefault(require("../../context/PlaceOrderContext")),useExternalScript_1=tslib_1.__importDefault(require("../../utils/hooks/useExternalScript")),jwt_1=require("../../utils/jwt"),localStorage_1=require("../../utils/localStorage"),scriptUrl="https://checkout-web-components.checkout.com/index.js";function CheckoutComPayment(_a){var _b,{publicKey,options}=_a,p=tslib_1.__rest(_a,["publicKey","options"]);const ref=(0,react_1.useRef)(null),loaded=(0,useExternalScript_1.default)(scriptUrl),{setPaymentRef,setPaymentSource}=(0,react_1.useContext)(PaymentMethodContext_1.default),{accessToken}=(0,react_1.useContext)(CommerceLayerContext_1.default),{order}=(0,react_1.useContext)(OrderContext_1.default),{setPlaceOrderStatus}=(0,react_1.useContext)(PlaceOrderContext_1.default),{containerClassName,templateCustomerSaveToWallet,show}=p,divProps=tslib_1.__rest(p,["containerClassName","templateCustomerSaveToWallet","show"]);return(0,react_1.useEffect)(()=>{var _a2;const ps=order?.payment_source;if(loaded&&window&&ps&&accessToken){const publicKey2=ps.public_key,paymentSession=ps.payment_session;if(window?.CheckoutWebComponents){const environment=(0,jwt_1.jwt)(accessToken).test?"sandbox":"production",locale=(_a2=order?.language_code)!==null&&_a2!==void 0?_a2:"en";tslib_1.__awaiter(this,void 0,void 0,function*(){(yield window.CheckoutWebComponents({appearance:Object.assign({},options?.appearance),showPayButton:!1,publicKey:publicKey2,environment,locale,paymentSession,componentOptions:{card:{displayCardholderName:"hidden"}},onChange:component=>{ref.current&&component.isValid()&&(ref.current.onsubmit=()=>tslib_1.__awaiter(this,void 0,void 0,function*(){var _a3,_b2;const element=(_a3=ref.current)===null||_a3===void 0?void 0:_a3.elements,savePaymentSourceToCustomerWallet=(_b2=element?.save_payment_source_to_customer_wallet)===null||_b2===void 0?void 0:_b2.checked;savePaymentSourceToCustomerWallet&&(0,localStorage_1.setCustomerOrderParam)("_save_payment_source_to_customer_wallet",savePaymentSourceToCustomerWallet);const{data}=yield component.tokenize(),token=data?.token,paymentSource=yield setPaymentSource({paymentSourceId:ps.id,paymentResource:"checkout_com_payments",attributes:{token,_authorize:!0}});if(paymentSource){const response=paymentSource.payment_response,securityRedirect=paymentSource?.redirect_uri;return response?.status.toLowerCase()==="pending"&&securityRedirect?(window.location.href=securityRedirect,!1):!0}return!1}),setPaymentRef?.({ref}))},onError:(component,error)=>{console.error("onError",{error},"Component",component.type)},onPaymentCompleted:(_component,paymentResponse)=>tslib_1.__awaiter(this,void 0,void 0,function*(){console.log("onPaymentCompleted",{paymentResponse}),paymentResponse.status.toLowerCase()==="approved"&&(yield setPaymentSource({paymentSourceId:ps.id,paymentResource:"checkout_com_payments",attributes:{token:paymentResponse.id,_authorize:!0}}),setPlaceOrderStatus?.({status:"placing"}))})})).create("flow").mount(document.getElementById("flow-container"))})}}},[loaded,(_b=order?.payment_source)===null||_b===void 0?void 0:_b.id,accessToken]),loaded&&show?(0,jsx_runtime_1.jsxs)("form",{ref,children:[(0,jsx_runtime_1.jsx)("div",Object.assign({className:containerClassName},divProps,{children:(0,jsx_runtime_1.jsx)("div",{id:"flow-container"})})),templateCustomerSaveToWallet&&(0,jsx_runtime_1.jsx)(Parent_1.default,{name:"save_payment_source_to_customer_wallet",children:templateCustomerSaveToWallet})]}):null}exports.default=CheckoutComPayment;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.StripePayment=StripePayment;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_stripe_js_1=require("@stripe/react-stripe-js"),react_1=require("react"),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),PaymentMethodContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodContext")),PlaceOrderContext_1=tslib_1.__importDefault(require("../../context/PlaceOrderContext")),useCommerceLayer_1=tslib_1.__importDefault(require("../../hooks/useCommerceLayer")),localStorage_1=require("../../utils/localStorage"),StripeExpressPayment_1=require("./StripeExpressPayment"),defaultOptions={layout:{type:"accordion",defaultCollapsed:!1,radios:!0,spacedAccordionItems:!1},fields:{billingDetails:"never"}},defaultAppearance={theme:"stripe",variables:{colorText:"#32325d",fontFamily:'"Helvetica Neue", Helvetica, sans-serif'}};let selectedPaymentMethodType=null;function StripePaymentForm({options=defaultOptions,templateCustomerSaveToWallet,stripe}){const ref=(0,react_1.useRef)(null),{currentPaymentMethodType,setPaymentMethodErrors,setPaymentRef}=(0,react_1.useContext)(PaymentMethodContext_1.default),{order,setOrderErrors}=(0,react_1.useContext)(OrderContext_1.default),{sdkClient}=(0,useCommerceLayer_1.default)(),{setPlaceOrderStatus}=(0,react_1.useContext)(PlaceOrderContext_1.default),elements=(0,react_stripe_js_1.useElements)();(0,react_1.useEffect)(()=>(ref.current&&stripe&&elements&&(ref.current.onsubmit=()=>tslib_1.__awaiter(this,void 0,void 0,function*(){return yield onSubmit({event:ref.current,stripe,elements})}),setPaymentRef({ref})),()=>{setPaymentRef({ref:{current:null}})}),[ref,stripe,elements]);const onSubmit=_a=>tslib_1.__awaiter(this,[_a],void 0,function*({event,stripe:stripe2,elements:elements2}){var _b,_c,_d,_e,_f,_g,_h;if(!stripe2)return!1;const sdk=sdkClient();if(sdk==null||order==null)return!1;if(selectedPaymentMethodType&&!["apple_pay","google_pay"].includes(selectedPaymentMethodType)){const{status}=yield sdk.orders.retrieve(order?.id,{fields:["status"]});if(status==="draft")return setOrderErrors([{code:"VALIDATION_ERROR",resource:"orders",message:"Draft order cannot be placed"}]),setPlaceOrderStatus?.({status:"disabled"}),!1}const savePaymentSourceToCustomerWallet=(_c=(_b=event?.elements)===null||_b===void 0?void 0:_b.save_payment_source_to_customer_wallet)===null||_c===void 0?void 0:_c.checked;if(savePaymentSourceToCustomerWallet&&(0,localStorage_1.setCustomerOrderParam)("_save_payment_source_to_customer_wallet",savePaymentSourceToCustomerWallet),elements2!=null){const billingInfo=order?.billing_address,email=(_d=order?.customer_email)!==null&&_d!==void 0?_d:"",billingDetails={name:(_e=billingInfo?.full_name)!==null&&_e!==void 0?_e:"",email,phone:billingInfo?.phone,address:{city:billingInfo?.city,country:billingInfo?.country_code,line1:billingInfo?.line_1,line2:(_f=billingInfo?.line_2)!==null&&_f!==void 0?_f:"",postal_code:(_g=billingInfo?.zip_code)!==null&&_g!==void 0?_g:"",state:billingInfo?.state_code}},url=new URL(window.location.href),cleanUrl=`${url.origin}${url.pathname}?accessToken=${url.searchParams.get("accessToken")}`,{error}=yield stripe2.confirmPayment({elements:elements2,confirmParams:{return_url:cleanUrl,payment_method_data:{billing_details:billingDetails}},redirect:"if_required"});return error?(console.error(error),setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:(_h=error.message)!==null&&_h!==void 0?_h:""}]),!1):!0}return!1});function handleChange(event){return tslib_1.__awaiter(this,void 0,void 0,function*(){if(console.debug("StripePaymentElement onChange event",{event}),selectedPaymentMethodType=event.value.type,event.complete&&["apple_pay","google_pay"].includes(event.value.type)){const sdk=sdkClient();if(sdk==null||order==null)return;const{status}=yield sdk.orders.retrieve(order?.id,{fields:["status"]});if(status==="draft"){setOrderErrors([{code:"VALIDATION_ERROR",resource:"orders",message:"Draft order cannot be placed"}]),setPlaceOrderStatus?.({status:"disabled"});return}}})}return(0,jsx_runtime_1.jsxs)("form",{ref,children:[(0,jsx_runtime_1.jsx)(react_stripe_js_1.PaymentElement,{id:"payment-element",options:Object.assign(Object.assign({},defaultOptions),options),onChange:handleChange}),templateCustomerSaveToWallet&&(0,jsx_runtime_1.jsx)(Parent_1.default,{name:"save_payment_source_to_customer_wallet",children:templateCustomerSaveToWallet})]})}function StripePayment(_a){var{publishableKey,show,options,clientSecret,locale="auto",expressPayments=!1,connectedAccount}=_a,p=tslib_1.__rest(_a,["publishableKey","show","options","clientSecret","locale","expressPayments","connectedAccount"]);const[isLoaded,setIsLoaded]=(0,react_1.useState)(!1),[stripe,setStripe]=(0,react_1.useState)(null),{containerClassName,templateCustomerSaveToWallet,fonts=[],appearance}=p,divProps=tslib_1.__rest(p,["containerClassName","templateCustomerSaveToWallet","fonts","appearance"]);(0,react_1.useEffect)(()=>(show&&publishableKey&&Promise.resolve().then(()=>tslib_1.__importStar(require("@stripe/stripe-js"))).then(({loadStripe})=>{tslib_1.__awaiter(this,void 0,void 0,function*(){const options2=Object.assign({locale},connectedAccount?{stripeAccount:connectedAccount}:{}),res=yield loadStripe(publishableKey,options2);res!=null?(setStripe(res),setIsLoaded(!0)):(console.error("Stripe failed to load"),setIsLoaded(!1))})}),()=>{setIsLoaded(!1)}),[show,publishableKey,connectedAccount]);const elementsOptions={clientSecret,appearance:Object.assign(Object.assign({},defaultAppearance),appearance),fonts};return isLoaded&&stripe!=null&&clientSecret!=null?(0,jsx_runtime_1.jsx)("div",Object.assign({className:containerClassName},divProps,{children:(0,jsx_runtime_1.jsx)(react_stripe_js_1.Elements,{stripe,options:elementsOptions,children:expressPayments?(0,jsx_runtime_1.jsx)(StripeExpressPayment_1.StripeExpressPayment,{clientSecret}):(0,jsx_runtime_1.jsx)(StripePaymentForm,{stripe,options,templateCustomerSaveToWallet})})})):null}exports.default=StripePayment;
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.StripePayment=StripePayment;const tslib_1=require("tslib"),jsx_runtime_1=require("react/jsx-runtime"),react_stripe_js_1=require("@stripe/react-stripe-js"),react_1=require("react"),Parent_1=tslib_1.__importDefault(require("../utils/Parent")),OrderContext_1=tslib_1.__importDefault(require("../../context/OrderContext")),PaymentMethodContext_1=tslib_1.__importDefault(require("../../context/PaymentMethodContext")),PlaceOrderContext_1=tslib_1.__importDefault(require("../../context/PlaceOrderContext")),useCommerceLayer_1=tslib_1.__importDefault(require("../../hooks/useCommerceLayer")),localStorage_1=require("../../utils/localStorage"),StripeExpressPayment_1=require("./StripeExpressPayment"),defaultOptions={layout:{type:"accordion",defaultCollapsed:!1,radios:!0,spacedAccordionItems:!1},fields:{billingDetails:"never"}},defaultAppearance={theme:"stripe",variables:{colorText:"#32325d",fontFamily:'"Helvetica Neue", Helvetica, sans-serif'}};let selectedPaymentMethodType=null;function StripePaymentForm({options=defaultOptions,templateCustomerSaveToWallet,stripe}){const ref=(0,react_1.useRef)(null),{currentPaymentMethodType,setPaymentMethodErrors,setPaymentRef}=(0,react_1.useContext)(PaymentMethodContext_1.default),{order,setOrderErrors}=(0,react_1.useContext)(OrderContext_1.default),{sdkClient}=(0,useCommerceLayer_1.default)(),{setPlaceOrderStatus}=(0,react_1.useContext)(PlaceOrderContext_1.default),elements=(0,react_stripe_js_1.useElements)();(0,react_1.useEffect)(()=>(ref.current&&stripe&&elements&&(ref.current.onsubmit=()=>tslib_1.__awaiter(this,void 0,void 0,function*(){return yield onSubmit({event:ref.current,stripe,elements})}),setPaymentRef({ref})),()=>{setPaymentRef({ref:{current:null}})}),[ref,stripe,elements]);const onSubmit=_a=>tslib_1.__awaiter(this,[_a],void 0,function*({event,stripe:stripe2,elements:elements2}){var _b,_c,_d,_e,_f,_g,_h;if(!stripe2)return!1;const sdk=sdkClient();if(sdk==null||order==null)return!1;if(selectedPaymentMethodType&&!["apple_pay","google_pay"].includes(selectedPaymentMethodType)){const{status}=yield sdk.orders.retrieve(order?.id,{fields:["status"]});if(status==="draft")return setOrderErrors([{code:"VALIDATION_ERROR",resource:"orders",message:"Draft order cannot be placed"}]),setPlaceOrderStatus?.({status:"disabled"}),!1}const savePaymentSourceToCustomerWallet=(_c=(_b=event?.elements)===null||_b===void 0?void 0:_b.save_payment_source_to_customer_wallet)===null||_c===void 0?void 0:_c.checked;if(savePaymentSourceToCustomerWallet&&(0,localStorage_1.setCustomerOrderParam)("_save_payment_source_to_customer_wallet",savePaymentSourceToCustomerWallet),elements2!=null){const billingInfo=order?.billing_address,email=(_d=order?.customer_email)!==null&&_d!==void 0?_d:"",billingDetails={name:(_e=billingInfo?.full_name)!==null&&_e!==void 0?_e:"",email,phone:billingInfo?.phone,address:{city:billingInfo?.city,country:billingInfo?.country_code,line1:billingInfo?.line_1,line2:(_f=billingInfo?.line_2)!==null&&_f!==void 0?_f:"",postal_code:(_g=billingInfo?.zip_code)!==null&&_g!==void 0?_g:"",state:billingInfo?.state_code}},url=new URL(window.location.href),cleanUrl=`${url.origin}${url.pathname}?accessToken=${url.searchParams.get("accessToken")}`,{error,paymentIntent}=yield stripe2.confirmPayment({elements:elements2,confirmParams:{return_url:cleanUrl,payment_method_data:{billing_details:billingDetails}},redirect:"if_required"});return console.log({paymentIntent}),error?(console.error(error),setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:(_h=error.message)!==null&&_h!==void 0?_h:""}]),!1):!0}return!1});function handleChange(event){return tslib_1.__awaiter(this,void 0,void 0,function*(){if(console.debug("StripePaymentElement onChange event",{event}),selectedPaymentMethodType=event.value.type,event.complete&&["apple_pay","google_pay"].includes(event.value.type)){const sdk=sdkClient();if(sdk==null||order==null)return;const{status}=yield sdk.orders.retrieve(order?.id,{fields:["status"]});if(status==="draft"){setOrderErrors([{code:"VALIDATION_ERROR",resource:"orders",message:"Draft order cannot be placed"}]),setPlaceOrderStatus?.({status:"disabled"});return}}})}return(0,jsx_runtime_1.jsxs)("form",{ref,children:[(0,jsx_runtime_1.jsx)(react_stripe_js_1.PaymentElement,{id:"payment-element",options:Object.assign(Object.assign({},defaultOptions),options),onChange:handleChange}),templateCustomerSaveToWallet&&(0,jsx_runtime_1.jsx)(Parent_1.default,{name:"save_payment_source_to_customer_wallet",children:templateCustomerSaveToWallet})]})}function StripePayment(_a){var{publishableKey,show,options,clientSecret,locale="auto",expressPayments=!1,connectedAccount}=_a,p=tslib_1.__rest(_a,["publishableKey","show","options","clientSecret","locale","expressPayments","connectedAccount"]);const[isLoaded,setIsLoaded]=(0,react_1.useState)(!1),[stripe,setStripe]=(0,react_1.useState)(null),{containerClassName,templateCustomerSaveToWallet,fonts=[],appearance}=p,divProps=tslib_1.__rest(p,["containerClassName","templateCustomerSaveToWallet","fonts","appearance"]);(0,react_1.useEffect)(()=>(show&&publishableKey&&Promise.resolve().then(()=>tslib_1.__importStar(require("@stripe/stripe-js"))).then(({loadStripe})=>{tslib_1.__awaiter(this,void 0,void 0,function*(){const options2=Object.assign({locale},connectedAccount?{stripeAccount:connectedAccount}:{}),res=yield loadStripe(publishableKey,options2);res!=null?(setStripe(res),setIsLoaded(!0)):(console.error("Stripe failed to load"),setIsLoaded(!1))})}),()=>{setIsLoaded(!1)}),[show,publishableKey,connectedAccount]);const elementsOptions={clientSecret,appearance:Object.assign(Object.assign({},defaultAppearance),appearance),fonts};return isLoaded&&stripe!=null&&clientSecret!=null?(0,jsx_runtime_1.jsx)("div",Object.assign({className:containerClassName},divProps,{children:(0,jsx_runtime_1.jsx)(react_stripe_js_1.Elements,{stripe,options:elementsOptions,children:expressPayments?(0,jsx_runtime_1.jsx)(StripeExpressPayment_1.StripeExpressPayment,{clientSecret}):(0,jsx_runtime_1.jsx)(StripePaymentForm,{stripe,options,templateCustomerSaveToWallet})})})):null}exports.default=StripePayment;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as _jsx}from"react/jsx-runtime";import isFunction from"lodash/isFunction";import{useContext,useEffect,useRef,useState}from"react";import OrderContext from"../../context/OrderContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import PlaceOrderContext from"../../context/PlaceOrderContext";import useCommerceLayer from"../../hooks/useCommerceLayer";import getCardDetails from"../../utils/getCardDetails";import{checkPaymentIntent}from"../../utils/stripe/retrievePaymentIntent";import Parent from"../utils/Parent";export function PlaceOrderButton(props){const ref=useRef(null),{children,label="Place order",loadingLabel="Placing...",autoPlaceOrder=!0,disabled,onClick,...p}=props,{isPermitted,setPlaceOrder,options,paymentType,setButtonRef,setPlaceOrderStatus,status}=useContext(PlaceOrderContext),[notPermitted,setNotPermitted]=useState(!0),[forceDisable,setForceDisable]=useState(disabled),[isLoading,setIsLoading]=useState(!1),{sdkClient}=useCommerceLayer(),{currentPaymentMethodRef,loading,currentPaymentMethodType,paymentSource,setPaymentSource,setPaymentMethodErrors,currentCustomerPaymentSourceId}=useContext(PaymentMethodContext),{order,setOrderErrors,errors}=useContext(OrderContext),isFree=order?.total_amount_with_taxes_cents===0;useEffect(()=>{if(loading)setNotPermitted(loading);else if(paymentType===currentPaymentMethodType&&paymentType){const card=getCardDetails({customerPayment:{payment_source:paymentSource},paymentType});currentCustomerPaymentSourceId!=null&&paymentSource?.id===currentCustomerPaymentSourceId&&card.brand===""&&(card.brand="credit-card"),(isFree&&isPermitted||currentPaymentMethodRef?.current?.onsubmit||card.brand)&&isPermitted&&setNotPermitted(!1)}else setNotPermitted(!(isFree&&isPermitted));return()=>{setNotPermitted(!0)}},[isPermitted,paymentType!=null,currentPaymentMethodRef?.current?.onsubmit!=null,loading,currentPaymentMethodType,order?.id,paymentSource?.id]),useEffect(()=>{errors&&errors.length>0&&(setNotPermitted(!0),setIsLoading(!1),setForceDisable(!1))},[errors]),useEffect(()=>{paymentType==="paypal_payments"&&options?.paypalPayerId&&order?.status&&["draft","pending"].includes(order?.status)&&autoPlaceOrder&&handleClick()},[options?.paypalPayerId,paymentType!=null]),useEffect(()=>{if(paymentType==="stripe_payments"&&options?.stripe?.paymentIntentClientSecret&&order?.payment_source?.publishable_key&&order?.status&&["draft","pending"].includes(order?.status)&&autoPlaceOrder){const publicApiKey=order?.payment_source?.publishable_key,paymentIntentClientSecret=options?.stripe?.paymentIntentClientSecret,getPaymentIntent=async()=>{const paymentIntentResult=await checkPaymentIntent({publicApiKey,paymentIntentClientSecret});switch(paymentIntentResult.status){case"valid":handleClick();break;case"processing":setTimeout(()=>{getPaymentIntent()},1e3);break;case"invalid":setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:paymentIntentResult.message}]);break}};getPaymentIntent()}},[options?.stripe?.paymentIntentClientSecret!=null,paymentType!=null,order?.payment_source!=null]),useEffect(()=>{if(order?.status!=null&&["draft","pending"].includes(order?.status)){const isAuthorized=order?.payment_source?.payment_response?.resultCode==="Authorised",paymentDetails=order?.payment_source?.payment_request_details?.details!=null;if(paymentType==="adyen_payments"&&options?.adyen?.redirectResult&&!paymentDetails){const attributes={payment_request_details:{details:{redirectResult:options?.adyen?.redirectResult}},_details:1};setPaymentSource({paymentSourceId:paymentSource?.id,paymentResource:"adyen_payments",attributes}).then(res=>{const resultCode=res?.payment_response?.resultCode,errorCode=res?.payment_response?.errorCode,message=res?.payment_response?.message;["Authorised","Pending","Received"].includes(resultCode)&&autoPlaceOrder?handleClick():errorCode!=null&&setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message}])})}else paymentType==="adyen_payments"&&isAuthorized&&paymentDetails&&autoPlaceOrder&&status==="standby"&&!options?.adyen?.redirectResult&&order?.payment_source?.payment_response?.merchantReference?.includes(order?.number)&&handleClick()}},[options?.adyen?.redirectResult!=null,order?.payment_source?.payment_response?.resultCode]),useEffect(()=>{order?.status==="placed"&&order?.payment_status==="authorized"&&paymentType==="adyen_payments"&&onClick?.({placed:!0,order})},[order?.id,order?.payment_status,order?.status,paymentType!=null]),useEffect(()=>{if(paymentType==="checkout_com_payments"&&options?.checkoutCom?.session_id&&order?.status&&["draft","pending"].includes(order?.status)&&autoPlaceOrder){const paymentStatus=order?.payment_source?.payment_response?.status;if(paymentStatus&&paymentStatus.toLowerCase()==="pending"){async function placingOrder(){const paymentStatus2=(await setPaymentSource({paymentSourceId:paymentSource?.id,paymentResource:"checkout_com_payments",attributes:{_details:1}}))?.payment_response?.status,isValidStatus=["authorized","captured"].includes(paymentStatus2?.toLowerCase());paymentStatus2&&isValidStatus?handleClick():(options?.checkoutCom&&(options.checkoutCom.session_id=void 0),setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:paymentStatus2}]))}placingOrder()}}else if(paymentType==="checkout_com_payments"&&order?.status&&status&&["pending"].includes(order?.status)&&["placing"].includes(status)&&autoPlaceOrder){const paymentSourceStatus=order?.payment_source?.payment_response?.status;paymentSourceStatus&&["captured","authorized"].includes(paymentSourceStatus.toLowerCase())&&setPlaceOrder?.({paymentSource}).then(placed=>{placed?.placed?(onClick?.(placed),setPlaceOrderStatus?.({status:"placing"})):setPlaceOrderStatus?.({status:"standby"})})}},[options?.checkoutCom?.session_id,order?.payment_source?.id]),useEffect(()=>{ref?.current!=null&&setButtonRef!=null&&setButtonRef(ref)},[ref?.current]),useEffect(()=>{switch(status){case"disabled":case"placing":setNotPermitted(!0);break;default:setNotPermitted(!1);break}},[status!=null]);const handleClick=async e=>{e?.preventDefault(),e?.stopPropagation();const sdk=sdkClient();if(sdk==null||order==null)return;if(!(paymentType==="stripe_payments")){const{status:status2}=await sdk.orders.retrieve(order?.id,{fields:["status"]}),isAlreadyPlaced=status2==="placed",isDraftOrder=status2==="draft";if(isAlreadyPlaced){setPlaceOrderStatus?.({status:"placing"}),onClick?.({placed:!0,order});return}if(isDraftOrder){setPlaceOrderStatus?.({status:"standby"}),onClick?.({placed:!1,order,errors:[{code:"VALIDATION_ERROR",resource:"orders",message:"Draft order cannot be placed"}]}),setOrderErrors([{code:"VALIDATION_ERROR",resource:"orders",message:"Draft order cannot be placed"}]);return}}setIsLoading(!0);let isValid=!0;const checkPaymentSource=paymentType!=="stripe_payments"?await setPaymentSource({paymentResource:paymentType,paymentSourceId:paymentSource?.id}):paymentSource,card=paymentType&&getCardDetails({paymentType,customerPayment:{payment_source:checkPaymentSource}});currentPaymentMethodRef?.current?.onsubmit&&[!options?.paypalPayerId,!options?.adyen?.MD,!options?.checkoutCom?.session_id].every(Boolean)?(isValid=await currentPaymentMethodRef.current?.onsubmit({paymentSource:checkPaymentSource,setPlaceOrder,onclickCallback:onClick}),!isValid&&checkPaymentSource?.payment_response?.resultCode==="Authorised"&&(isValid=!0)):currentPaymentMethodRef?.current?.onsubmit&&options?.checkoutCom?.session_id&&checkPaymentSource?.payment_response?.status&&checkPaymentSource?.payment_response?.status?.toLowerCase()==="declined"?isValid=await currentPaymentMethodRef.current?.onsubmit({paymentSource:checkPaymentSource,setPlaceOrder,onclickCallback:onClick}):card?.brand&&(isValid=!0),isValid&&setPlaceOrderStatus!=null&&(setPlaceOrderStatus({status:"placing"}),setForceDisable(!0));const placed=isValid&&setPlaceOrder&&(checkPaymentSource||isFree)&&await setPlaceOrder({paymentSource:checkPaymentSource,currentCustomerPaymentSourceId});placed&&setPlaceOrderStatus!=null&&(placed.placed?(setPlaceOrderStatus({status:"placing"}),onClick?.(placed)):(setForceDisable(!1),onClick?.(placed),setIsLoading(!1),setPlaceOrderStatus({status:"standby"})))},disabledButton=disabled!==void 0?disabled:notPermitted,labelButton=isLoading?loadingLabel:isFunction(label)?label():label,parentProps={...p,label,disabled:disabledButton,handleClick,parentRef:ref,isLoading};return children?_jsx(Parent,{...parentProps,children}):_jsx("button",{ref,type:"button",disabled:disabledButton||forceDisable,onClick:e=>{handleClick(e)},...p,children:labelButton})}export default PlaceOrderButton;
|
|
2
|
+
import{jsx as _jsx}from"react/jsx-runtime";import isFunction from"lodash/isFunction";import{useContext,useEffect,useRef,useState}from"react";import OrderContext from"../../context/OrderContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import PlaceOrderContext from"../../context/PlaceOrderContext";import useCommerceLayer from"../../hooks/useCommerceLayer";import getCardDetails from"../../utils/getCardDetails";import{checkPaymentIntent}from"../../utils/stripe/retrievePaymentIntent";import Parent from"../utils/Parent";export function PlaceOrderButton(props){const ref=useRef(null),{children,label="Place order",loadingLabel="Placing...",autoPlaceOrder=!0,disabled,onClick,...p}=props,{isPermitted,setPlaceOrder,options,paymentType,setButtonRef,setPlaceOrderStatus,status}=useContext(PlaceOrderContext),[notPermitted,setNotPermitted]=useState(!0),[forceDisable,setForceDisable]=useState(disabled),[isLoading,setIsLoading]=useState(!1),{sdkClient}=useCommerceLayer(),{currentPaymentMethodRef,loading,currentPaymentMethodType,paymentSource,setPaymentSource,setPaymentMethodErrors,currentCustomerPaymentSourceId}=useContext(PaymentMethodContext),{order,setOrderErrors,errors}=useContext(OrderContext),isFree=order?.total_amount_with_taxes_cents===0;useEffect(()=>{if(loading)setNotPermitted(loading);else if(paymentType===currentPaymentMethodType&&paymentType){const card=getCardDetails({customerPayment:{payment_source:paymentSource},paymentType});currentCustomerPaymentSourceId!=null&&paymentSource?.id===currentCustomerPaymentSourceId&&card.brand===""&&(card.brand="credit-card"),(isFree&&isPermitted||currentPaymentMethodRef?.current?.onsubmit||card.brand)&&isPermitted&&setNotPermitted(!1)}else setNotPermitted(!(isFree&&isPermitted));return()=>{setNotPermitted(!0)}},[isPermitted,paymentType!=null,currentPaymentMethodRef?.current?.onsubmit!=null,loading,currentPaymentMethodType,order?.id,paymentSource?.id]),useEffect(()=>{errors&&errors.length>0&&(setNotPermitted(!0),setIsLoading(!1),setForceDisable(!1))},[errors]),useEffect(()=>{paymentType==="paypal_payments"&&options?.paypalPayerId&&order?.status&&["draft","pending"].includes(order?.status)&&autoPlaceOrder&&handleClick()},[options?.paypalPayerId,paymentType!=null]),useEffect(()=>{if(paymentType==="stripe_payments"&&options?.stripe?.paymentIntentClientSecret&&order?.payment_source?.publishable_key&&order?.status&&["draft","pending"].includes(order?.status)&&autoPlaceOrder){console.log("Stripe redirect flow");const publicApiKey=order?.payment_source?.publishable_key,paymentIntentClientSecret=options?.stripe?.paymentIntentClientSecret,getPaymentIntent=async()=>{const paymentIntentResult=await checkPaymentIntent({publicApiKey,paymentIntentClientSecret});switch(paymentIntentResult.status){case"valid":handleClick();break;case"processing":setTimeout(()=>{getPaymentIntent()},1e3);break;case"invalid":setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:paymentIntentResult.message}]);break}};getPaymentIntent()}},[options?.stripe?.paymentIntentClientSecret!=null,paymentType!=null,order?.payment_source!=null]),useEffect(()=>{if(order?.status!=null&&["draft","pending"].includes(order?.status)){const isAuthorized=order?.payment_source?.payment_response?.resultCode==="Authorised",paymentDetails=order?.payment_source?.payment_request_details?.details!=null;if(paymentType==="adyen_payments"&&options?.adyen?.redirectResult&&!paymentDetails){const attributes={payment_request_details:{details:{redirectResult:options?.adyen?.redirectResult}},_details:1};setPaymentSource({paymentSourceId:paymentSource?.id,paymentResource:"adyen_payments",attributes}).then(res=>{const resultCode=res?.payment_response?.resultCode,errorCode=res?.payment_response?.errorCode,message=res?.payment_response?.message;["Authorised","Pending","Received"].includes(resultCode)&&autoPlaceOrder?handleClick():errorCode!=null&&setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message}])})}else paymentType==="adyen_payments"&&isAuthorized&&paymentDetails&&autoPlaceOrder&&status==="standby"&&!options?.adyen?.redirectResult&&order?.payment_source?.payment_response?.merchantReference?.includes(order?.number)&&handleClick()}},[options?.adyen?.redirectResult!=null,order?.payment_source?.payment_response?.resultCode]),useEffect(()=>{order?.status==="placed"&&order?.payment_status==="authorized"&&paymentType==="adyen_payments"&&onClick?.({placed:!0,order})},[order?.id,order?.payment_status,order?.status,paymentType!=null]),useEffect(()=>{if(console.log("Checkout.com redirect flow",{order,status}),paymentType==="checkout_com_payments"&&options?.checkoutCom?.session_id&&order?.status&&["draft","pending"].includes(order?.status)&&autoPlaceOrder){const paymentStatus=order?.payment_source?.payment_response?.status;if(paymentStatus&&paymentStatus.toLowerCase()==="pending"){async function placingOrder(){const paymentStatus2=(await setPaymentSource({paymentSourceId:paymentSource?.id,paymentResource:"checkout_com_payments",attributes:{_details:1}}))?.payment_response?.status,isValidStatus=["authorized","captured"].includes(paymentStatus2?.toLowerCase());paymentStatus2&&isValidStatus?handleClick():(options?.checkoutCom&&(options.checkoutCom.session_id=void 0),setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:paymentStatus2}]))}placingOrder()}}else if(paymentType==="checkout_com_payments"&&order?.status&&status&&["pending"].includes(order?.status)&&["placing"].includes(status)&&autoPlaceOrder){console.log("Placing order with Checkout.com express payments");const paymentSourceStatus=order?.payment_source?.payment_response?.status;console.log("Payment source status:",paymentSourceStatus),paymentSourceStatus&&["captured","authorized"].includes(paymentSourceStatus.toLowerCase())&&setPlaceOrder?.({paymentSource}).then(placed=>{placed?.placed?(onClick?.(placed),setPlaceOrderStatus?.({status:"placing"})):setPlaceOrderStatus?.({status:"standby"})})}},[options?.checkoutCom?.session_id,order?.payment_source?.id,status]),useEffect(()=>{ref?.current!=null&&setButtonRef!=null&&setButtonRef(ref)},[ref?.current]),useEffect(()=>{switch(status){case"disabled":case"placing":setNotPermitted(!0);break;default:setNotPermitted(!1);break}},[status!=null]);const handleClick=async e=>{e?.preventDefault(),e?.stopPropagation();const sdk=sdkClient();if(sdk==null||order==null)return;if(!(paymentType==="stripe_payments")){const{status:status2}=await sdk.orders.retrieve(order?.id,{fields:["status"]}),isAlreadyPlaced=status2==="placed",isDraftOrder=status2==="draft";if(isAlreadyPlaced){setPlaceOrderStatus?.({status:"placing"}),onClick?.({placed:!0,order});return}if(isDraftOrder){setPlaceOrderStatus?.({status:"standby"}),onClick?.({placed:!1,order,errors:[{code:"VALIDATION_ERROR",resource:"orders",message:"Draft order cannot be placed"}]}),setOrderErrors([{code:"VALIDATION_ERROR",resource:"orders",message:"Draft order cannot be placed"}]);return}}setIsLoading(!0);let isValid=!0;const checkPaymentSource=paymentType!=="stripe_payments"?await setPaymentSource({paymentResource:paymentType,paymentSourceId:paymentSource?.id}):paymentSource,card=paymentType&&getCardDetails({paymentType,customerPayment:{payment_source:checkPaymentSource}});currentPaymentMethodRef?.current?.onsubmit&&[!options?.paypalPayerId,!options?.adyen?.MD,!options?.checkoutCom?.session_id].every(Boolean)?(isValid=await currentPaymentMethodRef.current?.onsubmit({paymentSource:checkPaymentSource,setPlaceOrder,onclickCallback:onClick}),!isValid&&checkPaymentSource?.payment_response?.resultCode==="Authorised"&&(isValid=!0)):currentPaymentMethodRef?.current?.onsubmit&&options?.checkoutCom?.session_id&&checkPaymentSource?.payment_response?.status&&checkPaymentSource?.payment_response?.status?.toLowerCase()==="declined"?isValid=await currentPaymentMethodRef.current?.onsubmit({paymentSource:checkPaymentSource,setPlaceOrder,onclickCallback:onClick}):card?.brand&&(isValid=!0),isValid&&setPlaceOrderStatus!=null&&(setPlaceOrderStatus({status:"placing"}),setForceDisable(!0));const placed=isValid&&setPlaceOrder&&(checkPaymentSource||isFree)&&await setPlaceOrder({paymentSource:checkPaymentSource,currentCustomerPaymentSourceId});placed&&setPlaceOrderStatus!=null&&(placed.placed?(setPlaceOrderStatus({status:"placing"}),onClick?.(placed)):(setForceDisable(!1),onClick?.(placed),setIsLoading(!1),setPlaceOrderStatus({status:"standby"})))},disabledButton=disabled!==void 0?disabled:notPermitted,labelButton=isLoading?loadingLabel:isFunction(label)?label():label,parentProps={...p,label,disabled:disabledButton,handleClick,parentRef:ref,isLoading};return children?_jsx(Parent,{...parentProps,children}):_jsx("button",{ref,type:"button",disabled:disabledButton||forceDisable,onClick:e=>{handleClick(e)},...p,children:labelButton})}export default PlaceOrderButton;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useContext,useEffect,useRef}from"react";import Parent from"../utils/Parent";import CommerceLayerContext from"../../context/CommerceLayerContext";import OrderContext from"../../context/OrderContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import PlaceOrderContext from"../../context/PlaceOrderContext";import useExternalScript from"../../utils/hooks/useExternalScript";import{jwt}from"../../utils/jwt";import{setCustomerOrderParam}from"../../utils/localStorage";const scriptUrl="https://checkout-web-components.checkout.com/index.js";export function CheckoutComPayment({publicKey,options,...p}){const ref=useRef(null),loaded=useExternalScript(scriptUrl),{setPaymentRef,setPaymentSource}=useContext(PaymentMethodContext),{accessToken}=useContext(CommerceLayerContext),{order}=useContext(OrderContext),{setPlaceOrderStatus}=useContext(PlaceOrderContext),{containerClassName,templateCustomerSaveToWallet,show,...divProps}=p;return useEffect(()=>{const ps=order?.payment_source;if(loaded&&window&&ps&&accessToken){const publicKey2=ps.public_key,paymentSession=ps.payment_session;if(window?.CheckoutWebComponents){const environment=jwt(accessToken).test?"sandbox":"production",locale=order?.language_code??"en";(async()=>{(await window.CheckoutWebComponents({appearance:{...options?.appearance},showPayButton:!1,publicKey:publicKey2,environment,locale,paymentSession,componentOptions:{card:{displayCardholderName:"hidden"}},onChange:component=>{ref.current&&component.isValid()&&(ref.current.onsubmit=async()=>{const savePaymentSourceToCustomerWallet=ref.current?.elements?.save_payment_source_to_customer_wallet?.checked;savePaymentSourceToCustomerWallet&&setCustomerOrderParam("_save_payment_source_to_customer_wallet",savePaymentSourceToCustomerWallet);const{data}=await component.tokenize(),token=data?.token,paymentSource=await setPaymentSource({paymentSourceId:ps.id,paymentResource:"checkout_com_payments",attributes:{token,_authorize:!0}});if(paymentSource){const response=paymentSource.payment_response,securityRedirect=paymentSource?.redirect_uri;return response?.status.toLowerCase()==="pending"&&securityRedirect?(window.location.href=securityRedirect,!1):!0}return!1},setPaymentRef?.({ref}))},onError:(component,error)=>{console.error("onError",{error},"Component",component.type)},onPaymentCompleted:async(_component,paymentResponse)=>{paymentResponse.status.toLowerCase()==="approved"&&(await setPaymentSource({paymentSourceId:ps.id,paymentResource:"checkout_com_payments",attributes:{token:paymentResponse.id,_authorize:!0}}),setPlaceOrderStatus?.({status:"placing"}))}})).create("flow").mount(document.getElementById("flow-container"))})()}}},[loaded,order?.payment_source?.id,accessToken]),loaded&&show?_jsxs("form",{ref,children:[_jsx("div",{className:containerClassName,...divProps,children:_jsx("div",{id:"flow-container"})}),templateCustomerSaveToWallet&&_jsx(Parent,{name:"save_payment_source_to_customer_wallet",children:templateCustomerSaveToWallet})]}):null}export default CheckoutComPayment;
|
|
2
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useContext,useEffect,useRef}from"react";import Parent from"../utils/Parent";import CommerceLayerContext from"../../context/CommerceLayerContext";import OrderContext from"../../context/OrderContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import PlaceOrderContext from"../../context/PlaceOrderContext";import useExternalScript from"../../utils/hooks/useExternalScript";import{jwt}from"../../utils/jwt";import{setCustomerOrderParam}from"../../utils/localStorage";const scriptUrl="https://checkout-web-components.checkout.com/index.js";export function CheckoutComPayment({publicKey,options,...p}){const ref=useRef(null),loaded=useExternalScript(scriptUrl),{setPaymentRef,setPaymentSource}=useContext(PaymentMethodContext),{accessToken}=useContext(CommerceLayerContext),{order}=useContext(OrderContext),{setPlaceOrderStatus}=useContext(PlaceOrderContext),{containerClassName,templateCustomerSaveToWallet,show,...divProps}=p;return useEffect(()=>{const ps=order?.payment_source;if(loaded&&window&&ps&&accessToken){const publicKey2=ps.public_key,paymentSession=ps.payment_session;if(window?.CheckoutWebComponents){const environment=jwt(accessToken).test?"sandbox":"production",locale=order?.language_code??"en";(async()=>{(await window.CheckoutWebComponents({appearance:{...options?.appearance},showPayButton:!1,publicKey:publicKey2,environment,locale,paymentSession,componentOptions:{card:{displayCardholderName:"hidden"}},onChange:component=>{ref.current&&component.isValid()&&(ref.current.onsubmit=async()=>{const savePaymentSourceToCustomerWallet=ref.current?.elements?.save_payment_source_to_customer_wallet?.checked;savePaymentSourceToCustomerWallet&&setCustomerOrderParam("_save_payment_source_to_customer_wallet",savePaymentSourceToCustomerWallet);const{data}=await component.tokenize(),token=data?.token,paymentSource=await setPaymentSource({paymentSourceId:ps.id,paymentResource:"checkout_com_payments",attributes:{token,_authorize:!0}});if(paymentSource){const response=paymentSource.payment_response,securityRedirect=paymentSource?.redirect_uri;return response?.status.toLowerCase()==="pending"&&securityRedirect?(window.location.href=securityRedirect,!1):!0}return!1},setPaymentRef?.({ref}))},onError:(component,error)=>{console.error("onError",{error},"Component",component.type)},onPaymentCompleted:async(_component,paymentResponse)=>{console.log("onPaymentCompleted",{paymentResponse}),paymentResponse.status.toLowerCase()==="approved"&&(await setPaymentSource({paymentSourceId:ps.id,paymentResource:"checkout_com_payments",attributes:{token:paymentResponse.id,_authorize:!0}}),setPlaceOrderStatus?.({status:"placing"}))}})).create("flow").mount(document.getElementById("flow-container"))})()}}},[loaded,order?.payment_source?.id,accessToken]),loaded&&show?_jsxs("form",{ref,children:[_jsx("div",{className:containerClassName,...divProps,children:_jsx("div",{id:"flow-container"})}),templateCustomerSaveToWallet&&_jsx(Parent,{name:"save_payment_source_to_customer_wallet",children:templateCustomerSaveToWallet})]}):null}export default CheckoutComPayment;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{Elements,PaymentElement,useElements}from"@stripe/react-stripe-js";import{useContext,useEffect,useRef,useState}from"react";import Parent from"../utils/Parent";import OrderContext from"../../context/OrderContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import PlaceOrderContext from"../../context/PlaceOrderContext";import useCommerceLayer from"../../hooks/useCommerceLayer";import{setCustomerOrderParam}from"../../utils/localStorage";import{StripeExpressPayment}from"./StripeExpressPayment";const defaultOptions={layout:{type:"accordion",defaultCollapsed:!1,radios:!0,spacedAccordionItems:!1},fields:{billingDetails:"never"}},defaultAppearance={theme:"stripe",variables:{colorText:"#32325d",fontFamily:'"Helvetica Neue", Helvetica, sans-serif'}};let selectedPaymentMethodType=null;function StripePaymentForm({options=defaultOptions,templateCustomerSaveToWallet,stripe}){const ref=useRef(null),{currentPaymentMethodType,setPaymentMethodErrors,setPaymentRef}=useContext(PaymentMethodContext),{order,setOrderErrors}=useContext(OrderContext),{sdkClient}=useCommerceLayer(),{setPlaceOrderStatus}=useContext(PlaceOrderContext),elements=useElements();useEffect(()=>(ref.current&&stripe&&elements&&(ref.current.onsubmit=async()=>await onSubmit({event:ref.current,stripe,elements}),setPaymentRef({ref})),()=>{setPaymentRef({ref:{current:null}})}),[ref,stripe,elements]);const onSubmit=async({event,stripe:stripe2,elements:elements2})=>{if(!stripe2)return!1;const sdk=sdkClient();if(sdk==null||order==null)return!1;if(selectedPaymentMethodType&&!["apple_pay","google_pay"].includes(selectedPaymentMethodType)){const{status}=await sdk.orders.retrieve(order?.id,{fields:["status"]});if(status==="draft")return setOrderErrors([{code:"VALIDATION_ERROR",resource:"orders",message:"Draft order cannot be placed"}]),setPlaceOrderStatus?.({status:"disabled"}),!1}const savePaymentSourceToCustomerWallet=event?.elements?.save_payment_source_to_customer_wallet?.checked;if(savePaymentSourceToCustomerWallet&&setCustomerOrderParam("_save_payment_source_to_customer_wallet",savePaymentSourceToCustomerWallet),elements2!=null){const billingInfo=order?.billing_address,email=order?.customer_email??"",billingDetails={name:billingInfo?.full_name??"",email,phone:billingInfo?.phone,address:{city:billingInfo?.city,country:billingInfo?.country_code,line1:billingInfo?.line_1,line2:billingInfo?.line_2??"",postal_code:billingInfo?.zip_code??"",state:billingInfo?.state_code}},url=new URL(window.location.href),cleanUrl=`${url.origin}${url.pathname}?accessToken=${url.searchParams.get("accessToken")}`,{error}=await stripe2.confirmPayment({elements:elements2,confirmParams:{return_url:cleanUrl,payment_method_data:{billing_details:billingDetails}},redirect:"if_required"});return error?(console.error(error),setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:error.message??""}]),!1):!0}return!1};async function handleChange(event){if(console.debug("StripePaymentElement onChange event",{event}),selectedPaymentMethodType=event.value.type,event.complete&&["apple_pay","google_pay"].includes(event.value.type)){const sdk=sdkClient();if(sdk==null||order==null)return;const{status}=await sdk.orders.retrieve(order?.id,{fields:["status"]});if(status==="draft"){setOrderErrors([{code:"VALIDATION_ERROR",resource:"orders",message:"Draft order cannot be placed"}]),setPlaceOrderStatus?.({status:"disabled"});return}}}return _jsxs("form",{ref,children:[_jsx(PaymentElement,{id:"payment-element",options:{...defaultOptions,...options},onChange:handleChange}),templateCustomerSaveToWallet&&_jsx(Parent,{name:"save_payment_source_to_customer_wallet",children:templateCustomerSaveToWallet})]})}export function StripePayment({publishableKey,show,options,clientSecret,locale="auto",expressPayments=!1,connectedAccount,...p}){const[isLoaded,setIsLoaded]=useState(!1),[stripe,setStripe]=useState(null),{containerClassName,templateCustomerSaveToWallet,fonts=[],appearance,...divProps}=p;useEffect(()=>(show&&publishableKey&&import("@stripe/stripe-js").then(({loadStripe})=>{(async()=>{const options2={locale,...connectedAccount?{stripeAccount:connectedAccount}:{}},res=await loadStripe(publishableKey,options2);res!=null?(setStripe(res),setIsLoaded(!0)):(console.error("Stripe failed to load"),setIsLoaded(!1))})()}),()=>{setIsLoaded(!1)}),[show,publishableKey,connectedAccount]);const elementsOptions={clientSecret,appearance:{...defaultAppearance,...appearance},fonts};return isLoaded&&stripe!=null&&clientSecret!=null?_jsx("div",{className:containerClassName,...divProps,children:_jsx(Elements,{stripe,options:elementsOptions,children:expressPayments?_jsx(StripeExpressPayment,{clientSecret}):_jsx(StripePaymentForm,{stripe,options,templateCustomerSaveToWallet})})}):null}export default StripePayment;
|
|
2
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{Elements,PaymentElement,useElements}from"@stripe/react-stripe-js";import{useContext,useEffect,useRef,useState}from"react";import Parent from"../utils/Parent";import OrderContext from"../../context/OrderContext";import PaymentMethodContext from"../../context/PaymentMethodContext";import PlaceOrderContext from"../../context/PlaceOrderContext";import useCommerceLayer from"../../hooks/useCommerceLayer";import{setCustomerOrderParam}from"../../utils/localStorage";import{StripeExpressPayment}from"./StripeExpressPayment";const defaultOptions={layout:{type:"accordion",defaultCollapsed:!1,radios:!0,spacedAccordionItems:!1},fields:{billingDetails:"never"}},defaultAppearance={theme:"stripe",variables:{colorText:"#32325d",fontFamily:'"Helvetica Neue", Helvetica, sans-serif'}};let selectedPaymentMethodType=null;function StripePaymentForm({options=defaultOptions,templateCustomerSaveToWallet,stripe}){const ref=useRef(null),{currentPaymentMethodType,setPaymentMethodErrors,setPaymentRef}=useContext(PaymentMethodContext),{order,setOrderErrors}=useContext(OrderContext),{sdkClient}=useCommerceLayer(),{setPlaceOrderStatus}=useContext(PlaceOrderContext),elements=useElements();useEffect(()=>(ref.current&&stripe&&elements&&(ref.current.onsubmit=async()=>await onSubmit({event:ref.current,stripe,elements}),setPaymentRef({ref})),()=>{setPaymentRef({ref:{current:null}})}),[ref,stripe,elements]);const onSubmit=async({event,stripe:stripe2,elements:elements2})=>{if(!stripe2)return!1;const sdk=sdkClient();if(sdk==null||order==null)return!1;if(selectedPaymentMethodType&&!["apple_pay","google_pay"].includes(selectedPaymentMethodType)){const{status}=await sdk.orders.retrieve(order?.id,{fields:["status"]});if(status==="draft")return setOrderErrors([{code:"VALIDATION_ERROR",resource:"orders",message:"Draft order cannot be placed"}]),setPlaceOrderStatus?.({status:"disabled"}),!1}const savePaymentSourceToCustomerWallet=event?.elements?.save_payment_source_to_customer_wallet?.checked;if(savePaymentSourceToCustomerWallet&&setCustomerOrderParam("_save_payment_source_to_customer_wallet",savePaymentSourceToCustomerWallet),elements2!=null){const billingInfo=order?.billing_address,email=order?.customer_email??"",billingDetails={name:billingInfo?.full_name??"",email,phone:billingInfo?.phone,address:{city:billingInfo?.city,country:billingInfo?.country_code,line1:billingInfo?.line_1,line2:billingInfo?.line_2??"",postal_code:billingInfo?.zip_code??"",state:billingInfo?.state_code}},url=new URL(window.location.href),cleanUrl=`${url.origin}${url.pathname}?accessToken=${url.searchParams.get("accessToken")}`,{error,paymentIntent}=await stripe2.confirmPayment({elements:elements2,confirmParams:{return_url:cleanUrl,payment_method_data:{billing_details:billingDetails}},redirect:"if_required"});return console.log({paymentIntent}),error?(console.error(error),setPaymentMethodErrors([{code:"PAYMENT_INTENT_AUTHENTICATION_FAILURE",resource:"payment_methods",field:currentPaymentMethodType,message:error.message??""}]),!1):!0}return!1};async function handleChange(event){if(console.debug("StripePaymentElement onChange event",{event}),selectedPaymentMethodType=event.value.type,event.complete&&["apple_pay","google_pay"].includes(event.value.type)){const sdk=sdkClient();if(sdk==null||order==null)return;const{status}=await sdk.orders.retrieve(order?.id,{fields:["status"]});if(status==="draft"){setOrderErrors([{code:"VALIDATION_ERROR",resource:"orders",message:"Draft order cannot be placed"}]),setPlaceOrderStatus?.({status:"disabled"});return}}}return _jsxs("form",{ref,children:[_jsx(PaymentElement,{id:"payment-element",options:{...defaultOptions,...options},onChange:handleChange}),templateCustomerSaveToWallet&&_jsx(Parent,{name:"save_payment_source_to_customer_wallet",children:templateCustomerSaveToWallet})]})}export function StripePayment({publishableKey,show,options,clientSecret,locale="auto",expressPayments=!1,connectedAccount,...p}){const[isLoaded,setIsLoaded]=useState(!1),[stripe,setStripe]=useState(null),{containerClassName,templateCustomerSaveToWallet,fonts=[],appearance,...divProps}=p;useEffect(()=>(show&&publishableKey&&import("@stripe/stripe-js").then(({loadStripe})=>{(async()=>{const options2={locale,...connectedAccount?{stripeAccount:connectedAccount}:{}},res=await loadStripe(publishableKey,options2);res!=null?(setStripe(res),setIsLoaded(!0)):(console.error("Stripe failed to load"),setIsLoaded(!1))})()}),()=>{setIsLoaded(!1)}),[show,publishableKey,connectedAccount]);const elementsOptions={clientSecret,appearance:{...defaultAppearance,...appearance},fonts};return isLoaded&&stripe!=null&&clientSecret!=null?_jsx("div",{className:containerClassName,...divProps,children:_jsx(Elements,{stripe,options:elementsOptions,children:expressPayments?_jsx(StripeExpressPayment,{clientSecret}):_jsx(StripePaymentForm,{stripe,options,templateCustomerSaveToWallet})})}):null}export default StripePayment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../src/index.ts","../src/components/ExternalFunction.tsx","../src/components/MetadataInput.tsx","../src/components/SubmitButton.tsx","../src/components/addresses/Address.tsx","../src/components/addresses/AddressCountrySelector.tsx","../src/components/addresses/AddressField.tsx","../src/components/addresses/AddressInput.tsx","../src/components/addresses/AddressInputSelect.tsx","../src/components/addresses/AddressStateSelector.tsx","../src/components/addresses/AddressesContainer.tsx","../src/components/addresses/AddressesEmpty.tsx","../src/components/addresses/BillingAddressContainer.tsx","../src/components/addresses/BillingAddressForm.tsx","../src/components/addresses/SaveAddressesButton.tsx","../src/components/addresses/ShippingAddressContainer.tsx","../src/components/addresses/ShippingAddressForm.tsx","../src/components/auth/CommerceLayer.tsx","../src/components/customers/CustomerAddressForm.tsx","../src/components/customers/CustomerContainer.tsx","../src/components/customers/CustomerField.tsx","../src/components/customers/CustomerInput.tsx","../src/components/customers/CustomerPaymentSource.tsx","../src/components/customers/CustomerPaymentSourceEmpty.tsx","../src/components/customers/MyAccountLink.tsx","../src/components/customers/MyIdentityLink.tsx","../src/components/customers/SaveCustomerButton.tsx","../src/components/errors/Errors.tsx","../src/components/gift_cards/GiftCard.tsx","../src/components/gift_cards/GiftCardContainer.tsx","../src/components/gift_cards/GiftCardCurrencySelector.tsx","../src/components/gift_cards/GiftCardInput.tsx","../src/components/gift_cards/GiftCardOrCouponCode.tsx","../src/components/gift_cards/GiftCardOrCouponForm.tsx","../src/components/gift_cards/GiftCardOrCouponInput.tsx","../src/components/gift_cards/GiftCardOrCouponRemoveButton.tsx","../src/components/gift_cards/GiftCardOrCouponSubmit.tsx","../src/components/gift_cards/GiftCardRecipientInput.tsx","../src/components/in_stock_subscriptions/InStockSubscriptionButton.tsx","../src/components/in_stock_subscriptions/InStockSubscriptionsContainer.tsx","../src/components/line_items/LineItem.tsx","../src/components/line_items/LineItemAmount.tsx","../src/components/line_items/LineItemCode.tsx","../src/components/line_items/LineItemField.tsx","../src/components/line_items/LineItemImage.tsx","../src/components/line_items/LineItemName.tsx","../src/components/line_items/LineItemOption.tsx","../src/components/line_items/LineItemOptions.tsx","../src/components/line_items/LineItemQuantity.tsx","../src/components/line_items/LineItemRemoveLink.tsx","../src/components/line_items/LineItemsContainer.tsx","../src/components/line_items/LineItemsCount.tsx","../src/components/line_items/LineItemsEmpty.tsx","../src/components/orders/AddToCartButton.tsx","../src/components/orders/AdjustmentAmount.tsx","../src/components/orders/CartLink.tsx","../src/components/orders/CheckoutLink.tsx","../src/components/orders/DiscountAmount.tsx","../src/components/orders/GiftCardAmount.tsx","../src/components/orders/HostedCart.tsx","../src/components/orders/OrderContainer.tsx","../src/components/orders/OrderList.tsx","../src/components/orders/OrderListEmpty.tsx","../src/components/orders/OrderListPaginationButtons.tsx","../src/components/orders/OrderListPaginationInfo.tsx","../src/components/orders/OrderListRow.tsx","../src/components/orders/OrderNumber.tsx","../src/components/orders/OrderStorage.tsx","../src/components/orders/PaymentMethodAmount.tsx","../src/components/orders/PlaceOrderButton.tsx","../src/components/orders/PlaceOrderContainer.tsx","../src/components/orders/PrivacyAndTermsCheckbox.tsx","../src/components/orders/ShippingAmount.tsx","../src/components/orders/SubTotalAmount.tsx","../src/components/orders/TaxesAmount.tsx","../src/components/orders/TotalAmount.tsx","../src/components/parcels/ParcelField.tsx","../src/components/parcels/ParcelLineItem.tsx","../src/components/parcels/ParcelLineItemField.tsx","../src/components/parcels/ParcelLineItemsCount.tsx","../src/components/parcels/Parcels.tsx","../src/components/parcels/ParcelsCount.tsx","../src/components/payment_gateways/AdyenGateway.tsx","../src/components/payment_gateways/BraintreeGateway.tsx","../src/components/payment_gateways/CheckoutComGateway.tsx","../src/components/payment_gateways/ExternalGateway.tsx","../src/components/payment_gateways/KlarnaGateway.tsx","../src/components/payment_gateways/PaymentGateway.tsx","../src/components/payment_gateways/PaypalGateway.tsx","../src/components/payment_gateways/StripeGateway.tsx","../src/components/payment_gateways/WireTransferGateway.tsx","../src/components/payment_methods/PaymentMethod.tsx","../src/components/payment_methods/PaymentMethodName.tsx","../src/components/payment_methods/PaymentMethodPrice.tsx","../src/components/payment_methods/PaymentMethodRadioButton.tsx","../src/components/payment_methods/PaymentMethodsContainer.tsx","../src/components/payment_source/AdyenPayment.tsx","../src/components/payment_source/BraintreePayment.tsx","../src/components/payment_source/CheckoutComPayment.tsx","../src/components/payment_source/ExternalPayment.tsx","../src/components/payment_source/KlarnaPayment.tsx","../src/components/payment_source/PaymentSource.tsx","../src/components/payment_source/PaymentSourceBrandIcon.tsx","../src/components/payment_source/PaymentSourceBrandName.tsx","../src/components/payment_source/PaymentSourceDetail.tsx","../src/components/payment_source/PaymentSourceEditButton.tsx","../src/components/payment_source/PaypalPayment.tsx","../src/components/payment_source/StripeExpressPayment.tsx","../src/components/payment_source/StripePayment.tsx","../src/components/payment_source/WireTransferPayment.tsx","../src/components/prices/Price.tsx","../src/components/prices/PricesContainer.tsx","../src/components/shipments/Shipment.tsx","../src/components/shipments/ShipmentField.tsx","../src/components/shipments/ShipmentsContainer.tsx","../src/components/shipments/ShipmentsCount.tsx","../src/components/shipping_methods/ShippingMethod.tsx","../src/components/shipping_methods/ShippingMethodName.tsx","../src/components/shipping_methods/ShippingMethodPrice.tsx","../src/components/shipping_methods/ShippingMethodRadioButton.tsx","../src/components/skus/AvailabilityContainer.tsx","../src/components/skus/AvailabilityTemplate.tsx","../src/components/skus/DeliveryLeadTime.tsx","../src/components/skus/SkuField.tsx","../src/components/skus/SkuList.tsx","../src/components/skus/SkuListsContainer.tsx","../src/components/skus/Skus.tsx","../src/components/skus/SkusContainer.tsx","../src/components/stock_transfers/StockTransfer.tsx","../src/components/stock_transfers/StockTransferField.tsx","../src/components/utils/AddressCardsTemplate.tsx","../src/components/utils/BaseField.tsx","../src/components/utils/BaseInput.tsx","../src/components/utils/BaseOrderPrice.tsx","../src/components/utils/BaseSelect.tsx","../src/components/utils/ErrorBoundary.tsx","../src/components/utils/GenericFieldComponent.tsx","../src/components/utils/Parent.tsx","../src/components/utils/PaymentCardsTemplate.tsx","../src/components/utils/PriceTemplate.tsx","../src/components/utils/getAllErrors.tsx","../src/config/currency.ts","../src/context/AddressChildrenContext.ts","../src/context/AddressContext.ts","../src/context/AvailabilityContext.ts","../src/context/BillingAddressContext.ts","../src/context/BillingAddressFormContext.ts","../src/context/CommerceLayerContext.ts","../src/context/CouponAndGiftCardFormContext.ts","../src/context/CustomerAddressFormContext.ts","../src/context/CustomerContext.ts","../src/context/CustomerPaymentSourceContext.ts","../src/context/ExternalFunctionContext.ts","../src/context/GiftCardContext.ts","../src/context/InStockSubscriptionContext.ts","../src/context/LineItemChildrenContext.ts","../src/context/LineItemContext.ts","../src/context/LineItemOptionChildrenContext.ts","../src/context/OrderContext.ts","../src/context/OrderListChildrenContext.ts","../src/context/OrderListPaginationContext.ts","../src/context/OrderStorageContext.ts","../src/context/ParcelChildrenContext.ts","../src/context/ParcelLineItemChildrenContext.ts","../src/context/PaymentMethodChildrenContext.ts","../src/context/PaymentMethodContext.ts","../src/context/PaymentSourceContext.ts","../src/context/PlaceOrderContext.ts","../src/context/PricesContext.ts","../src/context/ShipmentChildrenContext.ts","../src/context/ShipmentContext.ts","../src/context/ShippingAddressContext.ts","../src/context/ShippingAddressFormContext.ts","../src/context/ShippingMethodChildrenContext.ts","../src/context/SkuChildrenContext.ts","../src/context/SkuContext.ts","../src/context/SkuListsContext.ts","../src/context/StockTransferChildrenContext.ts","../src/hooks/useCommerceLayer.ts","../src/hooks/useCustomerContainer.ts","../src/hooks/useOrderContainer.ts","../src/reducers/AddressReducer.ts","../src/reducers/AvailabilityReducer.ts","../src/reducers/BillingAddressReducer.ts","../src/reducers/CustomerReducer.ts","../src/reducers/GiftCardReducer.ts","../src/reducers/InStockSubscriptionReducer.ts","../src/reducers/LineItemReducer.ts","../src/reducers/OrderReducer.ts","../src/reducers/PaymentMethodReducer.ts","../src/reducers/PlaceOrderReducer.ts","../src/reducers/PriceReducer.ts","../src/reducers/ShipmentReducer.ts","../src/reducers/ShippingAddressReducer.ts","../src/reducers/SkuListsReducer.ts","../src/reducers/SkuReducer.ts","../src/typings/environment.d.ts","../src/typings/errors.ts","../src/typings/globals.ts","../src/typings/index.ts","../src/utils/PropsType.ts","../src/utils/addressesManager.ts","../src/utils/baseReducer.ts","../src/utils/browserInfo.ts","../src/utils/canPlaceOrder.ts","../src/utils/checkIncludeResource.ts","../src/utils/compareObjAttribute.ts","../src/utils/countryStateCity.ts","../src/utils/customMessages.ts","../src/utils/customerOrderOptions.ts","../src/utils/events.ts","../src/utils/expressPaymentHelper.ts","../src/utils/filterChildren.ts","../src/utils/formCleaner.ts","../src/utils/getAmount.ts","../src/utils/getApplicationLink.ts","../src/utils/getCardDetails.ts","../src/utils/getCustomerIdByToken.ts","../src/utils/getDomain.ts","../src/utils/getErrors.ts","../src/utils/getLineItemsCount.ts","../src/utils/getLoaderComponent.tsx","../src/utils/getPaymentAttributes.ts","../src/utils/getPrices.tsx","../src/utils/getPublicIp.ts","../src/utils/getSdk.ts","../src/utils/getSkus.ts","../src/utils/hasSubscriptions.ts","../src/utils/icons.tsx","../src/utils/isDate.ts","../src/utils/isEmpty.ts","../src/utils/isGuestToken.ts","../src/utils/isJSON.ts","../src/utils/jwt.ts","../src/utils/localStorage.ts","../src/utils/omit.ts","../src/utils/organization.ts","../src/utils/pick.ts","../src/utils/placeholderImages.ts","../src/utils/promisify.ts","../src/utils/replace.ts","../src/utils/scrollbarWidth.ts","../src/utils/shipments.ts","../src/utils/snakeToCamelCase.ts","../src/utils/triggerAttributeHelper.ts","../src/utils/updateOrderSubscriptionCustomerPaymentSource.ts","../src/utils/validateFormFields.ts","../src/utils/adyen/manageGiftCard.ts","../src/utils/hooks/useCustomContext.ts","../src/utils/hooks/useExternalScript.ts","../src/utils/payment-methods/sortPaymentMethods.ts","../src/utils/stripe/retrievePaymentIntent.ts"],"version":"5.8.3"}
|
|
1
|
+
{"root":["../src/index.ts","../src/components/ExternalFunction.tsx","../src/components/MetadataInput.tsx","../src/components/SubmitButton.tsx","../src/components/addresses/Address.tsx","../src/components/addresses/AddressCountrySelector.tsx","../src/components/addresses/AddressField.tsx","../src/components/addresses/AddressInput.tsx","../src/components/addresses/AddressInputSelect.tsx","../src/components/addresses/AddressStateSelector.tsx","../src/components/addresses/AddressesContainer.tsx","../src/components/addresses/AddressesEmpty.tsx","../src/components/addresses/BillingAddressContainer.tsx","../src/components/addresses/BillingAddressForm.tsx","../src/components/addresses/SaveAddressesButton.tsx","../src/components/addresses/ShippingAddressContainer.tsx","../src/components/addresses/ShippingAddressForm.tsx","../src/components/auth/CommerceLayer.tsx","../src/components/customers/CustomerAddressForm.tsx","../src/components/customers/CustomerContainer.tsx","../src/components/customers/CustomerField.tsx","../src/components/customers/CustomerInput.tsx","../src/components/customers/CustomerPaymentSource.tsx","../src/components/customers/CustomerPaymentSourceEmpty.tsx","../src/components/customers/MyAccountLink.tsx","../src/components/customers/MyIdentityLink.tsx","../src/components/customers/SaveCustomerButton.tsx","../src/components/errors/Errors.tsx","../src/components/gift_cards/GiftCard.tsx","../src/components/gift_cards/GiftCardContainer.tsx","../src/components/gift_cards/GiftCardCurrencySelector.tsx","../src/components/gift_cards/GiftCardInput.tsx","../src/components/gift_cards/GiftCardOrCouponCode.tsx","../src/components/gift_cards/GiftCardOrCouponForm.tsx","../src/components/gift_cards/GiftCardOrCouponInput.tsx","../src/components/gift_cards/GiftCardOrCouponRemoveButton.tsx","../src/components/gift_cards/GiftCardOrCouponSubmit.tsx","../src/components/gift_cards/GiftCardRecipientInput.tsx","../src/components/in_stock_subscriptions/InStockSubscriptionButton.tsx","../src/components/in_stock_subscriptions/InStockSubscriptionsContainer.tsx","../src/components/line_items/LineItem.tsx","../src/components/line_items/LineItemAmount.tsx","../src/components/line_items/LineItemCode.tsx","../src/components/line_items/LineItemField.tsx","../src/components/line_items/LineItemImage.tsx","../src/components/line_items/LineItemName.tsx","../src/components/line_items/LineItemOption.tsx","../src/components/line_items/LineItemOptions.tsx","../src/components/line_items/LineItemQuantity.tsx","../src/components/line_items/LineItemRemoveLink.tsx","../src/components/line_items/LineItemsContainer.tsx","../src/components/line_items/LineItemsCount.tsx","../src/components/line_items/LineItemsEmpty.tsx","../src/components/orders/AddToCartButton.tsx","../src/components/orders/AdjustmentAmount.tsx","../src/components/orders/CartLink.tsx","../src/components/orders/CheckoutLink.tsx","../src/components/orders/DiscountAmount.tsx","../src/components/orders/GiftCardAmount.tsx","../src/components/orders/HostedCart.tsx","../src/components/orders/OrderContainer.tsx","../src/components/orders/OrderList.tsx","../src/components/orders/OrderListEmpty.tsx","../src/components/orders/OrderListPaginationButtons.tsx","../src/components/orders/OrderListPaginationInfo.tsx","../src/components/orders/OrderListRow.tsx","../src/components/orders/OrderNumber.tsx","../src/components/orders/OrderStorage.tsx","../src/components/orders/PaymentMethodAmount.tsx","../src/components/orders/PlaceOrderButton.tsx","../src/components/orders/PlaceOrderContainer.tsx","../src/components/orders/PrivacyAndTermsCheckbox.tsx","../src/components/orders/ShippingAmount.tsx","../src/components/orders/SubTotalAmount.tsx","../src/components/orders/TaxesAmount.tsx","../src/components/orders/TotalAmount.tsx","../src/components/parcels/ParcelField.tsx","../src/components/parcels/ParcelLineItem.tsx","../src/components/parcels/ParcelLineItemField.tsx","../src/components/parcels/ParcelLineItemsCount.tsx","../src/components/parcels/Parcels.tsx","../src/components/parcels/ParcelsCount.tsx","../src/components/payment_gateways/AdyenGateway.tsx","../src/components/payment_gateways/BraintreeGateway.tsx","../src/components/payment_gateways/CheckoutComGateway.tsx","../src/components/payment_gateways/ExternalGateway.tsx","../src/components/payment_gateways/KlarnaGateway.tsx","../src/components/payment_gateways/PaymentGateway.tsx","../src/components/payment_gateways/PaypalGateway.tsx","../src/components/payment_gateways/StripeGateway.tsx","../src/components/payment_gateways/WireTransferGateway.tsx","../src/components/payment_methods/PaymentMethod.tsx","../src/components/payment_methods/PaymentMethodName.tsx","../src/components/payment_methods/PaymentMethodPrice.tsx","../src/components/payment_methods/PaymentMethodRadioButton.tsx","../src/components/payment_methods/PaymentMethodsContainer.tsx","../src/components/payment_source/AdyenPayment.tsx","../src/components/payment_source/BraintreePayment.tsx","../src/components/payment_source/CheckoutComPayment.tsx","../src/components/payment_source/ExternalPayment.tsx","../src/components/payment_source/KlarnaPayment.tsx","../src/components/payment_source/PaymentSource.tsx","../src/components/payment_source/PaymentSourceBrandIcon.tsx","../src/components/payment_source/PaymentSourceBrandName.tsx","../src/components/payment_source/PaymentSourceDetail.tsx","../src/components/payment_source/PaymentSourceEditButton.tsx","../src/components/payment_source/PaypalPayment.tsx","../src/components/payment_source/StripeExpressPayment.tsx","../src/components/payment_source/StripePayment.tsx","../src/components/payment_source/WireTransferPayment.tsx","../src/components/prices/Price.tsx","../src/components/prices/PricesContainer.tsx","../src/components/shipments/Shipment.tsx","../src/components/shipments/ShipmentField.tsx","../src/components/shipments/ShipmentsContainer.tsx","../src/components/shipments/ShipmentsCount.tsx","../src/components/shipping_methods/ShippingMethod.tsx","../src/components/shipping_methods/ShippingMethodName.tsx","../src/components/shipping_methods/ShippingMethodPrice.tsx","../src/components/shipping_methods/ShippingMethodRadioButton.tsx","../src/components/skus/AvailabilityContainer.tsx","../src/components/skus/AvailabilityTemplate.tsx","../src/components/skus/DeliveryLeadTime.tsx","../src/components/skus/SkuField.tsx","../src/components/skus/SkuList.tsx","../src/components/skus/SkuListsContainer.tsx","../src/components/skus/Skus.tsx","../src/components/skus/SkusContainer.tsx","../src/components/stock_transfers/StockTransfer.tsx","../src/components/stock_transfers/StockTransferField.tsx","../src/components/utils/AddressCardsTemplate.tsx","../src/components/utils/BaseField.tsx","../src/components/utils/BaseInput.tsx","../src/components/utils/BaseOrderPrice.tsx","../src/components/utils/BaseSelect.tsx","../src/components/utils/ErrorBoundary.tsx","../src/components/utils/GenericFieldComponent.tsx","../src/components/utils/Parent.tsx","../src/components/utils/PaymentCardsTemplate.tsx","../src/components/utils/PriceTemplate.tsx","../src/components/utils/getAllErrors.tsx","../src/config/currency.ts","../src/context/AddressChildrenContext.ts","../src/context/AddressContext.ts","../src/context/AvailabilityContext.ts","../src/context/BillingAddressContext.ts","../src/context/BillingAddressFormContext.ts","../src/context/CommerceLayerContext.ts","../src/context/CouponAndGiftCardFormContext.ts","../src/context/CustomerAddressFormContext.ts","../src/context/CustomerContext.ts","../src/context/CustomerPaymentSourceContext.ts","../src/context/ExternalFunctionContext.ts","../src/context/GiftCardContext.ts","../src/context/InStockSubscriptionContext.ts","../src/context/LineItemChildrenContext.ts","../src/context/LineItemContext.ts","../src/context/LineItemOptionChildrenContext.ts","../src/context/OrderContext.ts","../src/context/OrderListChildrenContext.ts","../src/context/OrderListPaginationContext.ts","../src/context/OrderStorageContext.ts","../src/context/ParcelChildrenContext.ts","../src/context/ParcelLineItemChildrenContext.ts","../src/context/PaymentMethodChildrenContext.ts","../src/context/PaymentMethodContext.ts","../src/context/PaymentSourceContext.ts","../src/context/PlaceOrderContext.ts","../src/context/PricesContext.ts","../src/context/ShipmentChildrenContext.ts","../src/context/ShipmentContext.ts","../src/context/ShippingAddressContext.ts","../src/context/ShippingAddressFormContext.ts","../src/context/ShippingMethodChildrenContext.ts","../src/context/SkuChildrenContext.ts","../src/context/SkuContext.ts","../src/context/SkuListsContext.ts","../src/context/StockTransferChildrenContext.ts","../src/hooks/useCommerceLayer.ts","../src/hooks/useCustomerContainer.ts","../src/hooks/useOrderContainer.ts","../src/reducers/AddressReducer.ts","../src/reducers/AvailabilityReducer.ts","../src/reducers/BillingAddressReducer.ts","../src/reducers/CustomerReducer.ts","../src/reducers/GiftCardReducer.ts","../src/reducers/InStockSubscriptionReducer.ts","../src/reducers/LineItemReducer.ts","../src/reducers/OrderReducer.ts","../src/reducers/PaymentMethodReducer.ts","../src/reducers/PlaceOrderReducer.ts","../src/reducers/PriceReducer.ts","../src/reducers/ShipmentReducer.ts","../src/reducers/ShippingAddressReducer.ts","../src/reducers/SkuListsReducer.ts","../src/reducers/SkuReducer.ts","../src/typings/environment.d.ts","../src/typings/errors.ts","../src/typings/globals.ts","../src/typings/index.ts","../src/utils/PropsType.ts","../src/utils/addressesManager.ts","../src/utils/baseReducer.ts","../src/utils/browserInfo.ts","../src/utils/canPlaceOrder.ts","../src/utils/checkIncludeResource.ts","../src/utils/compareObjAttribute.ts","../src/utils/countryStateCity.ts","../src/utils/customMessages.ts","../src/utils/customerOrderOptions.ts","../src/utils/events.ts","../src/utils/expressPaymentHelper.ts","../src/utils/filterChildren.ts","../src/utils/formCleaner.ts","../src/utils/getAmount.ts","../src/utils/getApplicationLink.ts","../src/utils/getCardDetails.ts","../src/utils/getCustomerIdByToken.ts","../src/utils/getDomain.ts","../src/utils/getErrors.ts","../src/utils/getLineItemsCount.ts","../src/utils/getLoaderComponent.tsx","../src/utils/getPaymentAttributes.ts","../src/utils/getPrices.tsx","../src/utils/getPublicIp.ts","../src/utils/getSdk.ts","../src/utils/getSkus.ts","../src/utils/hasSubscriptions.ts","../src/utils/icons.tsx","../src/utils/isDate.ts","../src/utils/isEmpty.ts","../src/utils/isGuestToken.ts","../src/utils/isJSON.ts","../src/utils/jwt.ts","../src/utils/localStorage.ts","../src/utils/omit.ts","../src/utils/organization.ts","../src/utils/pick.ts","../src/utils/placeholderImages.ts","../src/utils/promisify.ts","../src/utils/replace.ts","../src/utils/scrollbarWidth.ts","../src/utils/shipments.ts","../src/utils/snakeToCamelCase.ts","../src/utils/triggerAttributeHelper.ts","../src/utils/updateOrderSubscriptionCustomerPaymentSource.ts","../src/utils/validateFormFields.ts","../src/utils/adyen/manageGiftCard.ts","../src/utils/hooks/useCustomContext.ts","../src/utils/hooks/useExternalScript.ts","../src/utils/payment-methods/sortPaymentMethods.ts","../src/utils/stripe/retrievePaymentIntent.ts"],"version":"5.9.2"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../src/index.ts","../src/components/ExternalFunction.tsx","../src/components/MetadataInput.tsx","../src/components/SubmitButton.tsx","../src/components/addresses/Address.tsx","../src/components/addresses/AddressCountrySelector.tsx","../src/components/addresses/AddressField.tsx","../src/components/addresses/AddressInput.tsx","../src/components/addresses/AddressInputSelect.tsx","../src/components/addresses/AddressStateSelector.tsx","../src/components/addresses/AddressesContainer.tsx","../src/components/addresses/AddressesEmpty.tsx","../src/components/addresses/BillingAddressContainer.tsx","../src/components/addresses/BillingAddressForm.tsx","../src/components/addresses/SaveAddressesButton.tsx","../src/components/addresses/ShippingAddressContainer.tsx","../src/components/addresses/ShippingAddressForm.tsx","../src/components/auth/CommerceLayer.tsx","../src/components/customers/CustomerAddressForm.tsx","../src/components/customers/CustomerContainer.tsx","../src/components/customers/CustomerField.tsx","../src/components/customers/CustomerInput.tsx","../src/components/customers/CustomerPaymentSource.tsx","../src/components/customers/CustomerPaymentSourceEmpty.tsx","../src/components/customers/MyAccountLink.tsx","../src/components/customers/MyIdentityLink.tsx","../src/components/customers/SaveCustomerButton.tsx","../src/components/errors/Errors.tsx","../src/components/gift_cards/GiftCard.tsx","../src/components/gift_cards/GiftCardContainer.tsx","../src/components/gift_cards/GiftCardCurrencySelector.tsx","../src/components/gift_cards/GiftCardInput.tsx","../src/components/gift_cards/GiftCardOrCouponCode.tsx","../src/components/gift_cards/GiftCardOrCouponForm.tsx","../src/components/gift_cards/GiftCardOrCouponInput.tsx","../src/components/gift_cards/GiftCardOrCouponRemoveButton.tsx","../src/components/gift_cards/GiftCardOrCouponSubmit.tsx","../src/components/gift_cards/GiftCardRecipientInput.tsx","../src/components/in_stock_subscriptions/InStockSubscriptionButton.tsx","../src/components/in_stock_subscriptions/InStockSubscriptionsContainer.tsx","../src/components/line_items/LineItem.tsx","../src/components/line_items/LineItemAmount.tsx","../src/components/line_items/LineItemCode.tsx","../src/components/line_items/LineItemField.tsx","../src/components/line_items/LineItemImage.tsx","../src/components/line_items/LineItemName.tsx","../src/components/line_items/LineItemOption.tsx","../src/components/line_items/LineItemOptions.tsx","../src/components/line_items/LineItemQuantity.tsx","../src/components/line_items/LineItemRemoveLink.tsx","../src/components/line_items/LineItemsContainer.tsx","../src/components/line_items/LineItemsCount.tsx","../src/components/line_items/LineItemsEmpty.tsx","../src/components/orders/AddToCartButton.tsx","../src/components/orders/AdjustmentAmount.tsx","../src/components/orders/CartLink.tsx","../src/components/orders/CheckoutLink.tsx","../src/components/orders/DiscountAmount.tsx","../src/components/orders/GiftCardAmount.tsx","../src/components/orders/HostedCart.tsx","../src/components/orders/OrderContainer.tsx","../src/components/orders/OrderList.tsx","../src/components/orders/OrderListEmpty.tsx","../src/components/orders/OrderListPaginationButtons.tsx","../src/components/orders/OrderListPaginationInfo.tsx","../src/components/orders/OrderListRow.tsx","../src/components/orders/OrderNumber.tsx","../src/components/orders/OrderStorage.tsx","../src/components/orders/PaymentMethodAmount.tsx","../src/components/orders/PlaceOrderButton.tsx","../src/components/orders/PlaceOrderContainer.tsx","../src/components/orders/PrivacyAndTermsCheckbox.tsx","../src/components/orders/ShippingAmount.tsx","../src/components/orders/SubTotalAmount.tsx","../src/components/orders/TaxesAmount.tsx","../src/components/orders/TotalAmount.tsx","../src/components/parcels/ParcelField.tsx","../src/components/parcels/ParcelLineItem.tsx","../src/components/parcels/ParcelLineItemField.tsx","../src/components/parcels/ParcelLineItemsCount.tsx","../src/components/parcels/Parcels.tsx","../src/components/parcels/ParcelsCount.tsx","../src/components/payment_gateways/AdyenGateway.tsx","../src/components/payment_gateways/BraintreeGateway.tsx","../src/components/payment_gateways/CheckoutComGateway.tsx","../src/components/payment_gateways/ExternalGateway.tsx","../src/components/payment_gateways/KlarnaGateway.tsx","../src/components/payment_gateways/PaymentGateway.tsx","../src/components/payment_gateways/PaypalGateway.tsx","../src/components/payment_gateways/StripeGateway.tsx","../src/components/payment_gateways/WireTransferGateway.tsx","../src/components/payment_methods/PaymentMethod.tsx","../src/components/payment_methods/PaymentMethodName.tsx","../src/components/payment_methods/PaymentMethodPrice.tsx","../src/components/payment_methods/PaymentMethodRadioButton.tsx","../src/components/payment_methods/PaymentMethodsContainer.tsx","../src/components/payment_source/AdyenPayment.tsx","../src/components/payment_source/BraintreePayment.tsx","../src/components/payment_source/CheckoutComPayment.tsx","../src/components/payment_source/ExternalPayment.tsx","../src/components/payment_source/KlarnaPayment.tsx","../src/components/payment_source/PaymentSource.tsx","../src/components/payment_source/PaymentSourceBrandIcon.tsx","../src/components/payment_source/PaymentSourceBrandName.tsx","../src/components/payment_source/PaymentSourceDetail.tsx","../src/components/payment_source/PaymentSourceEditButton.tsx","../src/components/payment_source/PaypalPayment.tsx","../src/components/payment_source/StripeExpressPayment.tsx","../src/components/payment_source/StripePayment.tsx","../src/components/payment_source/WireTransferPayment.tsx","../src/components/prices/Price.tsx","../src/components/prices/PricesContainer.tsx","../src/components/shipments/Shipment.tsx","../src/components/shipments/ShipmentField.tsx","../src/components/shipments/ShipmentsContainer.tsx","../src/components/shipments/ShipmentsCount.tsx","../src/components/shipping_methods/ShippingMethod.tsx","../src/components/shipping_methods/ShippingMethodName.tsx","../src/components/shipping_methods/ShippingMethodPrice.tsx","../src/components/shipping_methods/ShippingMethodRadioButton.tsx","../src/components/skus/AvailabilityContainer.tsx","../src/components/skus/AvailabilityTemplate.tsx","../src/components/skus/DeliveryLeadTime.tsx","../src/components/skus/SkuField.tsx","../src/components/skus/SkuList.tsx","../src/components/skus/SkuListsContainer.tsx","../src/components/skus/Skus.tsx","../src/components/skus/SkusContainer.tsx","../src/components/stock_transfers/StockTransfer.tsx","../src/components/stock_transfers/StockTransferField.tsx","../src/components/utils/AddressCardsTemplate.tsx","../src/components/utils/BaseField.tsx","../src/components/utils/BaseInput.tsx","../src/components/utils/BaseOrderPrice.tsx","../src/components/utils/BaseSelect.tsx","../src/components/utils/ErrorBoundary.tsx","../src/components/utils/GenericFieldComponent.tsx","../src/components/utils/Parent.tsx","../src/components/utils/PaymentCardsTemplate.tsx","../src/components/utils/PriceTemplate.tsx","../src/components/utils/getAllErrors.tsx","../src/config/currency.ts","../src/context/AddressChildrenContext.ts","../src/context/AddressContext.ts","../src/context/AvailabilityContext.ts","../src/context/BillingAddressContext.ts","../src/context/BillingAddressFormContext.ts","../src/context/CommerceLayerContext.ts","../src/context/CouponAndGiftCardFormContext.ts","../src/context/CustomerAddressFormContext.ts","../src/context/CustomerContext.ts","../src/context/CustomerPaymentSourceContext.ts","../src/context/ExternalFunctionContext.ts","../src/context/GiftCardContext.ts","../src/context/InStockSubscriptionContext.ts","../src/context/LineItemChildrenContext.ts","../src/context/LineItemContext.ts","../src/context/LineItemOptionChildrenContext.ts","../src/context/OrderContext.ts","../src/context/OrderListChildrenContext.ts","../src/context/OrderListPaginationContext.ts","../src/context/OrderStorageContext.ts","../src/context/ParcelChildrenContext.ts","../src/context/ParcelLineItemChildrenContext.ts","../src/context/PaymentMethodChildrenContext.ts","../src/context/PaymentMethodContext.ts","../src/context/PaymentSourceContext.ts","../src/context/PlaceOrderContext.ts","../src/context/PricesContext.ts","../src/context/ShipmentChildrenContext.ts","../src/context/ShipmentContext.ts","../src/context/ShippingAddressContext.ts","../src/context/ShippingAddressFormContext.ts","../src/context/ShippingMethodChildrenContext.ts","../src/context/SkuChildrenContext.ts","../src/context/SkuContext.ts","../src/context/SkuListsContext.ts","../src/context/StockTransferChildrenContext.ts","../src/hooks/useCommerceLayer.ts","../src/hooks/useCustomerContainer.ts","../src/hooks/useOrderContainer.ts","../src/reducers/AddressReducer.ts","../src/reducers/AvailabilityReducer.ts","../src/reducers/BillingAddressReducer.ts","../src/reducers/CustomerReducer.ts","../src/reducers/GiftCardReducer.ts","../src/reducers/InStockSubscriptionReducer.ts","../src/reducers/LineItemReducer.ts","../src/reducers/OrderReducer.ts","../src/reducers/PaymentMethodReducer.ts","../src/reducers/PlaceOrderReducer.ts","../src/reducers/PriceReducer.ts","../src/reducers/ShipmentReducer.ts","../src/reducers/ShippingAddressReducer.ts","../src/reducers/SkuListsReducer.ts","../src/reducers/SkuReducer.ts","../src/typings/environment.d.ts","../src/typings/errors.ts","../src/typings/globals.ts","../src/typings/index.ts","../src/utils/PropsType.ts","../src/utils/addressesManager.ts","../src/utils/baseReducer.ts","../src/utils/browserInfo.ts","../src/utils/canPlaceOrder.ts","../src/utils/checkIncludeResource.ts","../src/utils/compareObjAttribute.ts","../src/utils/countryStateCity.ts","../src/utils/customMessages.ts","../src/utils/customerOrderOptions.ts","../src/utils/events.ts","../src/utils/expressPaymentHelper.ts","../src/utils/filterChildren.ts","../src/utils/formCleaner.ts","../src/utils/getAmount.ts","../src/utils/getApplicationLink.ts","../src/utils/getCardDetails.ts","../src/utils/getCustomerIdByToken.ts","../src/utils/getDomain.ts","../src/utils/getErrors.ts","../src/utils/getLineItemsCount.ts","../src/utils/getLoaderComponent.tsx","../src/utils/getPaymentAttributes.ts","../src/utils/getPrices.tsx","../src/utils/getPublicIp.ts","../src/utils/getSdk.ts","../src/utils/getSkus.ts","../src/utils/hasSubscriptions.ts","../src/utils/icons.tsx","../src/utils/isDate.ts","../src/utils/isEmpty.ts","../src/utils/isGuestToken.ts","../src/utils/isJSON.ts","../src/utils/jwt.ts","../src/utils/localStorage.ts","../src/utils/omit.ts","../src/utils/organization.ts","../src/utils/pick.ts","../src/utils/placeholderImages.ts","../src/utils/promisify.ts","../src/utils/replace.ts","../src/utils/scrollbarWidth.ts","../src/utils/shipments.ts","../src/utils/snakeToCamelCase.ts","../src/utils/triggerAttributeHelper.ts","../src/utils/updateOrderSubscriptionCustomerPaymentSource.ts","../src/utils/validateFormFields.ts","../src/utils/adyen/manageGiftCard.ts","../src/utils/hooks/useCustomContext.ts","../src/utils/hooks/useExternalScript.ts","../src/utils/payment-methods/sortPaymentMethods.ts","../src/utils/stripe/retrievePaymentIntent.ts"],"version":"5.8.3"}
|
|
1
|
+
{"root":["../src/index.ts","../src/components/ExternalFunction.tsx","../src/components/MetadataInput.tsx","../src/components/SubmitButton.tsx","../src/components/addresses/Address.tsx","../src/components/addresses/AddressCountrySelector.tsx","../src/components/addresses/AddressField.tsx","../src/components/addresses/AddressInput.tsx","../src/components/addresses/AddressInputSelect.tsx","../src/components/addresses/AddressStateSelector.tsx","../src/components/addresses/AddressesContainer.tsx","../src/components/addresses/AddressesEmpty.tsx","../src/components/addresses/BillingAddressContainer.tsx","../src/components/addresses/BillingAddressForm.tsx","../src/components/addresses/SaveAddressesButton.tsx","../src/components/addresses/ShippingAddressContainer.tsx","../src/components/addresses/ShippingAddressForm.tsx","../src/components/auth/CommerceLayer.tsx","../src/components/customers/CustomerAddressForm.tsx","../src/components/customers/CustomerContainer.tsx","../src/components/customers/CustomerField.tsx","../src/components/customers/CustomerInput.tsx","../src/components/customers/CustomerPaymentSource.tsx","../src/components/customers/CustomerPaymentSourceEmpty.tsx","../src/components/customers/MyAccountLink.tsx","../src/components/customers/MyIdentityLink.tsx","../src/components/customers/SaveCustomerButton.tsx","../src/components/errors/Errors.tsx","../src/components/gift_cards/GiftCard.tsx","../src/components/gift_cards/GiftCardContainer.tsx","../src/components/gift_cards/GiftCardCurrencySelector.tsx","../src/components/gift_cards/GiftCardInput.tsx","../src/components/gift_cards/GiftCardOrCouponCode.tsx","../src/components/gift_cards/GiftCardOrCouponForm.tsx","../src/components/gift_cards/GiftCardOrCouponInput.tsx","../src/components/gift_cards/GiftCardOrCouponRemoveButton.tsx","../src/components/gift_cards/GiftCardOrCouponSubmit.tsx","../src/components/gift_cards/GiftCardRecipientInput.tsx","../src/components/in_stock_subscriptions/InStockSubscriptionButton.tsx","../src/components/in_stock_subscriptions/InStockSubscriptionsContainer.tsx","../src/components/line_items/LineItem.tsx","../src/components/line_items/LineItemAmount.tsx","../src/components/line_items/LineItemCode.tsx","../src/components/line_items/LineItemField.tsx","../src/components/line_items/LineItemImage.tsx","../src/components/line_items/LineItemName.tsx","../src/components/line_items/LineItemOption.tsx","../src/components/line_items/LineItemOptions.tsx","../src/components/line_items/LineItemQuantity.tsx","../src/components/line_items/LineItemRemoveLink.tsx","../src/components/line_items/LineItemsContainer.tsx","../src/components/line_items/LineItemsCount.tsx","../src/components/line_items/LineItemsEmpty.tsx","../src/components/orders/AddToCartButton.tsx","../src/components/orders/AdjustmentAmount.tsx","../src/components/orders/CartLink.tsx","../src/components/orders/CheckoutLink.tsx","../src/components/orders/DiscountAmount.tsx","../src/components/orders/GiftCardAmount.tsx","../src/components/orders/HostedCart.tsx","../src/components/orders/OrderContainer.tsx","../src/components/orders/OrderList.tsx","../src/components/orders/OrderListEmpty.tsx","../src/components/orders/OrderListPaginationButtons.tsx","../src/components/orders/OrderListPaginationInfo.tsx","../src/components/orders/OrderListRow.tsx","../src/components/orders/OrderNumber.tsx","../src/components/orders/OrderStorage.tsx","../src/components/orders/PaymentMethodAmount.tsx","../src/components/orders/PlaceOrderButton.tsx","../src/components/orders/PlaceOrderContainer.tsx","../src/components/orders/PrivacyAndTermsCheckbox.tsx","../src/components/orders/ShippingAmount.tsx","../src/components/orders/SubTotalAmount.tsx","../src/components/orders/TaxesAmount.tsx","../src/components/orders/TotalAmount.tsx","../src/components/parcels/ParcelField.tsx","../src/components/parcels/ParcelLineItem.tsx","../src/components/parcels/ParcelLineItemField.tsx","../src/components/parcels/ParcelLineItemsCount.tsx","../src/components/parcels/Parcels.tsx","../src/components/parcels/ParcelsCount.tsx","../src/components/payment_gateways/AdyenGateway.tsx","../src/components/payment_gateways/BraintreeGateway.tsx","../src/components/payment_gateways/CheckoutComGateway.tsx","../src/components/payment_gateways/ExternalGateway.tsx","../src/components/payment_gateways/KlarnaGateway.tsx","../src/components/payment_gateways/PaymentGateway.tsx","../src/components/payment_gateways/PaypalGateway.tsx","../src/components/payment_gateways/StripeGateway.tsx","../src/components/payment_gateways/WireTransferGateway.tsx","../src/components/payment_methods/PaymentMethod.tsx","../src/components/payment_methods/PaymentMethodName.tsx","../src/components/payment_methods/PaymentMethodPrice.tsx","../src/components/payment_methods/PaymentMethodRadioButton.tsx","../src/components/payment_methods/PaymentMethodsContainer.tsx","../src/components/payment_source/AdyenPayment.tsx","../src/components/payment_source/BraintreePayment.tsx","../src/components/payment_source/CheckoutComPayment.tsx","../src/components/payment_source/ExternalPayment.tsx","../src/components/payment_source/KlarnaPayment.tsx","../src/components/payment_source/PaymentSource.tsx","../src/components/payment_source/PaymentSourceBrandIcon.tsx","../src/components/payment_source/PaymentSourceBrandName.tsx","../src/components/payment_source/PaymentSourceDetail.tsx","../src/components/payment_source/PaymentSourceEditButton.tsx","../src/components/payment_source/PaypalPayment.tsx","../src/components/payment_source/StripeExpressPayment.tsx","../src/components/payment_source/StripePayment.tsx","../src/components/payment_source/WireTransferPayment.tsx","../src/components/prices/Price.tsx","../src/components/prices/PricesContainer.tsx","../src/components/shipments/Shipment.tsx","../src/components/shipments/ShipmentField.tsx","../src/components/shipments/ShipmentsContainer.tsx","../src/components/shipments/ShipmentsCount.tsx","../src/components/shipping_methods/ShippingMethod.tsx","../src/components/shipping_methods/ShippingMethodName.tsx","../src/components/shipping_methods/ShippingMethodPrice.tsx","../src/components/shipping_methods/ShippingMethodRadioButton.tsx","../src/components/skus/AvailabilityContainer.tsx","../src/components/skus/AvailabilityTemplate.tsx","../src/components/skus/DeliveryLeadTime.tsx","../src/components/skus/SkuField.tsx","../src/components/skus/SkuList.tsx","../src/components/skus/SkuListsContainer.tsx","../src/components/skus/Skus.tsx","../src/components/skus/SkusContainer.tsx","../src/components/stock_transfers/StockTransfer.tsx","../src/components/stock_transfers/StockTransferField.tsx","../src/components/utils/AddressCardsTemplate.tsx","../src/components/utils/BaseField.tsx","../src/components/utils/BaseInput.tsx","../src/components/utils/BaseOrderPrice.tsx","../src/components/utils/BaseSelect.tsx","../src/components/utils/ErrorBoundary.tsx","../src/components/utils/GenericFieldComponent.tsx","../src/components/utils/Parent.tsx","../src/components/utils/PaymentCardsTemplate.tsx","../src/components/utils/PriceTemplate.tsx","../src/components/utils/getAllErrors.tsx","../src/config/currency.ts","../src/context/AddressChildrenContext.ts","../src/context/AddressContext.ts","../src/context/AvailabilityContext.ts","../src/context/BillingAddressContext.ts","../src/context/BillingAddressFormContext.ts","../src/context/CommerceLayerContext.ts","../src/context/CouponAndGiftCardFormContext.ts","../src/context/CustomerAddressFormContext.ts","../src/context/CustomerContext.ts","../src/context/CustomerPaymentSourceContext.ts","../src/context/ExternalFunctionContext.ts","../src/context/GiftCardContext.ts","../src/context/InStockSubscriptionContext.ts","../src/context/LineItemChildrenContext.ts","../src/context/LineItemContext.ts","../src/context/LineItemOptionChildrenContext.ts","../src/context/OrderContext.ts","../src/context/OrderListChildrenContext.ts","../src/context/OrderListPaginationContext.ts","../src/context/OrderStorageContext.ts","../src/context/ParcelChildrenContext.ts","../src/context/ParcelLineItemChildrenContext.ts","../src/context/PaymentMethodChildrenContext.ts","../src/context/PaymentMethodContext.ts","../src/context/PaymentSourceContext.ts","../src/context/PlaceOrderContext.ts","../src/context/PricesContext.ts","../src/context/ShipmentChildrenContext.ts","../src/context/ShipmentContext.ts","../src/context/ShippingAddressContext.ts","../src/context/ShippingAddressFormContext.ts","../src/context/ShippingMethodChildrenContext.ts","../src/context/SkuChildrenContext.ts","../src/context/SkuContext.ts","../src/context/SkuListsContext.ts","../src/context/StockTransferChildrenContext.ts","../src/hooks/useCommerceLayer.ts","../src/hooks/useCustomerContainer.ts","../src/hooks/useOrderContainer.ts","../src/reducers/AddressReducer.ts","../src/reducers/AvailabilityReducer.ts","../src/reducers/BillingAddressReducer.ts","../src/reducers/CustomerReducer.ts","../src/reducers/GiftCardReducer.ts","../src/reducers/InStockSubscriptionReducer.ts","../src/reducers/LineItemReducer.ts","../src/reducers/OrderReducer.ts","../src/reducers/PaymentMethodReducer.ts","../src/reducers/PlaceOrderReducer.ts","../src/reducers/PriceReducer.ts","../src/reducers/ShipmentReducer.ts","../src/reducers/ShippingAddressReducer.ts","../src/reducers/SkuListsReducer.ts","../src/reducers/SkuReducer.ts","../src/typings/environment.d.ts","../src/typings/errors.ts","../src/typings/globals.ts","../src/typings/index.ts","../src/utils/PropsType.ts","../src/utils/addressesManager.ts","../src/utils/baseReducer.ts","../src/utils/browserInfo.ts","../src/utils/canPlaceOrder.ts","../src/utils/checkIncludeResource.ts","../src/utils/compareObjAttribute.ts","../src/utils/countryStateCity.ts","../src/utils/customMessages.ts","../src/utils/customerOrderOptions.ts","../src/utils/events.ts","../src/utils/expressPaymentHelper.ts","../src/utils/filterChildren.ts","../src/utils/formCleaner.ts","../src/utils/getAmount.ts","../src/utils/getApplicationLink.ts","../src/utils/getCardDetails.ts","../src/utils/getCustomerIdByToken.ts","../src/utils/getDomain.ts","../src/utils/getErrors.ts","../src/utils/getLineItemsCount.ts","../src/utils/getLoaderComponent.tsx","../src/utils/getPaymentAttributes.ts","../src/utils/getPrices.tsx","../src/utils/getPublicIp.ts","../src/utils/getSdk.ts","../src/utils/getSkus.ts","../src/utils/hasSubscriptions.ts","../src/utils/icons.tsx","../src/utils/isDate.ts","../src/utils/isEmpty.ts","../src/utils/isGuestToken.ts","../src/utils/isJSON.ts","../src/utils/jwt.ts","../src/utils/localStorage.ts","../src/utils/omit.ts","../src/utils/organization.ts","../src/utils/pick.ts","../src/utils/placeholderImages.ts","../src/utils/promisify.ts","../src/utils/replace.ts","../src/utils/scrollbarWidth.ts","../src/utils/shipments.ts","../src/utils/snakeToCamelCase.ts","../src/utils/triggerAttributeHelper.ts","../src/utils/updateOrderSubscriptionCustomerPaymentSource.ts","../src/utils/validateFormFields.ts","../src/utils/adyen/manageGiftCard.ts","../src/utils/hooks/useCustomContext.ts","../src/utils/hooks/useExternalScript.ts","../src/utils/payment-methods/sortPaymentMethods.ts","../src/utils/stripe/retrievePaymentIntent.ts"],"version":"5.9.2"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commercelayer/react-components",
|
|
3
|
-
"version": "4.25.
|
|
3
|
+
"version": "4.25.8-beta.0",
|
|
4
4
|
"description": "The Official Commerce Layer React Components",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -186,15 +186,15 @@
|
|
|
186
186
|
},
|
|
187
187
|
"homepage": "https://github.com/commercelayer/commercelayer-react-components#readme",
|
|
188
188
|
"dependencies": {
|
|
189
|
-
"@adyen/adyen-web": "^6.
|
|
190
|
-
"@commercelayer/organization-config": "^2.
|
|
191
|
-
"@commercelayer/sdk": "^6.
|
|
192
|
-
"@stripe/react-stripe-js": "^
|
|
193
|
-
"@stripe/stripe-js": "^7.
|
|
189
|
+
"@adyen/adyen-web": "^6.21.0",
|
|
190
|
+
"@commercelayer/organization-config": "^2.4.0",
|
|
191
|
+
"@commercelayer/sdk": "^6.46.0",
|
|
192
|
+
"@stripe/react-stripe-js": "^4.0.2",
|
|
193
|
+
"@stripe/stripe-js": "^7.9.0",
|
|
194
194
|
"@tanstack/react-table": "^8.21.3",
|
|
195
195
|
"@types/iframe-resizer": "^3.5.13",
|
|
196
|
-
"braintree-web": "^3.
|
|
197
|
-
"frames-react": "^1.2.
|
|
196
|
+
"braintree-web": "^3.129.0",
|
|
197
|
+
"frames-react": "^1.2.3",
|
|
198
198
|
"iframe-resizer": "^4.3.6",
|
|
199
199
|
"jwt-decode": "^4.0.0",
|
|
200
200
|
"lodash": "^4.17.21",
|
|
@@ -202,29 +202,29 @@
|
|
|
202
202
|
},
|
|
203
203
|
"devDependencies": {
|
|
204
204
|
"@commercelayer/js-auth": "^6.7.2",
|
|
205
|
-
"@faker-js/faker": "^
|
|
206
|
-
"@playwright/test": "^1.
|
|
207
|
-
"@testing-library/dom": "^10.4.
|
|
205
|
+
"@faker-js/faker": "^10.0.0",
|
|
206
|
+
"@playwright/test": "^1.55.0",
|
|
207
|
+
"@testing-library/dom": "^10.4.1",
|
|
208
208
|
"@testing-library/react": "^16.3.0",
|
|
209
209
|
"@types/braintree-web": "^3.96.17",
|
|
210
|
-
"@types/lodash": "^4.17.
|
|
211
|
-
"@types/node": "^24.
|
|
210
|
+
"@types/lodash": "^4.17.20",
|
|
211
|
+
"@types/node": "^24.3.1",
|
|
212
212
|
"@types/prop-types": "^15.7.15",
|
|
213
213
|
"@types/react": "^18.3.1",
|
|
214
214
|
"@types/react-test-renderer": "^18.3.1",
|
|
215
215
|
"@types/react-window": "^1.8.8",
|
|
216
|
-
"@vitejs/plugin-react": "^
|
|
216
|
+
"@vitejs/plugin-react": "^5.0.2",
|
|
217
217
|
"@vitest/coverage-v8": "^3.2.4",
|
|
218
218
|
"jsdom": "^26.1.0",
|
|
219
219
|
"minimize-js": "^1.4.0",
|
|
220
|
-
"msw": "^2.
|
|
220
|
+
"msw": "^2.11.1",
|
|
221
221
|
"react": "^18.3.1",
|
|
222
222
|
"react-dom": "^18.3.1",
|
|
223
223
|
"react-test-renderer": "^18.3.1",
|
|
224
224
|
"tsc-alias": "^1.8.16",
|
|
225
225
|
"tslib": "^2.8.1",
|
|
226
|
-
"typescript": "^5.
|
|
227
|
-
"vite": "^
|
|
226
|
+
"typescript": "^5.9.2",
|
|
227
|
+
"vite": "^7.1.5",
|
|
228
228
|
"vite-tsconfig-paths": "^5.1.4",
|
|
229
229
|
"vitest": "^3.2.4"
|
|
230
230
|
},
|