@ikas/storefront 3.0.0-alpha.37 → 3.0.0-alpha.38

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.
@@ -1 +1 @@
1
- import e from'../ext/strict-uri-encode/index.js';export{default}from"../node_modules/strict-uri-encode/index.js";
1
+ import e from'../ext/decode-uri-component/index.js';export{default}from"../node_modules/decode-uri-component/index.js";
@@ -1 +1 @@
1
- import e from'../ext/decode-uri-component/index.js';export{default}from"../node_modules/decode-uri-component/index.js";
1
+ import o from'../ext/split-on-first/index.js';export{default}from"../node_modules/split-on-first/index.js";
@@ -1 +1 @@
1
- import o from'../ext/split-on-first/index.js';export{default}from"../node_modules/split-on-first/index.js";
1
+ import e from'../ext/strict-uri-encode/index.js';export{default}from"../node_modules/strict-uri-encode/index.js";
@@ -1 +1 @@
1
- import e,{useRef as t,useState as o,useEffect as a}from"react";import{observer as n}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 s}from"../../../../../utils/i18n.js";import{Button as r}from"../../button/index.js";import{FormItem as c}from"../../form-item/index.js";import{FormItemType as m}from"../../form-item/model.js";import l from"../modal/index.js";import i from"./svg/master-pass.js";import p from"./style.module.scss.js";var u=n((function(n){var u=n.visible,d=n.type,f=n.vm,h=n.onClose,v=s().t,b=t(),k=o(180),g=k[0],x=k[1],M=o(""),y=M[0],E=M[1],j=o(!1),P=j[0],T=j[1],C=o(!1),O=C[0],w=C[1],N=function(){if(!O&&y&&f.checkout.selectedPaymentGateway){w(!0),f.mpVM.onOtpFormSubmit({cartId:f.checkout.id,validationCode:y,paymentGateway:f.checkout.selectedPaymentGateway,store:f.store,checkout:f.checkout,callback:function(){w(!1),E(""),V()}})}},V=function(){x(0)},I=function(){x(180)};a((function(){if(!(g<1&&b.current))return b.current&&clearInterval(b.current),b.current=setInterval((function(){x(g-1)}),1e3),function(){b.current&&clearInterval(b.current)};clearInterval(b.current)}),[g]);var R,_,G,L,A,B,S=e.createElement("div",null,e.createElement("div",{className:p.Wrapper},"masterPassOtp"===d&&e.createElement("span",{"data-mr":!0,className:p.Logo},e.createElement(i,null)),e.createElement("p",{className:p.Text},v("masterPassOtp"===d?"checkout-page:masterPass.otpModal.otpTextMasterPass":"checkout-page:masterPass.otpModal.otpTextBank"))),e.createElement("div",{className:p.Countdown},v("checkout-page:masterPass.otpModal.countdownText"),e.createElement("strong",null,(R=g%3600,_=Math.floor(R/60),G=R%60,L=Math.ceil(G),A=_<10?"0".concat(_):_,B=L<10?"0".concat(L):L,"".concat(A,":").concat(B)))),f.mpVM.otpResponse.text&&e.createElement("div",{role:"error"===f.mpVM.otpResponse.status?"alert":"",className:p.OtpResponseText},f.mpVM.otpResponse.text),e.createElement("form",{onSubmit:function(e){e.preventDefault(),N()}},e.createElement(c,{type:m.TEXT,label:v("checkout-page:masterPass.otpModal.inputLabel"),name:"validationCode",rightContent:f.mpVM.isOtpFormSubmitAtLeastOnce?e.createElement("button",{type:"button",className:p.ResendButton,disabled:P,onClick:function(e){e.stopPropagation(),P||(T(!0),f.mpVM.resendOtp({store:f.store,checkout:f.checkout,callback:function(){T(!1),I(),E("")}}))}},v("checkout-page:masterPass.otpModal.resendText")):void 0,value:y,onChange:function(e){E(e)}}),e.createElement(r,{type:"submit",style:{width:"100%",marginTop:"16px"},text:v("checkout-page:masterPass.otpModal.buttonText"),isLoading:O,isDisabled:!y,onClick:N})));return a((function(){u?x(180):V()}),[u]),console.log("calisti modal",u),e.createElement(l,{visible:u,onClose:h},S)}));export{u as default};
1
+ import e,{useRef as t,useState as o,useEffect as a}from"react";import{observer as s}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 n}from"../../../../../utils/i18n.js";import{Button as r}from"../../button/index.js";import{FormItem as c}from"../../form-item/index.js";import{FormItemType as m}from"../../form-item/model.js";import l from"../modal/index.js";import i from"./svg/master-pass.js";import p from"./style.module.scss.js";var u=s((function(s){var u=s.visible,d=s.type,f=s.vm,h=s.onClose,v=n().t,b=t(),g=o(180),x=g[0],k=g[1],M=o(""),E=M[0],j=M[1],P=o(!1),T=P[0],y=P[1],C=o(!1),O=C[0],N=C[1],V=function(){if(!O&&E&&f.checkout.masterPassPaymentGateway){N(!0),f.mpVM.onOtpFormSubmit({validationCode:E,store:f.store,checkout:f.checkout,callback:function(){N(!1),j(""),R()}})}},R=function(){k(0)},_=function(){k(180)};a((function(){if(!(x<1&&b.current))return b.current&&clearInterval(b.current),b.current=setInterval((function(){k(x-1)}),1e3),function(){b.current&&clearInterval(b.current)};clearInterval(b.current)}),[x]);var w,I,L,A,B,S,D=e.createElement("div",null,e.createElement("div",{className:p.Wrapper},"masterPassOtp"===d&&e.createElement("span",{"data-mr":!0,className:p.Logo},e.createElement(i,null)),e.createElement("p",{className:p.Text},v("masterPassOtp"===d?"checkout-page:masterPass.otpModal.otpTextMasterPass":"checkout-page:masterPass.otpModal.otpTextBank"))),e.createElement("div",{className:p.Countdown},v("checkout-page:masterPass.otpModal.countdownText"),e.createElement("strong",null,(w=x%3600,I=Math.floor(w/60),L=w%60,A=Math.ceil(L),B=I<10?"0".concat(I):I,S=A<10?"0".concat(A):A,"".concat(B,":").concat(S)))),f.mpVM.otpResponse.text&&e.createElement("div",{role:"error"===f.mpVM.otpResponse.status?"alert":"",className:p.OtpResponseText},f.mpVM.otpResponse.text),e.createElement("form",{onSubmit:function(e){e.preventDefault(),V()}},e.createElement(c,{type:m.TEXT,label:v("checkout-page:masterPass.otpModal.inputLabel"),name:"validationCode",rightContent:f.mpVM.isOtpFormSubmitAtLeastOnce?e.createElement("button",{type:"button",className:p.ResendButton,disabled:T,onClick:function(e){e.stopPropagation(),T||(y(!0),f.mpVM.resendOtp({store:f.store,checkout:f.checkout,callback:function(){y(!1),_(),j("")}}))}},v("checkout-page:masterPass.otpModal.resendText")):void 0,value:E,onChange:function(e){j(e)}}),e.createElement(r,{type:"submit",style:{width:"100%",marginTop:"16px"},text:v("checkout-page:masterPass.otpModal.buttonText"),isLoading:O,isDisabled:!E,onClick:V})));return a((function(){u?k(180):R()}),[u]),console.log("calisti modal",u),e.createElement(l,{visible:u,onClose:h},D)}));export{u as default};
@@ -156,7 +156,7 @@ export default class MasterPassModel {
156
156
  * sonra linkleme başarıyla gerçekleşeceği için ListCard servisi ile kartlar listelenir.
157
157
  */
158
158
  linkCardToClient: ({ store, checkout, callback, }: LinkCardToClientParams) => Promise<void>;
159
- validateTransaction: ({ validationCode, store, cartId, paymentGateway, checkout, callback, }: ValidateTransactionParams) => Promise<void>;
159
+ validateTransaction: ({ validationCode, store, checkout, callback, }: ValidateTransactionParams) => Promise<void>;
160
160
  listCards: ({ store, checkout }: ListCardsParams) => Promise<void>;
161
161
  deleteCard: ({ store, checkout, card }: DeleteCardParams) => Promise<void>;
162
162
  }
