rebill 1.0.18 → 1.0.20
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/index.js +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Rebill=e():t.Rebill=e()}(this,(()=>(()=>{"use strict";var t={986:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.loader=e.CONSTANTS=void 0,e.CONSTANTS={IFRAME_READY:"IFRAME_READY",ON_SUCCESS:"ON_SUCCESS",ON_ERROR:"ON_ERROR",SET_TEXT:"SET_TEXT",SET_REQUEST:"SET_REQUEST",SET_CARDHOLDER:"SET_CARDHOLDER",SET_STYLES:"SET_STYLES",SET_CURRENCY:"SET_CURRENCY",SET_TRANSACTION_USE_CASE:"SET_TRANSACTION_USE_CASE",SET_PRICE:"SET_PRICE",SET_RENEW_CARD_USE_CASE:"SET_RENEW_CARD_USE_CASE",SET_ADD_CARD_USE_CASE:"SET_ADD_CARD_USE_CASE",SET_CONFIG_OPTIONS:"SET_CONFIG_OPTIONS",SET_CUSTOMER:"SET_CUSTOMER",SET_HEIGHT:"SET_HEIGHT",SUBMIT_PAYMENT:"SUBMIT_PAYMENT",SET_DISABLED:"SET_DISABLED",SET_LOADING:"SET_LOADING"},e.loader=' <div\n style="\n width: 100%;\n height: 450px;\n margin-left: auto;\n margin-right: auto;\n overflow: hidden;\n "\n >\n <div\n id="1"\n class="skeleton"\n style="height: 3rem; width: 100%; border-radius: 0.375rem"\n ></div>\n <div\n style="\n display: flex;\n gap: 1rem;\n align-items: center;\n margin-top: 1rem;\n "\n >\n <div\n class="skeleton"\n style="height: 3rem; width: 25%; border-radius: 0.375rem"\n ></div>\n <div\n class="skeleton"\n style="height: 3rem; width: 75%; border-radius: 0.375rem"\n ></div>\n </div>\n <div\n class="skeleton"\n style="\n height: 3.5rem;\n width: 100%;\n border-radius: 0.375rem;\n margin-top: 1rem;\n "\n ></div>\n <div\n class="skeleton"\n style="\n height: 0.7rem;\n width: 30%;\n margin: 0 auto;\n border-radius: 0.2rem;\n margin-top: 2rem;\n "\n ></div>\n <div\n style="\n display: flex;\n width: 100%;\n flex-direction: column;\n gap: 2rem;\n align-items: center;\n margin-top: 1rem;\n "\n >\n <div\n class="skeleton"\n style="height: 3rem; width: 100%; border-radius: 0.375rem"\n ></div>\n <div\n class="skeleton"\n style="height: 3rem; width: 100%; border-radius: 0.375rem"\n ></div>\n </div>\n </div>\n <style>\n @keyframes pulse {\n 0% {\n background-position: 200% 50%;\n }\n 100% {\n background-position: -100% 50%;\n }\n }\n\n .skeleton {\n background: #121212; /* Darker background */\n background-image: linear-gradient(\n 90deg,\n #121212 25%,\n #1c1c1c 50%,\n #121212 75%\n );\n background-size: 200% 100%;\n background-position: 100% 50%;\n animation: pulse 1.5s infinite ease-in-out;\n }\n </style>'},607:function(t,e,n){var i=this&&this.__assign||function(){return i=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},i.apply(this,arguments)},r=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),o=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),a=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&r(e,t,n);return o(e,t),e},s=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function a(t){try{c(i.next(t))}catch(t){o(t)}}function s(t){try{c(i.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}c((i=i.apply(t,e||[])).next())}))},c=this&&this.__generator||function(t,e){var n,i,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(n=1,i&&(r=2&s[0]?i.return:s[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,s[1])).done)return r;switch(i=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,i=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){a.label=s[1];break}if(6===s[0]&&a.label<r[1]){a.label=r[1],r=s;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(s);break}r[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],i=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.getCountryCodes=e.getCountries=e.getStatesBy=e.getIdentificationBy=e.setSdk=void 0;var u,l=a(n(0)),d=n(986),h="https://sdk-iframe.rebill.to/v3/index.html",p=function(){function t(t){var e=this;this.api_key=t,this.enableSync=!1,this.onSuccess=function(){},this.onError=function(){},this.onDisabled=function(){},this.onLoading=function(){},this.metadataObject={},this.styles={},this.gateway={},this.iframeHeight="450px",this.submitTransaction=!1,this.disabled=!1,window.addEventListener("message",(function(t){var n=t.data,i=n.type,r=n.detail;switch(i){case d.CONSTANTS.ON_SUCCESS:e.onSuccess(r);break;case d.CONSTANTS.ON_ERROR:e.onError(r);break;case d.CONSTANTS.SET_HEIGHT:var o=document.getElementById(e.html_id||"");o&&r&&(o.style.height=r);break;case d.CONSTANTS.SET_LOADING:e.onLoading(r);break;case d.CONSTANTS.SET_DISABLED:e.onDisabled(r)}}),!1),window.addEventListener(d.CONSTANTS.IFRAME_READY,(function(){var t,n,i,r,o=window.frames.rebill_elements;e.enableSync=!0,o.postMessage({type:d.CONSTANTS.SET_TRANSACTION_USE_CASE,detail:null===(t=e.priceData)||void 0===t?void 0:t.price.priceSetting.paymentMethods},h),o.postMessage({type:d.CONSTANTS.SET_ADD_CARD_USE_CASE,detail:e.customerId},h),o.postMessage({type:d.CONSTANTS.SET_RENEW_CARD_USE_CASE,detail:e.subscriptionId},h),o.postMessage({type:d.CONSTANTS.SET_REQUEST,detail:e.getRequest()},h),o.postMessage({type:d.CONSTANTS.SET_CURRENCY,detail:null===(n=e.priceData)||void 0===n?void 0:n.price.currency},h),o.postMessage({type:d.CONSTANTS.SET_PRICE,detail:{id:null===(i=e.priceData)||void 0===i?void 0:i.price.id,quantity:null===(r=e.priceData)||void 0===r?void 0:r.quantity}},h),o.postMessage({type:d.CONSTANTS.SET_CONFIG_OPTIONS,detail:e.config},h),o.postMessage({type:d.CONSTANTS.SET_TEXT,detail:e.text},h),o.postMessage({type:d.CONSTANTS.SET_STYLES,detail:e.styles},h),o.postMessage({type:d.CONSTANTS.SET_CARDHOLDER,detail:e.cardHolder},h),o.postMessage({type:d.CONSTANTS.SET_CUSTOMER,detail:e.customer},h),o.postMessage({type:d.CONSTANTS.SUBMIT_PAYMENT,detail:e.submitTransaction},h)}))}return t.prototype.setUpdate=function(){window.frames.rebill_elements.postMessage({type:d.CONSTANTS.SET_REQUEST,detail:this.getRequest()},h)},t.prototype.getRequest=function(){return{PAYLOAD:i(i({metadataObject:this.metadataObject},this.transaction),{priceData:this.priceData,gateway:{type:this.gateway.type,country:this.gateway.country}}),REBILL_DEVICE_ID:u,API_KEY:this.api_key}},t.prototype.setCustomer=function(t){this.customer=t},t.prototype.renewCard=function(t){return s(this,void 0,void 0,(function(){return c(this,(function(e){return this.subscriptionId=t,this.setIframe(),[2]}))}))},t.prototype.addCard=function(t){return s(this,void 0,void 0,(function(){return c(this,(function(e){return this.customerId=t,this.setIframe(),[2]}))}))},t.prototype.setTransaction=function(t){return s(this,void 0,void 0,(function(){var e,n,r,o,a,s,u,d,h;return c(this,(function(c){switch(c.label){case 0:return e=t.id,n=t.currency,r=t.quantity,o=this.api_key,this.enableSync&&this.setUpdate(),[4,l.getItemData(e,n,o)];case 1:if(!(a=c.sent()))throw new Error("Neither product nor plan found with the given ID.");return s=a.price,u=s.priceSetting,(d=s.gateway).publicKey&&((h=document.createElement("script")).src="".concat("https://secure.rebill.dev","/v1/Scripts/Antifraud.js?key=").concat(d.publicKey),h.type="text/javascript",document.head.appendChild(h)),this.priceData=i(i({},a),{quantity:r}),this.gateway={type:d.type,country:d.country},this.setIframe(),[2,u]}}))}))},t.prototype.setCallbacks=function(t){(null==t?void 0:t.onSuccess)&&(this.onSuccess=t.onSuccess),(null==t?void 0:t.onError)&&(this.onError=t.onError),(null==t?void 0:t.onLoading)&&(this.onLoading=t.onLoading),(null==t?void 0:t.onDisabled)&&(this.onDisabled=t.onDisabled)},t.prototype.setText=function(t){this.text=t,this.enableSync&&this.setUpdate()},t.prototype.setStyles=function(t){this.styles=t,this.enableSync&&this.setUpdate()},t.prototype.setElements=function(t){this.html_id=t;var e=document.getElementById(t);e&&(e.innerHTML=d.loader)},t.prototype.setIframe=function(){var t=this.html_id;if(!t)throw new Error("Missing element id");setTimeout((function(){var e;u=null===(e=null===window||void 0===window?void 0:window.fingerPrintModel)||void 0===e?void 0:e.sessionid;var n=document.getElementById(t);if(!n)throw new Error("HTMLElement invalid.");window.setReady=function(){dispatchEvent(new CustomEvent(d.CONSTANTS.IFRAME_READY));var t=document.getElementById("rebill-loader");t&&(t.style.display="none")};var i='\n <iframe\n id="rebill_elements"\n title="rebill_elements"\n name="rebill_elements"\n src="'.concat(h,'"\n onLoad="setReady()"\n style="height: 100%; width: 100%; border: unset; overflow: visible;"\n allow="clipboard-read; clipboard-write"\n />\n ');n.innerHTML=i}),1500)},t.prototype.setMetadata=function(t){void 0===t&&(t={});var e=i(i({},this.metadataObject),t);this.metadataObject=e,this.enableSync&&this.setUpdate()},t.prototype.setConfigOptions=function(t){this.config=t,this.enableSync&&this.setUpdate()},t.prototype.setCardHolder=function(t){this.cardHolder=t,this.enableSync&&this.setUpdate()},t.prototype.submitPaymentWithCard=function(){return s(this,void 0,void 0,(function(){return c(this,(function(t){return this.submitTransaction=!0,window.frames.rebill_elements.postMessage({type:d.CONSTANTS.SUBMIT_PAYMENT,detail:this.submitTransaction},h),[2]}))}))},t}();e.setSdk=p,e.getIdentificationBy=function(t){return s(this,void 0,void 0,(function(){var e;return c(this,(function(n){switch(n.label){case 0:return[4,fetch("".concat("https://api.rebill.com","/v2/data/identification/").concat(t))];case 1:if(!(e=n.sent()).ok)throw new Error("Error fetching identification data: ".concat(e.status));return[4,e.json()];case 2:return[2,n.sent()]}}))}))},e.getStatesBy=function(t){return s(this,void 0,void 0,(function(){var e;return c(this,(function(n){switch(n.label){case 0:return[4,fetch("".concat("https://api.rebill.com","/v2/data/states/").concat(t))];case 1:if(!(e=n.sent()).ok)throw new Error("Error fetching states data: ".concat(e.status));return[4,e.json()];case 2:return[2,n.sent()]}}))}))},e.getCountries=function(){return s(this,void 0,void 0,(function(){var t;return c(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat("https://api.rebill.com","/v2/data/countries"))];case 1:if(!(t=e.sent()).ok)throw new Error("Error fetching countries data: ".concat(t.status));return[4,t.json()];case 2:return[2,e.sent()]}}))}))},e.getCountryCodes=function(){return s(this,void 0,void 0,(function(){var t;return c(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat("https://api.rebill.com","/v2/data/countrycode"))];case 1:if(!(t=e.sent()).ok)throw new Error("Error fetching countries code data: ".concat(t.status));return[4,t.json()];case 2:return[2,e.sent()]}}))}))}},0:function(t,e){var n=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function a(t){try{c(i.next(t))}catch(t){o(t)}}function s(t){try{c(i.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}c((i=i.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,i,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(a=0)),a;)try{if(n=1,i&&(r=2&s[0]?i.return:s[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,s[1])).done)return r;switch(i=0,r&&(s=[2&s[0],r.value]),s[0]){case 0:case 1:r=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,i=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!r||s[1]>r[0]&&s[1]<r[3])){a.label=s[1];break}if(6===s[0]&&a.label<r[1]){a.label=r[1],r=s;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(s);break}r[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],i=0}finally{n=r=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.getItemData=void 0,e.getItemData=function(t,e,r){return n(this,void 0,void 0,(function(){var n,o;return i(this,(function(i){switch(i.label){case 0:return n={itemId:t,currency:e},[4,fetch("".concat("https://api.rebill.com","/v2/item/checkout"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(r)},body:JSON.stringify(n)})];case 1:if(!(o=i.sent()).ok)throw new Error("Network response was not ok");return[4,o.json()];case 2:return[2,i.sent()]}}))}))}}},e={};var n=function n(i){var r=e[i];if(void 0!==r)return r.exports;var o=e[i]={exports:{}};return t[i].call(o.exports,o,o.exports,n),o.exports}(607);return n})()));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Rebill=e():t.Rebill=e()}(this,(()=>(()=>{"use strict";var t={986:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.loader=e.CONSTANTS=void 0,e.CONSTANTS={IFRAME_READY:"IFRAME_READY",ON_SUCCESS:"ON_SUCCESS",ON_ERROR:"ON_ERROR",SET_TEXT:"SET_TEXT",SET_REQUEST:"SET_REQUEST",SET_CARDHOLDER:"SET_CARDHOLDER",SET_STYLES:"SET_STYLES",SET_CURRENCY:"SET_CURRENCY",SET_TRANSACTION_USE_CASE:"SET_TRANSACTION_USE_CASE",SET_PRICE:"SET_PRICE",SET_RENEW_CARD_USE_CASE:"SET_RENEW_CARD_USE_CASE",SET_ADD_CARD_USE_CASE:"SET_ADD_CARD_USE_CASE",SET_CONFIG_OPTIONS:"SET_CONFIG_OPTIONS",SET_CUSTOMER:"SET_CUSTOMER",SET_HEIGHT:"SET_HEIGHT",SUBMIT_PAYMENT:"SUBMIT_PAYMENT",SET_DISABLED:"SET_DISABLED",SET_LOADING:"SET_LOADING"},e.loader=' <div\n style="\n width: 100%;\n height: 450px;\n margin-left: auto;\n margin-right: auto;\n overflow: hidden;\n "\n >\n <div\n id="1"\n class="skeleton"\n style="height: 3rem; width: 100%; border-radius: 0.375rem"\n ></div>\n <div\n style="\n display: flex;\n gap: 1rem;\n align-items: center;\n margin-top: 1rem;\n "\n >\n <div\n class="skeleton"\n style="height: 3rem; width: 25%; border-radius: 0.375rem"\n ></div>\n <div\n class="skeleton"\n style="height: 3rem; width: 75%; border-radius: 0.375rem"\n ></div>\n </div>\n <div\n class="skeleton"\n style="\n height: 3.5rem;\n width: 100%;\n border-radius: 0.375rem;\n margin-top: 1rem;\n "\n ></div>\n <div\n class="skeleton"\n style="\n height: 0.7rem;\n width: 30%;\n margin: 0 auto;\n border-radius: 0.2rem;\n margin-top: 2rem;\n "\n ></div>\n <div\n style="\n display: flex;\n width: 100%;\n flex-direction: column;\n gap: 2rem;\n align-items: center;\n margin-top: 1rem;\n "\n >\n <div\n class="skeleton"\n style="height: 3rem; width: 100%; border-radius: 0.375rem"\n ></div>\n <div\n class="skeleton"\n style="height: 3rem; width: 100%; border-radius: 0.375rem"\n ></div>\n </div>\n </div>\n <style>\n @keyframes pulse {\n 0% {\n background-position: 200% 50%;\n }\n 100% {\n background-position: -100% 50%;\n }\n }\n\n .skeleton {\n background: #121212; /* Darker background */\n background-image: linear-gradient(\n 90deg,\n #121212 25%,\n #1c1c1c 50%,\n #121212 75%\n );\n background-size: 200% 100%;\n background-position: 100% 50%;\n animation: pulse 1.5s infinite ease-in-out;\n }\n </style>'},607:function(t,e,n){var i=this&&this.__assign||function(){return i=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var r in e=arguments[n])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t},i.apply(this,arguments)},r=this&&this.__createBinding||(Object.create?function(t,e,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(e,n);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,i,r)}:function(t,e,n,i){void 0===i&&(i=n),t[i]=e[n]}),o=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),s=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&r(e,t,n);return o(e,t),e},a=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{c(i.next(t))}catch(t){o(t)}}function a(t){try{c(i.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((i=i.apply(t,e||[])).next())}))},c=this&&this.__generator||function(t,e){var n,i,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,i&&(r=2&a[0]?i.return:a[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,a[1])).done)return r;switch(i=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,i=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){s.label=a[1];break}if(6===a[0]&&s.label<r[1]){s.label=r[1],r=a;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(a);break}r[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],i=0}finally{n=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.getCountryCodes=e.getCountries=e.getStatesBy=e.getIdentificationBy=e.setSdk=void 0;var u,l=s(n(0)),d=n(986),h="https://sdk-iframe.rebill.to/v3/index.html",p=function(){function t(t){var e=this;this.api_key=t,this.enableSync=!1,this.onSuccess=function(){},this.onError=function(){},this.onDisabled=function(){},this.onLoading=function(){},this.metadataObject={},this.styles={},this.gateway={},this.iframeHeight="450px",this.submitTransaction=!1,this.disabled=!1,window.addEventListener("message",(function(t){var n=t.data,i=n.type,r=n.detail;switch(i){case d.CONSTANTS.ON_SUCCESS:e.onSuccess(r);break;case d.CONSTANTS.ON_ERROR:e.onError(r);break;case d.CONSTANTS.SET_HEIGHT:var o=document.getElementById(e.html_id||"");o&&r&&(o.style.height=r);break;case d.CONSTANTS.SET_LOADING:e.onLoading(r);break;case d.CONSTANTS.SET_DISABLED:e.onDisabled(r)}}),!1),window.addEventListener(d.CONSTANTS.IFRAME_READY,(function(){var t,n,i,r,o=window.frames.rebill_elements;e.enableSync=!0,o.postMessage({type:d.CONSTANTS.SET_TRANSACTION_USE_CASE,detail:null===(t=e.priceData)||void 0===t?void 0:t.price.priceSetting.paymentMethods},h),o.postMessage({type:d.CONSTANTS.SET_ADD_CARD_USE_CASE,detail:e.customerId},h),o.postMessage({type:d.CONSTANTS.SET_RENEW_CARD_USE_CASE,detail:e.subscriptionId},h),o.postMessage({type:d.CONSTANTS.SET_REQUEST,detail:e.getRequest()},h),o.postMessage({type:d.CONSTANTS.SET_CURRENCY,detail:null===(n=e.priceData)||void 0===n?void 0:n.price.currency},h),o.postMessage({type:d.CONSTANTS.SET_PRICE,detail:{id:null===(i=e.priceData)||void 0===i?void 0:i.price.id,quantity:null===(r=e.priceData)||void 0===r?void 0:r.quantity}},h),o.postMessage({type:d.CONSTANTS.SET_CONFIG_OPTIONS,detail:e.config},h),o.postMessage({type:d.CONSTANTS.SET_TEXT,detail:e.text},h),o.postMessage({type:d.CONSTANTS.SET_STYLES,detail:e.styles},h),o.postMessage({type:d.CONSTANTS.SET_CARDHOLDER,detail:e.cardHolder},h),o.postMessage({type:d.CONSTANTS.SET_CUSTOMER,detail:e.customer},h),o.postMessage({type:d.CONSTANTS.SUBMIT_PAYMENT,detail:e.submitTransaction},h)}))}return t.prototype.setUpdate=function(){window.frames.rebill_elements.postMessage({type:d.CONSTANTS.SET_REQUEST,detail:this.getRequest()},h)},t.prototype.getRequest=function(){return{PAYLOAD:i(i({metadataObject:this.metadataObject},this.transaction),{priceData:this.priceData,gateway:{type:this.gateway.type,country:this.gateway.country}}),REBILL_DEVICE_ID:u,API_KEY:this.api_key}},t.prototype.setCustomer=function(t){this.customer=t},t.prototype.renewCard=function(t){return a(this,void 0,void 0,(function(){return c(this,(function(e){return this.subscriptionId=t,this.setIframe(),[2]}))}))},t.prototype.addCard=function(t){return a(this,void 0,void 0,(function(){return c(this,(function(e){return this.customerId=t,this.setIframe(),[2]}))}))},t.prototype.setTransaction=function(t){return a(this,void 0,void 0,(function(){var e,n,r,o,s,a,u,d,h;return c(this,(function(c){switch(c.label){case 0:return e=t.id,n=t.currency,r=t.quantity,o=this.api_key,this.enableSync&&this.setUpdate(),[4,l.getItemData(e,n,o)];case 1:if(!(s=c.sent()))throw new Error("Neither product nor plan found with the given ID.");return a=s.price,u=a.priceSetting,(d=a.gateway).publicKey&&((h=document.createElement("script")).src="".concat("https://secure.rebill.com","/v1/Scripts/Antifraud.js?key=").concat(d.publicKey),h.type="text/javascript",document.head.appendChild(h)),this.priceData=i(i({},s),{quantity:r}),this.gateway={type:d.type,country:d.country},this.setIframe(),[2,u]}}))}))},t.prototype.setCallbacks=function(t){(null==t?void 0:t.onSuccess)&&(this.onSuccess=t.onSuccess),(null==t?void 0:t.onError)&&(this.onError=t.onError),(null==t?void 0:t.onLoading)&&(this.onLoading=t.onLoading),(null==t?void 0:t.onDisabled)&&(this.onDisabled=t.onDisabled)},t.prototype.setText=function(t){this.text=t,this.enableSync&&this.setUpdate()},t.prototype.setStyles=function(t){this.styles=t,window.frames.rebill_elements.postMessage({type:d.CONSTANTS.SET_STYLES,detail:this.styles},h)},t.prototype.setElements=function(t){this.html_id=t;var e=document.getElementById(t);e&&(e.innerHTML=d.loader)},t.prototype.setIframe=function(){var t=this.html_id;if(!t)throw new Error("Missing element id");setTimeout((function(){var e;u=null===(e=null===window||void 0===window?void 0:window.fingerPrintModel)||void 0===e?void 0:e.sessionid;var n=document.getElementById(t);if(!n)throw new Error("HTMLElement invalid.");window.setReady=function(){dispatchEvent(new CustomEvent(d.CONSTANTS.IFRAME_READY));var t=document.getElementById("rebill-loader");t&&(t.style.display="none")};var i='\n <iframe\n id="rebill_elements"\n title="rebill_elements"\n name="rebill_elements"\n src="'.concat(h,'"\n onLoad="setReady()"\n style="height: 100%; width: 100%; border: unset; overflow: visible;"\n allow="clipboard-read; clipboard-write"\n />\n ');n.innerHTML=i}),1500)},t.prototype.setMetadata=function(t){void 0===t&&(t={});var e=i(i({},this.metadataObject),t);this.metadataObject=e,this.enableSync&&this.setUpdate()},t.prototype.setConfigOptions=function(t){this.config=t,this.enableSync&&this.setUpdate()},t.prototype.setCardHolder=function(t){this.cardHolder=t,this.enableSync&&this.setUpdate()},t.prototype.submitPaymentWithCard=function(){return a(this,void 0,void 0,(function(){return c(this,(function(t){return this.submitTransaction=!0,window.frames.rebill_elements.postMessage({type:d.CONSTANTS.SUBMIT_PAYMENT,detail:this.submitTransaction},h),[2]}))}))},t}();e.setSdk=p,e.getIdentificationBy=function(t){return a(this,void 0,void 0,(function(){var e;return c(this,(function(n){switch(n.label){case 0:return[4,fetch("".concat("https://api.rebill.com","/v2/data/identification/").concat(t))];case 1:if(!(e=n.sent()).ok)throw new Error("Error fetching identification data: ".concat(e.status));return[4,e.json()];case 2:return[2,n.sent()]}}))}))},e.getStatesBy=function(t){return a(this,void 0,void 0,(function(){var e;return c(this,(function(n){switch(n.label){case 0:return[4,fetch("".concat("https://api.rebill.com","/v2/data/states/").concat(t))];case 1:if(!(e=n.sent()).ok)throw new Error("Error fetching states data: ".concat(e.status));return[4,e.json()];case 2:return[2,n.sent()]}}))}))},e.getCountries=function(){return a(this,void 0,void 0,(function(){var t;return c(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat("https://api.rebill.com","/v2/data/countries"))];case 1:if(!(t=e.sent()).ok)throw new Error("Error fetching countries data: ".concat(t.status));return[4,t.json()];case 2:return[2,e.sent()]}}))}))},e.getCountryCodes=function(){return a(this,void 0,void 0,(function(){var t;return c(this,(function(e){switch(e.label){case 0:return[4,fetch("".concat("https://api.rebill.com","/v2/data/countrycode"))];case 1:if(!(t=e.sent()).ok)throw new Error("Error fetching countries code data: ".concat(t.status));return[4,t.json()];case 2:return[2,e.sent()]}}))}))}},0:function(t,e){var n=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{c(i.next(t))}catch(t){o(t)}}function a(t){try{c(i.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((i=i.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,i,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(n=1,i&&(r=2&a[0]?i.return:a[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,a[1])).done)return r;switch(i=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,i=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){s.label=a[1];break}if(6===a[0]&&s.label<r[1]){s.label=r[1],r=a;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(a);break}r[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],i=0}finally{n=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}};Object.defineProperty(e,"__esModule",{value:!0}),e.getItemData=void 0,e.getItemData=function(t,e,r){return n(this,void 0,void 0,(function(){var n,o;return i(this,(function(i){switch(i.label){case 0:return n={itemId:t,currency:e},[4,fetch("".concat("https://api.rebill.com","/v2/item/checkout"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(r)},body:JSON.stringify(n)})];case 1:if(!(o=i.sent()).ok)throw new Error("Network response was not ok");return[4,o.json()];case 2:return[2,i.sent()]}}))}))}}},e={};var n=function n(i){var r=e[i];if(void 0!==r)return r.exports;var o=e[i]={exports:{}};return t[i].call(o.exports,o,o.exports,n),o.exports}(607);return n})()));
|