rebill 1.0.13 → 1.0.14

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 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.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"}},607:function(t,e,n){var r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},r.apply(this,arguments)},i=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=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)&&i(e,t,n);return o(e,t),e},s=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function a(t){try{c(r.next(t))}catch(t){o(t)}}function s(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}c((r=r.apply(t,e||[])).next())}))},c=this&&this.__generator||function(t,e){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[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,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=i=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),p="https://sdk-iframe.rebill.to/v3/index.html",f=function(){function t(t){var e=this;this.api_key=t,this.enableSync=!1,this.onSuccess=function(){},this.onError=function(){},this.metadataObject={},this.styles={},this.gateway={},this.iframeHeight="450px",window.addEventListener("message",(function(t){var n=t.data,r=n.type,i=n.detail;switch(r){case d.CONSTANTS.ON_SUCCESS:e.onSuccess(i);break;case d.CONSTANTS.ON_ERROR:e.onError(i);break;case d.CONSTANTS.SET_HEIGHT:e.iframeHeight=i}}),!1),window.addEventListener(d.CONSTANTS.IFRAME_READY,(function(){var t,n,r,i,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},p),o.postMessage({type:d.CONSTANTS.SET_ADD_CARD_USE_CASE,detail:e.customerId},p),o.postMessage({type:d.CONSTANTS.SET_RENEW_CARD_USE_CASE,detail:e.subscriptionId},p),o.postMessage({type:d.CONSTANTS.SET_REQUEST,detail:e.getRequest()},p),o.postMessage({type:d.CONSTANTS.SET_CURRENCY,detail:null===(n=e.priceData)||void 0===n?void 0:n.price.currency},p),o.postMessage({type:d.CONSTANTS.SET_PRICE,detail:{id:null===(r=e.priceData)||void 0===r?void 0:r.price.id,quantity:null===(i=e.priceData)||void 0===i?void 0:i.quantity}},p),o.postMessage({type:d.CONSTANTS.SET_CONFIG_OPTIONS,detail:e.config},p),o.postMessage({type:d.CONSTANTS.SET_TEXT,detail:e.text},p),o.postMessage({type:d.CONSTANTS.SET_STYLES,detail:e.styles},p),o.postMessage({type:d.CONSTANTS.SET_CARDHOLDER,detail:e.cardHolder},p),o.postMessage({type:d.CONSTANTS.SET_CUSTOMER,detail:e.customer},p)}))}return t.prototype.setUpdate=function(){window.frames.rebill_elements.postMessage({type:d.CONSTANTS.SET_REQUEST,detail:this.getRequest()},p)},t.prototype.getRequest=function(){return{PAYLOAD:r(r({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,i,o,a,s,u,d,p;return c(this,(function(c){switch(c.label){case 0:return e=t.id,n=t.currency,i=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&&((p=document.createElement("script")).src="".concat("https://secure.rebill.dev","/v1/Scripts/Antifraud.js?key=").concat(d.publicKey),p.type="text/javascript",document.head.appendChild(p)),this.priceData=r(r({},a),{quantity:i}),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)},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},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(){return dispatchEvent(new CustomEvent(d.CONSTANTS.IFRAME_READY))};var r='\n <iframe\n id="rebill_elements"\n title="rebill_elements"\n name="rebill_elements"\n src="'.concat(p,'"\n onLoad="setReady()"\n style="height: 100%; width: 100%; border: unset; overflow: visible;"\n allow="clipboard-read; clipboard-write"\n />\n ');n.innerHTML=r}),1500)},t.prototype.setMetadata=function(t){void 0===t&&(t={});var e=r(r({},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.submit=function(t){return s(this,void 0,void 0,(function(){var t,e=this;return c(this,(function(n){switch(n.label){case 0:return t=this.getRequest(),[4,fetch("".concat("https://api.rebill.dev","/v2"),{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.PAYLOAD)}).then((function(t){if(t.ok)return t.json()})).then((function(t){return e.onSuccess(t)})).catch((function(t){return e.onError(t)}))];case 1:return n.sent(),[2]}}))}))},t}();e.setSdk=f,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.dev","/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.dev","/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.dev","/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.dev","/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,r){return new(n||(n=Promise))((function(i,o){function a(t){try{c(r.next(t))}catch(t){o(t)}}function s(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}c((r=r.apply(t,e||[])).next())}))},r=this&&this.__generator||function(t,e){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[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,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=i=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,i){return n(this,void 0,void 0,(function(){var n,o;return r(this,(function(r){switch(r.label){case 0:return n={itemId:t,currency:e},[4,fetch("".concat("https://api.rebill.dev","/v2/item/checkout"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(i)},body:JSON.stringify(n)})];case 1:if(!(o=r.sent()).ok)throw new Error("Network response was not ok");return[4,o.json()];case 2:return[2,r.sent()]}}))}))}}},e={};var n=function n(r){var i=e[r];if(void 0!==i)return i.exports;var o=e[r]={exports:{}};return t[r].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"},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: 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 r=this&&this.__assign||function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},r.apply(this,arguments)},i=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);i&&!("get"in i?!e.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=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)&&i(e,t,n);return o(e,t),e},s=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function a(t){try{c(r.next(t))}catch(t){o(t)}}function s(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}c((r=r.apply(t,e||[])).next())}))},c=this&&this.__generator||function(t,e){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[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,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=i=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.metadataObject={},this.styles={},this.gateway={},this.iframeHeight="450px",window.addEventListener("message",(function(t){var n=t.data,r=n.type,i=n.detail;switch(r){case d.CONSTANTS.ON_SUCCESS:e.onSuccess(i);break;case d.CONSTANTS.ON_ERROR:e.onError(i);break;case d.CONSTANTS.SET_HEIGHT:e.iframeHeight=i}}),!1),window.addEventListener(d.CONSTANTS.IFRAME_READY,(function(){var t,n,r,i,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===(r=e.priceData)||void 0===r?void 0:r.price.id,quantity:null===(i=e.priceData)||void 0===i?void 0:i.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)}))}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:r(r({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,i,o,a,s,u,d,h;return c(this,(function(c){switch(c.label){case 0:return e=t.id,n=t.currency,i=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=r(r({},a),{quantity:i}),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)},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,e=this.html_id;if(!e)throw new Error("Missing element id");u=null===(t=null===window||void 0===window?void 0:window.fingerPrintModel)||void 0===t?void 0:t.sessionid;var n=document.getElementById(e);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 r='\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=r},t.prototype.setMetadata=function(t){void 0===t&&(t={});var e=r(r({},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.submit=function(){return s(this,void 0,void 0,(function(){return c(this,(function(t){return[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.dev","/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.dev","/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.dev","/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.dev","/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,r){return new(n||(n=Promise))((function(i,o){function a(t){try{c(r.next(t))}catch(t){o(t)}}function s(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}c((r=r.apply(t,e||[])).next())}))},r=this&&this.__generator||function(t,e){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[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,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=i=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,i){return n(this,void 0,void 0,(function(){var n,o;return r(this,(function(r){switch(r.label){case 0:return n={itemId:t,currency:e},[4,fetch("".concat("https://api.rebill.dev","/v2/item/checkout"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(i)},body:JSON.stringify(n)})];case 1:if(!(o=r.sent()).ok)throw new Error("Network response was not ok");return[4,o.json()];case 2:return[2,r.sent()]}}))}))}}},e={};var n=function n(r){var i=e[r];if(void 0!==i)return i.exports;var o=e[r]={exports:{}};return t[r].call(o.exports,o,o.exports,n),o.exports}(607);return n})()));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rebill",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "description": "A Pure JavaScript SDK to integrate Rebill into your web or ecosystem",
5
5
  "main": "index.js",
6
6
  "types": "./sdk/index.d.ts",
package/sdk/index.d.ts CHANGED
@@ -60,7 +60,7 @@ export declare class setSdk {
60
60
  setMetadata(metadata?: {}): void;
61
61
  setConfigOptions(config: Config): void;
62
62
  setCardHolder(cardHolder: CardHolder): void;
63
- submit(card_values: Card): Promise<void>;
63
+ submit(): Promise<void>;
64
64
  }
65
65
  export declare function getIdentificationBy(isoCountryCode: IsoCountryEnum): Promise<Identification[]>;
66
66
  export declare function getStatesBy(isoCountryCode: IsoCountryEnum): Promise<State[]>;