@@ -184,9 +184,7 @@ declare type LinkCardToClientParams = {
184
184
  callback?: () => void;
185
185
  };
186
186
  declare type ValidateTransactionParams = {
187
- cartId: string;
188
187
  validationCode: string;
189
- paymentGateway: IkasPaymentGateway;
190
188
  store: IkasBaseStore;
191
189
  checkout: IkasCheckout;
192
190
  callback: () => void;
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as s,__rest as t}from'../../ext/tslib/tslib.es6.js';import{makeAutoObservable as o}from"mobx";import{IkasStorefrontConfig as a}from"../../storefront/index.js";import n from"../../__api/queries/getMasterpassRequestToken.js";import{MasterPassOperationTypeEnum as r}from"../../__api/types/index.js";import{useTranslation as i}from"../../utils/i18n.js";var c="undefined"==typeof localStorage,u=/000000[0|1]{10}/g,l=/[0|1]1100[0|1]{11}/g,d=/[0|1]11100[0|1]{10}/g,p=function(){function p(){var p=this;this.checkMasterPassData={status:""},this.saveCardToMasterPass={isCheckboxChecked:!1,cardName:"",phoneNumber:"",isSendConfirmationButtonPending:!1},this.otpResponse={status:"",text:""},this.isOtpFormSubmitAtLeastOnce=!1,this.visibleModal=void 0,this.cards=[],this.saveCardToMasterPassPhoneNumberDisabledInputValue=function(e){var s=e.store,t=e.checkout;return p.phoneNumber({store:s,checkout:t,withPlus:!0})||""},this.onSaveCardToMasterPassCheckedChange=function(e){p.saveCardToMasterPass.isCheckboxChecked=e},this.onSaveCardToMasterPassCardNameChange=function(e){p.saveCardToMasterPass.cardName=e},this.onSaveCardToMasterPassPhoneNumberChange=function(e){p.saveCardToMasterPass.phoneNumber=e},this.onSaveCardToMasterPassSendConfirmationButtonClick=function(e){var s=e.creditCard,t=e.store,o=e.checkout,a=e.paymentGateway,n=e.callback;console.log("onSaveCardToMasterPassSendConfirmationButtonClick 1"),p.register({creditCard:s,store:t,checkout:o,paymentGateway:a,callback:n})},this.showLinkCardToClientModal=function(){p.visibleModal="linkCardToClientModal"},this.hideLinkCardToClientModal=function(){p.visibleModal=void 0},this.showOtpModal=function(e){p.otpResponse.text="",p.otpResponse.status="",p.visibleModal="masterPassOtp"===e?"otpModalMasterPass":"otpModalBank",console.log("calisti",p.visibleModal)},this.hideOtpModal=function(){p.visibleModal=void 0,p.otpResponse.text="",p.otpResponse.status="",p.isOtpFormSubmitAtLeastOnce=!1},this.onResponseModalClose=function(){p.visibleModal=void 0,p.mfsResponseModalText=""},this.onSuccessModalClose=function(){p.visibleModal=void 0},this.onLinkCardToClientButtonClick=function(e){p.linkCardToClient(e)},this.onOtpFormSubmit=function(e){p.otpResponse.text="",p.otpResponse.status="",p.validateTransaction(e)},this.MFS=function(){var e;if(!c){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(t){var o=t.cartId,a=t.paymentGatewayId,r=t.operationType,i=t.phoneNumber;return e(p,void 0,void 0,(function(){var e;return s(this,(function(s){switch(s.label){case 0:return[4,n({cartId:o,paymentGatewayId:a,operationType:r,phoneNumber:i})];case 1:return(e=s.sent()).data&&e.isSuccess&&!e.errors.length?[2,e.data]:(this.showTokenErrorWithModal(),[2])}}))}))},this.phoneNumber=function(e){var s,t,o=e.store,a=e.checkout,n=e.withPlus,r=void 0!==n&&n,i=(null===(s=o.customerStore.customer)||void 0===s?void 0:s.phone)||(null===(t=a.shippingAddress)||void 0===t?void 0:t.phone);return i&&i.includes("+")&&!r&&(i=i.replace("+","")),i},this.sendSmsLanguage=function(e){var s,t="eng";if(e.localeOptions.length){var o=e.localeOptions.find((function(e){return e.routing.locale===a.getCurrentLocale()}));o&&o.iso3&&(t=null===(s=o.iso3)||void 0===s?void 0:s.toLowerCase())}return t},this.clearSaveCardToMasterPassForm=function(){p.saveCardToMasterPass.isCheckboxChecked=!1,p.saveCardToMasterPass.phoneNumber="",p.saveCardToMasterPass.cardName="",p.saveCardToMasterPass.isSendConfirmationButtonPending=!1},this.mfsResponseHandler=function(e){return function(s,t){console.log({field:"mfsResponseHandler",response:t}),e.callback&&e.callback();var o,a=function(e){var s;return null===(s=null==t?void 0:t.accountStatus)||void 0===s?void 0:s.match(e)};a(u)&&(p.checkMasterPassData.status="noMasterPassAccount",(o=p.phoneNumber({checkout:e.checkout,store:e.store,withPlus:!0}))&&(p.saveCardToMasterPass.phoneNumber=o));a(l)&&(p.checkMasterPassData.status="hasMasterPassAccountButDoesNotHaveAnyOperation",p.showLinkCardToClientModal(),(o=p.phoneNumber({checkout:e.checkout,store:e.store,withPlus:!0}))&&(p.saveCardToMasterPass.phoneNumber=o));if(a(d)&&(p.checkMasterPassData.status="hasMasterPassAccountAndHasRelation",(null==e?void 0:e.checkout)&&e.store&&(p.listCards({store:e.store,checkout:e.checkout}),console.log("call listcards"))),"validateTransaction"!==e.source&&"resendOtp"!==e.source||!t.responseDescription||(p.otpResponse.text=t.responseDescription,"1409"===t.responseCode&&(p.otpResponse.status="error")),"0000"!=t.responseCode&&""!=t.responseCode||(console.log("Register Success"),"deleteCard"===e.source&&p.listCards({store:e.store,checkout:e.checkout}),"validateTransaction"===e.source&&(null==e?void 0:e.checkout)&&e.store&&("hasMasterPassAccountButDoesNotHaveAnyOperation"===p.checkMasterPassData.status?p.visibleModal="linkCardToClientModalSuccess":p.visibleModal="otpModalSuccess",e.checkout.selectedPaymentGateway=void 0,p.clearSaveCardToMasterPassForm(),p.listCards({store:e.store,checkout:e.checkout}))),"5196"===t.responseCode&&t.responseDescription&&(p.visibleModal="mfsResponseModal",p.mfsResponseModalText=t.responseDescription),"5001"==t.responseCode||"5008"==t.responseCode){var n="5001"===t.responseCode?"bankOtp":"masterPassOtp";p.showOtpModal(n)}if("5010"==t.responseCode&&"undefined"!=typeof window)return console.log('response.responseCode == "5010"'),void window.location.assign(t.url3D+"&returnUrl="+window.location.href);console.log({source:"MFS response.responseDescription",responseDescription:t.responseDescription,response:t})}},this.showTokenErrorWithModal=function(){var e=i().t;p.visibleModal="mfsResponseModal",p.mfsResponseModalText=e("checkout-page:errorUnknown")},this.checkMasterPass=function(o){return e(p,void 0,void 0,(function(){var e,a,n,i,c,u,l=o.checkout,d=o.store;return t(o,["checkout","store"]),s(this,(function(s){switch(s.label){case 0:return console.log("checkMasterPass 1"),(e=this.MFS())?(a=this.phoneNumber({store:d,checkout:l}),console.log("checkMasterPass 2"),n=l.masterPassPaymentGateway,a&&n&&n.masterPassClientId?(console.log("checkMasterPass 3",a),[4,this.getToken({cartId:l.id,paymentGatewayId:n.id,operationType:r.CHECK_MASTER_PASS_USER,phoneNumber:a})]):[2]):[2];case 1:return(i=s.sent())?(e.setClientId(n.masterPassClientId),c=this.sendSmsLanguage(d),u=this.prepareFormData({sendSmsLanguage:c,sendSms:"N",referenceNo:i.requestReferenceNumber,token:i.token,userId:a}),e.checkMasterPass(u,this.mfsResponseHandler({source:"checkMasterPass",checkout:l,store:d})),console.log("checkMasterPass 4"),[2]):[2]}}))}))},this.register=function(t){var o=t.creditCard,a=t.store,n=t.checkout,i=t.paymentGateway,c=t.callback;return e(p,void 0,void 0,(function(){var e,t,u,l;return s(this,(function(s){switch(s.label){case 0:return console.log("register 1"),(e=this.MFS())?(console.log("register 2"),(t=o.phoneNumber)&&i.masterPassClientId?(console.log("register 3"),[4,this.getToken({cartId:n.id,paymentGatewayId:i.id,operationType:r.REGISTER_CARD,phoneNumber:t})]):[2]):[2];case 1:return u=s.sent(),console.log("register 4"),(null==u?void 0:u.token)?(l=this.prepareFormData({msisdn:t,token:null==u?void 0:u.token,referenceNo:u.requestReferenceNumber,sendSmsLanguage:this.sendSmsLanguage(a),rtaPan:o.rtaPan,expiryDate:o.expiryDate,cvc:o.cvc,accountAliasName:o.accountAliasName,timeZone:u.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:a,checkout:n,callback:c})),[2]):[2]}}))}))},this.resendOtp=function(t){var o=t.store,a=t.checkout,n=t.callback;return e(p,void 0,void 0,(function(){var e,t,r;return s(this,(function(s){return this.isOtpFormSubmitAtLeastOnce&&(e=this.MFS())?(t=e.getLastToken(),r=this.sendSmsLanguage(o),e.resendOtp(t,r,this.mfsResponseHandler({source:"resendOtp",store:o,checkout:a,callback:n})),[2]):[2]}))}))},this.linkCardToClient=function(t){var o=t.store,a=t.checkout,n=t.callback;return e(p,void 0,void 0,(function(){var e,t,i,c,u;return s(this,(function(s){switch(s.label){case 0:return(e=this.MFS())&&((t=this.phoneNumber({store:o,checkout:a}))&&(null==(i=a.masterPassPaymentGateway)?void 0:i.id))?[4,this.getToken({cartId:a.id,paymentGatewayId:i.id,operationType:r.REGISTER_CARD,phoneNumber:t})]:[2];case 1:return(c=s.sent())?(u=this.prepareFormData({sendSms:"Y",sendSmsLanguage:this.sendSmsLanguage(o),token:c.token,referenceNo:c.requestReferenceNumber,cardAliasName:"",msisdn:t}),e.linkCardToClient(u,this.mfsResponseHandler({source:"linkCardToClient",store:o,checkout:a,callback:n})),[2]):(n&&n(),[2])}}))}))},this.validateTransaction=function(t){var o=t.validationCode,a=t.store,n=t.cartId,i=t.paymentGateway,c=t.checkout,u=t.callback;return e(p,void 0,void 0,(function(){var e,t,l,d;return s(this,(function(s){switch(s.label){case 0:return(e=this.MFS())&&(t=this.phoneNumber({store:a,checkout:c}))?[4,this.getToken({cartId:n,paymentGatewayId:i.id,operationType:r.REGISTER_CARD,phoneNumber:t})]:[2];case 1:return(l=s.sent())?(d=this.prepareFormData({pinType:"otp",validationCode:o,sendSms:"Y",sendSmsLanguage:this.sendSmsLanguage(a),token:l.token,referenceNo:l.requestReferenceNumber}),this.isOtpFormSubmitAtLeastOnce||(this.isOtpFormSubmitAtLeastOnce=!0),e.validateTransaction(d,this.mfsResponseHandler({source:"validateTransaction",store:a,checkout:c,callback:u})),[2]):[2]}}))}))},this.listCards=function(t){var o=t.store,a=t.checkout;return e(p,void 0,void 0,(function(){var e,t,n,i,c,u,l=this;return s(this,(function(s){switch(s.label){case 0:return(e=this.MFS())&&(t=this.phoneNumber({store:o,checkout:a}))?(n=null===(u=a.masterPassPaymentGateway)||void 0===u?void 0:u.id,console.log("listCards paymentGatewayId",n),n?[4,this.getToken({cartId:a.id,paymentGatewayId:n,operationType:r.LIST_CARDS,phoneNumber:t})]:[2]):[2];case 1:return(i=s.sent())?(c=function(e,s){if("0000"!=s.responseCode&&""!=s.responseCode)return l.visibleModal="mfsResponseModal",l.mfsResponseModalText=s.responseDescription,console.error("mfs response.responseDescription",s.responseDescription),void console.log("TransactionID->",s.transactionId);var t=[];if(Array.isArray(s.cards))for(var o=0;o<s.cards.length;o++){var a=s.cards[o];a.paymentGatewayId=n,t.push(a)}l.cards=t,console.log("list_card response->",s),console.log("Cards",t),console.log("TransactionID->",s.transactionId)},e.listCards(t,i.token,c),[2]):[2]}}))}))},this.deleteCard=function(t){var o=t.store,a=t.checkout,n=t.card;return e(p,void 0,void 0,(function(){var e,t,i,c;return s(this,(function(s){switch(s.label){case 0:return(e=this.MFS())&&(t=this.phoneNumber({store:o,checkout:a}))?[4,this.getToken({cartId:a.id,paymentGatewayId:n.paymentGatewayId,operationType:r.DELETE_CARD,phoneNumber:t})]:[2];case 1:return(i=s.sent())?(c=this.prepareFormData({sendSms:"N",msisdn:t,token:i.token,referenceNo:i.requestReferenceNumber,sendSmsLanguage:this.sendSmsLanguage(o),accountAliasName:n.Name}),e.deleteCard(c,this.mfsResponseHandler({source:"deleteCard",store:o,checkout:a})),[2]):[2]}}))}))},o(this)}return Object.defineProperty(p.prototype,"isSaveCardToMasterPassPhoneNumberInputVisible",{get:function(){return("hasMasterPassAccountAndHasRelation"!==this.checkMasterPassData.status||!this.cards.length)&&("hasMasterPassAccountButDoesNotHaveAnyOperation"===this.checkMasterPassData.status||this.checkMasterPassData.status,!0)},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"isSaveCardToMasterPassPhoneNumberInputDisabled",{get:function(){return!("hasMasterPassAccountAndHasRelation"!==this.checkMasterPassData.status||!this.cards.length)||("hasMasterPassAccountButDoesNotHaveAnyOperation"===this.checkMasterPassData.status||"noMasterPassAccount"===this.checkMasterPassData.status)},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"isSendConfirmationButtonDisabled",{get:function(){if(this)return!this.saveCardToMasterPass.cardName||!this.saveCardToMasterPass.phoneNumber},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"isLinkCardToClientModalVisible",{get:function(){return"linkCardToClientModal"===this.visibleModal},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"isOtpModalVisible",{get:function(){return"otpModalBank"===this.visibleModal||"otpModalMasterPass"===this.visibleModal},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"isResponseModalVisible",{get:function(){return!("mfsResponseModal"!==this.visibleModal||!this.mfsResponseModalText)},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"isSuccessModalVisible",{get:function(){return"linkCardToClientModalSuccess"===this.visibleModal||"otpModalSuccess"===this.visibleModal},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"otpModalType",{get:function(){return"otpModalMasterPass"===this.visibleModal?"masterPassOtp":"bankOtp"},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"successModalType",{get:function(){return"hasMasterPassAccountButDoesNotHaveAnyOperation"===this.checkMasterPassData.status?"linkCardToClient":"register"},enumerable:!1,configurable:!0}),p.prototype.prepareFormData=function(e){var s=new FormData;return Object.entries(e).forEach((function(e){var t=e[0],o=e[1];return s.append(t,o)})),s},p}();export{p as default};
1
+ import{__awaiter as e,__generator as s,__rest as t}from'../../ext/tslib/tslib.es6.js';import{makeAutoObservable as o}from"mobx";import{IkasStorefrontConfig as a}from"../../storefront/index.js";import n from"../../__api/queries/getMasterpassRequestToken.js";import{MasterPassOperationTypeEnum as r}from"../../__api/types/index.js";import{useTranslation as i}from"../../utils/i18n.js";var c="undefined"==typeof localStorage,u=/000000[0|1]{10}/g,l=/[0|1]1100[0|1]{11}/g,d=/[0|1]11100[0|1]{10}/g,p=function(){function p(){var p=this;this.checkMasterPassData={status:""},this.saveCardToMasterPass={isCheckboxChecked:!1,cardName:"",phoneNumber:"",isSendConfirmationButtonPending:!1},this.otpResponse={status:"",text:""},this.isOtpFormSubmitAtLeastOnce=!1,this.visibleModal=void 0,this.cards=[],this.saveCardToMasterPassPhoneNumberDisabledInputValue=function(e){var s=e.store,t=e.checkout;return p.phoneNumber({store:s,checkout:t,withPlus:!0})||""},this.onSaveCardToMasterPassCheckedChange=function(e){p.saveCardToMasterPass.isCheckboxChecked=e},this.onSaveCardToMasterPassCardNameChange=function(e){p.saveCardToMasterPass.cardName=e},this.onSaveCardToMasterPassPhoneNumberChange=function(e){p.saveCardToMasterPass.phoneNumber=e},this.onSaveCardToMasterPassSendConfirmationButtonClick=function(e){var s=e.creditCard,t=e.store,o=e.checkout,a=e.paymentGateway,n=e.callback;console.log("onSaveCardToMasterPassSendConfirmationButtonClick 1"),p.register({creditCard:s,store:t,checkout:o,paymentGateway:a,callback:n})},this.showLinkCardToClientModal=function(){p.visibleModal="linkCardToClientModal"},this.hideLinkCardToClientModal=function(){p.visibleModal=void 0},this.showOtpModal=function(e){p.otpResponse.text="",p.otpResponse.status="",p.visibleModal="masterPassOtp"===e?"otpModalMasterPass":"otpModalBank",console.log("calisti",p.visibleModal)},this.hideOtpModal=function(){p.visibleModal=void 0,p.otpResponse.text="",p.otpResponse.status="",p.isOtpFormSubmitAtLeastOnce=!1},this.onResponseModalClose=function(){p.visibleModal=void 0,p.mfsResponseModalText=""},this.onSuccessModalClose=function(){p.visibleModal=void 0},this.onLinkCardToClientButtonClick=function(e){p.linkCardToClient(e)},this.onOtpFormSubmit=function(e){p.otpResponse.text="",p.otpResponse.status="",p.validateTransaction(e)},this.MFS=function(){var e;if(!c){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(t){var o=t.cartId,a=t.paymentGatewayId,r=t.operationType,i=t.phoneNumber;return e(p,void 0,void 0,(function(){var e;return s(this,(function(s){switch(s.label){case 0:return[4,n({cartId:o,paymentGatewayId:a,operationType:r,phoneNumber:i})];case 1:return(e=s.sent()).data&&e.isSuccess&&!e.errors.length?[2,e.data]:(this.showTokenErrorWithModal(),[2])}}))}))},this.phoneNumber=function(e){var s,t,o=e.store,a=e.checkout,n=e.withPlus,r=void 0!==n&&n,i=(null===(s=o.customerStore.customer)||void 0===s?void 0:s.phone)||(null===(t=a.shippingAddress)||void 0===t?void 0:t.phone);return i&&i.includes("+")&&!r&&(i=i.replace("+","")),i},this.sendSmsLanguage=function(e){var s,t="eng";if(e.localeOptions.length){var o=e.localeOptions.find((function(e){return e.routing.locale===a.getCurrentLocale()}));o&&o.iso3&&(t=null===(s=o.iso3)||void 0===s?void 0:s.toLowerCase())}return t},this.clearSaveCardToMasterPassForm=function(){p.saveCardToMasterPass.isCheckboxChecked=!1,p.saveCardToMasterPass.phoneNumber="",p.saveCardToMasterPass.cardName="",p.saveCardToMasterPass.isSendConfirmationButtonPending=!1},this.mfsResponseHandler=function(e){return function(s,t){console.log({field:"mfsResponseHandler",response:t}),e.callback&&e.callback();var o,a=function(e){var s;return null===(s=null==t?void 0:t.accountStatus)||void 0===s?void 0:s.match(e)};a(u)&&(p.checkMasterPassData.status="noMasterPassAccount",(o=p.phoneNumber({checkout:e.checkout,store:e.store,withPlus:!0}))&&(p.saveCardToMasterPass.phoneNumber=o));a(l)&&(p.checkMasterPassData.status="hasMasterPassAccountButDoesNotHaveAnyOperation",p.showLinkCardToClientModal(),(o=p.phoneNumber({checkout:e.checkout,store:e.store,withPlus:!0}))&&(p.saveCardToMasterPass.phoneNumber=o));if(a(d)&&(p.checkMasterPassData.status="hasMasterPassAccountAndHasRelation",(null==e?void 0:e.checkout)&&e.store&&(p.listCards({store:e.store,checkout:e.checkout}),console.log("call listcards"))),"validateTransaction"!==e.source&&"resendOtp"!==e.source||!t.responseDescription||(p.otpResponse.text=t.responseDescription,"1409"===t.responseCode&&(p.otpResponse.status="error")),"0000"!=t.responseCode&&""!=t.responseCode||(console.log("Register Success"),"deleteCard"===e.source&&p.listCards({store:e.store,checkout:e.checkout}),"validateTransaction"===e.source&&(null==e?void 0:e.checkout)&&e.store&&("hasMasterPassAccountButDoesNotHaveAnyOperation"===p.checkMasterPassData.status?p.visibleModal="linkCardToClientModalSuccess":p.visibleModal="otpModalSuccess",e.checkout.selectedPaymentGateway=void 0,p.clearSaveCardToMasterPassForm(),p.listCards({store:e.store,checkout:e.checkout}))),"5196"===t.responseCode&&t.responseDescription&&(p.visibleModal="mfsResponseModal",p.mfsResponseModalText=t.responseDescription),"5001"==t.responseCode||"5008"==t.responseCode){var n="5001"===t.responseCode?"bankOtp":"masterPassOtp";p.showOtpModal(n)}if("5010"==t.responseCode&&"undefined"!=typeof window)return console.log('response.responseCode == "5010"'),void window.location.assign(t.url3D+"&returnUrl="+window.location.href);console.log({source:"MFS response.responseDescription",responseDescription:t.responseDescription,response:t})}},this.showTokenErrorWithModal=function(){var e=i().t;p.visibleModal="mfsResponseModal",p.mfsResponseModalText=e("checkout-page:errorUnknown")},this.checkMasterPass=function(o){return e(p,void 0,void 0,(function(){var e,a,n,i,c,u,l=o.checkout,d=o.store;return t(o,["checkout","store"]),s(this,(function(s){switch(s.label){case 0:return console.log("checkMasterPass 1"),(e=this.MFS())?(a=this.phoneNumber({store:d,checkout:l}),console.log("checkMasterPass 2"),n=l.masterPassPaymentGateway,a&&n&&n.masterPassClientId?(console.log("checkMasterPass 3",a),[4,this.getToken({cartId:l.id,paymentGatewayId:n.id,operationType:r.CHECK_MASTER_PASS_USER,phoneNumber:a})]):[2]):[2];case 1:return(i=s.sent())?(e.setClientId(n.masterPassClientId),c=this.sendSmsLanguage(d),u=this.prepareFormData({sendSmsLanguage:c,sendSms:"N",referenceNo:i.requestReferenceNumber,token:i.token,userId:a}),e.checkMasterPass(u,this.mfsResponseHandler({source:"checkMasterPass",checkout:l,store:d})),console.log("checkMasterPass 4"),[2]):[2]}}))}))},this.register=function(t){var o=t.creditCard,a=t.store,n=t.checkout,i=t.paymentGateway,c=t.callback;return e(p,void 0,void 0,(function(){var e,t,u,l;return s(this,(function(s){switch(s.label){case 0:return console.log("register 1"),(e=this.MFS())?(console.log("register 2"),(t=o.phoneNumber)&&i.masterPassClientId?(console.log("register 3"),[4,this.getToken({cartId:n.id,paymentGatewayId:i.id,operationType:r.REGISTER_CARD,phoneNumber:t})]):[2]):[2];case 1:return u=s.sent(),console.log("register 4"),(null==u?void 0:u.token)?(l=this.prepareFormData({msisdn:t,token:null==u?void 0:u.token,referenceNo:u.requestReferenceNumber,sendSmsLanguage:this.sendSmsLanguage(a),rtaPan:o.rtaPan,expiryDate:o.expiryDate,cvc:o.cvc,accountAliasName:o.accountAliasName,timeZone:u.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:a,checkout:n,callback:c})),[2]):[2]}}))}))},this.resendOtp=function(t){var o=t.store,a=t.checkout,n=t.callback;return e(p,void 0,void 0,(function(){var e,t,r;return s(this,(function(s){return this.isOtpFormSubmitAtLeastOnce&&(e=this.MFS())?(t=e.getLastToken(),r=this.sendSmsLanguage(o),e.resendOtp(t,r,this.mfsResponseHandler({source:"resendOtp",store:o,checkout:a,callback:n})),[2]):[2]}))}))},this.linkCardToClient=function(t){var o=t.store,a=t.checkout,n=t.callback;return e(p,void 0,void 0,(function(){var e,t,i,c,u;return s(this,(function(s){switch(s.label){case 0:return(e=this.MFS())&&((t=this.phoneNumber({store:o,checkout:a}))&&(null==(i=a.masterPassPaymentGateway)?void 0:i.id))?[4,this.getToken({cartId:a.id,paymentGatewayId:i.id,operationType:r.REGISTER_CARD,phoneNumber:t})]:[2];case 1:return(c=s.sent())?(u=this.prepareFormData({sendSms:"Y",sendSmsLanguage:this.sendSmsLanguage(o),token:c.token,referenceNo:c.requestReferenceNumber,cardAliasName:"",msisdn:t}),e.linkCardToClient(u,this.mfsResponseHandler({source:"linkCardToClient",store:o,checkout:a,callback:n})),[2]):(n&&n(),[2])}}))}))},this.validateTransaction=function(t){var o=t.validationCode,a=t.store,n=t.checkout,i=t.callback;return e(p,void 0,void 0,(function(){var e,t,c,u,l;return s(this,(function(s){switch(s.label){case 0:return(e=this.MFS())&&((t=this.phoneNumber({store:a,checkout:n}))&&(c=n.masterPassPaymentGateway))?[4,this.getToken({cartId:n.id,paymentGatewayId:c.id,operationType:r.REGISTER_CARD,phoneNumber:t})]:[2];case 1:return(u=s.sent())?(l=this.prepareFormData({pinType:"otp",validationCode:o,sendSms:"Y",sendSmsLanguage:this.sendSmsLanguage(a),token:u.token,referenceNo:u.requestReferenceNumber}),this.isOtpFormSubmitAtLeastOnce||(this.isOtpFormSubmitAtLeastOnce=!0),e.validateTransaction(l,this.mfsResponseHandler({source:"validateTransaction",store:a,checkout:n,callback:i})),[2]):[2]}}))}))},this.listCards=function(t){var o=t.store,a=t.checkout;return e(p,void 0,void 0,(function(){var e,t,n,i,c,u,l=this;return s(this,(function(s){switch(s.label){case 0:return(e=this.MFS())&&(t=this.phoneNumber({store:o,checkout:a}))?(n=null===(u=a.masterPassPaymentGateway)||void 0===u?void 0:u.id,console.log("listCards paymentGatewayId",n),n?[4,this.getToken({cartId:a.id,paymentGatewayId:n,operationType:r.LIST_CARDS,phoneNumber:t})]:[2]):[2];case 1:return(i=s.sent())?(c=function(e,s){if("0000"!=s.responseCode&&""!=s.responseCode)return l.visibleModal="mfsResponseModal",l.mfsResponseModalText=s.responseDescription,console.error("mfs response.responseDescription",s.responseDescription),void console.log("TransactionID->",s.transactionId);var t=[];if(Array.isArray(s.cards))for(var o=0;o<s.cards.length;o++){var a=s.cards[o];a.paymentGatewayId=n,t.push(a)}l.cards=t,console.log("list_card response->",s),console.log("Cards",t),console.log("TransactionID->",s.transactionId)},e.listCards(t,i.token,c),[2]):[2]}}))}))},this.deleteCard=function(t){var o=t.store,a=t.checkout,n=t.card;return e(p,void 0,void 0,(function(){var e,t,i,c;return s(this,(function(s){switch(s.label){case 0:return(e=this.MFS())&&(t=this.phoneNumber({store:o,checkout:a}))?[4,this.getToken({cartId:a.id,paymentGatewayId:n.paymentGatewayId,operationType:r.DELETE_CARD,phoneNumber:t})]:[2];case 1:return(i=s.sent())?(c=this.prepareFormData({sendSms:"N",msisdn:t,token:i.token,referenceNo:i.requestReferenceNumber,sendSmsLanguage:this.sendSmsLanguage(o),accountAliasName:n.Name}),e.deleteCard(c,this.mfsResponseHandler({source:"deleteCard",store:o,checkout:a})),[2]):[2]}}))}))},o(this)}return Object.defineProperty(p.prototype,"isSaveCardToMasterPassPhoneNumberInputVisible",{get:function(){return("hasMasterPassAccountAndHasRelation"!==this.checkMasterPassData.status||!this.cards.length)&&("hasMasterPassAccountButDoesNotHaveAnyOperation"===this.checkMasterPassData.status||this.checkMasterPassData.status,!0)},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"isSaveCardToMasterPassPhoneNumberInputDisabled",{get:function(){return!("hasMasterPassAccountAndHasRelation"!==this.checkMasterPassData.status||!this.cards.length)||("hasMasterPassAccountButDoesNotHaveAnyOperation"===this.checkMasterPassData.status||"noMasterPassAccount"===this.checkMasterPassData.status)},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"isSendConfirmationButtonDisabled",{get:function(){if(this)return!this.saveCardToMasterPass.cardName||!this.saveCardToMasterPass.phoneNumber},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"isLinkCardToClientModalVisible",{get:function(){return"linkCardToClientModal"===this.visibleModal},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"isOtpModalVisible",{get:function(){return"otpModalBank"===this.visibleModal||"otpModalMasterPass"===this.visibleModal},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"isResponseModalVisible",{get:function(){return!("mfsResponseModal"!==this.visibleModal||!this.mfsResponseModalText)},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"isSuccessModalVisible",{get:function(){return"linkCardToClientModalSuccess"===this.visibleModal||"otpModalSuccess"===this.visibleModal},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"otpModalType",{get:function(){return"otpModalMasterPass"===this.visibleModal?"masterPassOtp":"bankOtp"},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"successModalType",{get:function(){return"hasMasterPassAccountButDoesNotHaveAnyOperation"===this.checkMasterPassData.status?"linkCardToClient":"register"},enumerable:!1,configurable:!0}),p.prototype.prepareFormData=function(e){var s=new FormData;return Object.entries(e).forEach((function(e){var t=e[0],o=e[1];return s.append(t,o)})),s},p}();export{p as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "3.0.0-alpha.37",
3
+ "version": "3.0.0-alpha.38",
4
4
  "main": "./build/index.js",
5
5
  "module": "./build/index.js",
6
6
  "author": "Umut Ozan Yıldırım",