FileMaster
Search
Toggle Dark Mode
Home
/
.
/
wp-content
/
plugins
/
surecart
/
dist
Edit File: 614.js
"use strict";(self.webpackChunk_surecart_surecart=self.webpackChunk_surecart_surecart||[]).push([[614],{4805:function(e,r,n){n.d(r,{a:function(){return p},b:function(){return s},g:function(){return l}});var t=n(4467),o=n(3453);function a(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r&&(t=t.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),n.push.apply(n,t)}return n}function i(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?a(Object(n),!0).forEach((function(r){(0,t.A)(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function c(e,r){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,r){if(e){if("string"==typeof e)return u(e,r);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(e,r):void 0}}(e))||r&&e&&"number"==typeof e.length){n&&(e=n);var _n=0,t=function(){};return{s:t,n:function(){return _n>=e.length?{done:!0}:{done:!1,value:e[_n++]}},e:function(e){throw e},f:t}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,i=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){i=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(i)throw o}}}}function u(e,r){(null==r||r>e.length)&&(r=e.length);for(var n=0,t=Array(r);n<r;n++)t[n]=e[n];return t}function s(e){for(var r,n="",t=Object.entries(e);r=t.shift();){var a=r,i=(0,o.A)(a,2),u=i[0],s=i[1];if(Array.isArray(s)||s&&s.constructor===Object){var d,l=c(Object.entries(s).reverse());try{for(l.s();!(d=l.n()).done;){var p=(0,o.A)(d.value,2),f=p[0],h=p[1];t.unshift(["".concat(u,"[").concat(f,"]"),h])}}catch(e){l.e(e)}finally{l.f()}}else void 0!==s&&(null===s&&(s=""),n+="&"+[u,s].map(encodeURIComponent).join("="))}return n.substr(1)}function d(e){try{return decodeURIComponent(e)}catch(r){return e}}function l(e){return(function(e){var r;try{r=new URL(e,"http://example.com").search.substring(1)}catch(e){}if(r)return r}(e)||"").replace(/\+/g,"%20").split("&").reduce((function(e,r){var n=r.split("=").filter(Boolean).map(d),t=(0,o.A)(n,2),a=t[0],c=t[1],u=void 0===c?"":c;return a&&function(e,r,n){for(var t=r.length,o=t-1,a=0;a<t;a++){var c=r[a];!c&&Array.isArray(e)&&(c=e.length.toString()),c=["__proto__","constructor","prototype"].includes(c)?c.toUpperCase():c;var u=!isNaN(Number(r[a+1]));e[c]=a===o?n:e[c]||(u?[]:{}),Array.isArray(e[c])&&!u&&(e[c]=i({},e[c])),e=e[c]}}(e,a.replace(/\]/g,"").split("["),u),e}),Object.create(null))}function p(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1?arguments[1]:void 0;if(!r||!Object.keys(r).length)return e;var n=e,t=e.indexOf("?");return-1!==t&&(r=Object.assign(l(e),r),n=n.substr(0,t)),n+"?"+s(r)}},8803:function(e,r,n){n.d(r,{a:function(){return J},h:function(){return G}});var t=n(9394),o=n(467),a=n(45),i=n(3453),c=n(4467),u=n(9280),s=n.n(u),d=n(4805),l=n(3506),p=["rest_route"],f=["path","url"],h=["url","path","data","parse"];function v(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r&&(t=t.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),n.push.apply(n,t)}return n}function w(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?v(Object(n),!0).forEach((function(r){(0,c.A)(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):v(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function m(e,r){return void 0!==(0,l.g)(e,r)}function y(e){var r=e.split("?"),n=r[1],t=r[0];return n?t+"?"+n.split("&").map((function(e){return e.split("=")})).map((function(e){return e.map(decodeURIComponent)})).sort((function(e,r){return e[0].localeCompare(r[0])})).map((function(e){return e.map(encodeURIComponent)})).map((function(e){return e.join("=")})).join("&"):t}var b=function(e,r){var n,t,o=e.path;return"string"==typeof e.namespace&&"string"==typeof e.endpoint&&(n=e.namespace.replace(/^\/|\/$/g,""),o=(t=e.endpoint.replace(/^\//,""))?n+"/"+t:n),delete e.namespace,delete e.endpoint,r(w(w({},e),{},{path:o}))};function g(e,r){return Promise.resolve(r?e.body:new window.Response(JSON.stringify(e.body),{status:200,statusText:"OK",headers:e.headers}))}var _=function(e){return e.json?e.json():Promise.reject(e)},O=function(e){return function(e){if(!e)return{};var r=e.match(/<([^>]+)>; rel="next"/);return r?{next:r[1]}:{}}(e.headers.get("link")).next},j=function(e){var r=!!e.path&&-1!==e.path.indexOf("per_page=-1"),n=!!e.url&&-1!==e.url.indexOf("per_page=-1");return r||n},k=function(){var e=(0,o.A)(s().mark((function e(r,n){var t,o,i,c,u,l;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!1!==r.parse){e.next=2;break}return e.abrupt("return",n(r));case 2:if(j(r)){e.next=4;break}return e.abrupt("return",n(r));case 4:return e.next=6,J(w(w({},(p={per_page:100},void 0,void 0,h=(s=r).path,v=s.url,w(w({},(0,a.A)(s,f)),{},{url:v&&(0,d.a)(v,p),path:h&&(0,d.a)(h,p)}))),{},{parse:!1}));case 6:return t=e.sent,e.next=9,_(t);case 9:if(o=e.sent,Array.isArray(o)){e.next=12;break}return e.abrupt("return",o);case 12:if(i=O(t)){e.next=15;break}return e.abrupt("return",o);case 15:c=[].concat(o);case 16:if(!i){e.next=27;break}return e.next=19,J(w(w({},r),{},{path:void 0,url:i,parse:!1}));case 19:return u=e.sent,e.next=22,_(u);case 22:l=e.sent,c=c.concat(l),i=O(u),e.next=16;break;case 27:return e.abrupt("return",c);case 28:case"end":return e.stop()}var s,p,h,v}),e)})));return function(_x,r){return e.apply(this,arguments)}}(),P=new Set(["PATCH","PUT","DELETE"]),x=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return Promise.resolve(function(e){return arguments.length>1&&void 0!==arguments[1]&&!arguments[1]?e:204===e.status?null:e.json?e.json():Promise.reject(e)}(e,r)).catch((function(e){return A(e,r)}))};function A(e){if(arguments.length>1&&void 0!==arguments[1]&&!arguments[1])throw e;return function(e){var r={code:"invalid_json",message:wp.i18n.__("The response is not a valid JSON response.")};if(!e||!e.json)throw r;return e.json().catch((function(){throw r}))}(e).then((function(e){var r={code:"unknown_error",message:wp.i18n.__("An unknown error occurred.")};throw e||r}))}var I,T,E,S,C,M,D,z={Accept:"application/json, */*;q=0.1"},U={credentials:"include"},N=[function(e,r){return"string"!=typeof e.url||m(e.url,"_locale")||(e.url=(0,d.a)(e.url,{_locale:"user"})),"string"!=typeof e.path||m(e.path,"_locale")||(e.path=(0,d.a)(e.path,{_locale:"user"})),r(e)},b,function(e,r){var n=e.method,t=void 0===n?"GET":n;return P.has(t.toUpperCase())&&(e=w(w({},e),{},{headers:w(w({},e.headers),{},{"X-HTTP-Method-Override":t,"Content-Type":"application/json"}),method:"POST"})),r(e)},k],R=function(e){if(e.status>=200&&e.status<300)return e;throw e},L=function(e){var r=e.url,n=e.path,t=e.data,o=e.parse,i=void 0===o||o,c=(0,a.A)(e,h),u=e.body,s=e.headers;return s=w(w({},z),s),t&&(u=JSON.stringify(t),s["Content-Type"]="application/json"),window.fetch(r||n||window.location.href,w(w(w({},U),c),{},{body:u,headers:s})).then((function(e){return Promise.resolve(e).then(R).catch((function(e){return A(e,i)})).then((function(e){return x(e,i)}))}),(function(e){if(e&&"AbortError"===e.name)throw e;throw{code:"fetch_error",message:wp.i18n.__("You are probably offline.")}}))};function J(e){return N.reduceRight((function(e,r){return function(n){return r(n,e)}}),L)(e).catch((function(r){return"rest_cookie_invalid_nonce"!==r.code?Promise.reject(r):window.fetch(J.nonceEndpoint).then(R).then((function(e){return e.text()})).then((function(r){return J.nonceMiddleware.nonce=r,J(e)}))}))}J.use=function(e){N.unshift(e)},J.setFetchHandler=function(e){L=e},J.createNonceMiddleware=function(e){var r=function e(r,n){var t=r.headers,o=void 0===t?{}:t;for(var a in o)if("x-wp-nonce"===a.toLowerCase()&&o[a]===e.nonce)return n(r);return n(w(w({},r),{},{headers:w(w({},o),{},{"X-WP-Nonce":e.nonce})}))};return r.nonce=e,r},J.createPreloadingMiddleware=function(e){var r=Object.fromEntries(Object.entries(e).map((function(e){var r=(0,i.A)(e,2),n=r[0],t=r[1];return[y(n),t]})));return function(e,n){var t=e.parse,o=void 0===t||t,i=e.path;if(!i&&e.url){var c=(0,d.g)(e.url),u=c.rest_route,s=(0,a.A)(c,p);"string"==typeof u&&(i=(0,d.a)(u,s))}if("string"!=typeof i)return n(e);var l=e.method||"GET",f=y(i);if("GET"===l&&r[f]){var h=r[f];return delete r[f],g(h,!!o)}if("OPTIONS"===l&&r[l]&&r[l][f]){var v=r[l][f];return delete r[l][f],g(v,!!o)}return n(e)}},J.createRootURLMiddleware=function(e){return function(r,n){return b(r,(function(r){var t,o=r.url,a=r.path;return"string"==typeof a&&(t=e,-1!==e.indexOf("?")&&(a=a.replace("?","&")),a=a.replace(/^\//,""),"string"==typeof t&&-1!==t.indexOf("?")&&(a=a.replace("?","&")),o=t+a),n(w(w({},r),{},{url:o}))}))}},J.fetchAllMiddleware=k,J.mediaUploadMiddleware=function(e,r){if(!function(e){var r=!!e.method&&"POST"===e.method;return(!!e.path&&-1!==e.path.indexOf("/wp/v2/media")||!!e.url&&-1!==e.url.indexOf("/wp/v2/media"))&&r}(e))return r(e);var n=0,t=function e(t){return n++,r({path:"/wp/v2/media/".concat(t,"/post-process"),method:"POST",data:{action:"create-image-subsizes"},parse:!1}).catch((function(){return n<5?e(t):(r({path:"/wp/v2/media/".concat(t,"?force=true"),method:"DELETE"}),Promise.reject())}))};return r(w(w({},e),{},{parse:!1})).catch((function(r){var n=r.headers.get("x-wp-upload-attachment-id");return r.status>=500&&r.status<600&&n?t(n).catch((function(){return!1!==e.parse?Promise.reject({code:"post_process",message:wp.i18n.__("Media upload failed. If this is a photo or a large image, please scale it down and try again.")}):Promise.reject(r)})):A(r,e.parse)})).then((function(r){return x(r,e.parse)}))},J.createThemePreviewMiddleware=function(e){return function(r,n){if("string"==typeof r.url){var t=(0,l.g)(r.url,"wp_theme_preview");void 0===t?r.url=(0,d.a)(r.url,{wp_theme_preview:e}):""===t&&(r.url=(0,l.r)(r.url,"wp_theme_preview"))}if("string"==typeof r.path){var o=(0,l.g)(r.path,"wp_theme_preview");void 0===o?r.path=(0,d.a)(r.path,{wp_theme_preview:e}):""===o&&(r.path=(0,l.r)(r.path,"wp_theme_preview"))}return n(r)}},J.fetchAllMiddleware=null,J.use(J.createRootURLMiddleware((null===(T=null===(I=null===window||void 0===window?void 0:window.parent)||void 0===I?void 0:I.scData)||void 0===T?void 0:T.root_url)||(null===(E=null===window||void 0===window?void 0:window.scData)||void 0===E?void 0:E.root_url))),(null===(S=null===window||void 0===window?void 0:window.scData)||void 0===S?void 0:S.nonce)&&(J.nonceMiddleware=J.createNonceMiddleware(null===(C=null===window||void 0===window?void 0:window.scData)||void 0===C?void 0:C.nonce),J.use(J.nonceMiddleware)),(null===(M=null===window||void 0===window?void 0:window.scData)||void 0===M?void 0:M.nonce_endpoint)&&(J.nonceEndpoint=null===(D=null===window||void 0===window?void 0:window.scData)||void 0===D?void 0:D.nonce_endpoint),J.use((function(e,r){return e.path=(0,d.a)(e.path,{t:Date.now()}),r(e)})),J.use((function(e,r){return e.path=(0,d.a)(e.path,w({},!!(0,l.g)(window.location.href,"currency")&&{currency:(0,l.g)(window.location.href,"currency")})),r(e)})),J.use((function(e,r){var n=r(e);return n.catch((function(e){var r;return"invalid_json"===e.code&&(e.message=wp.i18n.__("The response is not a valid JSON response.","surecart"),e.additional_errors=[{code:"invalid_json",message:wp.i18n.sprintf(/* translators: %s: URL to debug settings page */ wp.i18n.__("Please ensure that your site is not in debug mode as this may interfere with API responses. %s","surecart"),'<a href="'.concat("https://surecart.com/docs/is-not-a-valid-json-response/",'" target="_blank" rel="noopener noreferrer">').concat(wp.i18n.__("More Information","surecart"),"</a>"))}]),"checkout.finalize_error"===e.code&&(e.additional_errors=[].concat((0,t.A)((null===(r=null==e?void 0:e.additional_errors)||void 0===r?void 0:r.length)?[]:[{code:"checkout.finalize_error",message:e.message}]),(0,t.A)(e.additional_errors||[])),e.message=wp.i18n.__("We were not able to process this order","surecart")),Promise.reject(e)})),n}));var H=function(e){var r={code:"invalid_json",message:wp.i18n.__("The response is not a valid JSON response.","surecart")};if((null==e?void 0:e.code)&&(null==e?void 0:e.message))throw e;if(!e||!e.json)throw r;return e.json().catch((function(){throw r}))},G=function(){var e=(0,o.A)(s().mark((function e(r){var n;return s().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,H(r);case 2:if("rest_cookie_invalid_nonce"===(n=e.sent).code){e.next=5;break}throw n;case 5:return e.abrupt("return",window.fetch(J.nonceEndpoint).then((function(e){if(e.status>=200&&e.status<300)return e;throw e})).then((function(e){return e.text()})).then((function(e){J.nonceMiddleware.nonce=e})));case 6:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}()},158:function(e,r,n){n.d(r,{l:function(){return a}});var t=null,o=null,a=function(){return t?Promise.resolve(t):o||(o=new Promise((function(e,r){var n=document.createElement("script");n.src="https://checkout.razorpay.com/v1/checkout.js",n.async=!0,n.onload=function(){t=window.Razorpay,e(t)},n.onerror=function(){o=null,r(new Error(wp.i18n.__("Failed to load Razorpay script.","surecart")))},document.head.appendChild(n)})))}},3506:function(e,r,n){n.d(r,{g:function(){return o},r:function(){return a}});var t=n(4805);function o(e,r){return(0,t.g)(e)[r]}function a(e){var r=e.indexOf("?");if(-1===r)return e;for(var n=(0,t.g)(e),o=e.substr(0,r),a=arguments.length,i=new Array(a>1?a-1:0),c=1;c<a;c++)i[c-1]=arguments[c];i.forEach((function(e){return delete n[e]}));var u=(0,t.b)(n);return u?o+"?"+u:o}},614:function(e,r,n){n.r(r),n.d(r,{sc_razorpay_add_method:function(){return l}});var t=n(467),o=n(3029),a=n(2901),i=n(9280),c=n.n(i),u=n(1346),s=n(8803),d=n(158),l=function(){return(0,a.A)((function e(r){(0,o.A)(this,e),(0,u.r)(this,r),this.razorpayInstance=null,this.confirming=!1,this.liveMode=!0,this.customerId=void 0,this.successUrl=void 0,this.currency=void 0,this.loading=void 0,this.loaded=void 0,this.error=void 0,this.paymentIntent=void 0}),[{key:"handlePaymentIntentCreate",value:(r=(0,t.A)(c().mark((function e(){var r,n,o,a,i,u,s,l,p=this;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.confirming){e.next=2;break}return e.abrupt("return");case 2:if(r=this.paymentIntent||{},n=r.external_intent_id,o=r.processor_data,a=(null==o?void 0:o.razorpay)||{},i=a.public_key,u=a.customer_id,i&&n){e.next=6;break}return e.abrupt("return");case 6:if(this.confirming=!0,e.prev=7,this.razorpayInstance){e.next=12;break}return e.next=11,(0,d.l)();case 11:this.razorpayInstance=e.sent;case 12:s={key:i,order_id:n,customer_id:u,recurring:!0,handler:function(){var e=(0,t.A)(c().mark((function e(r){return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(null==r?void 0:r.razorpay_payment_id)?window.location.assign(p.successUrl):(p.error=wp.i18n.__("Payment verification failed. Please contact support.","surecart"),p.loading=!1);case 1:case"end":return e.stop()}}),e)})));return function(_x){return e.apply(this,arguments)}}(),modal:{ondismiss:function(){p.loading=!1}}},(l=new this.razorpayInstance(s)).on("payment.failed",(function(e){var r;p.error=(null===(r=null==e?void 0:e.error)||void 0===r?void 0:r.description)||wp.i18n.__("Payment failed. Please try again.","surecart"),p.loading=!1,console.error("payment.failed",e)})),l.open(),e.next=23;break;case 18:e.prev=18,e.t0=e.catch(7),this.error=(null===e.t0||void 0===e.t0?void 0:e.t0.message)||wp.i18n.__("Something went wrong","surecart"),this.loading=!1,console.error(e.t0);case 23:return e.prev=23,this.confirming=!1,e.finish(23);case 26:case"end":return e.stop()}}),e,this,[[7,18,23,26]])}))),function(){return r.apply(this,arguments)})},{key:"createPaymentIntent",value:(e=(0,t.A)(c().mark((function e(){var r,n;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,this.loading=!0,this.error="",e.next=5,(0,s.a)({method:"POST",path:"surecart/v1/payment_intents",data:{processor_type:"razorpay",reusable:!0,live_mode:this.liveMode,customer_id:this.customerId,currency:this.currency,refresh_status:!0}});case 5:this.paymentIntent=e.sent,e.next=13;break;case 8:e.prev=8,e.t0=e.catch(0),console.error(e.t0),this.error=(null===(n=null===(r=null===e.t0||void 0===e.t0?void 0:e.t0.additional_errors)||void 0===r?void 0:r[0])||void 0===n?void 0:n.message)||(null===e.t0||void 0===e.t0?void 0:e.t0.message)||wp.i18n.__("Something went wrong","surecart"),this.loading=!1;case 13:case"end":return e.stop()}}),e,this,[[0,8]])}))),function(){return e.apply(this,arguments)})},{key:"render",value:function(){var e=this;return(0,u.h)(u.H,{key:"ebafd5a3210bb2a7b2f7fc0a3411cb12f02b5479"},this.error&&(0,u.h)("sc-alert",{key:"0fa2906acf2b6ff355b888817eb0b6bd1e020b35",open:!!this.error,type:"danger"},(0,u.h)("span",{key:"b7c9714e15f20b86b1c4e9219e6360c84d309664",slot:"title"},wp.i18n.__("Error","surecart")),this.error),(0,u.h)("div",{key:"bf5cf63be0fbcf1e3f3f428f969e7f112f3b129b",class:"sc-razorpay-button-container"},(0,u.h)("sc-alert",{key:"243b0c714036125f5fb31329316931808fbdb1ad",open:!0,type:"warning"},wp.i18n.__("In order to add a new card, we will need to make a small transaction to authenticate it. This is for authentication purposes and will be immediately refunded.","surecart"),(0,u.h)("div",{key:"a67806699bda00e780b396ea3e7061c5f44d33f6"},(0,u.h)("sc-button",{key:"017eb9b8777cfcd04203ee4c8e29d8cabc272dd0",loading:this.loading,type:"primary",onClick:function(){return e.createPaymentIntent()},style:{marginTop:"var(--sc-spacing-medium)"}},wp.i18n.__("Add New Card","surecart"))))))}}],[{key:"watchers",get:function(){return{paymentIntent:["handlePaymentIntentCreate"]}}}]);var e,r}();l.style=".sc-razorpay-button-container{display:block}"}}]);
Save
Back