@ikas/storefront 3.0.0-alpha.32 → 3.0.0-alpha.34
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/build/_virtual/index.js_commonjs-proxy13.js +1 -1
- package/build/_virtual/index.js_commonjs-proxy14.js +1 -1
- package/build/_virtual/index.js_commonjs-proxy3.js +1 -1
- package/build/_virtual/index.js_commonjs-proxy4.js +1 -1
- package/build/components/checkout/components/credit-card-form/index.js +1 -1
- package/build/components/checkout/index.js +1 -1
- package/build/components/checkout/model.d.ts +1 -0
- package/build/components/checkout/model.js +1 -1
- package/build/components/checkout/modelMasterPass.d.ts +39 -0
- package/build/components/checkout/modelMasterPass.js +1 -1
- package/build/components/checkout/steps/step-payment/payment-gateways/index.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from'../ext/
|
|
1
|
+
import e from'../ext/safe-buffer/index.js';export{default}from"../node_modules/safe-buffer/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from'../ext/
|
|
1
|
+
import e from'../ext/inline-style-parser/index.js';export{default}from"../node_modules/inline-style-parser/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import e from'../ext/decode-uri-component/index.js';export{default}from"../node_modules/decode-uri-component/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import o from'../ext/split-on-first/index.js';export{default}from"../node_modules/split-on-first/index.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react";import{observer as r}from"mobx-react-lite";import"../../../../storefront/index.js";import'../../../../ext/lodash/isArguments.js';import'../../../../ext/lodash/isBuffer.js';import'../../../../ext/lodash/isTypedArray.js';import'../../../../ext/lodash/_baseGetTag.js';import{useTranslation as t}from"../../../../utils/i18n.js";import{TransactionCardAssociationEnum as
|
|
1
|
+
import*as e from"react";import{observer as r}from"mobx-react-lite";import"../../../../storefront/index.js";import'../../../../ext/lodash/isArguments.js';import'../../../../ext/lodash/isBuffer.js';import'../../../../ext/lodash/isTypedArray.js';import'../../../../ext/lodash/_baseGetTag.js';import{useTranslation as t}from"../../../../utils/i18n.js";import{TransactionCardAssociationEnum as o}from"../../../../__api/types/index.js";import{FormItem as a}from"../form-item/index.js";import{FormItemInputType as c,FormItemType as s}from"../form-item/model.js";import l from"./svg/amex.js";import m from"./svg/master-card.js";import n from"./svg/troy.js";import i from"./svg/visa.js";import d from"../../styles/common.module.scss.js";import u from"../../style.module.scss.js";import p from"./style.module.scss.js";var E=r((function(r){var E,v=r.vm,h=t().t,g=v.cardData;if(!g)return null;return e.createElement("div",null,e.createElement("div",{className:u.RowPB},e.createElement(a,{name:"cardnumber",autocomplete:"cc-number",inputType:c.NUMERIC,type:s.TEXT,label:h("checkout-page:cardNumber"),value:g.cardNumber,onChange:v.onCardNumberChange,errorText:h("checkout-page:cardNumberError"),rightContent:(null===(E=v.installmentInfo)||void 0===E?void 0:E.cardAssociation)?e.createElement("div",{className:p.CardLogo},function(r){switch(r){case o.AMERICAN_EXPRESS:return e.createElement(l,null);case o.MASTER_CARD:return e.createElement(m,null);case o.TROY:return e.createElement(n,null);case o.VISA:return e.createElement(i,null);default:return e.createElement("div",null)}}(v.installmentInfo.cardAssociation)):void 0,hasError:v.isErrorsVisible&&!g.validationResult.cardNumber})),e.createElement("div",{className:u.RowPB},e.createElement(a,{name:"ccname",autocomplete:"cc-name",type:s.TEXT,label:h("checkout-page:cardHolderName"),value:g.cardHolderName,onChange:v.onCardHolderNameChange,errorText:h("checkout-page:cardHolderError"),hasError:v.isErrorsVisible&&!g.validationResult.cardHolderName})),e.createElement("div",{className:[d.Grid,d.Grid2].join(" ")},e.createElement(a,{name:"cc-exp",autocomplete:"cc-exp",inputType:c.NUMERIC,type:s.TEXT,label:h("checkout-page:cardExpiry"),value:g.expirationDate,onChange:v.onExpirationDateChange,errorText:h("checkout-page:cardExpiryError"),hasError:v.isErrorsVisible&&!g.validationResult.expirationDate}),e.createElement(a,{name:"cvc",autocomplete:"cc-csc",inputType:c.NUMERIC,type:s.TEXT,label:h("checkout-page:cardCVC"),value:g.cvv,onChange:v.onCvcChange,errorText:h("checkout-page:cardCVCError"),tooltipText:h("checkout-page:cardCVCTooltip"),hasError:v.isErrorsVisible&&!g.validationResult.cvv})))}));export{E as CreditCardForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as t}from'../../ext/tslib/tslib.es6.js';import*as o from"react";import{observer as r}from"mobx-react-lite";import{useRouter as i}from"next/router.js";import s from"next/link.js";import a from'../../ext/react-tooltip/dist/index.es.js';import n,{CheckoutStep as m}from"./model.js";import{Analytics as l}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasStorefrontConfig as c}from"../../storefront/index.js";import'../../ext/lodash/isArguments.js';import'../../ext/lodash/isBuffer.js';import'../../ext/lodash/isTypedArray.js';import'../../ext/lodash/_baseGetTag.js';import{formatMoney as d}from"../../utils/currency.js";import{useTranslation as p}from"../../utils/i18n.js";import u from"./steps/step-info/index.js";import{CheckoutStepShipping as v}from"./steps/step-shipping/index.js";import{CheckoutStepPayment as h}from"./steps/step-payment/index.js";import{CartSummary as g}from"./components/cart-summary/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/index.js";import"../../models/data/city/index.js";import"mobx";import"../../models/data/country/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/attribute-value/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-attribute/customer-attribute-option/index.js";import"../../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../../models/data/customer-attribute/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/customer-review-summary/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/merchant-settings/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/adjustment/index.js";import"../../models/data/order/gift-line/index.js";import"../../models/data/order/invoice/index.js";import"../../models/data/order/line-item/discount/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/option/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/tracking-info/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/payment-method/index.js";import"../../models/data/order/refund/line-item/index.js";import"../../models/data/order/shipping-line/index.js";import"../../models/data/order/tax-line/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/product-campaign/campaign/index.js";import"../../models/data/product-campaign/filter/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/theme/theme.js";import{IkasThemePageType as E}from"../../models/theme/page/index.js";import"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-detail/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/register.js";import{ContactForm as x}from"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import{StepSuccess as f}from"./steps/step-success/index.js";import{Modal as j}from"./components/modal/index.js";import k from"./components/master-pass/modal-otp/index.js";import y from"./components/master-pass/modal-link-card-to-client/index.js";import C from"./components/master-pass/modal-response/index.js";import{Image as b}from"../image/index.js";import M,{Step as N}from"./components/step-container/index.js";import{StockError as F}from"./components/error/stock-error/index.js";import{FullscreenLoading as T}from"./components/fullscreen-loading/index.js";import P from"./components/notification-box/index.js";import{FormItem as S}from"./components/form-item/index.js";import{FormItemType as A}from"./components/form-item/model.js";import{Button as w}from"./components/button/index.js";import{IkasPageHead as B}from"../page/head.js";import I from"./components/svg/ikas.js";import L from"./style.module.scss.js";var V=r((function(e){var t,r,s,d=e.checkout,u=e.checkoutSettings,v=e.merchantSettings,h=e.customizationProps,x=e.returnPolicy,b=e.privacyPolicy,M=e.termsOfService,N=p().t,P=i(),S=o.useState((function(){return new n(d,u,v,P,x,b,M,N,h||{})}))[0];return S.step===m.PAYMENT&&l.disableHTML(),o.useEffect((function(){S.checkoutSettings.isAccountRequired&&!S.checkout.hasCustomer&&P.push("/account/login?redirect="+encodeURIComponent(S.checkoutUrl)),l.beginCheckout(S.checkout),l.pageView(E.CHECKOUT)}),[]),o.useEffect((function(){S.customizationProps=h,function(e){document.documentElement.style.setProperty("--checkout-button-bg-color",(null==e?void 0:e.buttonBgColor)||"#272727"),document.documentElement.style.setProperty("--checkout-button-text-color",(null==e?void 0:e.buttonTextColor)||"#FFFFFF"),document.documentElement.style.setProperty("--checkout-button-disabled-bg-color",(null==e?void 0:e.buttonDisabledBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-button-disabled-text-color",(null==e?void 0:e.buttonDisabledTextColor)||"#8A8B94"),document.documentElement.style.setProperty("--checkout-primary-text-color",(null==e?void 0:e.primaryTextColor)||"#272727"),document.documentElement.style.setProperty("--checkout-secondary-text-color",(null==e?void 0:e.secondaryTextColor)||"#8A8B94"),document.documentElement.style.setProperty("--checkout-primary-bg-color",(null==e?void 0:e.primaryBgColor)||"#FFFFFF"),document.documentElement.style.setProperty("--checkout-secondary-bg-color",(null==e?void 0:e.secondaryBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-border-color",(null==e?void 0:e.borderColor)||"#E5E4E9"),document.documentElement.style.setProperty("--checkout-card-bg-color",(null==e?void 0:e.cardBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-error-color",(null==e?void 0:e.errorColor)||"#FB4E4E"),document.documentElement.style.setProperty("--checkout-error-light-color",(null==e?void 0:e.errorLightColor)||"#FCF3F4"),document.documentElement.style.setProperty("--checkout-warning-color",(null==e?void 0:e.warningColor)||"#FFBC1F"),document.documentElement.style.setProperty("--checkout-warning-light-color",(null==e?void 0:e.warningLightColor)||"#FFFAEE"),document.documentElement.style.setProperty("--checkout-success-color",(null==e?void 0:e.successColor)||"#2DCA73"),document.documentElement.style.setProperty("--checkout-success-light-color",(null==e?void 0:e.successLightColor)||"#F6FFED")}(h)}),[h]),S.isCheckoutLoaded&&S.store.customerStore.initialized?S.checkout.hasCustomer&&(null===(t=S.store.customerStore.customer)||void 0===t?void 0:t.id)!==(null===(r=S.checkout.customer)||void 0===r?void 0:r.id)?(P.push("/account/login?redirect="+encodeURIComponent(S.checkoutUrl)),null):(console.log("vm.mpVM.visibleModal",S.mpVM.visibleModal),o.createElement(o.Fragment,null,o.createElement(B,{pageType:E.CHECKOUT,pageTitle:((null===(s=S.merchantSettings)||void 0===s?void 0:s.merchantName)||"")+" - "+N("checkout-page:securePayment"),pageDescription:N("checkout-page:securePayment")}),o.createElement("div",{id:"Checkout",className:L.CheckoutPage},o.createElement(a,{place:"top",type:"dark",effect:"solid",arrowColor:"transparent",multiline:!0,className:L.ReactTooltipWrap,globalEventOff:"touchstart"}),o.createElement("div",{className:L.Left},o.createElement("div",{className:L.LeftContent},o.createElement("div",null,o.createElement(O,{vm:S}),S.hasStockError&&o.createElement("div",{className:L.ErrorContainer},o.createElement(F,{vm:S,error:S.error})),!S.hasStockError&&o.createElement(o.Fragment,null,o.createElement(g,{vm:S,allowExpand:!0}),S.step===m.SUCCESS?o.createElement(f,{vm:S}):o.createElement(R,{vm:S})),o.createElement("div",{className:L.Space})),o.createElement(_,{vm:S}))),o.createElement("div",{className:L.Right},o.createElement("div",{className:L.RightContent},o.createElement(g,{vm:S}),o.createElement("div",{className:L.PoweredBy},o.createElement("span",null,"powered by"),o.createElement("a",{href:"https://ikas.com"+("tr"===c.getCurrentLocale()?"/tr":""),target:"_blank"},o.createElement(I,null))))),!!S.policyModalText&&o.createElement(j,{title:S.policyModalTitle,modalContent:S.policyModalText,onClose:function(){S.policyModalText=""}}),S.isContactModalVisible&&o.createElement(D,{vm:S,setVisible:S.setContactModalVisible}),"linkCardToClientModal"===S.mpVM.visibleModal&&o.createElement(y,{visible:!0,onClose:S.mpVM.hideLinkCardToClientModal,onButtonClick:function(){S.mpVM.onLinkCardToClientButtonClick({cartId:S.checkout.id,checkout:S.checkout,store:S.store})}}),("otpModalBank"===S.mpVM.visibleModal||"otpModalMasterPass"===S.mpVM.visibleModal)&&o.createElement(k,{vm:S,visible:!0,type:"otpModalMasterPass"===S.mpVM.visibleModal?"masterPassOtp":"bankOtp",onClose:S.mpVM.hideOtpModal}),"mfsResponseModal"===S.mpVM.visibleModal&&S.mpVM.mfsResponseModalText&&o.createElement(C,{visible:!0,text:S.mpVM.mfsResponseModalText,onClose:S.mpVM.onResponseModalClose})))):o.createElement(T,null)})),O=r((function(e){var t,r,i=e.vm,a=p().t;return o.createElement("div",{className:L.Header},o.createElement(s,{href:"/",passHref:!0},o.createElement("a",null,(null===(t=i.merchantSettings)||void 0===t?void 0:t.logo)?o.createElement("div",{className:L.Logo},o.createElement(b,{layout:"fill",image:i.merchantSettings.logo,sizes:"360px"})):(null===(r=i.merchantSettings)||void 0===r?void 0:r.merchantName)||"")),!i.checkout.hasCustomer&&o.createElement("div",{className:L.LoginText},o.createElement("span",{className:L.LoginCta},a("checkout-page:alreadyHaveAnAccount")),o.createElement(s,{href:"/account/login?redirect="+encodeURIComponent(i.checkoutUrl),passHref:!0},o.createElement("a",{className:L.LoginBtn},a("checkout-page:actions.login")))),i.checkout.hasCustomer&&o.createElement("div",{className:L.CustomerInfo},o.createElement("div",{className:L.Name},i.checkout.customerFullName),o.createElement("div",{className:L.Email},i.checkout.customerEmail)))})),R=r((function(e){var t=e.vm,r=p().t,i=o.useMemo((function(){switch(t.step){case m.INFO:return o.createElement(u,{vm:t});case m.SHIPPING:return o.createElement(v,{vm:t});case m.PAYMENT:return o.createElement(h,{vm:t});case m.SUCCESS:return o.createElement(f,{vm:t})}}),[t,t.step]),s=[new N(r("checkout-page:address"),t.step===m.INFO,t.step!==m.INFO,t.step!==m.INFO?o.createElement("div",{className:L.AdressStepInfo},o.createElement(U,{vm:t}),o.createElement("div",{className:L.EditBtn,onClick:t.onBackToInfoClick},r("checkout-page:actions.edit"))):void 0,t.step!==m.INFO?o.createElement("div",{className:L.AddressStepInfoMobile},o.createElement(U,{vm:t})):void 0),new N(r("checkout-page:payment"),t.step===m.PAYMENT,!1)];return"address"===t.deliveryMethod&&s.splice(1,0,new N(r("checkout-page:shipping"),t.step===m.SHIPPING,t.step===m.PAYMENT,t.step===m.PAYMENT?o.createElement("div",{className:L.AdressStepInfo},o.createElement(H,{vm:t}),t.checkout.availableShippingMethods&&t.checkout.availableShippingMethods.length>1&&o.createElement("div",{className:L.EditBtn,onClick:t.onBackToShippingClick},r("checkout-page:actions.edit"))):void 0,t.step===m.PAYMENT?o.createElement("div",{className:L.AddressStepInfoMobile},o.createElement(H,{vm:t})):void 0)),o.createElement(M,{steps:s,stepContent:i})})),U=r((function(e){var t,r,i,s,a,n=e.vm,m=p().t,l=((null===(t=n.checkout.shippingAddress)||void 0===t?void 0:t.firstName)||"")+" "+((null===(r=n.checkout.shippingAddress)||void 0===r?void 0:r.lastName)||"");return o.createElement("div",{className:L.Address},o.createElement("div",{className:[L.Text,L.WithMBottom].join(" ")},(null===(i=n.checkout.customer)||void 0===i?void 0:i.email)||""),"address"===n.deliveryMethod?o.createElement("div",{className:L.Text},l):o.createElement(o.Fragment,null,o.createElement("div",{className:L.Text},m("checkout-page:receiver")),o.createElement("div",{className:[L.Text,L.Gray].join(" ")},l)),o.createElement("div",{className:[L.Text,L.Gray].join(" ")},null===(s=n.checkout.shippingAddress)||void 0===s?void 0:s.phone),"in-store"===n.deliveryMethod&&o.createElement(o.Fragment,null,o.createElement("div",{className:[L.Text,L.WithMTop].join(" ")},m("checkout-page:pickUpLocation"))),o.createElement("div",{className:[L.Text,L.Gray].join(" ")},null===(a=n.checkout.shippingAddress)||void 0===a?void 0:a.addressText))})),H=r((function(e){var t=e.vm,r=p().t;return o.createElement("div",{className:L.Address},t.checkout.shippingLines&&t.checkout.shippingLines.length?o.createElement(o.Fragment,null,o.createElement("span",null,t.checkout.shippingLines[0].title),o.createElement("span",{className:L.LightText}," / "+(0===t.checkout.shippingLines[0].price?r("checkout-page:free"):d(t.checkout.shippingLines[0].price,t.checkout.currencyCode)))):r("checkout-page:standartShipping"))})),_=r((function(e){var t=e.vm,r=p().t;return o.createElement("div",{className:L.Footer},o.createElement("div",{className:L.FooterItem,onClick:function(){t.policyModalTitle=r("checkout-page:returnPolicy"),t.policyModalText=t.returnPolicy}},r("checkout-page:returnPolicy")),o.createElement("div",{className:L.FooterBullet},"•"),o.createElement("div",{className:L.FooterItem,onClick:function(){t.policyModalTitle=r("checkout-page:privacyPolicy"),t.policyModalText=t.privacyPolicy}},r("checkout-page:privacyPolicy")),o.createElement("div",{className:L.FooterBullet},"•"),o.createElement("div",{className:L.FooterItem,onClick:function(){t.policyModalTitle=r("checkout-page:termsOfService"),t.policyModalText=t.termsOfService}},r("checkout-page:termsOfService")))})),D=r((function(r){var i,s,a=r.vm,n=r.setVisible,m=p().t,l=o.useState(!1),c=l[0],d=l[1],u=o.useState(!1),v=u[0],h=u[1],g=o.useState(new x({message:{requiredRule:"",emailRule:"",minRule:""},store:a.store}))[0];g.email=a.checkout.customerEmail,g.firstName=(null===(i=a.checkout.customer)||void 0===i?void 0:i.firstName)||"",g.lastName=(null===(s=a.checkout.customer)||void 0===s?void 0:s.lastName)||"";var E=o.useCallback((function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return v?[2,n(!1)]:(d(!0),[4,g.saveContactForm()]);case 1:return e.sent()&&h(!0),d(!1),[2]}}))}))}),[c]);return o.createElement(j,{title:m("checkout-page:contactForm"),modalContent:o.createElement("div",null,v&&o.createElement("div",{style:{marginBottom:"12px",maxWidth:"352px"}},o.createElement(P,{type:"success",title:m("checkout-page:contactFormSent"),content:m("checkout-page:contactFormDescription")})),o.createElement(S,{type:A.TEXT_AREA,label:"",value:g.message||"",onChange:g.onMessageChange,textAreaPlaceholder:m("checkout-page:contactFormCta")}),o.createElement(w,{style:{width:"100%",marginTop:"24px"},text:m(v?"checkout-page:actions.close":"checkout-page:actions.sendMessage"),isLoading:c,isDisabled:!g.message,onClick:E})),onClose:function(){return n(!1)}})}));export{V as default};
|
|
1
|
+
import{__awaiter as e,__generator as t}from'../../ext/tslib/tslib.es6.js';import*as o from"react";import{observer as r}from"mobx-react-lite";import{useRouter as i}from"next/router.js";import s from"next/link.js";import a from'../../ext/react-tooltip/dist/index.es.js';import n,{CheckoutStep as l}from"./model.js";import{Analytics as m}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasStorefrontConfig as c}from"../../storefront/index.js";import'../../ext/lodash/isArguments.js';import'../../ext/lodash/isBuffer.js';import'../../ext/lodash/isTypedArray.js';import'../../ext/lodash/_baseGetTag.js';import{formatMoney as d}from"../../utils/currency.js";import{useTranslation as p}from"../../utils/i18n.js";import u from"./steps/step-info/index.js";import{CheckoutStepShipping as v}from"./steps/step-shipping/index.js";import{CheckoutStepPayment as h}from"./steps/step-payment/index.js";import{CartSummary as g}from"./components/cart-summary/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/index.js";import"../../models/data/city/index.js";import"mobx";import"../../models/data/country/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/attribute-value/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-attribute/customer-attribute-option/index.js";import"../../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../../models/data/customer-attribute/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/customer-review-summary/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/merchant-settings/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/adjustment/index.js";import"../../models/data/order/gift-line/index.js";import"../../models/data/order/invoice/index.js";import"../../models/data/order/line-item/discount/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/option/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/tracking-info/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/payment-method/index.js";import"../../models/data/order/refund/line-item/index.js";import"../../models/data/order/shipping-line/index.js";import"../../models/data/order/tax-line/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/product-campaign/campaign/index.js";import"../../models/data/product-campaign/filter/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/theme/theme.js";import{IkasThemePageType as x}from"../../models/theme/page/index.js";import"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-detail/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/register.js";import{ContactForm as E}from"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import{StepSuccess as f}from"./steps/step-success/index.js";import{Modal as j}from"./components/modal/index.js";import k from"./components/master-pass/modal-otp/index.js";import y from"./components/master-pass/modal-link-card-to-client/index.js";import M from"./components/master-pass/modal-response/index.js";import{Image as C}from"../image/index.js";import b,{Step as N}from"./components/step-container/index.js";import{StockError as T}from"./components/error/stock-error/index.js";import{FullscreenLoading as F}from"./components/fullscreen-loading/index.js";import P from"./components/notification-box/index.js";import{FormItem as S}from"./components/form-item/index.js";import{FormItemType as A}from"./components/form-item/model.js";import{Button as V}from"./components/button/index.js";import{IkasPageHead as w}from"../page/head.js";import B from"./components/svg/ikas.js";import I from"./style.module.scss.js";var L=r((function(e){var t,r,s,d=e.checkout,u=e.checkoutSettings,v=e.merchantSettings,h=e.customizationProps,E=e.returnPolicy,C=e.privacyPolicy,b=e.termsOfService,N=p().t,P=i(),S=o.useState((function(){return new n(d,u,v,P,E,C,b,N,h||{})}))[0];return S.step===l.PAYMENT&&m.disableHTML(),o.useEffect((function(){S.checkoutSettings.isAccountRequired&&!S.checkout.hasCustomer&&P.push("/account/login?redirect="+encodeURIComponent(S.checkoutUrl)),m.beginCheckout(S.checkout),m.pageView(x.CHECKOUT)}),[]),o.useEffect((function(){S.customizationProps=h,function(e){document.documentElement.style.setProperty("--checkout-button-bg-color",(null==e?void 0:e.buttonBgColor)||"#272727"),document.documentElement.style.setProperty("--checkout-button-text-color",(null==e?void 0:e.buttonTextColor)||"#FFFFFF"),document.documentElement.style.setProperty("--checkout-button-disabled-bg-color",(null==e?void 0:e.buttonDisabledBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-button-disabled-text-color",(null==e?void 0:e.buttonDisabledTextColor)||"#8A8B94"),document.documentElement.style.setProperty("--checkout-primary-text-color",(null==e?void 0:e.primaryTextColor)||"#272727"),document.documentElement.style.setProperty("--checkout-secondary-text-color",(null==e?void 0:e.secondaryTextColor)||"#8A8B94"),document.documentElement.style.setProperty("--checkout-primary-bg-color",(null==e?void 0:e.primaryBgColor)||"#FFFFFF"),document.documentElement.style.setProperty("--checkout-secondary-bg-color",(null==e?void 0:e.secondaryBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-border-color",(null==e?void 0:e.borderColor)||"#E5E4E9"),document.documentElement.style.setProperty("--checkout-card-bg-color",(null==e?void 0:e.cardBgColor)||"#F7F7F9"),document.documentElement.style.setProperty("--checkout-error-color",(null==e?void 0:e.errorColor)||"#FB4E4E"),document.documentElement.style.setProperty("--checkout-error-light-color",(null==e?void 0:e.errorLightColor)||"#FCF3F4"),document.documentElement.style.setProperty("--checkout-warning-color",(null==e?void 0:e.warningColor)||"#FFBC1F"),document.documentElement.style.setProperty("--checkout-warning-light-color",(null==e?void 0:e.warningLightColor)||"#FFFAEE"),document.documentElement.style.setProperty("--checkout-success-color",(null==e?void 0:e.successColor)||"#2DCA73"),document.documentElement.style.setProperty("--checkout-success-light-color",(null==e?void 0:e.successLightColor)||"#F6FFED")}(h)}),[h]),S.isCheckoutLoaded&&S.store.customerStore.initialized?S.checkout.hasCustomer&&(null===(t=S.store.customerStore.customer)||void 0===t?void 0:t.id)!==(null===(r=S.checkout.customer)||void 0===r?void 0:r.id)?(P.push("/account/login?redirect="+encodeURIComponent(S.checkoutUrl)),null):(console.log("vm.mpVM.visibleModal",S.mpVM.visibleModal),o.createElement(o.Fragment,null,o.createElement(w,{pageType:x.CHECKOUT,pageTitle:((null===(s=S.merchantSettings)||void 0===s?void 0:s.merchantName)||"")+" - "+N("checkout-page:securePayment"),pageDescription:N("checkout-page:securePayment")}),o.createElement("div",{id:"Checkout",className:I.CheckoutPage},o.createElement(a,{place:"top",type:"dark",effect:"solid",arrowColor:"transparent",multiline:!0,className:I.ReactTooltipWrap,globalEventOff:"touchstart"}),o.createElement("div",{className:I.Left},o.createElement("div",{className:I.LeftContent},o.createElement("div",null,o.createElement(R,{vm:S}),S.hasStockError&&o.createElement("div",{className:I.ErrorContainer},o.createElement(T,{vm:S,error:S.error})),!S.hasStockError&&o.createElement(o.Fragment,null,o.createElement(g,{vm:S,allowExpand:!0}),S.step===l.SUCCESS?o.createElement(f,{vm:S}):o.createElement(O,{vm:S})),o.createElement("div",{className:I.Space})),o.createElement(_,{vm:S}))),o.createElement("div",{className:I.Right},o.createElement("div",{className:I.RightContent},o.createElement(g,{vm:S}),o.createElement("div",{className:I.PoweredBy},o.createElement("span",null,"powered by"),o.createElement("a",{href:"https://ikas.com"+("tr"===c.getCurrentLocale()?"/tr":""),target:"_blank"},o.createElement(B,null))))),!!S.policyModalText&&o.createElement(j,{title:S.policyModalTitle,modalContent:S.policyModalText,onClose:function(){S.policyModalText=""}}),S.isContactModalVisible&&o.createElement(D,{vm:S,setVisible:S.setContactModalVisible}),"linkCardToClientModal"===S.mpVM.visibleModal&&o.createElement(y,{visible:"linkCardToClientModal"===S.mpVM.visibleModal,onClose:S.mpVM.hideLinkCardToClientModal,onButtonClick:function(){S.mpVM.onLinkCardToClientButtonClick({cartId:S.checkout.id,checkout:S.checkout,store:S.store})}}),("otpModalBank"===S.mpVM.visibleModal||"otpModalMasterPass"===S.mpVM.visibleModal)&&o.createElement(k,{vm:S,visible:"otpModalBank"===S.mpVM.visibleModal||"otpModalMasterPass"===S.mpVM.visibleModal,type:"otpModalMasterPass"===S.mpVM.visibleModal?"masterPassOtp":"bankOtp",onClose:S.mpVM.hideOtpModal}),"mfsResponseModal"===S.mpVM.visibleModal&&S.mpVM.mfsResponseModalText&&o.createElement(M,{visible:"mfsResponseModal"===S.mpVM.visibleModal,text:S.mpVM.mfsResponseModalText,onClose:S.mpVM.onResponseModalClose})),o.createElement("input",{type:"text",value:S.mpVM.mfsResponseModalText,onChange:function(e){S.mpVM.mfsResponseModalText=e.target.value}}),":",S.mpVM.mfsResponseModalText,o.createElement("button",{onClick:function(){S.showTestModal=!S.showTestModal,S.mpVM.visibleModal=S.mpVM.visibleModal?void 0:"otpModalMasterPass"}},"MODALI AC/KAPAT (",S.mpVM.visibleModal,") (",S.showTestModal,")"))):o.createElement(F,null)})),R=r((function(e){var t,r,i=e.vm,a=p().t;return o.createElement("div",{className:I.Header},o.createElement(s,{href:"/",passHref:!0},o.createElement("a",null,(null===(t=i.merchantSettings)||void 0===t?void 0:t.logo)?o.createElement("div",{className:I.Logo},o.createElement(C,{layout:"fill",image:i.merchantSettings.logo,sizes:"360px"})):(null===(r=i.merchantSettings)||void 0===r?void 0:r.merchantName)||"")),!i.checkout.hasCustomer&&o.createElement("div",{className:I.LoginText},o.createElement("span",{className:I.LoginCta},a("checkout-page:alreadyHaveAnAccount")),o.createElement(s,{href:"/account/login?redirect="+encodeURIComponent(i.checkoutUrl),passHref:!0},o.createElement("a",{className:I.LoginBtn},a("checkout-page:actions.login")))),i.checkout.hasCustomer&&o.createElement("div",{className:I.CustomerInfo},o.createElement("div",{className:I.Name},i.checkout.customerFullName),o.createElement("div",{className:I.Email},i.checkout.customerEmail)))})),O=r((function(e){var t=e.vm,r=p().t,i=o.useMemo((function(){switch(t.step){case l.INFO:return o.createElement(u,{vm:t});case l.SHIPPING:return o.createElement(v,{vm:t});case l.PAYMENT:return o.createElement(h,{vm:t});case l.SUCCESS:return o.createElement(f,{vm:t})}}),[t,t.step]),s=[new N(r("checkout-page:address"),t.step===l.INFO,t.step!==l.INFO,t.step!==l.INFO?o.createElement("div",{className:I.AdressStepInfo},o.createElement(U,{vm:t}),o.createElement("div",{className:I.EditBtn,onClick:t.onBackToInfoClick},r("checkout-page:actions.edit"))):void 0,t.step!==l.INFO?o.createElement("div",{className:I.AddressStepInfoMobile},o.createElement(U,{vm:t})):void 0),new N(r("checkout-page:payment"),t.step===l.PAYMENT,!1)];return"address"===t.deliveryMethod&&s.splice(1,0,new N(r("checkout-page:shipping"),t.step===l.SHIPPING,t.step===l.PAYMENT,t.step===l.PAYMENT?o.createElement("div",{className:I.AdressStepInfo},o.createElement(H,{vm:t}),t.checkout.availableShippingMethods&&t.checkout.availableShippingMethods.length>1&&o.createElement("div",{className:I.EditBtn,onClick:t.onBackToShippingClick},r("checkout-page:actions.edit"))):void 0,t.step===l.PAYMENT?o.createElement("div",{className:I.AddressStepInfoMobile},o.createElement(H,{vm:t})):void 0)),o.createElement(b,{steps:s,stepContent:i})})),U=r((function(e){var t,r,i,s,a,n=e.vm,l=p().t,m=((null===(t=n.checkout.shippingAddress)||void 0===t?void 0:t.firstName)||"")+" "+((null===(r=n.checkout.shippingAddress)||void 0===r?void 0:r.lastName)||"");return o.createElement("div",{className:I.Address},o.createElement("div",{className:[I.Text,I.WithMBottom].join(" ")},(null===(i=n.checkout.customer)||void 0===i?void 0:i.email)||""),"address"===n.deliveryMethod?o.createElement("div",{className:I.Text},m):o.createElement(o.Fragment,null,o.createElement("div",{className:I.Text},l("checkout-page:receiver")),o.createElement("div",{className:[I.Text,I.Gray].join(" ")},m)),o.createElement("div",{className:[I.Text,I.Gray].join(" ")},null===(s=n.checkout.shippingAddress)||void 0===s?void 0:s.phone),"in-store"===n.deliveryMethod&&o.createElement(o.Fragment,null,o.createElement("div",{className:[I.Text,I.WithMTop].join(" ")},l("checkout-page:pickUpLocation"))),o.createElement("div",{className:[I.Text,I.Gray].join(" ")},null===(a=n.checkout.shippingAddress)||void 0===a?void 0:a.addressText))})),H=r((function(e){var t=e.vm,r=p().t;return o.createElement("div",{className:I.Address},t.checkout.shippingLines&&t.checkout.shippingLines.length?o.createElement(o.Fragment,null,o.createElement("span",null,t.checkout.shippingLines[0].title),o.createElement("span",{className:I.LightText}," / "+(0===t.checkout.shippingLines[0].price?r("checkout-page:free"):d(t.checkout.shippingLines[0].price,t.checkout.currencyCode)))):r("checkout-page:standartShipping"))})),_=r((function(e){var t=e.vm,r=p().t;return o.createElement("div",{className:I.Footer},o.createElement("div",{className:I.FooterItem,onClick:function(){t.policyModalTitle=r("checkout-page:returnPolicy"),t.policyModalText=t.returnPolicy}},r("checkout-page:returnPolicy")),o.createElement("div",{className:I.FooterBullet},"•"),o.createElement("div",{className:I.FooterItem,onClick:function(){t.policyModalTitle=r("checkout-page:privacyPolicy"),t.policyModalText=t.privacyPolicy}},r("checkout-page:privacyPolicy")),o.createElement("div",{className:I.FooterBullet},"•"),o.createElement("div",{className:I.FooterItem,onClick:function(){t.policyModalTitle=r("checkout-page:termsOfService"),t.policyModalText=t.termsOfService}},r("checkout-page:termsOfService")))})),D=r((function(r){var i,s,a=r.vm,n=r.setVisible,l=p().t,m=o.useState(!1),c=m[0],d=m[1],u=o.useState(!1),v=u[0],h=u[1],g=o.useState(new E({message:{requiredRule:"",emailRule:"",minRule:""},store:a.store}))[0];g.email=a.checkout.customerEmail,g.firstName=(null===(i=a.checkout.customer)||void 0===i?void 0:i.firstName)||"",g.lastName=(null===(s=a.checkout.customer)||void 0===s?void 0:s.lastName)||"";var x=o.useCallback((function(){return e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return v?[2,n(!1)]:(d(!0),[4,g.saveContactForm()]);case 1:return e.sent()&&h(!0),d(!1),[2]}}))}))}),[c]);return o.createElement(j,{title:l("checkout-page:contactForm"),modalContent:o.createElement("div",null,v&&o.createElement("div",{style:{marginBottom:"12px",maxWidth:"352px"}},o.createElement(P,{type:"success",title:l("checkout-page:contactFormSent"),content:l("checkout-page:contactFormDescription")})),o.createElement(S,{type:A.TEXT_AREA,label:"",value:g.message||"",onChange:g.onMessageChange,textAreaPlaceholder:l("checkout-page:contactFormCta")}),o.createElement(V,{style:{width:"100%",marginTop:"24px"},text:l(v?"checkout-page:actions.close":"checkout-page:actions.sendMessage"),isLoading:c,isDisabled:!g.message,onClick:x})),onClose:function(){return n(!1)}})}));export{L as default};
|
|
@@ -51,6 +51,7 @@ export default class CheckoutViewModel {
|
|
|
51
51
|
error?: CheckoutError | null;
|
|
52
52
|
successTransaction?: IkasOrderTransaction;
|
|
53
53
|
mpVM: MasterPassModel;
|
|
54
|
+
showTestModal: boolean;
|
|
54
55
|
t: TFunction;
|
|
55
56
|
constructor(checkout: IkasCheckout, checkoutSettings: IkasCheckoutSettings, merchantSettings: IkasMerchantSettings | null, router: NextRouter, returnPolicy: string, privacyPolicy: string, termsOfService: string, t: TFunction, customizationProps: IkasCheckoutCustomizationProps);
|
|
56
57
|
init: () => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as e,__assign as i}from'../../ext/tslib/tslib.es6.js';import{makeAutoObservable as s}from"mobx";import n from'../../ext/lodash/cloneDeep.js';import r from'../../ext/lodash/sortBy.js';import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import{IkasCustomerAddress as o}from"../../models/data/customer/address/index.js";import"../../models/data/customer/attribute-value/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-attribute/customer-attribute-option/index.js";import"../../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../../models/data/customer-attribute/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/customer-review-summary/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/merchant-settings/index.js";import{IkasOrderAddress as a}from"../../models/data/order/address/index.js";import"../../models/data/order/adjustment/index.js";import{IkasOrderCustomer as d}from"../../models/data/order/customer/index.js";import"../../models/data/order/gift-line/index.js";import"../../models/data/order/invoice/index.js";import"../../models/data/order/line-item/discount/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/option/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/tracking-info/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/payment-method/index.js";import"../../models/data/order/refund/line-item/index.js";import"../../models/data/order/shipping-line/index.js";import"../../models/data/order/tax-line/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/product-campaign/campaign/index.js";import"../../models/data/product-campaign/filter/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/theme/theme.js";import"../../models/theme/page/index.js";import"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-detail/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import"../../models/data/payment-gateway/index.js";import c from"./components/credit-card-form/model.js";import{IkasStorefrontConfig as l}from"../../storefront/index.js";import{IkasCheckoutSettings as u}from"../../models/data/checkout-settings/index.js";import{Analytics as h}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import p from"../../models/data/checkout/index.js";import m from"../../store/customer/api.js";import v from"../../store/merchant/index.js";import f from"../../store/checkout/index.js";import{CheckStocksLineInput as g}from"../../__api/models/CheckStocksLineInput.js";import y from"../../store/cart/api.js";import{SaveCartInput as S}from"../../__api/models/SaveCartInput.js";import{PaymentMethodEnum as k,PaymentGatewayTypeEnum as b,TransactionStatusEnum as I}from"../../__api/types/index.js";import C from"./modelMasterPass.js";import P from'../../ext/uuid/dist/esm-node/v4.js';var A,j,w=/^\d+$/,N="undefined"==typeof localStorage,R=function(){function w(w,R,T,O,D,M,G,_,L){var U=this;this.checkout=new p,this.checkoutSettings=new u,this.storefront=null,this.store=l.store,this.isCheckoutLoaded=!1,this.isErrorsVisible=!1,this.isStepLoading=!1,this.isTermsAndConditionsChecked=!1,this.isChangingShippingMethod=!1,this.isContactModalVisible=!1,this.step=A.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],this.installmentInfo=null,this.useDifferentAddress=!1,this.shouldSaveAddress=!0,this.addressTitle="",this.shippingCountryIds=null,this.selectedShippingAddressId="-1",this.selectedBillingAddressId="-1",this.stockLocations=[],this.availableStockLocations=[],this.deliveryMethod="address",this.stripeResponse=null,this.policyModalTitle="",this.policyModalText="",this.error=null,this.init=function(){return t(U,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,this.store.customerStore.waitUntilInitialized()];case 1:return t.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getMerchantSettings()];case 2:return t.sent(),[4,this.initStep()];case 3:return t.sent(),[2]}}))}))},this.initStep=function(){return t(U,void 0,void 0,(function(){var t,i,s,n,r,o,a;return e(this,(function(e){switch(e.label){case 0:if(l.isEditor)return this.step=A.INFO,this.isCheckoutLoaded=!0,[2];if(t=new URLSearchParams(window.location.search),i=t.get("step"),s=t.get("failed"),n=t.get("error"),i){if(this.step=i,this.step===A.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(A.INFO)];if(this.step!==A.PAYMENT||this.canProceedToPayment){if(![A.INFO,A.SUCCESS,A.SHIPPING,A.PAYMENT].includes(this.step))return[2,this.changeStep(A.INFO)]}else{if(!this.isInStoreDelivery)return[2,this.changeStep(A.INFO)];this.deliveryMethod="in-store"}}return s&&(this.error={type:j.PAYMENT_ERROR,data:n||null}),this.step!==A.INFO?[3,4]:[4,this.getShippingCountries()];case 1:return e.sent(),this.checkShippingCountries(),[4,this.getStockLocations()];case 2:return e.sent(),[4,this.getAvailableStockLocations()];case 3:e.sent(),this.isInStoreDelivery&&(this.deliveryMethod="in-store"),e.label=4;case 4:return this.step!==A.SHIPPING||1!==(null===(o=this.checkout.availableShippingMethods)||void 0===o?void 0:o.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=A.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==A.SHIPPING||(null===(a=this.checkout.availableShippingMethods)||void 0===a?void 0:a.length)?this.step!==A.PAYMENT&&this.step!==A.SUCCESS?[3,8]:[4,this.listPaymentGateways()]:(this.error={type:j.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 5:return e.sent(),this.isInStoreDelivery?(this.deliveryMethod="in-store",[4,this.getStockLocations()]):[3,7];case 6:e.sent(),e.label=7;case 7:if(!this.paymentGateways.length)return this.error={type:j.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];e.label=8;case 8:return this.step===A.SUCCESS?[3,12]:this.checkout.isComplete?[2,this.changeStep(A.SUCCESS)]:[3,9];case 9:return[4,this.initialStockCheck()];case 10:e.sent(),e.label=11;case 11:return[3,14];case 12:return[4,this.getSuccessTransaction()];case 13:e.sent(),this.successTransaction&&(r=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(t){return t.id===r}))),e.label=14;case 14:return this.isCheckoutLoaded=!0,h.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getMerchantSettings=function(){return t(U,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.merchantSettings?[3,2]:[4,v.listMerchantSettings({})];case 1:t=e.sent(),this.merchantSettings=t.data||void 0,e.label=2;case 2:return[2]}}))}))},this.getSuccessTransaction=function(){return t(U,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,m.listOrderTransactions({orderId:{eq:this.checkout.id}})];case 1:return t=e.sent(),this.successTransaction=t.isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)?t.data[0]:void 0,[2]}}))}))},this.saveCart=function(){return t(U,void 0,void 0,(function(){var t,i,s,n;return e(this,(function(e){switch(e.label){case 0:return(t=new S(this.checkout)).cartId=this.checkout.id,"in-store"!==this.deliveryMethod?[3,2]:[4,this.inStockDeliveryInputData(t)];case 1:t=e.sent(),e.label=2;case 2:return[4,y.saveCart({input:t})];case 3:if((null==(i=e.sent())?void 0:i.graphQLErrors)&&i.graphQLErrors.length)throw s=i.graphQLErrors[0],"CUSTOMER_LOGIN_REQUIRED"===(null===(n=s.extensions)||void 0===n?void 0:n.code)?{type:j.CUSTOMER_LOGIN_REQUIRED_ERROR}:{type:j.API_ERROR};return[2,i.data]}}))}))},this.inStockDeliveryInputData=function(i){return t(U,void 0,void 0,(function(){var t,s,n=this;return e(this,(function(e){return t=i,(s=this.stockLocations.find((function(t){return t.id===n.checkout.stockLocationId})))&&t.shippingAddress&&s.address&&(t.shippingAddress.country=s.address.country,t.shippingAddress.city=s.address.city,t.shippingAddress.state=s.address.state,t.shippingAddress.district=s.address.district,t.shippingAddress.postalCode=s.address.postalCode,t.shippingAddress.addressLine1=s.address.address||"",t.shippingAddress.addressLine2=null),t.billingAddress=null,[2,t]}))}))},this.checkStocks=function(){return t(U,void 0,void 0,(function(){var t,i,s,n,r,o,a,d,c,u,h,p;return e(this,(function(e){switch(e.label){case 0:return t=this.checkout.items.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,f.checkStocks({lines:t.map((function(t){return new g(t)})),stockLocationIdList:l.pickUpStockLocationIds||[]})];case 1:if(!(i=e.sent()).isSuccess)throw{type:j.API_ERROR};if(null==(s=null===(h=null===(u=i.data)||void 0===u?void 0:u.lines)||void 0===h?void 0:h.filter((function(t){return!t.isAvailable})))?void 0:s.length){for(n=[],r=function(t){var e=null===(p=o.store.cartStore.cart)||void 0===p?void 0:p.items.find((function(e){return e.variant.id===t.variantId}));e&&n.push(e)},o=this,a=0,d=s;a<d.length;a++)c=d[a],r(c);throw{type:j.STOCK_ERROR,data:n}}return[2]}}))}))},this.removeUnavailableItems=function(i){return t(U,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:t=0,s=i,e.label=1;case 1:return t<s.length?(n=s[t],[4,this.store.cartStore.removeItem(n)]):[3,4];case 2:e.sent(),e.label=3;case 3:return t++,[3,1];case 4:return[2]}}))}))},this.getShippingCountries=function(){return t(U,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,f.getAvailableShippingCountries({salesChannelId:l.salesChannelId})];case 1:return t=e.sent(),this.shippingCountryIds=t.data,[2]}}))}))},this.getStockLocations=function(){return t(U,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return l.pickUpStockLocationIds?[4,f.listStockLocation({id:{in:l.pickUpStockLocationIds}})]:[3,2];case 1:if(!(t=e.sent()).isSuccess||!(null===(i=t.data)||void 0===i?void 0:i.length))return this.error={type:j.API_ERROR},[2];this.stockLocations=t.data,e.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return t(U,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return l.pickUpStockLocationIds?(t=this.checkout.items.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,f.getAvailableStockLocations({lines:t.map((function(t){return new g(t)})),stockLocationIdList:l.pickUpStockLocationIds})]):[3,2];case 1:if(!(i=e.sent()).isSuccess)return this.error={type:j.API_ERROR},[2];this.availableStockLocations=i.data||[],e.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var t;(null===(t=U.shippingCountryIds)||void 0===t?void 0:t.length)||(U.error={type:j.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(t){"address"===t&&(U.checkout.stockLocationId=null),U.deliveryMethod=t,U.isErrorsVisible=!1},this.initialStockCheck=function(){return t(U,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.checkStocks()];case 1:return e.sent(),[3,3];case 2:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:j.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return t(U,void 0,void 0,(function(){var t,i,s,n,o,a,d,c,u,h=this;return e(this,(function(e){switch(e.label){case 0:return t="local"===process.env.NEXT_PUBLIC_ENV,i=l.paymentGateways.map((function(t){return t.id})),[4,f.listPaymentGateway({id:t?void 0:{in:i}})];case 1:return(s=e.sent()).isSuccess&&(null===(c=s.data)||void 0===c?void 0:c.length)?(n=s.data,this.step===A.PAYMENT&&(n=n.filter((function(t){return!t.supportedCurrencies.length||t.supportedCurrencies.includes(h.checkout.currencyCode)})),(o=null===(u=this.checkout.shippingAddress)||void 0===u?void 0:u.country)&&o.iso2&&(n=n.filter((function(t){return!t.availableCountries.length||t.availableCountries.includes(o.iso2||"")})))),a=[],r(l.paymentGateways,"order").forEach((function(t){var e=null==n?void 0:n.find((function(e){return e.id===t.id}));e&&a.push(e)})),this.paymentGateways=t?n:a,this.checkout.selectedPaymentGateway||this.setPaymentGateway(0),console.log("1"),this.step===A.PAYMENT&&(console.log("2",{paymentGateways:n}),(d=n.find((function(t){return!!t.masterPassClientId})))&&(console.log("3"),this.checkout.masterPassPaymentGateway=d,this.mpVM.checkMasterPass({checkout:this.checkout,store:this.store}))),[2]):(this.error={type:j.API_ERROR},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return t(U,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return[4,f.retrieveInstallmentInfo(i)];case 1:return t=e.sent(),s=t.data,null===(n=null==s?void 0:s.installmentPrices)||void 0===n||n.sort((function(t,e){return(t.installmentCount||-1)>(e.installmentCount||-1)?1:-1})),this.installmentInfo=s,[2]}}))}))},this.createCustomer=function(){var t;U.store.customerStore.customer?(null===(t=U.store.customerStore.customer.addresses)||void 0===t||t.forEach((function(t){return t.checkoutSettings=U.checkoutSettings})),U.checkout.customer=new d(U.store.customerStore.customer)):U.checkout.customer||(U.checkout.customer=new d({}))},this.createShippingAddress=function(){var t;if(U.checkout.shippingAddress)U.selectedShippingAddressId=U.checkout.shippingAddress.id||"-1",U.checkout.shippingAddress.checkoutSettings=U.checkoutSettings;else{var e=null===(t=U.store.customerStore.customer)||void 0===t?void 0:t.addresses;U.onSelectedShippingAddressIdChange((null==e?void 0:e.length)?e[0].id:"-1")}},this.createBillingAddress=function(){"undefined"!=typeof localStorage&&(U.useDifferentAddress=!!localStorage.getItem("sAddr"),U.useDifferentAddress?(U.checkout.billingAddress&&(U.selectedBillingAddressId=U.checkout.billingAddress.id||"-1"),U.checkout.billingAddress=U.checkout.billingAddress||new a):U.checkout.billingAddress=new a(n(U.checkout.shippingAddress)||{}),U.checkout.billingAddress.checkoutSettings=U.checkoutSettings)},this.onShippingMethodChange=function(i){return t(U,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.isChangingShippingMethod?[2]:(this.isChangingShippingMethod=!0,this.checkout.shippingSettingsId=i.shippingSettingsId,this.checkout.shippingZoneRateId=i.shippingZoneRateId,[4,this.saveCart()]);case 1:return(t=e.sent())&&(this.checkout=new p(t)),this.isChangingShippingMethod=!1,[2]}}))}))},this.onStockLocationChange=function(i){return t(U,void 0,void 0,(function(){return e(this,(function(t){return this.checkout.stockLocationId=i.id,[2]}))}))},this.onCouponCodeApply=function(){return t(U,void 0,void 0,(function(){var t,s,n,r,o,a;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,y.saveCartCouponCode({cartId:this.checkout.id,couponCode:this.checkout.couponCode||null})];case 1:return(t=e.sent()).isSuccess&&t.data&&(s=t.data,n=null===(a=null===(o=this.cardData)||void 0===o?void 0:o.cardNumber)||void 0===a?void 0:a.split(" ").join(""),this.step===A.PAYMENT&&(null==n?void 0:n.length)&&n.length>=6&&this.retrieveInstallmentInfo({input:{binNumber:n.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:s.totalFinalPrice}}),s&&(r=this.checkout,this.checkout=new p(i(i({},s),{shippingAddress:r.shippingAddress,billingAddress:r.billingAddress,customer:r.customer,selectedPaymentGateway:r.selectedPaymentGateway})))),[3,3];case 2:return e.sent(),[3,3];case 3:return[2]}}))}))},this.onSelectedShippingAddressIdChange=function(t){var e,i;if(U.selectedShippingAddressId=t,"-1"===t)U.checkout.shippingAddress=new a;else{var s=null===(i=null===(e=U.store.customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===i?void 0:i.find((function(e){return e.id===t}));s&&(U.checkout.shippingAddress=new a(s))}U.checkout.shippingAddress&&(U.checkout.shippingAddress.checkoutSettings=U.checkoutSettings)},this.onSelectedBillingAddressIdChange=function(t){var e,i;if(U.selectedBillingAddressId=t,"-1"===t)U.checkout.billingAddress=new a;else{var s=null===(i=null===(e=U.store.customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===i?void 0:i.find((function(e){return e.id===t}));s&&(U.checkout.billingAddress=new a(s))}U.checkout.billingAddress&&(U.checkout.billingAddress.checkoutSettings=U.checkoutSettings)},this.onTermsAndConditionsCheckedChange=function(t){U.isTermsAndConditionsChecked=t},this.onCardNumberChange=function(t){if(U.cardData&&(!(t.length>U.cardData.cardNumber.length)||E(t))){var e=(U.cardData.cardNumber||"").split(" ").join(""),i=t.split(" ").join("");i.length>16||(e.length<6&&i.length>=6&&!U.installmentInfo?U.retrieveInstallmentInfo({input:{binNumber:i.slice(0,6),paymentGatewayId:U.checkout.selectedPaymentGateway.id,price:U.checkout.totalFinalPrice}}):i.length<6&&e.length>i.length&&(U.cardData.installmentCount=1,U.installmentInfo=void 0),U.cardData.cardNumber=x(i,4).join(" "))}},this.onCardHolderNameChange=function(t){U.cardData&&(U.cardData.cardHolderName=t)},this.onExpirationDateChange=function(t){var e;if(U.cardData&&(!(t.length>U.cardData.expirationDate.length)||E(t))){if(0===(null===(e=U.cardData.expirationDate)||void 0===e?void 0:e.length)){var i=t.split("/");if(2===i.length){var s=i[0].trim(),n=i[1].trim();if(4===s.length&&2===n.length){var r=parseInt(s.slice(2)),o=parseInt(n);if(!isNaN(r)&&!isNaN(o))return void(U.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}if(2===s.length&&4===n.length){o=parseInt(s),r=parseInt(n.slice(2));if(!isNaN(r)&&!isNaN(o))return void(U.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var a=t.split(" / ").join("");a.length>4||(U.cardData.expirationDate=x(a,2).join(" / "))}},this.onCvcChange=function(t){U.cardData&&(t.length>U.cardData.cvv.length&&!E(t)||t.length>4||(U.cardData.cvv=t))},this.saveAddress=function(s){return t(U,void 0,void 0,(function(){var t,r,a,d,c;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),this.shouldSaveAddress&&this.store.customerStore.customer?(t="shipping"===s?this.checkout.shippingAddress:this.checkout.billingAddress,(null===(c=this.store.customerStore.customer.addresses)||void 0===c?void 0:c.find((function(e){return e.id===(null==t?void 0:t.id)})))?[2]:(r=new o(i(i({},t),{title:this.addressTitle||this.t("checkout-page:newAddress"),id:P()})),(a=n(this.store.customerStore.customer)).addresses||(a.addresses=[]),a.addresses.push(r),[4,this.store.customerStore.saveCustomer(a)])):[3,2];case 1:e.sent(),"shipping"===s?(this.checkout.shippingAddress.id=r.id,this.selectedShippingAddressId=r.id||"-1"):(this.checkout.billingAddress.id=r.id,this.selectedBillingAddressId=r.id||"-1"),e.label=2;case 2:return[3,4];case 3:return d=e.sent(),console.error(d),[3,4];case 4:return[2]}}))}))},this.onGoToCartClick=function(){U.router.push("/cart")},this.onBackToShoppingClick=function(){U.router.push("/")},this.onProceedToShippingClick=function(){return t(U,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if("address"===this.deliveryMethod){if(!this.canProceedToShipping)return this.isErrorsVisible=!0,[2]}else if(!this.canProceedToInStoreDelivery)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,6,,7]),this.isStepLoading=!0,"address"!==this.deliveryMethod?[3,3]:[4,this.saveAddress("shipping")];case 2:e.sent(),e.label=3;case 3:return[4,this.checkStocks()];case 4:return e.sent(),[4,this.saveCart()];case 5:return e.sent(),"address"===this.deliveryMethod?this.changeStep(A.SHIPPING):this.changeStep(A.PAYMENT),[3,7];case 6:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:j.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToPaymentClick=function(){return t(U,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),[4,this.saveCart()];case 3:return e.sent(),this.error=void 0,this.changeStep(A.PAYMENT),[3,5];case 4:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:j.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onCompletePaymentClick=function(){return t(U,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:if(!this.canPerformPayment)return this.isErrorsVisible=!0,[2];this.useDifferentAddress||(this.checkout.billingAddress=this.checkout.shippingAddress),e.label=1;case 1:return e.trys.push([1,7,,8]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),"address"!==this.deliveryMethod?[3,4]:[4,this.saveAddress("billing")];case 3:e.sent(),e.label=4;case 4:return[4,this.saveCart()];case 5:return e.sent(),this.isCustomFlowStripe?((t=document.querySelector("#stripe-form-btn"))&&t.click(),[2]):[4,this.createSaleTransaction()];case 6:return e.sent(),[3,8];case 7:return(i=e.sent()).type?this.error=i:this.error={type:j.UNKNOWN},this.isStepLoading=!1,[3,8];case 8:return[2]}}))}))},this.createSaleTransaction=function(){return t(U,void 0,void 0,(function(){var t,i,s,n,r,o,a,d,c,l,u,h,p,m,v;return e(this,(function(e){switch(e.label){case 0:return(i=this.mpVM.selectedCard)&&(null===(d=this.mpVM.selectedCard)||void 0===d?void 0:d.Name)?((n=this.mpVM.phoneNumber({store:this.store,checkout:this.checkout}))&&(t=n),void 0===(null===(c=this.cardData)||void 0===c?void 0:c.installmentCount)?[2]:[4,f.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:{phoneNumber:t,savedCardName:null===(l=this.mpVM.selectedCard)||void 0===l?void 0:l.Name},paymentGatewayId:null===(u=this.mpVM.selectedCard)||void 0===u?void 0:u.paymentGatewayId,paymentMethodDetail:{cardNumber:this.mpVM.selectedCard.Value1,cardHolderName:this.mpVM.selectedCard.Name,cvv:this.mpVM.selectedCard.Value2,expiredMonth:11,expiredYear:11,installmentCount:this.cardData.installmentCount,threeDSecure:!!(null===(h=this.cardData)||void 0===h?void 0:h.threeDSecure)}}})]):[3,2];case 1:return s=e.sent(),[3,4];case 2:return this.checkout.selectedPaymentGateway?[4,f.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:i&&t?{phoneNumber:t,savedCardName:null===(p=this.mpVM.selectedCard)||void 0===p?void 0:p.Name}:void 0,paymentGatewayId:this.checkout.selectedPaymentGateway.id,paymentMethodDetail:i?void 0:this.checkout.selectedPaymentGateway.paymentMethodType===k.CREDIT_CARD&&this.checkout.selectedPaymentGateway.type===b.INTERNAL&&this.cardData?this.cardData.toInput():void 0}})]:[2];case 3:s=e.sent(),e.label=4;case 4:return r=null===(m=null==s?void 0:s.data)||void 0===m?void 0:m.transactionStatus,o=r&&[I.SUCCESS,I.AUTHORIZED].includes(r),a=r===I.PENDING,o?[4,this.getSuccessTransaction()]:[3,7];case 5:return e.sent(),[4,this.onCheckoutTransactionSuccess()];case 6:return e.sent(),[3,8];case 7:if(!a||!(null===(v=null==s?void 0:s.data)||void 0===v?void 0:v.returnSlug))throw{type:j.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+s.data.returnSlug,e.label=8;case 8:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(){return t(U,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return localStorage.removeItem("sAddr"),(null===(t=this.checkout.customer)||void 0===t?void 0:t.notificationsAccepted)?[4,this.store.customerStore.createEmailSubscription((null===(i=this.checkout.customer)||void 0===i?void 0:i.email)||"")]:[3,2];case 1:e.sent(),e.label=2;case 2:return this.changeStep(A.SUCCESS),[2]}}))}))},this.onBackToInfoClick=function(){U.changeStep(A.INFO)},this.onBackToShippingClick=function(){U.changeStep(A.SHIPPING)},this.setCustomerConsentGranted=function(t){U.checkout.customer&&(U.checkout.customer.notificationsAccepted=t)},this.setUseDifferentAddress=function(t){U.useDifferentAddress=t,U.useDifferentAddress?(localStorage.setItem("sAddr","1"),U.checkout.billingAddress=U.checkout.billingAddress||new a):(localStorage.removeItem("sAddr"),U.checkout.billingAddress=U.checkout.shippingAddress)},this.setShouldSaveAddress=function(t){U.shouldSaveAddress=t},this.setAddressTitle=function(t){U.addressTitle=t},this.setPaymentGateway=function(i){return t(U,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return this.paymentGateways.length?"STRIPE"!==(t=this.paymentGateways[i]).code||!(null===(n=t.settings)||void 0===n?void 0:n.find((function(t){return"allow_custom_flow"===t.label&&"true"===t.value})))||this.stripeResponse?[3,2]:[4,f.createStripePaymentIntent({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}})]:[2];case 1:(s=e.sent()).isSuccess&&s.data&&(this.stripeResponse=s.data),e.label=2;case 2:return this.checkout.selectedPaymentGateway=t,this.step!==A.SUCCESS&&(t.paymentMethodType===k.CREDIT_CARD&&t.type===b.INTERNAL&&(this.cardData=new c),this.installmentInfo=void 0),[2]}}))}))},this.setInstallmentCount=function(t){U.cardData&&(U.cardData.installmentCount=t)},this.changeStep=function(i){return t(U,void 0,void 0,(function(){return e(this,(function(t){return N||window.location.replace("".concat(window.location.pathname,"?id=").concat(this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return t(U,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:this.checkout.customer=null,this.store.customerStore.logout(),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.saveCart()];case 2:case 3:return t.sent(),[3,4];case 4:return this.createCustomer(),[2]}}))}))},this.setContactModalVisible=function(t){U.isContactModalVisible=t},this.checkout=w,this.checkoutSettings=R,this.router=O,this.returnPolicy=D,this.privacyPolicy=M,this.termsOfService=G,this.t=_,this.customizationProps=L,this.mpVM=new C,T&&(this.merchantSettings=T),this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.init(),s(this)}return Object.defineProperty(w.prototype,"selectedPaymentGatewayIndex",{get:function(){var t=this;return this.paymentGateways.findIndex((function(e){var i;return e.id===(null===(i=t.checkout.selectedPaymentGateway)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"selectedInstallmentIndex",{get:function(){var t,e,i=this;return(null===(e=null===(t=this.installmentInfo)||void 0===t?void 0:t.installmentPrices)||void 0===e?void 0:e.findIndex((function(t){var e;return t.installmentCount===(null===(e=i.cardData)||void 0===e?void 0:e.installmentCount)})))||0},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"customerAddressOptions",{get:function(){var t,e,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(e=null===(t=this.store.customerStore.customer)||void 0===t?void 0:t.addresses)||void 0===e?void 0:e.map((function(t){return{label:t.title+" - "+t.addressText,value:t.id}})))||[];return[i].concat(s)},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"installmentPrice",{get:function(){var t,e,i,s=this;if(this.installmentInfo&&(null===(t=this.cardData)||void 0===t?void 0:t.installmentCount))return null===(i=null===(e=this.installmentInfo.installmentPrices)||void 0===e?void 0:e.find((function(t){var e;return t.installmentCount===(null===(e=s.cardData)||void 0===e?void 0:e.installmentCount)})))||void 0===i?void 0:i.totalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"finalPrice",{get:function(){return this.step===A.SUCCESS?this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"hasStockError",{get:function(){var t;return(null===(t=this.error)||void 0===t?void 0:t.type)===j.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"canProceedToShipping",{get:function(){var t,e;return(null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.isValid)&&this.checkout.hasValidCustomerEmail&&(null===(e=this.error)||void 0===e?void 0:e.type)!==j.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"canProceedToInStoreDelivery",{get:function(){var t,e,i;return!!((null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.firstName)&&(null===(e=this.checkout.shippingAddress)||void 0===e?void 0:e.lastName)&&(null===(i=this.checkout.customer)||void 0===i?void 0:i.email)&&this.checkout.stockLocationId)},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"isCustomFlowStripe",{get:function(){var t,e=this.checkout.selectedPaymentGateway;return e&&"STRIPE"===e.code&&(null===(t=e.settings)||void 0===t?void 0:t.find((function(t){return"allow_custom_flow"===t.label&&"true"===t.value})))},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"canPerformPayment",{get:function(){var t,e;if(this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)return!1;var i=this.checkout.selectedPaymentGateway,s="in-store"===this.deliveryMethod,n=!!s||!!this.canProceedToShipping,r=!!s||!!(null===(t=this.checkout.billingAddress)||void 0===t?void 0:t.isValid),o=!!this.mpVM.selectedCard||((null==i?void 0:i.paymentMethodType)===k.CREDIT_CARD&&i.type===b.INTERNAL?!!this.isCustomFlowStripe||(null===(e=this.cardData)||void 0===e?void 0:e.isValid):!!i);return n&&r&&o},enumerable:!1,configurable:!0}),w}();function x(t,e){return t.match(new RegExp(".{1,"+e+"}","g"))||[]}function E(t){return t&&w.test(t.charAt(t.length-1))}!function(t){t.INFO="info",t.SHIPPING="shipping",t.PAYMENT="payment",t.SUCCESS="success"}(A||(A={})),function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.API_ERROR=1]="API_ERROR",t[t.STOCK_ERROR=2]="STOCK_ERROR",t[t.PAYMENT_ERROR=3]="PAYMENT_ERROR",t[t.NO_SHIPPING_ERROR=4]="NO_SHIPPING_ERROR",t[t.CUSTOMER_LOGIN_REQUIRED_ERROR=5]="CUSTOMER_LOGIN_REQUIRED_ERROR"}(j||(j={}));export{A as CheckoutStep,j as ErrorType,R as default};
|
|
1
|
+
import{__awaiter as t,__generator as e,__assign as i}from'../../ext/tslib/tslib.es6.js';import{makeAutoObservable as s}from"mobx";import n from'../../ext/lodash/cloneDeep.js';import r from'../../ext/lodash/sortBy.js';import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import{IkasCustomerAddress as o}from"../../models/data/customer/address/index.js";import"../../models/data/customer/attribute-value/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-attribute/customer-attribute-option/index.js";import"../../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../../models/data/customer-attribute/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/customer-review-summary/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/merchant-settings/index.js";import{IkasOrderAddress as a}from"../../models/data/order/address/index.js";import"../../models/data/order/adjustment/index.js";import{IkasOrderCustomer as d}from"../../models/data/order/customer/index.js";import"../../models/data/order/gift-line/index.js";import"../../models/data/order/invoice/index.js";import"../../models/data/order/line-item/discount/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/option/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/tracking-info/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/payment-method/index.js";import"../../models/data/order/refund/line-item/index.js";import"../../models/data/order/shipping-line/index.js";import"../../models/data/order/tax-line/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/product-campaign/campaign/index.js";import"../../models/data/product-campaign/filter/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/theme/theme.js";import"../../models/theme/page/index.js";import"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-detail/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import"../../models/data/payment-gateway/index.js";import c from"./components/credit-card-form/model.js";import{IkasStorefrontConfig as l}from"../../storefront/index.js";import{IkasCheckoutSettings as u}from"../../models/data/checkout-settings/index.js";import{Analytics as h}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import p from"../../models/data/checkout/index.js";import m from"../../store/customer/api.js";import v from"../../store/merchant/index.js";import f from"../../store/checkout/index.js";import{CheckStocksLineInput as g}from"../../__api/models/CheckStocksLineInput.js";import y from"../../store/cart/api.js";import{SaveCartInput as S}from"../../__api/models/SaveCartInput.js";import{PaymentMethodEnum as k,PaymentGatewayTypeEnum as b,TransactionStatusEnum as I}from"../../__api/types/index.js";import C from"./modelMasterPass.js";import P from'../../ext/uuid/dist/esm-node/v4.js';var A,j,w=/^\d+$/,N="undefined"==typeof localStorage,R=function(){function w(w,R,T,O,D,M,G,_,L){var U=this;this.checkout=new p,this.checkoutSettings=new u,this.storefront=null,this.store=l.store,this.isCheckoutLoaded=!1,this.isErrorsVisible=!1,this.isStepLoading=!1,this.isTermsAndConditionsChecked=!1,this.isChangingShippingMethod=!1,this.isContactModalVisible=!1,this.step=A.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],this.installmentInfo=null,this.useDifferentAddress=!1,this.shouldSaveAddress=!0,this.addressTitle="",this.shippingCountryIds=null,this.selectedShippingAddressId="-1",this.selectedBillingAddressId="-1",this.stockLocations=[],this.availableStockLocations=[],this.deliveryMethod="address",this.stripeResponse=null,this.policyModalTitle="",this.policyModalText="",this.error=null,this.showTestModal=!1,this.init=function(){return t(U,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,this.store.customerStore.waitUntilInitialized()];case 1:return t.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getMerchantSettings()];case 2:return t.sent(),[4,this.initStep()];case 3:return t.sent(),[2]}}))}))},this.initStep=function(){return t(U,void 0,void 0,(function(){var t,i,s,n,r,o,a;return e(this,(function(e){switch(e.label){case 0:if(l.isEditor)return this.step=A.INFO,this.isCheckoutLoaded=!0,[2];if(t=new URLSearchParams(window.location.search),i=t.get("step"),s=t.get("failed"),n=t.get("error"),i){if(this.step=i,this.step===A.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(A.INFO)];if(this.step!==A.PAYMENT||this.canProceedToPayment){if(![A.INFO,A.SUCCESS,A.SHIPPING,A.PAYMENT].includes(this.step))return[2,this.changeStep(A.INFO)]}else{if(!this.isInStoreDelivery)return[2,this.changeStep(A.INFO)];this.deliveryMethod="in-store"}}return s&&(this.error={type:j.PAYMENT_ERROR,data:n||null}),this.step!==A.INFO?[3,4]:[4,this.getShippingCountries()];case 1:return e.sent(),this.checkShippingCountries(),[4,this.getStockLocations()];case 2:return e.sent(),[4,this.getAvailableStockLocations()];case 3:e.sent(),this.isInStoreDelivery&&(this.deliveryMethod="in-store"),e.label=4;case 4:return this.step!==A.SHIPPING||1!==(null===(o=this.checkout.availableShippingMethods)||void 0===o?void 0:o.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=A.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==A.SHIPPING||(null===(a=this.checkout.availableShippingMethods)||void 0===a?void 0:a.length)?this.step!==A.PAYMENT&&this.step!==A.SUCCESS?[3,8]:[4,this.listPaymentGateways()]:(this.error={type:j.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 5:return e.sent(),this.isInStoreDelivery?(this.deliveryMethod="in-store",[4,this.getStockLocations()]):[3,7];case 6:e.sent(),e.label=7;case 7:if(!this.paymentGateways.length)return this.error={type:j.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];e.label=8;case 8:return this.step===A.SUCCESS?[3,12]:this.checkout.isComplete?[2,this.changeStep(A.SUCCESS)]:[3,9];case 9:return[4,this.initialStockCheck()];case 10:e.sent(),e.label=11;case 11:return[3,14];case 12:return[4,this.getSuccessTransaction()];case 13:e.sent(),this.successTransaction&&(r=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(t){return t.id===r}))),e.label=14;case 14:return this.isCheckoutLoaded=!0,h.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getMerchantSettings=function(){return t(U,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.merchantSettings?[3,2]:[4,v.listMerchantSettings({})];case 1:t=e.sent(),this.merchantSettings=t.data||void 0,e.label=2;case 2:return[2]}}))}))},this.getSuccessTransaction=function(){return t(U,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,m.listOrderTransactions({orderId:{eq:this.checkout.id}})];case 1:return t=e.sent(),this.successTransaction=t.isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)?t.data[0]:void 0,[2]}}))}))},this.saveCart=function(){return t(U,void 0,void 0,(function(){var t,i,s,n;return e(this,(function(e){switch(e.label){case 0:return(t=new S(this.checkout)).cartId=this.checkout.id,"in-store"!==this.deliveryMethod?[3,2]:[4,this.inStockDeliveryInputData(t)];case 1:t=e.sent(),e.label=2;case 2:return[4,y.saveCart({input:t})];case 3:if((null==(i=e.sent())?void 0:i.graphQLErrors)&&i.graphQLErrors.length)throw s=i.graphQLErrors[0],"CUSTOMER_LOGIN_REQUIRED"===(null===(n=s.extensions)||void 0===n?void 0:n.code)?{type:j.CUSTOMER_LOGIN_REQUIRED_ERROR}:{type:j.API_ERROR};return[2,i.data]}}))}))},this.inStockDeliveryInputData=function(i){return t(U,void 0,void 0,(function(){var t,s,n=this;return e(this,(function(e){return t=i,(s=this.stockLocations.find((function(t){return t.id===n.checkout.stockLocationId})))&&t.shippingAddress&&s.address&&(t.shippingAddress.country=s.address.country,t.shippingAddress.city=s.address.city,t.shippingAddress.state=s.address.state,t.shippingAddress.district=s.address.district,t.shippingAddress.postalCode=s.address.postalCode,t.shippingAddress.addressLine1=s.address.address||"",t.shippingAddress.addressLine2=null),t.billingAddress=null,[2,t]}))}))},this.checkStocks=function(){return t(U,void 0,void 0,(function(){var t,i,s,n,r,o,a,d,c,u,h,p;return e(this,(function(e){switch(e.label){case 0:return t=this.checkout.items.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,f.checkStocks({lines:t.map((function(t){return new g(t)})),stockLocationIdList:l.pickUpStockLocationIds||[]})];case 1:if(!(i=e.sent()).isSuccess)throw{type:j.API_ERROR};if(null==(s=null===(h=null===(u=i.data)||void 0===u?void 0:u.lines)||void 0===h?void 0:h.filter((function(t){return!t.isAvailable})))?void 0:s.length){for(n=[],r=function(t){var e=null===(p=o.store.cartStore.cart)||void 0===p?void 0:p.items.find((function(e){return e.variant.id===t.variantId}));e&&n.push(e)},o=this,a=0,d=s;a<d.length;a++)c=d[a],r(c);throw{type:j.STOCK_ERROR,data:n}}return[2]}}))}))},this.removeUnavailableItems=function(i){return t(U,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:t=0,s=i,e.label=1;case 1:return t<s.length?(n=s[t],[4,this.store.cartStore.removeItem(n)]):[3,4];case 2:e.sent(),e.label=3;case 3:return t++,[3,1];case 4:return[2]}}))}))},this.getShippingCountries=function(){return t(U,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,f.getAvailableShippingCountries({salesChannelId:l.salesChannelId})];case 1:return t=e.sent(),this.shippingCountryIds=t.data,[2]}}))}))},this.getStockLocations=function(){return t(U,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return l.pickUpStockLocationIds?[4,f.listStockLocation({id:{in:l.pickUpStockLocationIds}})]:[3,2];case 1:if(!(t=e.sent()).isSuccess||!(null===(i=t.data)||void 0===i?void 0:i.length))return this.error={type:j.API_ERROR},[2];this.stockLocations=t.data,e.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return t(U,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return l.pickUpStockLocationIds?(t=this.checkout.items.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,f.getAvailableStockLocations({lines:t.map((function(t){return new g(t)})),stockLocationIdList:l.pickUpStockLocationIds})]):[3,2];case 1:if(!(i=e.sent()).isSuccess)return this.error={type:j.API_ERROR},[2];this.availableStockLocations=i.data||[],e.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var t;(null===(t=U.shippingCountryIds)||void 0===t?void 0:t.length)||(U.error={type:j.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(t){"address"===t&&(U.checkout.stockLocationId=null),U.deliveryMethod=t,U.isErrorsVisible=!1},this.initialStockCheck=function(){return t(U,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.checkStocks()];case 1:return e.sent(),[3,3];case 2:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:j.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return t(U,void 0,void 0,(function(){var t,i,s,n,o,a,d,c,u,h=this;return e(this,(function(e){switch(e.label){case 0:return t="local"===process.env.NEXT_PUBLIC_ENV,i=l.paymentGateways.map((function(t){return t.id})),[4,f.listPaymentGateway({id:t?void 0:{in:i}})];case 1:return(s=e.sent()).isSuccess&&(null===(c=s.data)||void 0===c?void 0:c.length)?(n=s.data,this.step===A.PAYMENT&&(n=n.filter((function(t){return!t.supportedCurrencies.length||t.supportedCurrencies.includes(h.checkout.currencyCode)})),(o=null===(u=this.checkout.shippingAddress)||void 0===u?void 0:u.country)&&o.iso2&&(n=n.filter((function(t){return!t.availableCountries.length||t.availableCountries.includes(o.iso2||"")})))),a=[],r(l.paymentGateways,"order").forEach((function(t){var e=null==n?void 0:n.find((function(e){return e.id===t.id}));e&&a.push(e)})),this.paymentGateways=t?n:a,this.checkout.selectedPaymentGateway||this.setPaymentGateway(0),console.log("1"),this.step===A.PAYMENT&&(console.log("2",{paymentGateways:n}),(d=n.find((function(t){return!!t.masterPassClientId})))&&(console.log("3"),this.checkout.masterPassPaymentGateway=d,this.mpVM.checkMasterPass({checkout:this.checkout,store:this.store}))),[2]):(this.error={type:j.API_ERROR},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return t(U,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return[4,f.retrieveInstallmentInfo(i)];case 1:return t=e.sent(),s=t.data,null===(n=null==s?void 0:s.installmentPrices)||void 0===n||n.sort((function(t,e){return(t.installmentCount||-1)>(e.installmentCount||-1)?1:-1})),this.installmentInfo=s,[2]}}))}))},this.createCustomer=function(){var t;U.store.customerStore.customer?(null===(t=U.store.customerStore.customer.addresses)||void 0===t||t.forEach((function(t){return t.checkoutSettings=U.checkoutSettings})),U.checkout.customer=new d(U.store.customerStore.customer)):U.checkout.customer||(U.checkout.customer=new d({}))},this.createShippingAddress=function(){var t;if(U.checkout.shippingAddress)U.selectedShippingAddressId=U.checkout.shippingAddress.id||"-1",U.checkout.shippingAddress.checkoutSettings=U.checkoutSettings;else{var e=null===(t=U.store.customerStore.customer)||void 0===t?void 0:t.addresses;U.onSelectedShippingAddressIdChange((null==e?void 0:e.length)?e[0].id:"-1")}},this.createBillingAddress=function(){"undefined"!=typeof localStorage&&(U.useDifferentAddress=!!localStorage.getItem("sAddr"),U.useDifferentAddress?(U.checkout.billingAddress&&(U.selectedBillingAddressId=U.checkout.billingAddress.id||"-1"),U.checkout.billingAddress=U.checkout.billingAddress||new a):U.checkout.billingAddress=new a(n(U.checkout.shippingAddress)||{}),U.checkout.billingAddress.checkoutSettings=U.checkoutSettings)},this.onShippingMethodChange=function(i){return t(U,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.isChangingShippingMethod?[2]:(this.isChangingShippingMethod=!0,this.checkout.shippingSettingsId=i.shippingSettingsId,this.checkout.shippingZoneRateId=i.shippingZoneRateId,[4,this.saveCart()]);case 1:return(t=e.sent())&&(this.checkout=new p(t)),this.isChangingShippingMethod=!1,[2]}}))}))},this.onStockLocationChange=function(i){return t(U,void 0,void 0,(function(){return e(this,(function(t){return this.checkout.stockLocationId=i.id,[2]}))}))},this.onCouponCodeApply=function(){return t(U,void 0,void 0,(function(){var t,s,n,r,o,a;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,y.saveCartCouponCode({cartId:this.checkout.id,couponCode:this.checkout.couponCode||null})];case 1:return(t=e.sent()).isSuccess&&t.data&&(s=t.data,n=null===(a=null===(o=this.cardData)||void 0===o?void 0:o.cardNumber)||void 0===a?void 0:a.split(" ").join(""),this.step===A.PAYMENT&&(null==n?void 0:n.length)&&n.length>=6&&this.retrieveInstallmentInfo({input:{binNumber:n.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:s.totalFinalPrice}}),s&&(r=this.checkout,this.checkout=new p(i(i({},s),{shippingAddress:r.shippingAddress,billingAddress:r.billingAddress,customer:r.customer,selectedPaymentGateway:r.selectedPaymentGateway})))),[3,3];case 2:return e.sent(),[3,3];case 3:return[2]}}))}))},this.onSelectedShippingAddressIdChange=function(t){var e,i;if(U.selectedShippingAddressId=t,"-1"===t)U.checkout.shippingAddress=new a;else{var s=null===(i=null===(e=U.store.customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===i?void 0:i.find((function(e){return e.id===t}));s&&(U.checkout.shippingAddress=new a(s))}U.checkout.shippingAddress&&(U.checkout.shippingAddress.checkoutSettings=U.checkoutSettings)},this.onSelectedBillingAddressIdChange=function(t){var e,i;if(U.selectedBillingAddressId=t,"-1"===t)U.checkout.billingAddress=new a;else{var s=null===(i=null===(e=U.store.customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===i?void 0:i.find((function(e){return e.id===t}));s&&(U.checkout.billingAddress=new a(s))}U.checkout.billingAddress&&(U.checkout.billingAddress.checkoutSettings=U.checkoutSettings)},this.onTermsAndConditionsCheckedChange=function(t){U.isTermsAndConditionsChecked=t},this.onCardNumberChange=function(t){if(U.cardData&&(!(t.length>U.cardData.cardNumber.length)||E(t))){var e=(U.cardData.cardNumber||"").split(" ").join(""),i=t.split(" ").join("");i.length>16||(e.length<6&&i.length>=6&&!U.installmentInfo?U.retrieveInstallmentInfo({input:{binNumber:i.slice(0,6),paymentGatewayId:U.checkout.selectedPaymentGateway.id,price:U.checkout.totalFinalPrice}}):i.length<6&&e.length>i.length&&(U.cardData.installmentCount=1,U.installmentInfo=void 0),U.cardData.cardNumber=x(i,4).join(" "))}},this.onCardHolderNameChange=function(t){U.cardData&&(U.cardData.cardHolderName=t)},this.onExpirationDateChange=function(t){var e;if(U.cardData&&(!(t.length>U.cardData.expirationDate.length)||E(t))){if(0===(null===(e=U.cardData.expirationDate)||void 0===e?void 0:e.length)){var i=t.split("/");if(2===i.length){var s=i[0].trim(),n=i[1].trim();if(4===s.length&&2===n.length){var r=parseInt(s.slice(2)),o=parseInt(n);if(!isNaN(r)&&!isNaN(o))return void(U.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}if(2===s.length&&4===n.length){o=parseInt(s),r=parseInt(n.slice(2));if(!isNaN(r)&&!isNaN(o))return void(U.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var a=t.split(" / ").join("");a.length>4||(U.cardData.expirationDate=x(a,2).join(" / "))}},this.onCvcChange=function(t){U.cardData&&(t.length>U.cardData.cvv.length&&!E(t)||t.length>4||(U.cardData.cvv=t))},this.saveAddress=function(s){return t(U,void 0,void 0,(function(){var t,r,a,d,c;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),this.shouldSaveAddress&&this.store.customerStore.customer?(t="shipping"===s?this.checkout.shippingAddress:this.checkout.billingAddress,(null===(c=this.store.customerStore.customer.addresses)||void 0===c?void 0:c.find((function(e){return e.id===(null==t?void 0:t.id)})))?[2]:(r=new o(i(i({},t),{title:this.addressTitle||this.t("checkout-page:newAddress"),id:P()})),(a=n(this.store.customerStore.customer)).addresses||(a.addresses=[]),a.addresses.push(r),[4,this.store.customerStore.saveCustomer(a)])):[3,2];case 1:e.sent(),"shipping"===s?(this.checkout.shippingAddress.id=r.id,this.selectedShippingAddressId=r.id||"-1"):(this.checkout.billingAddress.id=r.id,this.selectedBillingAddressId=r.id||"-1"),e.label=2;case 2:return[3,4];case 3:return d=e.sent(),console.error(d),[3,4];case 4:return[2]}}))}))},this.onGoToCartClick=function(){U.router.push("/cart")},this.onBackToShoppingClick=function(){U.router.push("/")},this.onProceedToShippingClick=function(){return t(U,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if("address"===this.deliveryMethod){if(!this.canProceedToShipping)return this.isErrorsVisible=!0,[2]}else if(!this.canProceedToInStoreDelivery)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,6,,7]),this.isStepLoading=!0,"address"!==this.deliveryMethod?[3,3]:[4,this.saveAddress("shipping")];case 2:e.sent(),e.label=3;case 3:return[4,this.checkStocks()];case 4:return e.sent(),[4,this.saveCart()];case 5:return e.sent(),"address"===this.deliveryMethod?this.changeStep(A.SHIPPING):this.changeStep(A.PAYMENT),[3,7];case 6:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:j.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToPaymentClick=function(){return t(U,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),[4,this.saveCart()];case 3:return e.sent(),this.error=void 0,this.changeStep(A.PAYMENT),[3,5];case 4:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:j.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onCompletePaymentClick=function(){return t(U,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:if(!this.canPerformPayment)return this.isErrorsVisible=!0,[2];this.useDifferentAddress||(this.checkout.billingAddress=this.checkout.shippingAddress),e.label=1;case 1:return e.trys.push([1,7,,8]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),"address"!==this.deliveryMethod?[3,4]:[4,this.saveAddress("billing")];case 3:e.sent(),e.label=4;case 4:return[4,this.saveCart()];case 5:return e.sent(),this.isCustomFlowStripe?((t=document.querySelector("#stripe-form-btn"))&&t.click(),[2]):[4,this.createSaleTransaction()];case 6:return e.sent(),[3,8];case 7:return(i=e.sent()).type?this.error=i:this.error={type:j.UNKNOWN},this.isStepLoading=!1,[3,8];case 8:return[2]}}))}))},this.createSaleTransaction=function(){return t(U,void 0,void 0,(function(){var t,i,s,n,r,o,a,d,c,l,u,h,p,m,v;return e(this,(function(e){switch(e.label){case 0:return(i=this.mpVM.selectedCard)&&(null===(d=this.mpVM.selectedCard)||void 0===d?void 0:d.Name)?((n=this.mpVM.phoneNumber({store:this.store,checkout:this.checkout}))&&(t=n),void 0===(null===(c=this.cardData)||void 0===c?void 0:c.installmentCount)?[2]:[4,f.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:{phoneNumber:t,savedCardName:null===(l=this.mpVM.selectedCard)||void 0===l?void 0:l.Name},paymentGatewayId:null===(u=this.mpVM.selectedCard)||void 0===u?void 0:u.paymentGatewayId,paymentMethodDetail:{cardNumber:this.mpVM.selectedCard.Value1,cardHolderName:this.mpVM.selectedCard.Name,cvv:this.mpVM.selectedCard.Value2,expiredMonth:11,expiredYear:11,installmentCount:this.cardData.installmentCount,threeDSecure:!!(null===(h=this.cardData)||void 0===h?void 0:h.threeDSecure)}}})]):[3,2];case 1:return s=e.sent(),[3,4];case 2:return this.checkout.selectedPaymentGateway?[4,f.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:i&&t?{phoneNumber:t,savedCardName:null===(p=this.mpVM.selectedCard)||void 0===p?void 0:p.Name}:void 0,paymentGatewayId:this.checkout.selectedPaymentGateway.id,paymentMethodDetail:i?void 0:this.checkout.selectedPaymentGateway.paymentMethodType===k.CREDIT_CARD&&this.checkout.selectedPaymentGateway.type===b.INTERNAL&&this.cardData?this.cardData.toInput():void 0}})]:[2];case 3:s=e.sent(),e.label=4;case 4:return r=null===(m=null==s?void 0:s.data)||void 0===m?void 0:m.transactionStatus,o=r&&[I.SUCCESS,I.AUTHORIZED].includes(r),a=r===I.PENDING,o?[4,this.getSuccessTransaction()]:[3,7];case 5:return e.sent(),[4,this.onCheckoutTransactionSuccess()];case 6:return e.sent(),[3,8];case 7:if(!a||!(null===(v=null==s?void 0:s.data)||void 0===v?void 0:v.returnSlug))throw{type:j.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+s.data.returnSlug,e.label=8;case 8:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(){return t(U,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return localStorage.removeItem("sAddr"),(null===(t=this.checkout.customer)||void 0===t?void 0:t.notificationsAccepted)?[4,this.store.customerStore.createEmailSubscription((null===(i=this.checkout.customer)||void 0===i?void 0:i.email)||"")]:[3,2];case 1:e.sent(),e.label=2;case 2:return this.changeStep(A.SUCCESS),[2]}}))}))},this.onBackToInfoClick=function(){U.changeStep(A.INFO)},this.onBackToShippingClick=function(){U.changeStep(A.SHIPPING)},this.setCustomerConsentGranted=function(t){U.checkout.customer&&(U.checkout.customer.notificationsAccepted=t)},this.setUseDifferentAddress=function(t){U.useDifferentAddress=t,U.useDifferentAddress?(localStorage.setItem("sAddr","1"),U.checkout.billingAddress=U.checkout.billingAddress||new a):(localStorage.removeItem("sAddr"),U.checkout.billingAddress=U.checkout.shippingAddress)},this.setShouldSaveAddress=function(t){U.shouldSaveAddress=t},this.setAddressTitle=function(t){U.addressTitle=t},this.setPaymentGateway=function(i){return t(U,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return this.paymentGateways.length?"STRIPE"!==(t=this.paymentGateways[i]).code||!(null===(n=t.settings)||void 0===n?void 0:n.find((function(t){return"allow_custom_flow"===t.label&&"true"===t.value})))||this.stripeResponse?[3,2]:[4,f.createStripePaymentIntent({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}})]:[2];case 1:(s=e.sent()).isSuccess&&s.data&&(this.stripeResponse=s.data),e.label=2;case 2:return this.checkout.selectedPaymentGateway=t,this.step!==A.SUCCESS&&(t.paymentMethodType===k.CREDIT_CARD&&t.type===b.INTERNAL&&(this.cardData=new c),this.installmentInfo=void 0),[2]}}))}))},this.setInstallmentCount=function(t){U.cardData&&(U.cardData.installmentCount=t)},this.changeStep=function(i){return t(U,void 0,void 0,(function(){return e(this,(function(t){return N||window.location.replace("".concat(window.location.pathname,"?id=").concat(this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return t(U,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:this.checkout.customer=null,this.store.customerStore.logout(),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.saveCart()];case 2:case 3:return t.sent(),[3,4];case 4:return this.createCustomer(),[2]}}))}))},this.setContactModalVisible=function(t){U.isContactModalVisible=t},this.checkout=w,this.checkoutSettings=R,this.router=O,this.returnPolicy=D,this.privacyPolicy=M,this.termsOfService=G,this.t=_,this.customizationProps=L,this.mpVM=new C,T&&(this.merchantSettings=T),this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.init(),s(this)}return Object.defineProperty(w.prototype,"selectedPaymentGatewayIndex",{get:function(){var t=this;return this.paymentGateways.findIndex((function(e){var i;return e.id===(null===(i=t.checkout.selectedPaymentGateway)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"selectedInstallmentIndex",{get:function(){var t,e,i=this;return(null===(e=null===(t=this.installmentInfo)||void 0===t?void 0:t.installmentPrices)||void 0===e?void 0:e.findIndex((function(t){var e;return t.installmentCount===(null===(e=i.cardData)||void 0===e?void 0:e.installmentCount)})))||0},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"customerAddressOptions",{get:function(){var t,e,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(e=null===(t=this.store.customerStore.customer)||void 0===t?void 0:t.addresses)||void 0===e?void 0:e.map((function(t){return{label:t.title+" - "+t.addressText,value:t.id}})))||[];return[i].concat(s)},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"installmentPrice",{get:function(){var t,e,i,s=this;if(this.installmentInfo&&(null===(t=this.cardData)||void 0===t?void 0:t.installmentCount))return null===(i=null===(e=this.installmentInfo.installmentPrices)||void 0===e?void 0:e.find((function(t){var e;return t.installmentCount===(null===(e=s.cardData)||void 0===e?void 0:e.installmentCount)})))||void 0===i?void 0:i.totalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"finalPrice",{get:function(){return this.step===A.SUCCESS?this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"hasStockError",{get:function(){var t;return(null===(t=this.error)||void 0===t?void 0:t.type)===j.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"canProceedToShipping",{get:function(){var t,e;return(null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.isValid)&&this.checkout.hasValidCustomerEmail&&(null===(e=this.error)||void 0===e?void 0:e.type)!==j.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"canProceedToInStoreDelivery",{get:function(){var t,e,i;return!!((null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.firstName)&&(null===(e=this.checkout.shippingAddress)||void 0===e?void 0:e.lastName)&&(null===(i=this.checkout.customer)||void 0===i?void 0:i.email)&&this.checkout.stockLocationId)},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"isCustomFlowStripe",{get:function(){var t,e=this.checkout.selectedPaymentGateway;return e&&"STRIPE"===e.code&&(null===(t=e.settings)||void 0===t?void 0:t.find((function(t){return"allow_custom_flow"===t.label&&"true"===t.value})))},enumerable:!1,configurable:!0}),Object.defineProperty(w.prototype,"canPerformPayment",{get:function(){var t,e;if(this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)return!1;var i=this.checkout.selectedPaymentGateway,s="in-store"===this.deliveryMethod,n=!!s||!!this.canProceedToShipping,r=!!s||!!(null===(t=this.checkout.billingAddress)||void 0===t?void 0:t.isValid),o=!!this.mpVM.selectedCard||((null==i?void 0:i.paymentMethodType)===k.CREDIT_CARD&&i.type===b.INTERNAL?!!this.isCustomFlowStripe||(null===(e=this.cardData)||void 0===e?void 0:e.isValid):!!i);return n&&r&&o},enumerable:!1,configurable:!0}),w}();function x(t,e){return t.match(new RegExp(".{1,"+e+"}","g"))||[]}function E(t){return t&&w.test(t.charAt(t.length-1))}!function(t){t.INFO="info",t.SHIPPING="shipping",t.PAYMENT="payment",t.SUCCESS="success"}(A||(A={})),function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.API_ERROR=1]="API_ERROR",t[t.STOCK_ERROR=2]="STOCK_ERROR",t[t.PAYMENT_ERROR=3]="PAYMENT_ERROR",t[t.NO_SHIPPING_ERROR=4]="NO_SHIPPING_ERROR",t[t.CUSTOMER_LOGIN_REQUIRED_ERROR=5]="CUSTOMER_LOGIN_REQUIRED_ERROR"}(j||(j={}));export{A as CheckoutStep,j as ErrorType,R as default};
|
|
@@ -83,15 +83,54 @@ export default class MasterPassModel {
|
|
|
83
83
|
checkout: IkasCheckout;
|
|
84
84
|
}) => string | null | undefined;
|
|
85
85
|
sendSmsLanguage: (store: IkasBaseStore) => string;
|
|
86
|
+
/**
|
|
87
|
+
* Send object return value is FormData
|
|
88
|
+
* @returns FormData
|
|
89
|
+
*/
|
|
86
90
|
prepareFormData<T>(data: T): FormData;
|
|
91
|
+
/**
|
|
92
|
+
* MFS (MasterPass js library) response handler.
|
|
93
|
+
*/
|
|
87
94
|
mfsResponseHandler: MFS_CB_HOC_TYPE;
|
|
95
|
+
/**
|
|
96
|
+
* CheckMasterPass for customer. Call it on initial. For more detail keep reading. [tr]
|
|
97
|
+
|
|
98
|
+
* Soldan ilk 6 hane 000000 ise
|
|
99
|
+
* Kullanıcının masterpass hesabı yok anlamına gelmektedir. Burada isterseniz kart kaydına
|
|
100
|
+
* yönlendirebilirsiniz. Kart kaydını sizin üzerinizden gerçekleştirdiğinde otomatik linklenecektir
|
|
101
|
+
* ve tekrar checkmasterpass servisine istek yaptığınızda ilk 6 hanenin değiştiğini göreceksiniz.
|
|
102
|
+
|
|
103
|
+
* Soldan ilk 6 hane 011000 ise
|
|
104
|
+
* Kullanıcının daha önce başka üye işyerinde kayıtlı hesabı olduğu anlamına gelmektedir.
|
|
105
|
+
* Bu aşamada kullanıcıyı linkleme (linkCardtoClient) akışına sokmanız gerekmektedir.
|
|
106
|
+
* “Masterpass’e kayıtlı kartların var, kullanmak ister misin?” sorusu sorulur
|
|
107
|
+
* ve evet cevabında linkCardtoClient servisi çağrılır. Sms doğrulaması yapıldıktan
|
|
108
|
+
* sonra linkleme başarıyla gerçekleşeceği için ListCard servisi ile kartlar listelenir.
|
|
109
|
+
|
|
110
|
+
* Soldan ilk 6 hane 011100 ise
|
|
111
|
+
* Kullanıcı daha önce ikas üzerinde linkli ve kartları kaydedilmiş demektir.
|
|
112
|
+
* Bu durumda kullanıcıdan herhangi bir aksiyon almasını beklemeden doğrudan
|
|
113
|
+
* kayıtlı kartlarının listelenmesi (ListCard servisi ile) gerekiyor.
|
|
114
|
+
*/
|
|
88
115
|
checkMasterPass: ({ checkout, store, ...rest }: CheckMasterPassParams) => Promise<void>;
|
|
116
|
+
/**
|
|
117
|
+
* Save card to MasterPass
|
|
118
|
+
*/
|
|
89
119
|
register: ({ creditCard, store, checkout, paymentGateway, callback, }: RegisterParams) => Promise<void>;
|
|
90
120
|
resendOtp: ({ store, checkout, callback, }: {
|
|
91
121
|
store: IkasBaseStore;
|
|
92
122
|
checkout: IkasCheckout;
|
|
93
123
|
callback: () => void;
|
|
94
124
|
}) => Promise<void>;
|
|
125
|
+
/**
|
|
126
|
+
* First checkMasterPass then check respone;
|
|
127
|
+
* [tr] Soldan ilk 6 hane 011000 ise
|
|
128
|
+
* Kullanıcının daha önce başka üye işyerinde kayıtlı hesabı olduğu anlamına gelmektedir.
|
|
129
|
+
* Bu aşamada kullanıcıyı linkleme (linkCardtoClient) akışına sokmanız gerekmektedir.
|
|
130
|
+
* “Masterpass’e kayıtlı kartların var, kullanmak ister misin?” sorusu sorulur
|
|
131
|
+
* ve evet cevabında linkCardtoClient servisi çağrılır. Sms doğrulaması yapıldıktan
|
|
132
|
+
* sonra linkleme başarıyla gerçekleşeceği için ListCard servisi ile kartlar listelenir.
|
|
133
|
+
*/
|
|
95
134
|
linkCardToClient: ({ store, checkout }: LinkCardToClientParams) => Promise<void>;
|
|
96
135
|
validateTransaction: ({ validationCode, store, cartId, paymentGateway, checkout, callback, }: ValidateTransactionParams) => Promise<void>;
|
|
97
136
|
listCards: ({ store, checkout }: ListCardsParams) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as t,__rest as s}from'../../ext/tslib/tslib.es6.js';import{makeAutoObservable as o}from"mobx";import{IkasStorefrontConfig as n}from"../../storefront/index.js";import a from"../../__api/queries/getMasterpassRequestToken.js";import{MasterPassOperationTypeEnum as r}from"../../__api/types/index.js";var i="undefined"==typeof localStorage,c=/000000[0|1]{10}/g,d=/[0|1]1100[0|1]{11}/g,
|
|
1
|
+
import{__awaiter as e,__generator as t,__rest as s}from'../../ext/tslib/tslib.es6.js';import{makeAutoObservable as o}from"mobx";import{IkasStorefrontConfig as n}from"../../storefront/index.js";import a from"../../__api/queries/getMasterpassRequestToken.js";import{MasterPassOperationTypeEnum as r}from"../../__api/types/index.js";var i="undefined"==typeof localStorage,c=/000000[0|1]{10}/g,d=/[0|1]1100[0|1]{11}/g,l=/[0|1]11100[0|1]{10}/g,u=function(){function u(){var u=this;this.checkMasterPassData={status:""},this.saveCardToMasterPass={isCheckboxChecked:!1,cardName:"",phoneNumber:"",isSendConfirmationButtonPending:!1},this.visibleModal=void 0,this.cards=[],this.onSaveCardToMasterPassCheckedChange=function(e){u.saveCardToMasterPass.isCheckboxChecked=e},this.onSaveCardToMasterPassCardNameChange=function(e){u.saveCardToMasterPass.cardName=e},this.onSaveCardToMasterPassPhoneNumberChange=function(e){u.saveCardToMasterPass.phoneNumber=e},this.onSaveCardToMasterPassSendConfirmationButtonClick=function(e){var t=e.creditCard,s=e.store,o=e.checkout,n=e.paymentGateway,a=e.callback;console.log("onSaveCardToMasterPassSendConfirmationButtonClick 1"),u.register({creditCard:t,store:s,checkout:o,paymentGateway:n,callback:a})},this.showLinkCardToClientModal=function(){u.visibleModal="linkCardToClientModal"},this.hideLinkCardToClientModal=function(){u.visibleModal=void 0},this.showOtpModal=function(e){u.visibleModal="masterPassOtp"===e?"otpModalMasterPass":"otpModalBank",console.log("calisti",u.visibleModal)},this.hideOtpModal=function(){u.visibleModal=void 0},this.onResponseModalClose=function(){u.visibleModal=void 0,u.mfsResponseModalText=""},this.onLinkCardToClientButtonClick=function(e){u.linkCardToClient(e)},this.onOtpFormSubmit=function(e){u.validateTransaction(e)},this.MFS=function(){var e;if(!i){if(window.MFS&&(null===(e=window.MFS)||void 0===e?void 0:e.setClientId))return window.MFS;console.error("MFS can not use.")}},this.getToken=function(s){var o=s.cartId,n=s.paymentGatewayId,r=s.operationType,i=s.phoneNumber;return e(u,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,a({cartId:o,paymentGatewayId:n,operationType:r,phoneNumber:i})];case 1:return(e=t.sent()).data&&e.isSuccess&&!e.errors.length?[2,e.data]:[2]}}))}))},this.phoneNumber=function(e){var t,s,o=e.store,n=e.checkout,a=(null===(t=o.customerStore.customer)||void 0===t?void 0:t.phone)||(null===(s=n.shippingAddress)||void 0===s?void 0:s.phone);return a&&a.includes("+")&&(a=a.replace("+","")),a},this.sendSmsLanguage=function(e){var t,s="eng";if(e.localeOptions.length){var o=e.localeOptions.find((function(e){return e.routing.locale===n.getCurrentLocale()}));o&&o.iso3&&(s=null===(t=o.iso3)||void 0===t?void 0:t.toLowerCase())}return s},this.mfsResponseHandler=function(e){return function(t,s){console.log({field:"mfsResponseHandler",response:s}),e.callback&&e.callback();var o=function(e){var t;return null===(t=null==s?void 0:s.accountStatus)||void 0===t?void 0:t.match(e)};if(o(c)&&(u.checkMasterPassData.status="noMasterPassAccount"),o(d)&&(u.checkMasterPassData.status="hasMasterPassAccountButDoesNotHaveAnyOperation",u.showLinkCardToClientModal()),o(l)&&(u.checkMasterPassData.status="hasMasterPassAccountAndHasRelation",(null==e?void 0:e.checkout)&&e.store&&(u.listCards({store:e.store,checkout:e.checkout}),console.log("call listcards"))),"1409"===s.responseCode&&s.responseDescription&&(u.otpResponse=s.responseDescription),"0000"!=s.responseCode&&""!=s.responseCode||(console.log("Register Success"),"deleteCard"===e.source&&u.listCards({store:e.store,checkout:e.checkout}),"validateTransaction"===e.source&&(null==e?void 0:e.checkout)&&e.store&&(u.visibleModal=void 0,u.listCards({store:e.store,checkout:e.checkout}))),"5196"===s.responseCode&&s.responseDescription&&(u.visibleModal="mfsResponseModal",u.mfsResponseModalText=s.responseDescription),"5001"!=s.responseCode&&"5008"!=s.responseCode)"5010"!=s.responseCode||"undefined"==typeof window?console.error("MFS response.responseDescription",s.responseDescription):window.location.assign(s.url3D+"&returnUrl="+window.location.href);else{var n="5001"===s.responseCode?"bankOtp":"masterPassOtp";u.showOtpModal(n)}}},this.checkMasterPass=function(o){return e(u,void 0,void 0,(function(){var e,n,a,i,c,d,l=o.checkout,u=o.store;return s(o,["checkout","store"]),t(this,(function(t){switch(t.label){case 0:return console.log("checkMasterPass 1"),(e=this.MFS())?(n=this.phoneNumber({store:u,checkout:l}),console.log("checkMasterPass 2"),a=l.masterPassPaymentGateway,n&&a&&a.masterPassClientId?(console.log("checkMasterPass 3",n),[4,this.getToken({cartId:l.id,paymentGatewayId:a.id,operationType:r.CHECK_MASTER_PASS_USER,phoneNumber:n})]):[2]):[2];case 1:return(i=t.sent())?(e.setClientId(a.masterPassClientId),c=this.sendSmsLanguage(u),d=this.prepareFormData({sendSmsLanguage:c,sendSms:"N",referenceNo:i.requestReferenceNumber,token:i.token,userId:n}),e.checkMasterPass(d,this.mfsResponseHandler({source:"checkMasterPass",checkout:l,store:u})),console.log("checkMasterPass 4"),[2]):[2]}}))}))},this.register=function(s){var o=s.creditCard,n=s.store,a=s.checkout,i=s.paymentGateway,c=s.callback;return e(u,void 0,void 0,(function(){var e,s,d,l;return t(this,(function(t){switch(t.label){case 0:return console.log("register 1"),(e=this.MFS())?(console.log("register 2"),(s=o.phoneNumber)&&i.masterPassClientId?(console.log("register 3"),[4,this.getToken({cartId:a.id,paymentGatewayId:i.id,operationType:r.REGISTER_CARD,phoneNumber:s})]):[2]):[2];case 1:return d=t.sent(),console.log("register 4"),(null==d?void 0:d.token)?(l=this.prepareFormData({msisdn:s,token:null==d?void 0:d.token,referenceNo:d.requestReferenceNumber,sendSmsLanguage:this.sendSmsLanguage(n),rtaPan:o.rtaPan,expiryDate:o.expiryDate,cvc:o.cvc,accountAliasName:o.accountAliasName,timeZone:d.timeZone,sendSms:"Y",actionType:"A",clientIp:"",delinkReason:"",eActionType:"A",cardTypeFlag:"05",cpinFlag:"Y",defaultAccount:"Y",mmrpConfig:"110010",identityVerificationFlag:"Y",mobileAccountConfig:"MWA",uiChannelType:"6"}),console.log("reigster 5"),e.setClientId(i.masterPassClientId),e.register(l,this.mfsResponseHandler({source:"register",store:n,checkout:a,callback:c})),[2]):[2]}}))}))},this.resendOtp=function(s){var o=s.store,n=s.checkout,a=s.callback;return e(u,void 0,void 0,(function(){var e,s,r;return t(this,(function(t){return(e=this.MFS())?(s=e.getLastToken(),r=this.sendSmsLanguage(o),e.resendOtp(s,r,this.mfsResponseHandler({source:"resendOtp",store:o,checkout:n,callback:a})),[2]):[2]}))}))},this.linkCardToClient=function(s){var o=s.store,n=s.checkout;return e(u,void 0,void 0,(function(){var e,s,a,i,c;return t(this,(function(t){switch(t.label){case 0:return(e=this.MFS())&&((s=this.phoneNumber({store:o,checkout:n}))&&(null==(a=n.masterPassPaymentGateway)?void 0:a.id))?[4,this.getToken({cartId:n.id,paymentGatewayId:a.id,operationType:r.REGISTER_CARD,phoneNumber:s})]:[2];case 1:return(i=t.sent())?(c=this.prepareFormData({sendSms:"Y",sendSmsLanguage:this.sendSmsLanguage(o),token:i.token,referenceNo:i.requestReferenceNumber,cardAliasName:"",msisdn:s}),e.linkCardToClient(c,this.mfsResponseHandler({source:"linkCardToClient",store:o,checkout:n})),[2]):[2]}}))}))},this.validateTransaction=function(s){var o=s.validationCode,n=s.store,a=s.cartId,i=s.paymentGateway,c=s.checkout,d=s.callback;return e(u,void 0,void 0,(function(){var e,s,l,u;return t(this,(function(t){switch(t.label){case 0:return(e=this.MFS())&&(s=this.phoneNumber({store:n,checkout:c}))?[4,this.getToken({cartId:a,paymentGatewayId:i.id,operationType:r.REGISTER_CARD,phoneNumber:s})]:[2];case 1:return(l=t.sent())?(u=this.prepareFormData({pinType:"otp",validationCode:o,sendSms:"Y",sendSmsLanguage:this.sendSmsLanguage(n),token:l.token,referenceNo:l.requestReferenceNumber}),e.validateTransaction(u,this.mfsResponseHandler({source:"validateTransaction",store:n,checkout:c,callback:d})),[2]):[2]}}))}))},this.listCards=function(s){var o=s.store,n=s.checkout;return e(u,void 0,void 0,(function(){var e,s,a,i,c,d,l=this;return t(this,(function(t){switch(t.label){case 0:return(e=this.MFS())&&(s=this.phoneNumber({store:o,checkout:n}))?(a=null===(d=n.masterPassPaymentGateway)||void 0===d?void 0:d.id,console.log("listCards paymentGatewayId",a),a?[4,this.getToken({cartId:n.id,paymentGatewayId:a,operationType:r.LIST_CARDS,phoneNumber:s})]:[2]):[2];case 1:return(i=t.sent())?(c=function(e,t){if("0000"!=t.responseCode&&""!=t.responseCode)return l.visibleModal="mfsResponseModal",l.mfsResponseModalText=t.responseDescription,console.error("mfs response.responseDescription",t.responseDescription),void console.log("TransactionID->",t.transactionId);var s=[];if(Array.isArray(t.cards))for(var o=0;o<t.cards.length;o++){var n=t.cards[o];n.paymentGatewayId=a,s.push(n)}l.cards=s,console.log("list_card response->",t),console.log("Cards",s),console.log("TransactionID->",t.transactionId)},e.listCards(s,i.token,c),[2]):[2]}}))}))},this.deleteCard=function(s){var o=s.store,n=s.checkout,a=s.card;return e(u,void 0,void 0,(function(){var e,s,i,c;return t(this,(function(t){switch(t.label){case 0:return(e=this.MFS())&&(s=this.phoneNumber({store:o,checkout:n}))?[4,this.getToken({cartId:n.id,paymentGatewayId:a.paymentGatewayId,operationType:r.DELETE_CARD,phoneNumber:s})]:[2];case 1:return(i=t.sent())?(c=this.prepareFormData({sendSms:"N",msisdn:s,token:i.token,referenceNo:i.requestReferenceNumber,sendSmsLanguage:this.sendSmsLanguage(o),accountAliasName:a.Name}),e.deleteCard(c,this.mfsResponseHandler({source:"deleteCard",store:o,checkout:n})),[2]):[2]}}))}))},o(this)}return Object.defineProperty(u.prototype,"isSendConfirmationButtonDisabled",{get:function(){return!this.saveCardToMasterPass.cardName||!this.saveCardToMasterPass.phoneNumber},enumerable:!1,configurable:!0}),u.prototype.prepareFormData=function(e){var t=new FormData;return Object.entries(e).forEach((function(e){var s=e[0],o=e[1];return t.append(s,o)})),t},u}();export{u as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"react";import{observer as t}from"mobx-react-lite";import"../../../../../models/data/payment-gateway/index.js";import{CreditCardForm as n}from"../../../components/credit-card-form/index.js";import{Installments as a}from"./installments/index.js";import o from"../../../components/select-box/index.js";import r from"./style.module.scss.js";import"../../../../../storefront/index.js";import'../../../../../ext/lodash/isArguments.js';import'../../../../../ext/lodash/isBuffer.js';import'../../../../../ext/lodash/isTypedArray.js';import'../../../../../ext/lodash/_baseGetTag.js';import{formatMoney as l}from"../../../../../utils/currency.js";import{useTranslation as m}from"../../../../../utils/i18n.js";import i from"../../../components/svg/external.js";import
|
|
1
|
+
import*as e from"react";import{observer as t}from"mobx-react-lite";import"../../../../../models/data/payment-gateway/index.js";import{CreditCardForm as n}from"../../../components/credit-card-form/index.js";import{Installments as a}from"./installments/index.js";import o from"../../../components/select-box/index.js";import r from"./style.module.scss.js";import"../../../../../storefront/index.js";import'../../../../../ext/lodash/isArguments.js';import'../../../../../ext/lodash/isBuffer.js';import'../../../../../ext/lodash/isTypedArray.js';import'../../../../../ext/lodash/_baseGetTag.js';import{formatMoney as l}from"../../../../../utils/currency.js";import{useTranslation as m}from"../../../../../utils/i18n.js";import i from"../../../components/svg/external.js";import s from"../../../components/master-pass/payment-gateway/svg/master-card.js";import{StripeForm as c}from"../../../components/stripe/index.js";import d from"../../../components/credit-card-form/model.js";import p from"../../../components/master-pass/index.js";import{PaymentMethodEnum as u,PaymentGatewayTypeEnum as y,PaymentGatewayTransactionFeeTypeEnum as f,PaymentGatewayAdditionalPriceTypeEnum as v}from"../../../../../__api/types/index.js";var E=t((function(t){var E=t.vm,g=m().t,h=function(t){return e.createElement("div",{style:{display:"flex",justifyContent:"flex-end",alignItems:"center",flexWrap:"wrap"}},t.children)},I=function(t){return e.createElement("div",{className:r.AdditionalPrice},t.children)},x=function(e){var t;return"STRIPE"===e.code&&(null===(t=e.settings)||void 0===t?void 0:t.find((function(e){return"allow_custom_flow"===e.label&&"true"===e.value})))};return e.createElement(e.Fragment,null,!!E.mpVM.cards.length&&E.mpVM.cards.map((function(t,n){var l,m=E.paymentGateways.find((function(e){return e.id===t.paymentGatewayId})),i=e.createElement("button",{className:r.MasterPassSelectBoxDeleteButton,onClick:function(e){e.stopPropagation(),E.mpVM.deleteCard({store:E.store,checkout:E.checkout,card:t})}},g("checkout-page:masterPass.paymentGatewaySelectBox.delete")),c=e.createElement("div",{style:{display:"flex",alignItems:"center"}},e.createElement("span",{className:r.MasterPassSelectBoxLabelLogo},e.createElement(s,null)),t.Name," ",t.Value1),p=(null==m?void 0:m.id)&&m.paymentMethodType===u.CREDIT_CARD&&m.type===y.INTERNAL?E.installmentInfo&&e.createElement(a,{vm:E}):void 0;return e.createElement(o,{key:n,isSelected:(null===(l=E.mpVM.selectedCard)||void 0===l?void 0:l.UniqueId)===t.UniqueId,label:c,rightContent:i,bottomContent:p,onClick:function(){var e;(null===(e=E.mpVM.selectedCard)||void 0===e?void 0:e.UniqueId)!==t.UniqueId&&(E.checkout.selectedPaymentGateway=null,E.cardData=new d,E.installmentInfo=void 0,E.mpVM.selectedCard=t,t.Value1&&t.paymentGatewayId&&E.checkout.totalFinalPrice&&E.retrieveInstallmentInfo({input:{binNumber:t.Value1.slice(0,6),paymentGatewayId:t.paymentGatewayId,price:E.checkout.totalFinalPrice}}))}})})),E.paymentGateways.map((function(t,m){var s,d;return e.createElement(o,{key:t.id,label:t.paymentMethodType===u.CREDIT_CARD&&t.type===y.INTERNAL?x(t)?" ":g("checkout-page:creditCard"):t.name,isSelected:E.selectedPaymentGatewayIndex===m,rightContent:(null===(s=t.additionalPrices)||void 0===s?void 0:s.length)?e.createElement(I,null,(d=t.additionalPrices[0],0===d.amount?"":"".concat(d.amountType===f.AMOUNT?l(d.amount,E.checkout.currencyCode):" %"+d.amount).concat(d.type===v.DECREMENT?" "+g("checkout-page:paymentMethodDiscount"):" "+g("checkout-page:paymentMethodAdditionalPrice")))):e.createElement(h,null,!!t.logoUrl&&e.createElement("div",{className:r.PaymentLogoContainer},e.createElement("img",{src:t.logoUrl}))),bottomContent:t.paymentMethodType===u.CREDIT_CARD&&t.type===y.INTERNAL?e.createElement(e.Fragment,null,x(t)?e.createElement(c,{vm:E,pg:t}):e.createElement("div",null,e.createElement(n,{vm:E}),E.isPaymentGatewayHasMasterPass&&e.createElement(p,{vm:E}),E.installmentInfo&&e.createElement(a,{vm:E}))):t.description?e.createElement(e.Fragment,null,t.type===y.EXTERNAL&&e.createElement("div",{style:{height:"52px",display:"flex",justifyContent:"center",margin:"24px 0"}},e.createElement(i,null)),e.createElement("div",{dangerouslySetInnerHTML:{__html:t.description}})):void 0,onClick:function(){E.selectedPaymentGatewayIndex!==m&&(E.setPaymentGateway(m),E.mpVM.selectedCard=void 0)}})})))}));export{E as PaymentGateways};
|