@ikas/storefront 4.0.11 → 4.0.13
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{__awaiter as e,__generator as s,__rest as t}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as o}from"mobx";import{useTranslation as a}from"../../utils/i18n.js";import{getMasterPassRequestToken as n,MasterPassOperationTypeEnum as r}from"@ikas/storefront-api";import{IkasStorefrontConfig as i}from"@ikas/storefront-config";var c="ikasMasterPass",u="https://cdn.myikas.com/sf/scripts/mfs-client-nojquery.min.js",d="undefined"==typeof localStorage,l=/000000[0|1]{10}/g,h=/[0|1]1100[0|1]{11}/g,p=/[0|1]11100[0|1]{10}/g,m=function(){function c(){var c=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,o=e.withPlus;return c.phoneNumber({store:s,checkout:t,withPlus:o})||""},this.onSaveCardToMasterPassCheckedChange=function(e){c.saveCardToMasterPass.isCheckboxChecked=e},this.onSaveCardToMasterPassCardNameChange=function(e){c.saveCardToMasterPass.cardName=e},this.onSaveCardToMasterPassPhoneNumberChange=function(e){c.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"),c.register({creditCard:s,store:t,checkout:o,paymentGateway:a,callback:n})},this.showLinkCardToClientModal=function(){c.visibleModal="linkCardToClientModal"},this.hideLinkCardToClientModal=function(){c.visibleModal=void 0},this.showOtpModal=function(e){c.otpResponse.text="",c.otpResponse.status="",c.visibleModal="masterPassOtp"===e?"otpModalMasterPass":"otpModalBank",console.log("calisti",c.visibleModal)},this.hideOtpModal=function(){c.visibleModal=void 0,c.otpResponse.text="",c.otpResponse.status="",c.isOtpFormSubmitAtLeastOnce=!1},this.onResponseModalClose=function(){c.visibleModal=void 0,c.mfsResponseModalText=""},this.onSuccessModalClose=function(){c.visibleModal=void 0},this.onLinkCardToClientButtonClick=function(e){c.linkCardToClient(e)},this.onOtpFormSubmit=function(e){c.otpResponse.text="",c.otpResponse.status="",c.validateTransaction(e)},this.MFS=function(){var e;if(!d){if(window.MFS&&(null===(e=window.MFS)||void 0===e?void 0:e.setClientId)){var s=window.MFS;return s.setAddress("https://uatui.masterpassturkiye.com/v2"),s}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(c,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="tur";if(e.localeOptions.length){var o=e.localeOptions.find((function(e){return e.routing.locale===i.getCurrentLocale()}));o&&o.iso3&&(t=null===(s=o.iso3)||void 0===s?void 0:s.toLowerCase())}return t},this.clearSaveCardToMasterPassForm=function(){c.saveCardToMasterPass.isCheckboxChecked=!1,c.saveCardToMasterPass.phoneNumber="",c.saveCardToMasterPass.cardName="",c.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(l)&&(c.checkMasterPassData.status="noMasterPassAccount",(o=c.phoneNumber({checkout:e.checkout,store:e.store,withPlus:!0}))&&(c.saveCardToMasterPass.phoneNumber=o));a(h)&&(c.checkMasterPassData.status="hasMasterPassAccountButDoesNotHaveAnyOperation",c.showLinkCardToClientModal(),(o=c.phoneNumber({checkout:e.checkout,store:e.store,withPlus:!0}))&&(c.saveCardToMasterPass.phoneNumber=o));if(a(p)&&(c.checkMasterPassData.status="hasMasterPassAccountAndHasRelation",(null==e?void 0:e.checkout)&&e.store&&(c.listCards({store:e.store,checkout:e.checkout}),console.log("call listcards"))),"validateTransaction"!==e.source&&"resendOtp"!==e.source||!t.responseDescription||(c.otpResponse.text=t.responseDescription,"1409"===t.responseCode&&(c.otpResponse.status="error")),"0000"!=t.responseCode&&""!=t.responseCode||(console.log("Register Success"),"deleteCard"===e.source&&c.listCards({store:e.store,checkout:e.checkout}),"validateTransaction"===e.source&&(null==e?void 0:e.checkout)&&e.store&&("hasMasterPassAccountButDoesNotHaveAnyOperation"===c.checkMasterPassData.status?c.visibleModal="linkCardToClientModalSuccess":c.visibleModal="otpModalSuccess",e.checkout.selectedPaymentGateway=void 0,c.clearSaveCardToMasterPassForm(),c.listCards({store:e.store,checkout:e.checkout}))),"5196"===t.responseCode&&t.responseDescription&&(c.visibleModal="mfsResponseModal",c.mfsResponseModalText=t.responseDescription),"5001"==t.responseCode||"5008"==t.responseCode){var n="5001"===t.responseCode?"bankOtp":"masterPassOtp";c.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=a().t;c.visibleModal="mfsResponseModal",c.mfsResponseModalText=e("checkout-page:errorUnknown")},this.checkMasterPass=function(o){return e(c,void 0,void 0,(function(){var e,a,n,i,c,u,d=o.checkout,l=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:l,checkout:d}),console.log("checkMasterPass 2"),n=d.masterPassPaymentGateway,a&&n&&n.masterPassClientId?(console.log("checkMasterPass 3",a),[4,this.getToken({cartId:d.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(l),u=this.prepareFormData({sendSmsLanguage:c,sendSms:"N",referenceNo:i.requestReferenceNumber,token:i.token,userId:a}),e.checkMasterPass(u,this.mfsResponseHandler({source:"checkMasterPass",checkout:d,store:l})),console.log("checkMasterPass 4"),[2]):[2]}}))}))},this.register=function(t){var o=t.creditCard,a=t.store,n=t.checkout,i=t.paymentGateway,u=t.callback;return e(c,void 0,void 0,(function(){var e,t,c,d;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 c=s.sent(),console.log("register 4"),(null==c?void 0:c.token)?(d=this.prepareFormData({msisdn:t,token:null==c?void 0:c.token,referenceNo:c.requestReferenceNumber,sendSmsLanguage:this.sendSmsLanguage(a),rtaPan:o.rtaPan,expiryDate:o.expiryDate,cvc:o.cvc,accountAliasName:o.accountAliasName,timeZone:c.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(d,this.mfsResponseHandler({source:"register",store:a,checkout:n,callback:u})),[2]):[2]}}))}))},this.resendOtp=function(t){var o=t.store,a=t.checkout,n=t.callback;return e(c,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(c,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(c,void 0,void 0,(function(){var e,t,c,u,d;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())?(d=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(d,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(c,void 0,void 0,(function(){var e,t,n,i,c,u,d=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){"0000"!=s.responseCode&&""!=s.responseCode&&(console.error({source:"mfs response.responseDescription",responseDescription:s.responseDescription,response:s}),console.log("TransactionID->",s.transactionId));var t=[];if(Array.isArray(s.cards)&&s.cards.length)for(var o=0;o<s.cards.length;o++){var a=s.cards[o];a.paymentGatewayId=n,t.push(a)}d.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(c,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(c.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(c.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(c.prototype,"isSendConfirmationButtonDisabled",{get:function(){return this.isSaveCardToMasterPassPhoneNumberInputVisible?this.isSaveCardToMasterPassPhoneNumberInputDisabled?!this.saveCardToMasterPass.cardName:!this.saveCardToMasterPass.cardName||!this.saveCardToMasterPass.phoneNumber:!this.saveCardToMasterPass.cardName},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"isLinkCardToClientModalVisible",{get:function(){return"linkCardToClientModal"===this.visibleModal},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"isOtpModalVisible",{get:function(){return"otpModalBank"===this.visibleModal||"otpModalMasterPass"===this.visibleModal},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"isResponseModalVisible",{get:function(){return!("mfsResponseModal"!==this.visibleModal||!this.mfsResponseModalText)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"isSuccessModalVisible",{get:function(){return"linkCardToClientModalSuccess"===this.visibleModal||"otpModalSuccess"===this.visibleModal},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"otpModalType",{get:function(){return"otpModalMasterPass"===this.visibleModal?"masterPassOtp":"bankOtp"},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"successModalType",{get:function(){return"hasMasterPassAccountButDoesNotHaveAnyOperation"===this.checkMasterPassData.status?"linkCardToClient":"register"},enumerable:!1,configurable:!0}),c.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},c}();export{c as MFS_ELEMENT_ID,u as MFS_SCRIPT_URL,m 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{useTranslation as a}from"../../utils/i18n.js";import{getMasterPassRequestToken as n,MasterPassOperationTypeEnum as r}from"@ikas/storefront-api";import{IkasStorefrontConfig as i}from"@ikas/storefront-config";var c="ikasMasterPass",u="https://cdn.myikas.com/sf/scripts/mfs-client-nojquery.min.js",d="undefined"==typeof localStorage,l=/000000[0|1]{10}/g,h=/[0|1]1100[0|1]{11}/g,p=/[0|1]11100[0|1]{10}/g,m=function(){function c(){var c=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,o=e.withPlus;return c.phoneNumber({store:s,checkout:t,withPlus:o})||""},this.onSaveCardToMasterPassCheckedChange=function(e){c.saveCardToMasterPass.isCheckboxChecked=e},this.onSaveCardToMasterPassCardNameChange=function(e){c.saveCardToMasterPass.cardName=e},this.onSaveCardToMasterPassPhoneNumberChange=function(e){c.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"),c.register({creditCard:s,store:t,checkout:o,paymentGateway:a,callback:n})},this.showLinkCardToClientModal=function(){c.visibleModal="linkCardToClientModal"},this.hideLinkCardToClientModal=function(){c.visibleModal=void 0},this.showOtpModal=function(e){c.otpResponse.text="",c.otpResponse.status="",c.visibleModal="masterPassOtp"===e?"otpModalMasterPass":"otpModalBank",console.log("calisti",c.visibleModal)},this.hideOtpModal=function(){c.visibleModal=void 0,c.otpResponse.text="",c.otpResponse.status="",c.isOtpFormSubmitAtLeastOnce=!1},this.onResponseModalClose=function(){c.visibleModal=void 0,c.mfsResponseModalText=""},this.onSuccessModalClose=function(){c.visibleModal=void 0},this.onLinkCardToClientButtonClick=function(e){c.linkCardToClient(e)},this.onOtpFormSubmit=function(e){c.otpResponse.text="",c.otpResponse.status="",c.validateTransaction(e)},this.MFS=function(){var e;if(!d){if(window.MFS&&(null===(e=window.MFS)||void 0===e?void 0:e.setClientId)){var s=window.MFS;return s.setAddress("https://ui.masterpassturkiye.com/v2"),s}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(c,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="tur";if(e.localeOptions.length){var o=e.localeOptions.find((function(e){return e.routing.locale===i.getCurrentLocale()}));o&&o.iso3&&(t=null===(s=o.iso3)||void 0===s?void 0:s.toLowerCase())}return t},this.clearSaveCardToMasterPassForm=function(){c.saveCardToMasterPass.isCheckboxChecked=!1,c.saveCardToMasterPass.phoneNumber="",c.saveCardToMasterPass.cardName="",c.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(l)&&(c.checkMasterPassData.status="noMasterPassAccount",(o=c.phoneNumber({checkout:e.checkout,store:e.store,withPlus:!0}))&&(c.saveCardToMasterPass.phoneNumber=o));a(h)&&(c.checkMasterPassData.status="hasMasterPassAccountButDoesNotHaveAnyOperation",c.showLinkCardToClientModal(),(o=c.phoneNumber({checkout:e.checkout,store:e.store,withPlus:!0}))&&(c.saveCardToMasterPass.phoneNumber=o));if(a(p)&&(c.checkMasterPassData.status="hasMasterPassAccountAndHasRelation",(null==e?void 0:e.checkout)&&e.store&&(c.listCards({store:e.store,checkout:e.checkout}),console.log("call listcards"))),"validateTransaction"!==e.source&&"resendOtp"!==e.source||!t.responseDescription||(c.otpResponse.text=t.responseDescription,"1409"===t.responseCode&&(c.otpResponse.status="error")),"0000"!=t.responseCode&&""!=t.responseCode||(console.log("Register Success"),"deleteCard"===e.source&&c.listCards({store:e.store,checkout:e.checkout}),"validateTransaction"===e.source&&(null==e?void 0:e.checkout)&&e.store&&("hasMasterPassAccountButDoesNotHaveAnyOperation"===c.checkMasterPassData.status?c.visibleModal="linkCardToClientModalSuccess":c.visibleModal="otpModalSuccess",e.checkout.selectedPaymentGateway=void 0,c.clearSaveCardToMasterPassForm(),c.listCards({store:e.store,checkout:e.checkout}))),"5196"===t.responseCode&&t.responseDescription&&(c.visibleModal="mfsResponseModal",c.mfsResponseModalText=t.responseDescription),"5001"==t.responseCode||"5008"==t.responseCode){var n="5001"===t.responseCode?"bankOtp":"masterPassOtp";c.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=a().t;c.visibleModal="mfsResponseModal",c.mfsResponseModalText=e("checkout-page:errorUnknown")},this.checkMasterPass=function(o){return e(c,void 0,void 0,(function(){var e,a,n,i,c,u,d=o.checkout,l=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:l,checkout:d}),console.log("checkMasterPass 2"),n=d.masterPassPaymentGateway,a&&n&&n.masterPassClientId?(console.log("checkMasterPass 3",a),[4,this.getToken({cartId:d.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(l),u=this.prepareFormData({sendSmsLanguage:c,sendSms:"N",referenceNo:i.requestReferenceNumber,token:i.token,userId:a}),e.checkMasterPass(u,this.mfsResponseHandler({source:"checkMasterPass",checkout:d,store:l})),console.log("checkMasterPass 4"),[2]):[2]}}))}))},this.register=function(t){var o=t.creditCard,a=t.store,n=t.checkout,i=t.paymentGateway,u=t.callback;return e(c,void 0,void 0,(function(){var e,t,c,d;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 c=s.sent(),console.log("register 4"),(null==c?void 0:c.token)?(d=this.prepareFormData({msisdn:t,token:null==c?void 0:c.token,referenceNo:c.requestReferenceNumber,sendSmsLanguage:this.sendSmsLanguage(a),rtaPan:o.rtaPan,expiryDate:o.expiryDate,cvc:o.cvc,accountAliasName:o.accountAliasName,timeZone:c.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(d,this.mfsResponseHandler({source:"register",store:a,checkout:n,callback:u})),[2]):[2]}}))}))},this.resendOtp=function(t){var o=t.store,a=t.checkout,n=t.callback;return e(c,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(c,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(c,void 0,void 0,(function(){var e,t,c,u,d;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())?(d=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(d,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(c,void 0,void 0,(function(){var e,t,n,i,c,u,d=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){"0000"!=s.responseCode&&""!=s.responseCode&&(console.error({source:"mfs response.responseDescription",responseDescription:s.responseDescription,response:s}),console.log("TransactionID->",s.transactionId));var t=[];if(Array.isArray(s.cards)&&s.cards.length)for(var o=0;o<s.cards.length;o++){var a=s.cards[o];a.paymentGatewayId=n,t.push(a)}d.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(c,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(c.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(c.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(c.prototype,"isSendConfirmationButtonDisabled",{get:function(){return this.isSaveCardToMasterPassPhoneNumberInputVisible?this.isSaveCardToMasterPassPhoneNumberInputDisabled?!this.saveCardToMasterPass.cardName:!this.saveCardToMasterPass.cardName||!this.saveCardToMasterPass.phoneNumber:!this.saveCardToMasterPass.cardName},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"isLinkCardToClientModalVisible",{get:function(){return"linkCardToClientModal"===this.visibleModal},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"isOtpModalVisible",{get:function(){return"otpModalBank"===this.visibleModal||"otpModalMasterPass"===this.visibleModal},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"isResponseModalVisible",{get:function(){return!("mfsResponseModal"!==this.visibleModal||!this.mfsResponseModalText)},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"isSuccessModalVisible",{get:function(){return"linkCardToClientModalSuccess"===this.visibleModal||"otpModalSuccess"===this.visibleModal},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"otpModalType",{get:function(){return"otpModalMasterPass"===this.visibleModal?"masterPassOtp":"bankOtp"},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"successModalType",{get:function(){return"hasMasterPassAccountButDoesNotHaveAnyOperation"===this.checkMasterPassData.status?"linkCardToClient":"register"},enumerable:!1,configurable:!0}),c.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},c}();export{c as MFS_ELEMENT_ID,u as MFS_SCRIPT_URL,m as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikas/storefront",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.13",
|
|
4
4
|
"description": "Storefront functionality for ikas storefront themes.",
|
|
5
5
|
"author": "ikas",
|
|
6
6
|
"license": "ISC",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"libphonenumber-js": "^1.10.6"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@ikas/storefront-api": "^4.0.
|
|
27
|
-
"@ikas/storefront-config": "^4.0.
|
|
28
|
-
"@ikas/storefront-model-functions": "^4.0.
|
|
29
|
-
"@ikas/storefront-models": "^4.0.
|
|
30
|
-
"@ikas/storefront-providers": "^4.0.
|
|
26
|
+
"@ikas/storefront-api": "^4.0.13",
|
|
27
|
+
"@ikas/storefront-config": "^4.0.13",
|
|
28
|
+
"@ikas/storefront-model-functions": "^4.0.13",
|
|
29
|
+
"@ikas/storefront-models": "^4.0.13",
|
|
30
|
+
"@ikas/storefront-providers": "^4.0.13",
|
|
31
31
|
"@rollup/plugin-commonjs": "^22.0.0",
|
|
32
32
|
"@rollup/plugin-json": "^4.1.0",
|
|
33
33
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
"query-string": "^6.13.8"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@ikas/storefront-api": "^4.0.
|
|
57
|
-
"@ikas/storefront-config": "^4.0.
|
|
58
|
-
"@ikas/storefront-model-functions": "^4.0.
|
|
59
|
-
"@ikas/storefront-models": "^4.0.
|
|
60
|
-
"@ikas/storefront-providers": "^4.0.
|
|
56
|
+
"@ikas/storefront-api": "^4.0.13",
|
|
57
|
+
"@ikas/storefront-config": "^4.0.13",
|
|
58
|
+
"@ikas/storefront-model-functions": "^4.0.13",
|
|
59
|
+
"@ikas/storefront-models": "^4.0.13",
|
|
60
|
+
"@ikas/storefront-providers": "^4.0.13",
|
|
61
61
|
"mobx": "^6.1.3",
|
|
62
62
|
"mobx-react-lite": "^3.1.5",
|
|
63
63
|
"next": "12.2.0",
|