diff --git a/dist/index.d.ts b/dist/index.d.ts index c0561bd..575f91b 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -12,6 +12,13 @@ export interface Constructor { submission: (response: any) => void; settings?: Settings; } +export interface Address { + address?: string; + city?: string; + state?: string; + zip?: string; + country?: string; +} export interface GuardianData { events: Record[]; session_id: string; @@ -46,6 +53,8 @@ export default class Tokenizer { submit(amount?: string): void; setExpDate(expDate: string): void; setError(input: string): void; + setBilling(address: Address): void; + setShipping(address: Address): void; postMessage(msg: Message): void; onLoad: () => void; validCard: (card: any) => void; diff --git a/dist/tokenizer.amd.js b/dist/tokenizer.amd.js index a390f4a..86703f3 100644 --- a/dist/tokenizer.amd.js +++ b/dist/tokenizer.amd.js @@ -1 +1 @@ -define("Tokenizer",[],(function(){return function(){"use strict";var t={};return{658:function(t,e){var n=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(a,o){function r(t){try{p(i.next(t))}catch(t){o(t)}}function s(t){try{p(i.throw(t))}catch(t){o(t)}}function p(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,s)}p((i=i.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,i,a,o,r={label:0,sent:function(){if(1&a[0])throw a[1];return a[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(p){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(r=0)),r;)try{if(n=1,i&&(a=2&s[0]?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return r.label++,{value:s[1],done:!1};case 5:r.label++,i=s[1],s=[0];continue;case 7:s=r.ops.pop(),r.trys.pop();continue;default:if(!((a=(a=r.trys).length>0&&a[a.length-1])||6!==s[0]&&2!==s[0])){r=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]\n apple-pay-button {\n --apple-pay-button-width: 100%;\n --apple-pay-button-height: 20px;\n border-radius: 4px;\n border: solid 1px #DCDEE2;\n }\n \n ");var r=document.createElement("script");r.setAttribute("src","https://applepay.cdn-apple.com/jsapi/v1.1.0/apple-pay-sdk.js"),r.setAttribute("async",""),r.setAttribute("crossorigin",""),document.head.appendChild(r),this.populateApplePayBtn(t)}},t.prototype.populateApplePayBtn=function(t){this.applePay.btn=document.createElement("apple-pay-button"),this.applePay.btn.setAttribute("buttonstyle","white"),this.applePay.btn.setAttribute("type","pay"),this.applePay.btn.setAttribute("locale","en-US"),this.applePay.btn.onclick=this.clickApplePay,t.appendChild(this.applePay.btn)},t.prototype.hideAutoPayButtons=function(t){var e,n=this;""!==t&&"apple_pay"!==t?(null===(e=this.applePay.btn)||void 0===e||e.remove(),this.applePay.btn=null):this.waitForContainer(this.container,(function(t){t&&(n.applePay.btn||n.populateApplePayBtn(t))}))},t.prototype.isSurchargeable=function(t,e){return""!==t&&-1===["CO","CT","ME","MA"].indexOf(t.toUpperCase())&&!(!e||!e.card_type||"credit"!==e.card_type.toLowerCase())},t.prototype.submit=function(t){var e=this;this.getGuardianData().then((function(t){var n;(null===(n=t.events)||void 0===n?void 0:n.length)&&e.postMessage({event:"setGuardian",data:t})})).then((function(){e.postMessage({event:"submit",data:{amount:t}})})).catch((function(){e.postMessage({event:"submit",data:{amount:t}})}))},t.prototype.setExpDate=function(t){this.postMessage({event:"setExpDate",data:{value:t}})},t.prototype.setError=function(t){this.postMessage({event:"setError",data:{input:t}})},t.prototype.postMessage=function(t){var e=this.iframe.contentWindow;if(null!==e){var n=JSON.stringify(t);e.postMessage(n,"*")}},t.prototype.uuid=function(){function t(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()},t.prototype.waitForContainer=function(t,e){if(t){var n=Date.now();!function i(){"string"!=typeof t||null===document.querySelector(t)?"string"!=typeof t&&t?e(t):setTimeout((function(){Date.now()-n>1e4?e(null):i()}),1e3):e(document.querySelector(t))}()}else e(null)},t.prototype.buildIframe=function(){var t=document.createElement("iframe");return t.src=this.getApiKeyURL(),t.setAttribute("allow","payment"),t.style.display="block",t.style.border="none",t.style.margin="0px",t.style.padding="0px",t.style.width="1px",t.style.minWidth="100%",t.style.height="30px",t.style.overflow="hidden",t.style.backgroundColor="transparent",t.style.transition="all .3s ease-out",t.frameBorder="0",t},t.prototype.setSettings=function(t){this.postMessage({event:"setSettings",data:t})},t.prototype.updateHeight=function(t){t&&(this.iframe.style.height=t+"px")},t.prototype.getGuardianData=function(){var t=window.Guardian;return t&&t.getData&&"function"==typeof t.getData?t.getData():Promise.reject()},t.prototype.messageListener=function(t){try{var e=JSON.parse(t.data),n=e.id;if(this.id!==n)return;var i=e.event,a=e.data;if(!i)return;switch(i){case"submission":this.submission(a);break;case"validCard":this.validCard(a);break;case"achOnChange":this.achOnChange(a);break;case"magStripeSwipe":this.magStripeSwipe(a);break;case"onPaymentChange":this.onPaymentChange(a.type),this.hideAutoPayButtons(a.type);break;case"setHeight":this.updateHeight(a.height)}}catch(t){}},t}();e.default=o}}[658](0,t),t.default}()})); \ No newline at end of file +define("Tokenizer",[],(function(){return function(){"use strict";var t={};return{658:function(t,e){var n=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(a,o){function s(t){try{p(i.next(t))}catch(t){o(t)}}function r(t){try{p(i.throw(t))}catch(t){o(t)}}function p(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,r)}p((i=i.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,i,a,o,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:r(0),throw:r(1),return:r(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function r(r){return function(p){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,r[0]&&(s=0)),s;)try{if(n=1,i&&(a=2&r[0]?i.return:r[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,r[1])).done)return a;switch(i=0,a&&(r=[2&r[0],a.value]),r[0]){case 0:case 1:a=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,i=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!((a=(a=s.trys).length>0&&a[a.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!a||r[1]>a[0]&&r[1]1e4?e(null):i()}),1e3):e(document.querySelector(t))}()}else e(null)},t.prototype.buildIframe=function(){var t=document.createElement("iframe");return t.src=this.getApiKeyURL(),t.setAttribute("allow","payment"),t.style.display="block",t.style.border="none",t.style.margin="0px",t.style.padding="0px",t.style.width="1px",t.style.minWidth="100%",t.style.height="30px",t.style.overflow="hidden",t.style.backgroundColor="transparent",t.style.transition="all .3s ease-out",t.frameBorder="0",t},t.prototype.setSettings=function(t){this.postMessage({event:"setSettings",data:t})},t.prototype.updateHeight=function(t){t&&(this.iframe.style.height=t+"px")},t.prototype.getGuardianData=function(){var t=window.Guardian;return t&&t.getData&&"function"==typeof t.getData?t.getData():Promise.reject()},t.prototype.messageListener=function(t){try{var e=JSON.parse(t.data),n=e.id;if(this.id!==n)return;var i=e.event,a=e.data;if(!i)return;switch(i){case"submission":this.submission(a);break;case"validCard":this.validCard(a);break;case"achOnChange":this.achOnChange(a);break;case"magStripeSwipe":this.magStripeSwipe(a);break;case"onPaymentChange":this.onPaymentChange(a.type),this.hideAutoPayButtons(a.type);break;case"setHeight":this.updateHeight(a.height)}}catch(t){}},t}();e.default=a}}[658](0,t),t.default}()})); \ No newline at end of file diff --git a/dist/tokenizer.commonjs2.js b/dist/tokenizer.commonjs2.js index 37b6776..46e65c9 100644 --- a/dist/tokenizer.commonjs2.js +++ b/dist/tokenizer.commonjs2.js @@ -1 +1 @@ -!function(){"use strict";var t={};({658:function(t,e){var n=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(a,o){function r(t){try{p(i.next(t))}catch(t){o(t)}}function s(t){try{p(i.throw(t))}catch(t){o(t)}}function p(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,s)}p((i=i.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,i,a,o,r={label:0,sent:function(){if(1&a[0])throw a[1];return a[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(p){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(r=0)),r;)try{if(n=1,i&&(a=2&s[0]?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return r.label++,{value:s[1],done:!1};case 5:r.label++,i=s[1],s=[0];continue;case 7:s=r.ops.pop(),r.trys.pop();continue;default:if(!((a=(a=r.trys).length>0&&a[a.length-1])||6!==s[0]&&2!==s[0])){r=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]\n apple-pay-button {\n --apple-pay-button-width: 100%;\n --apple-pay-button-height: 20px;\n border-radius: 4px;\n border: solid 1px #DCDEE2;\n }\n \n ");var r=document.createElement("script");r.setAttribute("src","https://applepay.cdn-apple.com/jsapi/v1.1.0/apple-pay-sdk.js"),r.setAttribute("async",""),r.setAttribute("crossorigin",""),document.head.appendChild(r),this.populateApplePayBtn(t)}},t.prototype.populateApplePayBtn=function(t){this.applePay.btn=document.createElement("apple-pay-button"),this.applePay.btn.setAttribute("buttonstyle","white"),this.applePay.btn.setAttribute("type","pay"),this.applePay.btn.setAttribute("locale","en-US"),this.applePay.btn.onclick=this.clickApplePay,t.appendChild(this.applePay.btn)},t.prototype.hideAutoPayButtons=function(t){var e,n=this;""!==t&&"apple_pay"!==t?(null===(e=this.applePay.btn)||void 0===e||e.remove(),this.applePay.btn=null):this.waitForContainer(this.container,(function(t){t&&(n.applePay.btn||n.populateApplePayBtn(t))}))},t.prototype.isSurchargeable=function(t,e){return""!==t&&-1===["CO","CT","ME","MA"].indexOf(t.toUpperCase())&&!(!e||!e.card_type||"credit"!==e.card_type.toLowerCase())},t.prototype.submit=function(t){var e=this;this.getGuardianData().then((function(t){var n;(null===(n=t.events)||void 0===n?void 0:n.length)&&e.postMessage({event:"setGuardian",data:t})})).then((function(){e.postMessage({event:"submit",data:{amount:t}})})).catch((function(){e.postMessage({event:"submit",data:{amount:t}})}))},t.prototype.setExpDate=function(t){this.postMessage({event:"setExpDate",data:{value:t}})},t.prototype.setError=function(t){this.postMessage({event:"setError",data:{input:t}})},t.prototype.postMessage=function(t){var e=this.iframe.contentWindow;if(null!==e){var n=JSON.stringify(t);e.postMessage(n,"*")}},t.prototype.uuid=function(){function t(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()},t.prototype.waitForContainer=function(t,e){if(t){var n=Date.now();!function i(){"string"!=typeof t||null===document.querySelector(t)?"string"!=typeof t&&t?e(t):setTimeout((function(){Date.now()-n>1e4?e(null):i()}),1e3):e(document.querySelector(t))}()}else e(null)},t.prototype.buildIframe=function(){var t=document.createElement("iframe");return t.src=this.getApiKeyURL(),t.setAttribute("allow","payment"),t.style.display="block",t.style.border="none",t.style.margin="0px",t.style.padding="0px",t.style.width="1px",t.style.minWidth="100%",t.style.height="30px",t.style.overflow="hidden",t.style.backgroundColor="transparent",t.style.transition="all .3s ease-out",t.frameBorder="0",t},t.prototype.setSettings=function(t){this.postMessage({event:"setSettings",data:t})},t.prototype.updateHeight=function(t){t&&(this.iframe.style.height=t+"px")},t.prototype.getGuardianData=function(){var t=window.Guardian;return t&&t.getData&&"function"==typeof t.getData?t.getData():Promise.reject()},t.prototype.messageListener=function(t){try{var e=JSON.parse(t.data),n=e.id;if(this.id!==n)return;var i=e.event,a=e.data;if(!i)return;switch(i){case"submission":this.submission(a);break;case"validCard":this.validCard(a);break;case"achOnChange":this.achOnChange(a);break;case"magStripeSwipe":this.magStripeSwipe(a);break;case"onPaymentChange":this.onPaymentChange(a.type),this.hideAutoPayButtons(a.type);break;case"setHeight":this.updateHeight(a.height)}}catch(t){}},t}();e.default=o}})[658](0,t),module.exports.Tokenizer=t.default}(); \ No newline at end of file +!function(){"use strict";var t={};({658:function(t,e){var n=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(a,o){function s(t){try{p(i.next(t))}catch(t){o(t)}}function r(t){try{p(i.throw(t))}catch(t){o(t)}}function p(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,r)}p((i=i.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,i,a,o,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:r(0),throw:r(1),return:r(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function r(r){return function(p){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,r[0]&&(s=0)),s;)try{if(n=1,i&&(a=2&r[0]?i.return:r[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,r[1])).done)return a;switch(i=0,a&&(r=[2&r[0],a.value]),r[0]){case 0:case 1:a=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,i=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!((a=(a=s.trys).length>0&&a[a.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!a||r[1]>a[0]&&r[1]1e4?e(null):i()}),1e3):e(document.querySelector(t))}()}else e(null)},t.prototype.buildIframe=function(){var t=document.createElement("iframe");return t.src=this.getApiKeyURL(),t.setAttribute("allow","payment"),t.style.display="block",t.style.border="none",t.style.margin="0px",t.style.padding="0px",t.style.width="1px",t.style.minWidth="100%",t.style.height="30px",t.style.overflow="hidden",t.style.backgroundColor="transparent",t.style.transition="all .3s ease-out",t.frameBorder="0",t},t.prototype.setSettings=function(t){this.postMessage({event:"setSettings",data:t})},t.prototype.updateHeight=function(t){t&&(this.iframe.style.height=t+"px")},t.prototype.getGuardianData=function(){var t=window.Guardian;return t&&t.getData&&"function"==typeof t.getData?t.getData():Promise.reject()},t.prototype.messageListener=function(t){try{var e=JSON.parse(t.data),n=e.id;if(this.id!==n)return;var i=e.event,a=e.data;if(!i)return;switch(i){case"submission":this.submission(a);break;case"validCard":this.validCard(a);break;case"achOnChange":this.achOnChange(a);break;case"magStripeSwipe":this.magStripeSwipe(a);break;case"onPaymentChange":this.onPaymentChange(a.type),this.hideAutoPayButtons(a.type);break;case"setHeight":this.updateHeight(a.height)}}catch(t){}},t}();e.default=a}})[658](0,t),module.exports.Tokenizer=t.default}(); \ No newline at end of file diff --git a/dist/tokenizer.js b/dist/tokenizer.js index 3b0728a..81ee1f1 100644 --- a/dist/tokenizer.js +++ b/dist/tokenizer.js @@ -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.Tokenizer=e():t.Tokenizer=e()}(self,(function(){return function(){"use strict";var t={};return{658:function(t,e){var n=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(a,o){function r(t){try{p(i.next(t))}catch(t){o(t)}}function s(t){try{p(i.throw(t))}catch(t){o(t)}}function p(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,s)}p((i=i.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,i,a,o,r={label:0,sent:function(){if(1&a[0])throw a[1];return a[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(p){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(r=0)),r;)try{if(n=1,i&&(a=2&s[0]?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return r.label++,{value:s[1],done:!1};case 5:r.label++,i=s[1],s=[0];continue;case 7:s=r.ops.pop(),r.trys.pop();continue;default:if(!((a=(a=r.trys).length>0&&a[a.length-1])||6!==s[0]&&2!==s[0])){r=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]\n apple-pay-button {\n --apple-pay-button-width: 100%;\n --apple-pay-button-height: 20px;\n border-radius: 4px;\n border: solid 1px #DCDEE2;\n }\n \n ");var r=document.createElement("script");r.setAttribute("src","https://applepay.cdn-apple.com/jsapi/v1.1.0/apple-pay-sdk.js"),r.setAttribute("async",""),r.setAttribute("crossorigin",""),document.head.appendChild(r),this.populateApplePayBtn(t)}},t.prototype.populateApplePayBtn=function(t){this.applePay.btn=document.createElement("apple-pay-button"),this.applePay.btn.setAttribute("buttonstyle","white"),this.applePay.btn.setAttribute("type","pay"),this.applePay.btn.setAttribute("locale","en-US"),this.applePay.btn.onclick=this.clickApplePay,t.appendChild(this.applePay.btn)},t.prototype.hideAutoPayButtons=function(t){var e,n=this;""!==t&&"apple_pay"!==t?(null===(e=this.applePay.btn)||void 0===e||e.remove(),this.applePay.btn=null):this.waitForContainer(this.container,(function(t){t&&(n.applePay.btn||n.populateApplePayBtn(t))}))},t.prototype.isSurchargeable=function(t,e){return""!==t&&-1===["CO","CT","ME","MA"].indexOf(t.toUpperCase())&&!(!e||!e.card_type||"credit"!==e.card_type.toLowerCase())},t.prototype.submit=function(t){var e=this;this.getGuardianData().then((function(t){var n;(null===(n=t.events)||void 0===n?void 0:n.length)&&e.postMessage({event:"setGuardian",data:t})})).then((function(){e.postMessage({event:"submit",data:{amount:t}})})).catch((function(){e.postMessage({event:"submit",data:{amount:t}})}))},t.prototype.setExpDate=function(t){this.postMessage({event:"setExpDate",data:{value:t}})},t.prototype.setError=function(t){this.postMessage({event:"setError",data:{input:t}})},t.prototype.postMessage=function(t){var e=this.iframe.contentWindow;if(null!==e){var n=JSON.stringify(t);e.postMessage(n,"*")}},t.prototype.uuid=function(){function t(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()},t.prototype.waitForContainer=function(t,e){if(t){var n=Date.now();!function i(){"string"!=typeof t||null===document.querySelector(t)?"string"!=typeof t&&t?e(t):setTimeout((function(){Date.now()-n>1e4?e(null):i()}),1e3):e(document.querySelector(t))}()}else e(null)},t.prototype.buildIframe=function(){var t=document.createElement("iframe");return t.src=this.getApiKeyURL(),t.setAttribute("allow","payment"),t.style.display="block",t.style.border="none",t.style.margin="0px",t.style.padding="0px",t.style.width="1px",t.style.minWidth="100%",t.style.height="30px",t.style.overflow="hidden",t.style.backgroundColor="transparent",t.style.transition="all .3s ease-out",t.frameBorder="0",t},t.prototype.setSettings=function(t){this.postMessage({event:"setSettings",data:t})},t.prototype.updateHeight=function(t){t&&(this.iframe.style.height=t+"px")},t.prototype.getGuardianData=function(){var t=window.Guardian;return t&&t.getData&&"function"==typeof t.getData?t.getData():Promise.reject()},t.prototype.messageListener=function(t){try{var e=JSON.parse(t.data),n=e.id;if(this.id!==n)return;var i=e.event,a=e.data;if(!i)return;switch(i){case"submission":this.submission(a);break;case"validCard":this.validCard(a);break;case"achOnChange":this.achOnChange(a);break;case"magStripeSwipe":this.magStripeSwipe(a);break;case"onPaymentChange":this.onPaymentChange(a.type),this.hideAutoPayButtons(a.type);break;case"setHeight":this.updateHeight(a.height)}}catch(t){}},t}();e.default=o}}[658](0,t),t.default}()})); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Tokenizer=e():t.Tokenizer=e()}(self,(function(){return function(){"use strict";var t={};return{658:function(t,e){var n=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(a,o){function s(t){try{p(i.next(t))}catch(t){o(t)}}function r(t){try{p(i.throw(t))}catch(t){o(t)}}function p(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,r)}p((i=i.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,i,a,o,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:r(0),throw:r(1),return:r(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function r(r){return function(p){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,r[0]&&(s=0)),s;)try{if(n=1,i&&(a=2&r[0]?i.return:r[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,r[1])).done)return a;switch(i=0,a&&(r=[2&r[0],a.value]),r[0]){case 0:case 1:a=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,i=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!((a=(a=s.trys).length>0&&a[a.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!a||r[1]>a[0]&&r[1]1e4?e(null):i()}),1e3):e(document.querySelector(t))}()}else e(null)},t.prototype.buildIframe=function(){var t=document.createElement("iframe");return t.src=this.getApiKeyURL(),t.setAttribute("allow","payment"),t.style.display="block",t.style.border="none",t.style.margin="0px",t.style.padding="0px",t.style.width="1px",t.style.minWidth="100%",t.style.height="30px",t.style.overflow="hidden",t.style.backgroundColor="transparent",t.style.transition="all .3s ease-out",t.frameBorder="0",t},t.prototype.setSettings=function(t){this.postMessage({event:"setSettings",data:t})},t.prototype.updateHeight=function(t){t&&(this.iframe.style.height=t+"px")},t.prototype.getGuardianData=function(){var t=window.Guardian;return t&&t.getData&&"function"==typeof t.getData?t.getData():Promise.reject()},t.prototype.messageListener=function(t){try{var e=JSON.parse(t.data),n=e.id;if(this.id!==n)return;var i=e.event,a=e.data;if(!i)return;switch(i){case"submission":this.submission(a);break;case"validCard":this.validCard(a);break;case"achOnChange":this.achOnChange(a);break;case"magStripeSwipe":this.magStripeSwipe(a);break;case"onPaymentChange":this.onPaymentChange(a.type),this.hideAutoPayButtons(a.type);break;case"setHeight":this.updateHeight(a.height)}}catch(t){}},t}();e.default=a}}[658](0,t),t.default}()})); \ No newline at end of file diff --git a/dist/tokenizer.umd.js b/dist/tokenizer.umd.js index 3b0728a..81ee1f1 100644 --- a/dist/tokenizer.umd.js +++ b/dist/tokenizer.umd.js @@ -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.Tokenizer=e():t.Tokenizer=e()}(self,(function(){return function(){"use strict";var t={};return{658:function(t,e){var n=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(a,o){function r(t){try{p(i.next(t))}catch(t){o(t)}}function s(t){try{p(i.throw(t))}catch(t){o(t)}}function p(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,s)}p((i=i.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,i,a,o,r={label:0,sent:function(){if(1&a[0])throw a[1];return a[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(p){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(r=0)),r;)try{if(n=1,i&&(a=2&s[0]?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return r.label++,{value:s[1],done:!1};case 5:r.label++,i=s[1],s=[0];continue;case 7:s=r.ops.pop(),r.trys.pop();continue;default:if(!((a=(a=r.trys).length>0&&a[a.length-1])||6!==s[0]&&2!==s[0])){r=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]\n apple-pay-button {\n --apple-pay-button-width: 100%;\n --apple-pay-button-height: 20px;\n border-radius: 4px;\n border: solid 1px #DCDEE2;\n }\n \n ");var r=document.createElement("script");r.setAttribute("src","https://applepay.cdn-apple.com/jsapi/v1.1.0/apple-pay-sdk.js"),r.setAttribute("async",""),r.setAttribute("crossorigin",""),document.head.appendChild(r),this.populateApplePayBtn(t)}},t.prototype.populateApplePayBtn=function(t){this.applePay.btn=document.createElement("apple-pay-button"),this.applePay.btn.setAttribute("buttonstyle","white"),this.applePay.btn.setAttribute("type","pay"),this.applePay.btn.setAttribute("locale","en-US"),this.applePay.btn.onclick=this.clickApplePay,t.appendChild(this.applePay.btn)},t.prototype.hideAutoPayButtons=function(t){var e,n=this;""!==t&&"apple_pay"!==t?(null===(e=this.applePay.btn)||void 0===e||e.remove(),this.applePay.btn=null):this.waitForContainer(this.container,(function(t){t&&(n.applePay.btn||n.populateApplePayBtn(t))}))},t.prototype.isSurchargeable=function(t,e){return""!==t&&-1===["CO","CT","ME","MA"].indexOf(t.toUpperCase())&&!(!e||!e.card_type||"credit"!==e.card_type.toLowerCase())},t.prototype.submit=function(t){var e=this;this.getGuardianData().then((function(t){var n;(null===(n=t.events)||void 0===n?void 0:n.length)&&e.postMessage({event:"setGuardian",data:t})})).then((function(){e.postMessage({event:"submit",data:{amount:t}})})).catch((function(){e.postMessage({event:"submit",data:{amount:t}})}))},t.prototype.setExpDate=function(t){this.postMessage({event:"setExpDate",data:{value:t}})},t.prototype.setError=function(t){this.postMessage({event:"setError",data:{input:t}})},t.prototype.postMessage=function(t){var e=this.iframe.contentWindow;if(null!==e){var n=JSON.stringify(t);e.postMessage(n,"*")}},t.prototype.uuid=function(){function t(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()},t.prototype.waitForContainer=function(t,e){if(t){var n=Date.now();!function i(){"string"!=typeof t||null===document.querySelector(t)?"string"!=typeof t&&t?e(t):setTimeout((function(){Date.now()-n>1e4?e(null):i()}),1e3):e(document.querySelector(t))}()}else e(null)},t.prototype.buildIframe=function(){var t=document.createElement("iframe");return t.src=this.getApiKeyURL(),t.setAttribute("allow","payment"),t.style.display="block",t.style.border="none",t.style.margin="0px",t.style.padding="0px",t.style.width="1px",t.style.minWidth="100%",t.style.height="30px",t.style.overflow="hidden",t.style.backgroundColor="transparent",t.style.transition="all .3s ease-out",t.frameBorder="0",t},t.prototype.setSettings=function(t){this.postMessage({event:"setSettings",data:t})},t.prototype.updateHeight=function(t){t&&(this.iframe.style.height=t+"px")},t.prototype.getGuardianData=function(){var t=window.Guardian;return t&&t.getData&&"function"==typeof t.getData?t.getData():Promise.reject()},t.prototype.messageListener=function(t){try{var e=JSON.parse(t.data),n=e.id;if(this.id!==n)return;var i=e.event,a=e.data;if(!i)return;switch(i){case"submission":this.submission(a);break;case"validCard":this.validCard(a);break;case"achOnChange":this.achOnChange(a);break;case"magStripeSwipe":this.magStripeSwipe(a);break;case"onPaymentChange":this.onPaymentChange(a.type),this.hideAutoPayButtons(a.type);break;case"setHeight":this.updateHeight(a.height)}}catch(t){}},t}();e.default=o}}[658](0,t),t.default}()})); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Tokenizer=e():t.Tokenizer=e()}(self,(function(){return function(){"use strict";var t={};return{658:function(t,e){var n=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(a,o){function s(t){try{p(i.next(t))}catch(t){o(t)}}function r(t){try{p(i.throw(t))}catch(t){o(t)}}function p(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,r)}p((i=i.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,i,a,o,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:r(0),throw:r(1),return:r(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function r(r){return function(p){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,r[0]&&(s=0)),s;)try{if(n=1,i&&(a=2&r[0]?i.return:r[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,r[1])).done)return a;switch(i=0,a&&(r=[2&r[0],a.value]),r[0]){case 0:case 1:a=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,i=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!((a=(a=s.trys).length>0&&a[a.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!a||r[1]>a[0]&&r[1]1e4?e(null):i()}),1e3):e(document.querySelector(t))}()}else e(null)},t.prototype.buildIframe=function(){var t=document.createElement("iframe");return t.src=this.getApiKeyURL(),t.setAttribute("allow","payment"),t.style.display="block",t.style.border="none",t.style.margin="0px",t.style.padding="0px",t.style.width="1px",t.style.minWidth="100%",t.style.height="30px",t.style.overflow="hidden",t.style.backgroundColor="transparent",t.style.transition="all .3s ease-out",t.frameBorder="0",t},t.prototype.setSettings=function(t){this.postMessage({event:"setSettings",data:t})},t.prototype.updateHeight=function(t){t&&(this.iframe.style.height=t+"px")},t.prototype.getGuardianData=function(){var t=window.Guardian;return t&&t.getData&&"function"==typeof t.getData?t.getData():Promise.reject()},t.prototype.messageListener=function(t){try{var e=JSON.parse(t.data),n=e.id;if(this.id!==n)return;var i=e.event,a=e.data;if(!i)return;switch(i){case"submission":this.submission(a);break;case"validCard":this.validCard(a);break;case"achOnChange":this.achOnChange(a);break;case"magStripeSwipe":this.magStripeSwipe(a);break;case"onPaymentChange":this.onPaymentChange(a.type),this.hideAutoPayButtons(a.type);break;case"setHeight":this.updateHeight(a.height)}}catch(t){}},t}();e.default=a}}[658](0,t),t.default}()})); \ No newline at end of file diff --git a/dist/tokenizer.var.js b/dist/tokenizer.var.js index 311136c..9fb74eb 100644 --- a/dist/tokenizer.var.js +++ b/dist/tokenizer.var.js @@ -1 +1 @@ -var Tokenizer;!function(){"use strict";var t={658:function(t,e){var n=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(a,o){function r(t){try{p(i.next(t))}catch(t){o(t)}}function s(t){try{p(i.throw(t))}catch(t){o(t)}}function p(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,s)}p((i=i.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,i,a,o,r={label:0,sent:function(){if(1&a[0])throw a[1];return a[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(p){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,s[0]&&(r=0)),r;)try{if(n=1,i&&(a=2&s[0]?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return r.label++,{value:s[1],done:!1};case 5:r.label++,i=s[1],s=[0];continue;case 7:s=r.ops.pop(),r.trys.pop();continue;default:if(!((a=(a=r.trys).length>0&&a[a.length-1])||6!==s[0]&&2!==s[0])){r=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]\n apple-pay-button {\n --apple-pay-button-width: 100%;\n --apple-pay-button-height: 20px;\n border-radius: 4px;\n border: solid 1px #DCDEE2;\n }\n \n ");var r=document.createElement("script");r.setAttribute("src","https://applepay.cdn-apple.com/jsapi/v1.1.0/apple-pay-sdk.js"),r.setAttribute("async",""),r.setAttribute("crossorigin",""),document.head.appendChild(r),this.populateApplePayBtn(t)}},t.prototype.populateApplePayBtn=function(t){this.applePay.btn=document.createElement("apple-pay-button"),this.applePay.btn.setAttribute("buttonstyle","white"),this.applePay.btn.setAttribute("type","pay"),this.applePay.btn.setAttribute("locale","en-US"),this.applePay.btn.onclick=this.clickApplePay,t.appendChild(this.applePay.btn)},t.prototype.hideAutoPayButtons=function(t){var e,n=this;""!==t&&"apple_pay"!==t?(null===(e=this.applePay.btn)||void 0===e||e.remove(),this.applePay.btn=null):this.waitForContainer(this.container,(function(t){t&&(n.applePay.btn||n.populateApplePayBtn(t))}))},t.prototype.isSurchargeable=function(t,e){return""!==t&&-1===["CO","CT","ME","MA"].indexOf(t.toUpperCase())&&!(!e||!e.card_type||"credit"!==e.card_type.toLowerCase())},t.prototype.submit=function(t){var e=this;this.getGuardianData().then((function(t){var n;(null===(n=t.events)||void 0===n?void 0:n.length)&&e.postMessage({event:"setGuardian",data:t})})).then((function(){e.postMessage({event:"submit",data:{amount:t}})})).catch((function(){e.postMessage({event:"submit",data:{amount:t}})}))},t.prototype.setExpDate=function(t){this.postMessage({event:"setExpDate",data:{value:t}})},t.prototype.setError=function(t){this.postMessage({event:"setError",data:{input:t}})},t.prototype.postMessage=function(t){var e=this.iframe.contentWindow;if(null!==e){var n=JSON.stringify(t);e.postMessage(n,"*")}},t.prototype.uuid=function(){function t(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()},t.prototype.waitForContainer=function(t,e){if(t){var n=Date.now();!function i(){"string"!=typeof t||null===document.querySelector(t)?"string"!=typeof t&&t?e(t):setTimeout((function(){Date.now()-n>1e4?e(null):i()}),1e3):e(document.querySelector(t))}()}else e(null)},t.prototype.buildIframe=function(){var t=document.createElement("iframe");return t.src=this.getApiKeyURL(),t.setAttribute("allow","payment"),t.style.display="block",t.style.border="none",t.style.margin="0px",t.style.padding="0px",t.style.width="1px",t.style.minWidth="100%",t.style.height="30px",t.style.overflow="hidden",t.style.backgroundColor="transparent",t.style.transition="all .3s ease-out",t.frameBorder="0",t},t.prototype.setSettings=function(t){this.postMessage({event:"setSettings",data:t})},t.prototype.updateHeight=function(t){t&&(this.iframe.style.height=t+"px")},t.prototype.getGuardianData=function(){var t=window.Guardian;return t&&t.getData&&"function"==typeof t.getData?t.getData():Promise.reject()},t.prototype.messageListener=function(t){try{var e=JSON.parse(t.data),n=e.id;if(this.id!==n)return;var i=e.event,a=e.data;if(!i)return;switch(i){case"submission":this.submission(a);break;case"validCard":this.validCard(a);break;case"achOnChange":this.achOnChange(a);break;case"magStripeSwipe":this.magStripeSwipe(a);break;case"onPaymentChange":this.onPaymentChange(a.type),this.hideAutoPayButtons(a.type);break;case"setHeight":this.updateHeight(a.height)}}catch(t){}},t}();e.default=o}},e={};t[658](0,e),Tokenizer=e.default}(); \ No newline at end of file +var Tokenizer;!function(){"use strict";var t={658:function(t,e){var n=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(a,o){function s(t){try{p(i.next(t))}catch(t){o(t)}}function r(t){try{p(i.throw(t))}catch(t){o(t)}}function p(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,r)}p((i=i.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,i,a,o,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:r(0),throw:r(1),return:r(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function r(r){return function(p){return function(r){if(n)throw new TypeError("Generator is already executing.");for(;o&&(o=0,r[0]&&(s=0)),s;)try{if(n=1,i&&(a=2&r[0]?i.return:r[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,r[1])).done)return a;switch(i=0,a&&(r=[2&r[0],a.value]),r[0]){case 0:case 1:a=r;break;case 4:return s.label++,{value:r[1],done:!1};case 5:s.label++,i=r[1],r=[0];continue;case 7:r=s.ops.pop(),s.trys.pop();continue;default:if(!((a=(a=s.trys).length>0&&a[a.length-1])||6!==r[0]&&2!==r[0])){s=0;continue}if(3===r[0]&&(!a||r[1]>a[0]&&r[1]1e4?e(null):i()}),1e3):e(document.querySelector(t))}()}else e(null)},t.prototype.buildIframe=function(){var t=document.createElement("iframe");return t.src=this.getApiKeyURL(),t.setAttribute("allow","payment"),t.style.display="block",t.style.border="none",t.style.margin="0px",t.style.padding="0px",t.style.width="1px",t.style.minWidth="100%",t.style.height="30px",t.style.overflow="hidden",t.style.backgroundColor="transparent",t.style.transition="all .3s ease-out",t.frameBorder="0",t},t.prototype.setSettings=function(t){this.postMessage({event:"setSettings",data:t})},t.prototype.updateHeight=function(t){t&&(this.iframe.style.height=t+"px")},t.prototype.getGuardianData=function(){var t=window.Guardian;return t&&t.getData&&"function"==typeof t.getData?t.getData():Promise.reject()},t.prototype.messageListener=function(t){try{var e=JSON.parse(t.data),n=e.id;if(this.id!==n)return;var i=e.event,a=e.data;if(!i)return;switch(i){case"submission":this.submission(a);break;case"validCard":this.validCard(a);break;case"achOnChange":this.achOnChange(a);break;case"magStripeSwipe":this.magStripeSwipe(a);break;case"onPaymentChange":this.onPaymentChange(a.type),this.hideAutoPayButtons(a.type);break;case"setHeight":this.updateHeight(a.height)}}catch(t){}},t}();e.default=a}},e={};t[658](0,e),Tokenizer=e.default}(); \ No newline at end of file diff --git a/dist/types.d.ts b/dist/types.d.ts index 3d81db9..e70078e 100644 --- a/dist/types.d.ts +++ b/dist/types.d.ts @@ -37,9 +37,10 @@ export interface StylesSettings { [key: string]: any; } export interface PaymentSettings { - types: string[]; + types: string | string[]; calculateFees: boolean; processorId?: string; + forcePaymentSelection: boolean; showTitle: boolean; showLabel: boolean; placeholderCreditCard: null | string; diff --git a/src/tokenizer/index.ts b/src/tokenizer/index.ts index 001637d..7ad5dc5 100644 --- a/src/tokenizer/index.ts +++ b/src/tokenizer/index.ts @@ -135,7 +135,7 @@ export default class Tokenizer { } const applePayScript = document.createElement('script') - const applePaySDKUrl = 'https://applepay.cdn-apple.com/jsapi/v1.1.0/apple-pay-sdk.js' + const applePaySDKUrl = 'https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js' applePayScript.setAttribute('src', applePaySDKUrl) applePayScript.setAttribute('async', '') applePayScript.setAttribute('crossorigin', '')