rebill 1.0.4 → 1.0.6
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/sdk/index.d.ts +5 -15
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_STYLES:"SET_STYLES",SET_CURRENCY:"SET_CURRENCY",SET_PAYMENT_METHODS:"SET_PAYMENT_METHODS",SET_PRICE:"SET_PRICE",SET_RENEW_CARD:"SET_RENEW_CARD"}},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}),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)&&i(e,t,n);return o(e,t),e},a=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function s(t){try{c(r.next(t))}catch(t){o(t)}}function a(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(s,a)}c((r=r.apply(t,e||[])).next())}))},c=this&&this.__generator||function(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[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,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=i=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.com/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={},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)}}),!1),window.addEventListener(d.CONSTANTS.IFRAME_READY,(function(){var t,n,r,i=window.frames.rebill_elements;e.enableSync=!0,i.postMessage({type:d.CONSTANTS.SET_REQUEST,detail:e.getRequest()},h),i.postMessage({type:d.CONSTANTS.SET_CURRENCY,detail:null===(t=e.priceData)||void 0===t?void 0:t.price.currency},h),i.postMessage({type:d.CONSTANTS.SET_PAYMENT_METHODS,detail:null===(n=e.priceData)||void 0===n?void 0:n.price.priceSetting.paymentMethods},h),i.postMessage({type:d.CONSTANTS.SET_PRICE,detail:null===(r=e.priceData)||void 0===r?void 0:r.price},h)}))}return t.prototype.setUpdate=function(){window.frames.rebill_elements.postMessage({type:d.CONSTANTS.SET_REQUEST,detail:this.getRequest()},h)},t.prototype.getRequest=function(){var t,e;return{URI:"".concat("https://api.rebill.com","/v2"),PAYLOAD:r(r({metadataObject:this.metadataObject,customer:r({},this.customer)},this.transaction),{priceData:{id:null===(t=this.priceData)||void 0===t?void 0:t.price.id,quantity:null===(e=this.priceData)||void 0===e?void 0:e.quantity},gateway:{type:this.gateway.type,country:this.gateway.country},subscriptionId:this.subscriptionId,customerId:this.customerId,styles:this.styles,text:this.text}),REBILL_DEVICE_ID:u,API_KEY:this.api_key}},t.prototype.setCustomer=function(t){this.customer=t,this.enableSync&&this.setUpdate()},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,i,o,s,a,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(!(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=r(r({},s),{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){if(!t)throw new Error("Missing element id");if(!document.getElementById(t))throw new Error("HTMLElement invalid.");this.html_id=t},t.prototype.setIframe=function(){var t=this,e=this.html_id;if(!e)throw new Error("Missing element id");setTimeout((function(){var n;u=null===(n=null===window||void 0===window?void 0:window.fingerPrintModel)||void 0===n?void 0:n.sessionid;var r=document.getElementById(e);if(!r)throw new Error("HTMLElement invalid.");t.api_key&&t.getRequest(),window.setReady=function(){return dispatchEvent(new CustomEvent(d.CONSTANTS.IFRAME_READY))};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 ');r.innerHTML=i}),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.submit=function(t){return a(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(t.URI,{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 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,r){return new(n||(n=Promise))((function(i,o){function s(t){try{c(r.next(t))}catch(t){o(t)}}function a(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(s,a)}c((r=r.apply(t,e||[])).next())}))},r=this&&this.__generator||function(t,e){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[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,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=e.call(t,s)}catch(t){a=[6,t],r=0}finally{n=i=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,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.com","/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.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"}},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 o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(t,e,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(e,n);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,o)}:function(t,e,n,r){void 0===r&&(r=n),t[r]=e[n]}),i=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)&&o(e,t,n);return i(e,t),e},s=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function s(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(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,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=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(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=o=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="http://localhost:3006/v3/",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={},window.addEventListener("message",(function(t){var n=t.data,r=n.type,o=n.detail;switch(r){case d.CONSTANTS.ON_SUCCESS:e.onSuccess(o);break;case d.CONSTANTS.ON_ERROR:e.onError(o)}}),!1),window.addEventListener(d.CONSTANTS.IFRAME_READY,(function(){var t,n,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:null===(r=e.priceData)||void 0===r?void 0:r.price},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(){var t,e;return{PAYLOAD:r(r({metadataObject:this.metadataObject},this.transaction),{priceData:{id:null===(t=this.priceData)||void 0===t?void 0:t.price.id,quantity:null===(e=this.priceData)||void 0===e?void 0:e.quantity},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,o,i,a,s,u,d,h;return c(this,(function(c){switch(c.label){case 0:return e=t.id,n=t.currency,o=t.quantity,i=this.api_key,this.enableSync&&this.setUpdate(),[4,l.getItemData(e,n,i)];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:o}),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){if(!t)throw new Error("Missing element id");if(!document.getElementById(t))throw new Error("HTMLElement invalid.");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(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}),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("http://localhost:8000","/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=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("http://localhost:8000","/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("http://localhost:8000","/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("http://localhost:8000","/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("http://localhost:8000","/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(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function s(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(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,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=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(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=o=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,o){return n(this,void 0,void 0,(function(){var n,i;return r(this,(function(r){switch(r.label){case 0:return n={itemId:t,currency:e},[4,fetch("".concat("http://localhost:8000","/v2/item/checkout"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(o)},body:JSON.stringify(n)})];case 1:if(!(i=r.sent()).ok)throw new Error("Network response was not ok");return[4,i.json()];case 2:return[2,r.sent()]}}))}))}}},e={};var n=function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return t[r].call(i.exports,i,i.exports,n),i.exports}(607);return n})()));
|
package/package.json
CHANGED
package/sdk/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { Customer } from "./schemas/customer.schema";
|
|
|
6
6
|
import { CardHolder } from "./schemas/cardHolder.schema";
|
|
7
7
|
import { Transaction } from "./schemas/transaction.schema";
|
|
8
8
|
import { Country } from "./schemas/country.schema";
|
|
9
|
+
import { Config } from "./schemas/config.schema";
|
|
9
10
|
import { Identification } from "./schemas/identification.schema";
|
|
10
11
|
import countryCode from "./schemas/countryCode.schema";
|
|
11
12
|
import { PriceData } from "./schemas/item.schema";
|
|
@@ -15,7 +16,7 @@ export declare class setSdk {
|
|
|
15
16
|
api_key: string;
|
|
16
17
|
text?: Text;
|
|
17
18
|
customer?: Customer;
|
|
18
|
-
|
|
19
|
+
cardHolder?: CardHolder;
|
|
19
20
|
transaction?: Transaction;
|
|
20
21
|
card?: Card;
|
|
21
22
|
enableSync?: boolean;
|
|
@@ -28,10 +29,10 @@ export declare class setSdk {
|
|
|
28
29
|
subscriptionId?: string;
|
|
29
30
|
customerId?: string;
|
|
30
31
|
html_id?: string;
|
|
32
|
+
config?: Config;
|
|
31
33
|
constructor(apiKey: string);
|
|
32
34
|
setUpdate(): void;
|
|
33
35
|
getRequest(): {
|
|
34
|
-
URI: string;
|
|
35
36
|
PAYLOAD: {
|
|
36
37
|
priceData: {
|
|
37
38
|
id: string | undefined;
|
|
@@ -41,23 +42,10 @@ export declare class setSdk {
|
|
|
41
42
|
type: any;
|
|
42
43
|
country: any;
|
|
43
44
|
};
|
|
44
|
-
subscriptionId: string | undefined;
|
|
45
|
-
customerId: string | undefined;
|
|
46
|
-
styles: Styles | undefined;
|
|
47
|
-
text: Text | undefined;
|
|
48
45
|
id?: string | undefined;
|
|
49
46
|
currency?: import("./schemas/currencyEnum.schema").CurrencyTypeEnum | undefined;
|
|
50
47
|
quantity?: number | undefined;
|
|
51
48
|
metadataObject: any;
|
|
52
|
-
customer: {
|
|
53
|
-
firstName?: string | undefined;
|
|
54
|
-
lastName?: string | undefined;
|
|
55
|
-
email?: string | undefined;
|
|
56
|
-
birthday?: string | undefined;
|
|
57
|
-
phone?: import("./schemas/customer.schema").Phone | undefined;
|
|
58
|
-
personalId?: import("./schemas/personalId.schema").PersonalId | undefined;
|
|
59
|
-
address?: import("./schemas/address.schema").Address | undefined;
|
|
60
|
-
};
|
|
61
49
|
};
|
|
62
50
|
REBILL_DEVICE_ID: string | undefined;
|
|
63
51
|
API_KEY: string;
|
|
@@ -72,6 +60,8 @@ export declare class setSdk {
|
|
|
72
60
|
setElements(html_id: string): void;
|
|
73
61
|
setIframe(): void;
|
|
74
62
|
setMetadata(metadata?: {}): void;
|
|
63
|
+
setConfigOptions(config: Config): void;
|
|
64
|
+
setCardHolder(cardHolder: CardHolder): void;
|
|
75
65
|
submit(card_values: Card): Promise<void>;
|
|
76
66
|
}
|
|
77
67
|
export declare function getIdentificationBy(isoCountryCode: IsoCountryEnum): Promise<Identification[]>;
|