!function(e){var t={};function n(o){if(t[o])return t[o].exports;var a=t[o]={i:o,l:!1,exports:{}};return e[o].call(a.exports,a,a.exports,n),a.l=!0,a.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(o,a,function(t){return e[t]}.bind(null,a));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=7)}([function(e,t,n){
/*!
 * Bowser - a browser detector
 * https://github.com/ded/bowser
 * MIT License | (c) Dustin Diaz 2015
 */
!function(t,o,a){void 0!==e&&e.exports?e.exports=a():n(3)("bowser",a)}(0,0,function(){var e=!0;function t(t){function n(e){var n=t.match(e);return n&&n.length>1&&n[1]||""}var o,a=n(/(ipod|iphone|ipad)/i).toLowerCase(),i=!/like android/i.test(t)&&/android/i.test(t),r=/nexus\s*[0-6]\s*/i.test(t),s=!r&&/nexus\s*[0-9]+/i.test(t),p=/CrOS/.test(t),c=/silk/i.test(t),l=/sailfish/i.test(t),u=/tizen/i.test(t),d=/(web|hpw)os/i.test(t),m=/windows phone/i.test(t),h=(/SamsungBrowser/i.test(t),!m&&/windows/i.test(t)),y=!a&&!c&&/macintosh/i.test(t),f=!i&&!l&&!u&&!d&&/linux/i.test(t),g=n(/edge\/(\d+(\.\d+)?)/i),v=n(/version\/(\d+(\.\d+)?)/i),P=/tablet/i.test(t)&&!/tablet pc/i.test(t),b=!P&&/[^-]mobi/i.test(t),_=/xbox/i.test(t);/opera/i.test(t)?o={name:"Opera",opera:e,version:v||n(/(?:opera|opr|opios)[\s\/](\d+(\.\d+)?)/i)}:/opr\/|opios/i.test(t)?o={name:"Opera",opera:e,version:n(/(?:opr|opios)[\s\/](\d+(\.\d+)?)/i)||v}:/SamsungBrowser/i.test(t)?o={name:"Samsung Internet for Android",samsungBrowser:e,version:v||n(/(?:SamsungBrowser)[\s\/](\d+(\.\d+)?)/i)}:/coast/i.test(t)?o={name:"Opera Coast",coast:e,version:v||n(/(?:coast)[\s\/](\d+(\.\d+)?)/i)}:/yabrowser/i.test(t)?o={name:"Yandex Browser",yandexbrowser:e,version:v||n(/(?:yabrowser)[\s\/](\d+(\.\d+)?)/i)}:/ucbrowser/i.test(t)?o={name:"UC Browser",ucbrowser:e,version:n(/(?:ucbrowser)[\s\/](\d+(?:\.\d+)+)/i)}:/mxios/i.test(t)?o={name:"Maxthon",maxthon:e,version:n(/(?:mxios)[\s\/](\d+(?:\.\d+)+)/i)}:/epiphany/i.test(t)?o={name:"Epiphany",epiphany:e,version:n(/(?:epiphany)[\s\/](\d+(?:\.\d+)+)/i)}:/puffin/i.test(t)?o={name:"Puffin",puffin:e,version:n(/(?:puffin)[\s\/](\d+(?:\.\d+)?)/i)}:/sleipnir/i.test(t)?o={name:"Sleipnir",sleipnir:e,version:n(/(?:sleipnir)[\s\/](\d+(?:\.\d+)+)/i)}:/k-meleon/i.test(t)?o={name:"K-Meleon",kMeleon:e,version:n(/(?:k-meleon)[\s\/](\d+(?:\.\d+)+)/i)}:m?(o={name:"Windows Phone",osname:"Windows Phone",windowsphone:e},g?(o.msedge=e,o.version=g):(o.msie=e,o.version=n(/iemobile\/(\d+(\.\d+)?)/i))):/msie|trident/i.test(t)?o={name:"Internet Explorer",msie:e,version:n(/(?:msie |rv:)(\d+(\.\d+)?)/i)}:p?o={name:"Chrome",osname:"Chrome OS",chromeos:e,chromeBook:e,chrome:e,version:n(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)}:/chrome.+? edge/i.test(t)?o={name:"Microsoft Edge",msedge:e,version:g}:/vivaldi/i.test(t)?o={name:"Vivaldi",vivaldi:e,version:n(/vivaldi\/(\d+(\.\d+)?)/i)||v}:l?o={name:"Sailfish",osname:"Sailfish OS",sailfish:e,version:n(/sailfish\s?browser\/(\d+(\.\d+)?)/i)}:/seamonkey\//i.test(t)?o={name:"SeaMonkey",seamonkey:e,version:n(/seamonkey\/(\d+(\.\d+)?)/i)}:/firefox|iceweasel|fxios/i.test(t)?(o={name:"Firefox",firefox:e,version:n(/(?:firefox|iceweasel|fxios)[ \/](\d+(\.\d+)?)/i)},/\((mobile|tablet);[^\)]*rv:[\d\.]+\)/i.test(t)&&(o.firefoxos=e,o.osname="Firefox OS")):c?o={name:"Amazon Silk",silk:e,version:n(/silk\/(\d+(\.\d+)?)/i)}:/phantom/i.test(t)?o={name:"PhantomJS",phantom:e,version:n(/phantomjs\/(\d+(\.\d+)?)/i)}:/slimerjs/i.test(t)?o={name:"SlimerJS",slimer:e,version:n(/slimerjs\/(\d+(\.\d+)?)/i)}:/blackberry|\bbb\d+/i.test(t)||/rim\stablet/i.test(t)?o={name:"BlackBerry",osname:"BlackBerry OS",blackberry:e,version:v||n(/blackberry[\d]+\/(\d+(\.\d+)?)/i)}:d?(o={name:"WebOS",osname:"WebOS",webos:e,version:v||n(/w(?:eb)?osbrowser\/(\d+(\.\d+)?)/i)},/touchpad\//i.test(t)&&(o.touchpad=e)):/bada/i.test(t)?o={name:"Bada",osname:"Bada",bada:e,version:n(/dolfin\/(\d+(\.\d+)?)/i)}:u?o={name:"Tizen",osname:"Tizen",tizen:e,version:n(/(?:tizen\s?)?browser\/(\d+(\.\d+)?)/i)||v}:/qupzilla/i.test(t)?o={name:"QupZilla",qupzilla:e,version:n(/(?:qupzilla)[\s\/](\d+(?:\.\d+)+)/i)||v}:/chromium/i.test(t)?o={name:"Chromium",chromium:e,version:n(/(?:chromium)[\s\/](\d+(?:\.\d+)?)/i)||v}:/chrome|crios|crmo/i.test(t)?o={name:"Chrome",chrome:e,version:n(/(?:chrome|crios|crmo)\/(\d+(\.\d+)?)/i)}:i?o={name:"Android",version:v}:/safari|applewebkit/i.test(t)?(o={name:"Safari",safari:e},v&&(o.version=v)):a?(o={name:"iphone"==a?"iPhone":"ipad"==a?"iPad":"iPod"},v&&(o.version=v)):o=/googlebot/i.test(t)?{name:"Googlebot",googlebot:e,version:n(/googlebot\/(\d+(\.\d+))/i)||v}:{name:n(/^(.*)\/(.*) /),version:function(e){var n=t.match(e);return n&&n.length>1&&n[2]||""}(/^(.*)\/(.*) /)},!o.msedge&&/(apple)?webkit/i.test(t)?(/(apple)?webkit\/537\.36/i.test(t)?(o.name=o.name||"Blink",o.blink=e):(o.name=o.name||"Webkit",o.webkit=e),!o.version&&v&&(o.version=v)):!o.opera&&/gecko\//i.test(t)&&(o.name=o.name||"Gecko",o.gecko=e,o.version=o.version||n(/gecko\/(\d+(\.\d+)?)/i)),o.windowsphone||o.msedge||!i&&!o.silk?o.windowsphone||o.msedge||!a?y?(o.mac=e,o.osname="macOS"):_?(o.xbox=e,o.osname="Xbox"):h?(o.windows=e,o.osname="Windows"):f&&(o.linux=e,o.osname="Linux"):(o[a]=e,o.ios=e,o.osname="iOS"):(o.android=e,o.osname="Android");var S="";o.windows?S=function(e){switch(e){case"NT":return"NT";case"XP":return"XP";case"NT 5.0":return"2000";case"NT 5.1":return"XP";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}}(n(/Windows ((NT|XP)( \d\d?.\d)?)/i)):o.windowsphone?S=n(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i):o.mac?S=(S=n(/Mac OS X (\d+([_\.\s]\d+)*)/i)).replace(/[_\s]/g,"."):a?S=(S=n(/os (\d+([_\s]\d+)*) like mac os x/i)).replace(/[_\s]/g,"."):i?S=n(/android[ \/-](\d+(\.\d+)*)/i):o.webos?S=n(/(?:web|hpw)os\/(\d+(\.\d+)*)/i):o.blackberry?S=n(/rim\stablet\sos\s(\d+(\.\d+)*)/i):o.bada?S=n(/bada\/(\d+(\.\d+)*)/i):o.tizen&&(S=n(/tizen[\/\s](\d+(\.\d+)*)/i)),S&&(o.osversion=S);var w=!o.windows&&S.split(".")[0];return P||s||"ipad"==a||i&&(3==w||w>=4&&!b)||o.silk?o.tablet=e:(b||"iphone"==a||"ipod"==a||i||r||o.blackberry||o.webos||o.bada)&&(o.mobile=e),o.msedge||o.msie&&o.version>=10||o.yandexbrowser&&o.version>=15||o.vivaldi&&o.version>=1||o.chrome&&o.version>=20||o.samsungBrowser&&o.version>=4||o.firefox&&o.version>=20||o.safari&&o.version>=6||o.opera&&o.version>=10||o.ios&&o.osversion&&o.osversion.split(".")[0]>=6||o.blackberry&&o.version>=10.1||o.chromium&&o.version>=20?o.a=e:o.msie&&o.version<10||o.chrome&&o.version<20||o.firefox&&o.version<20||o.safari&&o.version<6||o.opera&&o.version<10||o.ios&&o.osversion&&o.osversion.split(".")[0]<6||o.chromium&&o.version<20?o.c=e:o.x=e,o}var n=t("undefined"!=typeof navigator&&navigator.userAgent||"");function o(e){return e.split(".").length}function a(e,t){var n,o=[];if(Array.prototype.map)return Array.prototype.map.call(e,t);for(n=0;n<e.length;n++)o.push(t(e[n]));return o}function i(e){for(var t=Math.max(o(e[0]),o(e[1])),n=a(e,function(e){var n=t-o(e);return a((e+=new Array(n+1).join(".0")).split("."),function(e){return new Array(20-e.length).join("0")+e}).reverse()});--t>=0;){if(n[0][t]>n[1][t])return 1;if(n[0][t]!==n[1][t])return-1;if(0===t)return 0}}function r(e,o,a){var r=n;"string"==typeof o&&(a=o,o=void 0),void 0===o&&(o=!1),a&&(r=t(a));var s=""+r.version;for(var p in e)if(e.hasOwnProperty(p)&&r[p]){if("string"!=typeof e[p])throw new Error("Browser version in the minVersion map should be a string: "+p+": "+String(e));return i([s,e[p]])<0}return o}return n.test=function(e){for(var t=0;t<e.length;++t){var o=e[t];if("string"==typeof o&&o in n)return!0}return!1},n.isUnsupportedBrowser=r,n.compareVersions=i,n.check=function(e,t,n){return!r(e,t,n)},n._detect=t,n})},function(e,t,n){(function(t,n){
/*!
 * @overview es6-promise - a tiny implementation of Promises/A+.
 * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
 * @license   Licensed under MIT license
 *            See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
 * @version   v4.2.4+314e4831
 */
!function(t,n){e.exports=n()}(0,function(){"use strict";function e(e){return"function"==typeof e}var o=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},a=0,i=void 0,r=void 0,s=function(e,t){h[a]=e,h[a+1]=t,2===(a+=2)&&(r?r(y):f())};var p="undefined"!=typeof window?window:void 0,c=p||{},l=c.MutationObserver||c.WebKitMutationObserver,u="undefined"==typeof self&&void 0!==t&&"[object process]"==={}.toString.call(t),d="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function m(){var e=setTimeout;return function(){return e(y,1)}}var h=new Array(1e3);function y(){for(var e=0;e<a;e+=2){(0,h[e])(h[e+1]),h[e]=void 0,h[e+1]=void 0}a=0}var f=void 0;function g(e,t){var n=this,o=new this.constructor(b);void 0===o[P]&&E(o);var a=n._state;if(a){var i=arguments[a-1];s(function(){return I(a,o,i,n._result)})}else D(n,o,e,t);return o}function v(e){if(e&&"object"==typeof e&&e.constructor===this)return e;var t=new this(b);return k(t,e),t}f=u?function(){return t.nextTick(y)}:l?function(){var e=0,t=new l(y),n=document.createTextNode("");return t.observe(n,{characterData:!0}),function(){n.data=e=++e%2}}():d?function(){var e=new MessageChannel;return e.port1.onmessage=y,function(){return e.port2.postMessage(0)}}():void 0===p?function(){try{var e=Function("return this")().require("vertx");return void 0!==(i=e.runOnLoop||e.runOnContext)?function(){i(y)}:m()}catch(e){return m()}}():m();var P=Math.random().toString(36).substring(2);function b(){}var _=void 0,S=1,w=2,C={error:null};function T(e){try{return e.then}catch(e){return C.error=e,C}}function A(t,n,o){n.constructor===t.constructor&&o===g&&n.constructor.resolve===v?function(e,t){t._state===S?R(e,t._result):t._state===w?q(e,t._result):D(t,void 0,function(t){return k(e,t)},function(t){return q(e,t)})}(t,n):o===C?(q(t,C.error),C.error=null):void 0===o?R(t,n):e(o)?function(e,t,n){s(function(e){var o=!1,a=function(e,t,n,o){try{e.call(t,n,o)}catch(e){return e}}(n,t,function(n){o||(o=!0,t!==n?k(e,n):R(e,n))},function(t){o||(o=!0,q(e,t))},e._label);!o&&a&&(o=!0,q(e,a))},e)}(t,n,o):R(t,n)}function k(e,t){e===t?q(e,new TypeError("You cannot resolve a promise with itself")):!function(e){var t=typeof e;return null!==e&&("object"===t||"function"===t)}(t)?R(e,t):A(e,t,T(t))}function M(e){e._onerror&&e._onerror(e._result),x(e)}function R(e,t){e._state===_&&(e._result=t,e._state=S,0!==e._subscribers.length&&s(x,e))}function q(e,t){e._state===_&&(e._state=w,e._result=t,s(M,e))}function D(e,t,n,o){var a=e._subscribers,i=a.length;e._onerror=null,a[i]=t,a[i+S]=n,a[i+w]=o,0===i&&e._state&&s(x,e)}function x(e){var t=e._subscribers,n=e._state;if(0!==t.length){for(var o=void 0,a=void 0,i=e._result,r=0;r<t.length;r+=3)o=t[r],a=t[r+n],o?I(n,o,a,i):a(i);e._subscribers.length=0}}function I(t,n,o,a){var i=e(o),r=void 0,s=void 0,p=void 0,c=void 0;if(i){if((r=function(e,t){try{return e(t)}catch(e){return C.error=e,C}}(o,a))===C?(c=!0,s=r.error,r.error=null):p=!0,n===r)return void q(n,new TypeError("A promises callback cannot return that same promise."))}else r=a,p=!0;n._state!==_||(i&&p?k(n,r):c?q(n,s):t===S?R(n,r):t===w&&q(n,r))}var O=0;function E(e){e[P]=O++,e._state=void 0,e._result=void 0,e._subscribers=[]}var N=function(){function e(e,t){this._instanceConstructor=e,this.promise=new e(b),this.promise[P]||E(this.promise),o(t)?(this.length=t.length,this._remaining=t.length,this._result=new Array(this.length),0===this.length?R(this.promise,this._result):(this.length=this.length||0,this._enumerate(t),0===this._remaining&&R(this.promise,this._result))):q(this.promise,new Error("Array Methods must be provided an Array"))}return e.prototype._enumerate=function(e){for(var t=0;this._state===_&&t<e.length;t++)this._eachEntry(e[t],t)},e.prototype._eachEntry=function(e,t){var n=this._instanceConstructor,o=n.resolve;if(o===v){var a=T(e);if(a===g&&e._state!==_)this._settledAt(e._state,t,e._result);else if("function"!=typeof a)this._remaining--,this._result[t]=e;else if(n===L){var i=new n(b);A(i,e,a),this._willSettleAt(i,t)}else this._willSettleAt(new n(function(t){return t(e)}),t)}else this._willSettleAt(o(e),t)},e.prototype._settledAt=function(e,t,n){var o=this.promise;o._state===_&&(this._remaining--,e===w?q(o,n):this._result[t]=n),0===this._remaining&&R(o,this._result)},e.prototype._willSettleAt=function(e,t){var n=this;D(e,void 0,function(e){return n._settledAt(S,t,e)},function(e){return n._settledAt(w,t,e)})},e}();var L=function(){function e(t){this[P]=O++,this._result=this._state=void 0,this._subscribers=[],b!==t&&("function"!=typeof t&&function(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}(),this instanceof e?function(e,t){try{t(function(t){k(e,t)},function(t){q(e,t)})}catch(t){q(e,t)}}(this,t):function(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}())}return e.prototype.catch=function(e){return this.then(null,e)},e.prototype.finally=function(e){var t=this.constructor;return this.then(function(n){return t.resolve(e()).then(function(){return n})},function(n){return t.resolve(e()).then(function(){throw n})})},e}();return L.prototype.then=g,L.all=function(e){return new N(this,e).promise},L.race=function(e){var t=this;return o(e)?new t(function(n,o){for(var a=e.length,i=0;i<a;i++)t.resolve(e[i]).then(n,o)}):new t(function(e,t){return t(new TypeError("You must pass an array to race."))})},L.resolve=v,L.reject=function(e){var t=new this(b);return q(t,e),t},L._setScheduler=function(e){r=e},L._setAsap=function(e){s=e},L._asap=s,L.polyfill=function(){var e=void 0;if(void 0!==n)e=n;else if("undefined"!=typeof self)e=self;else try{e=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var t=e.Promise;if(t){var o=null;try{o=Object.prototype.toString.call(t.resolve())}catch(e){}if("[object Promise]"===o&&!t.cast)return}e.Promise=L},L.Promise=L,L})}).call(this,n(4),n(5))},function(e,t,n){(function(e){var n,o,a;function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}!function(r,s){"object"==i(t)&&"object"==i(e)?e.exports=s():(o=[],void 0===(a="function"==typeof(n=s)?n.apply(t,o):n)||(e.exports=a))}(0,function(){return function(e){function t(o){if(n[o])return n[o].exports;var a=n[o]={i:o,l:!1,exports:{}};return e[o].call(a.exports,a,a.exports,t),a.l=!0,a.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),window.ApplePaySession&&(t.PaymentRequest=function(){function e(e,t,n){this.paymentRequestID="",this.shippingAddress=null,this.shippingOption="",this.shippingType="shipping",this.paymentResolver=null,this.paymentRejector=null,this.onshippingaddresschange=null,this.onshippingoptionchange=null,this.onpaymentmethodselected=null,this.validationEndpoint="",this.merchantIdentifier="";var o=!1;this.paymentRequest={countryCode:"",currencyCode:"",lineItems:[],merchantCapabilities:["supports3DS"],supportedNetworks:[],total:null,billingContact:null,requiredBillingContactFields:[],requiredShippingContactFields:[],shippingContact:null,shippingMethods:[],shippingType:"shipping"};for(var a,i=0,r=e;i<r.length;i++)if(-1<(a=r[i]).supportedMethods.indexOf("https://apple.com/apple-pay")){this.paymentRequest.supportedNetworks=a.data.supportedNetworks,this.paymentRequest.countryCode=a.data.countryCode,a.data.billingContact?this.paymentRequest.billingContact=a.data.billingContact:delete this.paymentRequest.billingContact,a.data.shippingContact?this.paymentRequest.shippingContact=a.data.shippingContact:delete this.paymentRequest.shippingContact,a.data.merchantCapabilities&&(this.paymentRequest.merchantCapabilities=a.data.merchantCapabilities),this.validationEndpoint=a.data.validationEndpoint,this.merchantIdentifier=a.data.merchantIdentifier,o=!0;break}if(!o)throw"Payment method not specified for Apple Pay.";t&&(n&&!0!==n.requestShipping&&delete t.shippingOptions,this.updatePaymentDetails(t),this.paymentRequest.shippingMethods&&this.paymentRequest.shippingMethods.length&&(this.shippingOption=this.convertShippingMethod(this.paymentRequest.shippingMethods[0]))),n&&(n.requestShipping&&(this.paymentRequest.requiredBillingContactFields.push("postalAddress"),this.paymentRequest.requiredShippingContactFields.push("postalAddress")),n.requestPayerName&&this.paymentRequest.requiredShippingContactFields.push("name"),n.requestPayerEmail&&this.paymentRequest.requiredShippingContactFields.push("email"),n.requestPayerPhone&&this.paymentRequest.requiredShippingContactFields.push("phone"),this.paymentRequest.shippingType="pickup"===n.shippingType?"servicePickup":n.shippingType||"shipping"),this.session=new ApplePaySession(1,this.paymentRequest),this.session.addEventListener("validatemerchant",this.onValidateMerchant.bind(this)),this.session.addEventListener("paymentauthorized",this.onPaymentAuthorized.bind(this)),this.session.addEventListener("paymentmethodselected",this.onPaymentMethodSelected.bind(this)),this.session.addEventListener("shippingcontactselected",this.onShippingAddressChange.bind(this)),this.session.addEventListener("shippingmethodselected",this.onShippingOptionChange.bind(this)),this.session.addEventListener("cancel",this.onPaymentCanceled.bind(this))}return e.prototype.updatePaymentDetails=function(e){if(e.displayItems){this.paymentRequest.lineItems=[];for(var t=0,n=e.displayItems;t<n.length;t++){var o=n[t],a={type:!0===o.pending?"pending":"final",label:o.label,amount:o.amount.value};this.paymentRequest.lineItems.push(a)}}if(e.shippingOptions){this.paymentRequest.shippingMethods=[];for(var i=0,r=e.shippingOptions;i<r.length;i++){var s=r[i],p={label:s.label,detail:s.detail||"",amount:s.amount.value,identifier:s.id};this.paymentRequest.shippingMethods.push(p)}}if(!e.total)throw"`total` is required parameter for `PaymentDetails`.";this.paymentRequest.currencyCode=e.total.amount.currency,this.paymentRequest.total={type:!0===e.total.pending?"pending":"final",label:e.total.label,amount:e.total.amount.value}},e.prototype.updatePaymentMethod=function(){},e.prototype.convertPaymentAddress=function(e){return{country:e.countryCode||"",addressLine:e.addressLines||[],region:e.administrativeArea||"",city:e.locality||"",dependentLocality:"",postalCode:e.postalCode||"",sortingCode:e.country||"",languageCode:"",organization:"",recipient:e.givenName+" "+e.familyName,phone:e.phoneNumber||""}},e.prototype.convertShippingMethod=function(e){for(var t,n=0,o=this.paymentRequest.shippingMethods;n<o.length;n++)if(t=o[n],e.identifier===t.identifier)return t.identifier;return""},e.prototype.convertPaymentResponse=function(e){var t=e.shippingContact?this.convertPaymentAddress(e.shippingContact):void 0,n=e.billingContact?this.convertPaymentAddress(e.billingContact):void 0,o=e.shippingContact||{},a=e.billingContact?e.billingContact.givenName+" "+e.billingContact.familyName:void 0;return{details:{billingAddress:n},methodName:"https://apple.com/apple-pay",payerEmail:o.emailAddress,payerName:a,payerPhone:o.phoneNumber,shippingAddress:t,shippingOption:this.shippingOption,applePayRaw:e,complete:this.onPaymentComplete.bind(this)}},e.prototype.show=function(){var e=this;return this.session.begin(),new Promise(function(t,n){e.paymentResolver=function(e){t(e)},e.paymentRejector=function(e){n(e)}})},e.prototype.abort=function(){this.session.abort()},e.prototype.canMakePayment=function(){if(this.merchantIdentifier)return ApplePaySession.canMakePaymentsWithActiveCard(this.merchantIdentifier);throw"`merchantIdentifier` is not specified."},e.prototype.completeMerchantValidation=function(e){this.session.completeMerchantValidation(e)},e.prototype.completePaymentMethodSelection=function(e,t){this.session.completePaymentMethodSelection(e,t)},e.prototype.addEventListener=function(e,t){if("shippingaddresschange"!==e&&"shippingoptionchange"!==e&&"paymentmethodselected"!==e&&"validatemerchant"!==e)throw'Unknown event type "'+e+'" for `addEventListener`.';this["on"+e]=t},e.prototype.onValidateMerchant=function(e){var t=this;if(e.stopPropagation(),this.onvalidatemerchant)this.onvalidatemerchant(e);else{var n=new Headers({"Content-Type":"application/json"});fetch(this.validationEndpoint,{method:"POST",headers:n,body:JSON.stringify({validationURL:e.validationURL})}).then(function(e){if(200===e.status)return e.json();throw"Merchant validation error."}).then(function(e){t.completeMerchantValidation(e)}).catch(function(e){throw e})}},e.prototype.onPaymentMethodSelected=function(e){if(e.stopPropagation(),this.onpaymentmethodselected)this.onpaymentmethodselected(e);else{var t=this.paymentRequest.total,n=this.paymentRequest.lineItems;this.session.completePaymentMethodSelection(t,n)}},e.prototype.onShippingAddressChange=function(e){var t=this;if(this.onshippingaddresschange){e.stopPropagation();var n=e.shippingContact;this.shippingAddress=this.convertPaymentAddress(n),this.onshippingaddresschange({updateWith:function(e){Promise.resolve(e).then(function(e){t.updatePaymentDetails(e),t.session.completeShippingContactSelection(ApplePaySession.STATUS_SUCCESS,t.paymentRequest.shippingMethods,t.paymentRequest.total,t.paymentRequest.lineItems)},function(e){t.updatePaymentDetails(e),t.session.completeShippingContactSelection(ApplePaySession.STATUS_FAILURE,t.paymentRequest.shippingMethods,t.paymentRequest.total,t.paymentRequest.lineItems)})}})}},e.prototype.onShippingOptionChange=function(e){var t=this;if(this.onshippingoptionchange){e.stopPropagation();var n=e.shippingMethod;this.shippingOption=this.convertShippingMethod(n),this.onshippingoptionchange({updateWith:function(e){Promise.resolve(e).then(function(e){t.updatePaymentDetails(e),t.session.completeShippingMethodSelection(ApplePaySession.STATUS_SUCCESS,t.paymentRequest.total,t.paymentRequest.lineItems)},function(e){t.updatePaymentDetails(e),t.session.completeShippingMethodSelection(ApplePaySession.STATUS_FAILURE,null,null)})}})}},e.prototype.onPaymentAuthorized=function(e){if(this.paymentResolver){var t=this.convertPaymentResponse(e.payment);this.paymentResolver(t),this.paymentResolver=null,this.paymentRejector=null}},e.prototype.onPaymentCanceled=function(){this.paymentRejector&&(this.paymentRejector(),this.paymentResolver=null,this.paymentRejector=null)},e.prototype.onPaymentComplete=function(e){if("success"!==e&&"fail"!==e&&"unknown"!==e&&""!==e)throw"Unkown status code for complete().";var t;switch(e){case"success":t=ApplePaySession.STATUS_SUCCESS;break;case"fail":t=ApplePaySession.STATUS_FAILURE;break;case"unknown":default:t=ApplePaySession.STATUS_SUCCESS}this.session.completePayment(t)},e}())}])})}).call(this,n(6)(e))},function(e,t){e.exports=function(){throw new Error("define cannot be used indirect")}},function(e,t){var n,o,a=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function s(e){if(n===setTimeout)return setTimeout(e,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(e){n=i}try{o="function"==typeof clearTimeout?clearTimeout:r}catch(e){o=r}}();var p,c=[],l=!1,u=-1;function d(){l&&p&&(l=!1,p.length?c=p.concat(c):u=-1,c.length&&m())}function m(){if(!l){var e=s(d);l=!0;for(var t=c.length;t;){for(p=c,c=[];++u<t;)p&&p[u].run();u=-1,t=c.length}p=null,l=!1,function(e){if(o===clearTimeout)return clearTimeout(e);if((o===r||!o)&&clearTimeout)return o=clearTimeout,clearTimeout(e);try{o(e)}catch(t){try{return o.call(null,e)}catch(t){return o.call(this,e)}}}(e)}}function h(e,t){this.fun=e,this.array=t}function y(){}a.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new h(e,t)),1!==c.length||l||s(m)},h.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=y,a.addListener=y,a.once=y,a.off=y,a.removeListener=y,a.removeAllListeners=y,a.emit=y,a.prependListener=y,a.prependOnceListener=y,a.listeners=function(e){return[]},a.binding=function(e){throw new Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(e){throw new Error("process.chdir is not supported")},a.umask=function(){return 0}},function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,n){"use strict";n.r(t);var o="https://sandbox-redirect.tappaysdk.com",a="https://prod-redirect.tappaysdk.com",i="https://js.tappaysdk.com",r=i+"/tpdirect/v4/api/html",s=i+"/tpdirect/v4/card-view/html",p=i+"/tpdirect/v4/tappay-field/html",c=i+"/tpdirect/v4/samsung-pay/html",l=i+"/tpdirect/image/samsung-pay/",u={en:"Pay Now",zh:"付款"},d={VISA:1,MASTERCARD:2,JCB:3,UNIONPAY:4,AMEX:5},m={VI:1,MC:2},h={CREDIT:0,DEBIT:1,PREPAID:2},y={OK:0,CLEAN:1,ERROR:2,TYPING:3},f={CARD_NUMBER:"card-number",EXPIRATION_DATE:"expiration-date",CVC:"cvc"},g="function",v="api",P=n(0),b=n.n(P),_=n(1),S=n(2),w=null;function C(e){for(var t=1;t<arguments.length;t++){var n=null==arguments[t]?{}:arguments[t],o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){T(e,t,n[t])})}return e}function T(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var A=function e(t){var n=this;(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")})(this,e),T(this,"can_use_google_pay",void 0),T(this,"tpDirect",void 0),T(this,"payment_data_request",void 0),T(this,"google_pay_setting",void 0),T(this,"google_pay_client",void 0),T(this,"is_ready_to_pay_request",void 0),T(this,"get_prime_callback",void 0),T(this,"setupTransactionPrice",function(e){n.payment_data_request.transactionInfo={currencyCode:e.currency,totalPrice:e.price,totalPriceStatus:"FINAL"}}),T(this,"setupGooglePay",function(e){n.google_pay_setting=e}),T(this,"setupGooglePayButton",function(e){var t=n.google_pay_client.createButton({buttonColor:e.color,buttonType:e.type,onClick:function(){n.loadPaymentDataAndGetPrime(e.getPrimeCallback)}});document.querySelector(e.el).appendChild(t)}),T(this,"setupPaymentRequest",function(e,t){var o=n.tpDirect._type,a="production"===o?"PRODUCTION":"TEST";return null===google?console.error("[TapPay] Please includ the google pay sdk from https://pay.google.com/gp/p/js/pay.js"):void(!n.parsePaymentRequestData(e)||(n.google_pay_client=new google.payments.api.PaymentsClient({environment:a}),n.google_pay_client.isReadyToPay(n.is_ready_to_pay_request).then(function(e){e.result&&(n.can_use_google_pay=!0),t(null,{canUseGooglePay:n.can_use_google_pay})}).catch(function(e){t(e,{canUseGooglePay:!1})})))}),T(this,"getPrime",function(e){this.loadPaymentDataAndGetPrime(function(t,n){e(t,n)})}),T(this,"messageListener",function(e){"google_pay_get_prime_done"===e.event&&n.get_prime_callback(null,e.result)}),T(this,"validateItemInSupportedArray",function(e,t){return!!(e instanceof Array)&&e.map(function(e){return-1!==t.indexOf(e)}).every(function(e){return!0===e})}),T(this,"parsePaymentRequestData",function(e){var t=n.google_pay_setting,o={apiVersion:2,apiVersionMinor:0},a=e.allowedNetworks,i=t.allowedCardAuthMethods;if(!n.validateItemInSupportedArray(a,["AMEX","DISCOVER","JCB","MASTERCARD","VISA"]))return!1;if(!n.validateItemInSupportedArray(i,["PAN_ONLY","CRYPTOGRAM_3DS"]))return!1;var r={type:"CARD",parameters:{allowPrepaidCards:t.allowPrepaidCards,allowedAuthMethods:i,allowedCardNetworks:a,billingAddressParameters:{format:t.billingAddressFormat,phoneNumberRequired:t.phoneNumberRequired},billingAddressRequired:t.billingAddressRequired}},s=C({},o);s.allowedPaymentMethods=[r];var p=C({},r,{tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"tappay",gatewayMerchantId:"tappay"}}}),c=C({},o);return c.allowedPaymentMethods=[p],c.transactionInfo={totalPriceStatus:"FINAL",totalPrice:e.price,currencyCode:e.currency},c.merchantInfo={merchantName:t.merchantName,merchantId:t.googleMerchantId},c.emailRequired=t.emailRequired,c.shippingAddressRequired=t.shippingAddressRequired,c.shippingAddressParameters={allowedCountryCodes:t.allowedCountryCodes,phoneNumberRequired:t.phoneNumberRequired},n.is_ready_to_pay_request=s,n.payment_data_request=c,!0}),T(this,"loadPaymentDataAndGetPrime",function(e){return n.can_use_google_pay?void n.google_pay_client.loadPaymentData(n.payment_data_request).then(function(t){(function(e){w.contentWindow.postMessage(JSON.stringify(e),i)})({event:"google_pay_get_prime",payment_data:t}),n.get_prime_callback=function(t,n){if(0!==n.status){var o=new Error(n.msg);e(o,null)}else e(null,n.prime)}}).catch(function(t){console.error(t),e(t,null)}):console.error("[TapPay] Your device doesn't support Google Pay")}),this.tpDirect=t,function(e){window.addEventListener("message",function(t){if(t.origin===i){var n=JSON.parse(t.data);e(n)}},!1)}(this.messageListener)};function k(e){return(k="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}!function(e){function t(e){ee.contentWindow.postMessage(JSON.stringify(e),i)}function n(t){if(t.origin===i){var n=JSON.parse(t.data);if("get_prime_done"===n.event)U(n.result);else if("iframe_get_prime_ready"===n.event)se();else if("setup_payment_request_done"===n.event)W({browserSupportPaymentRequest:!0,canMakePaymentWithActiveCard:n.result.canMakePaymentWithActiveCard,canMakePaymentError:n.result.error});else if("payment_request_not_support_in_iframe"===n.event)e.TPDirect.paymentRequestApi.iosChromeSetupPaymentRequest(),e.TPDirect.paymentRequestApi.iosChromeCheckCanMakePaymentWithActiveCard();else if("payment_request_get_prime_done"===n.event)j(n.result);else if("payment_request_apple_pay_get_prime_done"===n.event)V(n.err,n.result);else if("apple_pay_get_prime_done"===n.event)z(n.err,n.result);else if("apple_pay_get_session_done"===n.event)K(n.err,n.result);else if("line_pay_get_prime_done"===n.event)B(n.result,n.url);else if("update"===n.event)oe=n,ce(n);else if("cardtype-change"===n.event){ne.cardType=n.result;var o=P();ce(o)}else if("field-focus-change"===n.event){var a=n.result,r=ne[a.type].el;"focus"===a.state?T(r,"tappay-field-focus"):M(r,"tappay-field-focus")}else if("field-status-change"===n.event){var s=n.result,p=ne.status;s.type===f.CARD_NUMBER?p.number=s.status:s.type===f.EXPIRATION_DATE?p.expiry=s.status:s.type===f.CVC&&(p.cvc=s.status);var c=P();ce(c)}else"get_prime_for_tappay_fields_done"===n.event?X(n.result):"get_prime_for_card_view_done"===n.event?$(n.result):"samsung_pay_iframe_result"===n.event&&Y(n.result)}}function P(){var e=ne.status;return{canGetPrime:e.number===y.OK&&e.expiry===y.OK&&e.cvc===y.OK,hasError:e.number===y.ERROR||e.expiry===y.ERROR||e.cvc===y.ERROR,cardType:ne.cardType,status:e}}function C(e,t){return e.classList?e.classList.contains(t):!!e.className.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))}function T(e,t){e.classList?e.classList.add(t):!C(e,t)&&(e.className+=" "+t)}function M(e,t){if(e.classList)e.classList.remove(t);else if(C(e,t)){var n=new RegExp("(\\s|^)"+t+"(\\s|$)");e.className=e.className.replace(n," ")}}function R(){try{var e=(navigator.languages&&navigator.languages.length?navigator.languages[0]:navigator.userLanguage?navigator.userLanguage:navigator.language).split("-")[0].toLowerCase()}catch(e){return u.en}var t=u[e];return t||u.en}function q(e){var t;if(null!==URL&&"undefined"!=typeof URL)try{t=new URL(e)}catch(t){return!1}else(t=document.createElement("a")).href=e;return(t.origin===o||t.origin===a)&&"https:"===t.protocol}function D(e){try{var t=e.token.paymentData;if(!t)return!1;if(!t.data||"string"!=typeof t.data)return!1;if(!t.version||"string"!=typeof t.version)return!1;if(!t.signature||"string"!=typeof t.signature)return!1;if(!t.header)return!1;if(!t.header.publicKeyHash||"string"!=typeof t.header.publicKeyHash)return!1;if(!t.header.ephemeralPublicKey||"string"!=typeof t.header.ephemeralPublicKey)return!1;if(!t.header.transactionId||"string"!=typeof t.header.transactionId)return!1}catch(e){return!1}return!0}function x(e){return e instanceof Element}e.location.origin||(e.location.origin=e.location.protocol+"//"+e.location.hostname+(e.location.port?":"+e.location.port:""));var I,O,E,N,L,F,U,W,j,V,B,z,K,G,Y,J,H,X,$,Z,Q,ee,te,ne,oe,ae,ie=!1,re=[],se=function(){ie=!0,re.forEach(function(e){e()})},pe="",ce=function(){},le=function(t,n,o,a){var i=new XMLHttpRequest,r={c1:I.getFraudId(),name:n,type:o,app_id:I.appID||"",app_key:I.appKey||"",server_type:I._type||"",sdk_version:ae||"test",get_prime_type:!0===a?"with form":!1===a?"without form":"",platform_type:"web",response:t,user_info:{hostname:e.location.hostname,origin:e.location.origin,referrer:document.referrer,href:e.location.href,android_merchant_id:void 0===I.paymentRequestApi?"":I.paymentRequestApi.androidPayTapPayMerchantID,android_pub_key:void 0===I.paymentRequestApi?"":I.paymentRequestApi.androidPayPublickKey,apple_merchant_id:void 0===I.applePay?"":I.applePay.applePayMerchantID}};r=JSON.stringify(r),i.open("POST","https://js.tappaysdk.com/log",!0),i.setRequestHeader("Content-type","application/json"),i.send(r)};if(E="https://js.tappaysdk.com","https://js.tappaysdk.com",N=document.querySelectorAll('script[src^="'+E+'"]'),ae=0>=N.length?"v4":"v"+N[0].src.split("/v")[1],"withCredentials"in new XMLHttpRequest)L=!0;else{if(!e.XDomainRequest)return L=!1,le({msg:"[TapPay] It looks like browser not support cors."},"CORS",g),console.warn("[TapPay] It looks like browser not support cors.");L=!0}e.TPDirect?(e.TPDirect.isDoubleLoaded=!0,console.warn("[TapPay] It looks like TPDirect.js was loaded more than one time.")):(e.TPDirect=function(t){return F=e.location.hostname,e.location.origin,e.location.port,e.location.protocol,(t={}).version=1,t.isDoubleLoaded=!1,t.setPublishableKey=function(e,n,o){t.appID=e,t.appKey=n,t.endPoint="production"===o?"https://prod.tappaysdk.com":"https://sandbox.tappaysdk.com"},t.setupSDK=function(o,a,i){if(!o||!a||!i)return console.error("[TapPay] TPDirect.setupSDK error, appID = "+o+", appKey = "+a+", serverType = "+i);if("string"!=typeof i)return console.error('[TapPay] TPDirect.setupSDK error, serverType is not "sandbox" nor "production", serverType = '+i);if("production"!==(i=i.toLowerCase())&&"sandbox"!==i)return console.error('[TapPay] TPDirect.setupSDK error, serverType is not "sandbox" nor "production", serverType = '+i);t.appID=o,t.appKey=a,t._type=i,t.endPoint="production"===i?"https://prod.tappaysdk.com":"https://sandbox.tappaysdk.com";var s={appKey:t.appKey,appID:t.appID,serverType:t._type,hostname:e.location.hostname,origin:e.location.origin,referrer:document.referrer,href:e.location.href,port:e.location.port,protocol:e.location.protocol,sdk_version:ae};(Q=document.createElement("iframe")).setAttribute("style","display: none;"),Q.src="https://fraud.tappaysdk.com/iframe?"+encodeURIComponent(JSON.stringify(s)),(ee=document.createElement("iframe")).setAttribute("allowpaymentrequest",!0),ee.setAttribute("frameborder","0"),ee.setAttribute("allowtransparency","true"),ee.setAttribute("scrolling","no"),ee.setAttribute("style","display: none;"),ee.src=r+"?"+encodeURIComponent(JSON.stringify(s)),"complete"===document.readyState||"loaded"===document.readyState||"interactive"===document.readyState?(document.body.appendChild(Q),document.body.appendChild(ee)):document.addEventListener("DOMContentLoaded",function(){document.body.appendChild(Q),document.body.appendChild(ee)}),function(e){w=e}(ee),e.addEventListener("message",n,!1),e.addEventListener("message",function(e){if("https://fraud.tappaysdk.com"===e.origin){var t=JSON.parse(e.data);"fraud_id"===t.event&&(pe=t.result)}},!1)},t.getFraudId=function(){return Q?pe:(le({msg:"[TapPay] TPDirect.getFraudId(): You need to call TPDirect.setupSDK first"},"getFraudId",g),console.error("[TapPay] TPDirect.getFraudId(): You need to call TPDirect.setupSDK first"))},t.redirect=function(t){return q(t)?void(e.location=t):console.error("[TapPay] Your payment url is not valid.")},I=t}(I),e.TPDirect.logger=le,e.TPDirect.card=function(o,a){return(a={}).createToken=function(e,n,a,i,r){return o.validate.cardNumber(e)?o.validate.expiry(n,a)?o.validate.ccv(i)?o.validate.sdkError()?(U=r,void t({event:"get_prime",card:{number:e,exp_month:n,exp_year:a,ccv:i}})):r({card:{},clientip:"",msg:"SDK Loading Error",status:-1}):r({card:{},clientip:"",msg:"Wrong Card Format",status:41}):r({card:{},clientip:"",msg:"Expired Card",status:2013}):r({card:{},clientip:"",msg:"Wrong Card Format",status:41})},a.setup=function(t,i){if("string"==typeof t&&(t=document.querySelector(t)),x(t)){if(!t)return console.warn("[TapPay] TPDirect.card.setup(element): Missing element param");var r={appKey:o.appKey,appID:o.appID,serverType:o._type,hostname:e.location.hostname,origin:e.location.origin,style:i};(Z=document.createElement("iframe")).setAttribute("frameborder","0"),Z.setAttribute("allowtransparency","true"),Z.setAttribute("scrolling","no"),Z.setAttribute("style","border: none; margin: 0px; padding: 0px; width: 1px; min-width: 100%; overflow: hidden; display: block; height: 24px;"),i&&i.lineHeight&&(Z.style.height=i.lineHeight),Z.src=s+"?"+encodeURIComponent(JSON.stringify(r)),t.appendChild(Z),e.addEventListener("message",n,!1)}else{var p=t;a.setupTappayFields(p)}},a.setupTappayFields=function(t){var n=a.setupTappayField(t.fields.number.element,{origin:e.location.origin,type:f.CARD_NUMBER,placeholder:t.fields.number.placeholder,styles:t.styles}),o=a.setupTappayField(t.fields.expirationDate.element,{origin:e.location.origin,type:f.EXPIRATION_DATE,placeholder:t.fields.expirationDate.placeholder,styles:t.styles}),i=a.setupTappayField(t.fields.ccv.element,{origin:e.location.origin,type:f.CVC,placeholder:t.fields.ccv.placeholder,styles:t.styles});return n&&o&&i?void(ne={"card-number":n,"expiration-date":o,cvc:i,cardType:"unknown",status:{number:y.CLEAN,expiry:y.CLEAN,cvc:y.CLEAN}}):console.error("[TapPay] TPDirect.card.setup: failed to setup TapPay fields")},a.setupTappayField=function(e,t){if("string"==typeof e&&(e=document.querySelector(e)),!x(e))return console.warn("[TapPay] TPDirect.card.setup(): Cannot find element for "+t.type);var n=document.createElement("iframe");return n.setAttribute("frameborder","0"),n.setAttribute("allowtransparency","true"),n.setAttribute("scrolling","no"),n.setAttribute("style","border: none; width: 100%; height: 100%; float: left;"),n.src=p+"?"+encodeURIComponent(JSON.stringify(t)),e.appendChild(n),{el:e,iframe:n}},a.onUpdate=function(e){return"function"==typeof e?void(ce=e):console.error("[TapPay] TPDirect.card.onUpdate(callback): callback in not a function")},a.getPrime=function(e){return"function"==typeof e?ne?a.getPrimeForTappayFields(e):Z?void a.getPrimeForCardView(e):(le({msg:"[TapPay] You need to call TPDirect.card.setup(element) first"},"getPrime",g,!0),console.error("[TapPay] You need to call TPDirect.card.setup(element) first")):console.error("[TapPay] TPDirect.card.getPrime(callback): callback is not a function")},a.getTappayFieldsStatus=function(){return P()},a.getPrimeForTappayFields=function(e){return P().canGetPrime?(X=e,void t({event:"get_prime_for_tappay_fields"})):e({status:-5,msg:"[TapPay] TapPay fields are not ready, please use TPDirect.card.getTappayFieldsStatus() to check status, or listen to update with TPDirect.card.onUpdate"})},a.getPrimeForCardView=function(e){return oe&&oe.canGetPrime?($=e,void t({event:"get_prime_for_card_view"})):e({status:-5,msg:"[TapPay] TapPay Card View are not ready, please listen to update with TPDirect.card.onUpdate"})},a.validate=function(e,t,n,a){var i=o.validate.cardType(e);return{cardType:i,isCardNumberValid:o.validate.cardNumber(e,i),isExpiryDateValid:o.validate.expiry(t,n),isCCVValid:o.validate.ccv(a,i)}},O=a}(I,O),e.TPDirect.consumer=function(){this.requiredShippingContactFields={},this.requiredBillingContactFields={},this.shippingContact=null,this.billingContact=null},e.TPDirect.merchant=function(){this.merchantCapabilities=["supports3DS"],this.acquirerMerchantID="",this.applePayMerchantIdentifier="",this.countryCode="TW",this.currencyCode="TWD",this.supportedNetworks=["amex","discover","masterCard","visa"],this.shippingMethods=null,this.merchantName=""},e.TPDirect.cart=function(){this.shippingType="shipping",this.paymentItems=[]},e.TPDirect.applePay=function(n,o){return(o={}).nowShippingMethod=null,o.sessionCallback={},o.paymentRequest=null,o.merchant={},o.consumer={},o.cart={},o.applePayMerchantID="",o.checkAvailability=function(){return e.ApplePaySession?ApplePaySession.canMakePayments()?"https:"===location.protocol||(console.warn("[TapPay] Trying to call an ApplePaySession API from an insecure document."),!1):(console.warn("[TapPay] User Can Not Use Apple Pay"),!1):(console.warn("[TapPay] Your Browser Did Not Support Apple Pay"),!1)},o.canMakePaymentsWithActiveCard=function(e,t){return o.checkAvailability()?void ApplePaySession.canMakePaymentsWithActiveCard(e).then(function(e){t({browserSupportPaymentRequest:!0,canMakePaymentWithActiveCard:e,canMakePaymentError:null})}).catch(function(e){t({browserSupportPaymentRequest:!0,canMakePaymentWithActiveCard:!1,canMakePaymentError:e})}):t({browserSupportPaymentRequest:!1,canMakePaymentWithActiveCard:!1,canMakePaymentError:null})},o.buildSession=function(e,a,i,r){return"https:"===location.protocol?(o.applePayMerchantID=a||"",o.session=new ApplePaySession(1,e),o.session.onvalidatemerchant=function(e){var n=e.validationURL,a="appId="+I.appID+"&appKey="+I.appKey+"&appName="+F+"&appleMerchantId="+o.applePayMerchantID+"&merchant_domain="+F+"&validationURL="+n+"&tappay_endpoint="+I.endPoint;K=function(e,t){return e?void r({status:401,msg:"[TapPay]: Apple Pay getSession error: "+e.status}):void o.session.completeMerchantValidation(t)},t({event:"apple_pay_get_session",paramsString:a})},o.session.onpaymentauthorized=function(e){var s=e.payment;if(!D(s))return r({status:402,msg:"Parsing Apple Pay result happen error"}),o.session.completePayment(ApplePaySession.STATUS_FAILURE);var p={app_id:n.appID,app_key:n.appKey,app_name:F,pay_token_data:s.token.paymentData,apple_merchant_id:a,platform_type:"2",fraud_id:n.getFraudId()},c=function(e){o.session.completePayment(e)};z=function(t,n){return t?r(t):0===n.status?void i(n.prime,e,c):onerror(n)},t({event:"apple_pay_get_prime",parameter:p})},o.session):console.warn("[TapPay] Trying to call an ApplePaySession API from an insecure document.")},o.setupPayment=function(e,t,n){return null===e&&null===t&&null===n?console.warn("[TapPay] TPDirect.applePay.setupPayment(merchant, consumer, cart), Lost Parameter"):(o.merchant=e,o.consumer=t,o.cart=n,o.paymentRequest=o.preparePaymentRequest(),null!==o.merchant.shippingMethods&&0<o.merchant.shippingMethods.length&&(o.nowShippingMethod=o.merchant.shippingMethods[0]),o)},o.startPayment=function(){return"https:"===location.protocol?(o.session=new ApplePaySession(1,o.paymentRequest),o.session.onvalidatemerchant=function(e){return null===o.sessionCallback.onValidateMerchant?console.warn("[TapPay] You Need To Implement 'TPDirect.applePay.onValidateMerchant' For Validate Merchant And Use Url To Send Apple Pay Session By Your Server."):void o.sessionCallback.onValidateMerchant(e)},o.session.onpaymentauthorized=function(e){return null===o.sessionCallback.onPaymentAuthorized?console.warn("[TapPay] You Need To Implement 'TPDirect.applePay.onPaymentAuthorized' Get Payment Data, Shipping Contact And Send Payment Data To TapPay Server Finished Payment"):void o.sessionCallback.onPaymentAuthorized(e)},o.session.onshippingmethodselected=function(e){return 0<o.merchant.shippingMethods.length&&(o.nowShippingMethod=e.shippingMethod),null!==o.merchant.shippingMethods&&0<o.merchant.shippingMethods.length&&null===o.sessionCallback.onShippingMethodSelected?(console.log("[TapPay] You Can Implement 'TPDirect.applePay.onShippingMethodSelected' And Listen User Select Shipping Method Behavior"),o.completeShippingMethodSelection(ApplePaySession.STATUS_SUCCESS,o.cart)):void o.sessionCallback.onShippingMethodSelected(e)},o.session.onshippingcontactselected=function(e){return null===o.sessionCallback.onShippingContactSelected?(console.log("[TapPay] You Can Implement 'TPDirect.applePay.onShippingContactSelected' And Listen User Select Shipping Contact Behavior"),o.completeShippingContactSelection(ApplePaySession.STATUS_SUCCESS,o.nowShippingMethod,o.cart)):void o.sessionCallback.onShippingContactSelected(e)},o.session.onpaymentmethodselected=function(e){return null===o.sessionCallback.onPaymentMethodSelected?(console.log("[TapPay] You Can Implement 'TPDirect.applePay.onPaymentMethodSelected' And Linsten User Select PaymentMethod Behavior"),o.completePaymentMethodSelection(o.cart)):void o.sessionCallback.onPaymentMethodSelected(e)},o.session.oncancel=function(e){return null===o.sessionCallback.onCancel?console.log("[TapPay] You Can Implement 'TPDirect.applePay.onCancel' And Listen User Cancel Behavior"):void o.sessionCallback.onCancel(e)},void o.session.begin()):(o.sessionCallback.onFailure&&o.sessionCallback.onFailure(-1,"Trying to call an ApplePaySession API from an insecure document"),console.warn("[TapPay] Trying to call an ApplePaySession API from an insecure document."))},o.onValidateMerchant=function(e){return o.sessionCallback.onValidateMerchant=e,o},o.onPaymentAuthorized=function(e){return o.sessionCallback.onPaymentAuthorized=e,o},o.onShippingMethodSelected=function(e){return o.sessionCallback.onShippingMethodSelected=e,o},o.onShippingContactSelected=function(e){return o.sessionCallback.onShippingContactSelected=e,o},o.onPaymentMethodSelected=function(e){return o.sessionCallback.onPaymentMethodSelected=e,o},o.onFailure=function(e){return o.sessionCallback.onFailure=e,o},o.onCancel=function(e){return o.sessionCallback.onCancel=e,o},o.completePayment=function(e){o.session.completePayment(e)},o.completePaymentMethodSelection=function(e){o.cart=e||o.cart;var t=o.preparePaymentItems(o.cart.paymentItems,o.nowShippingMethod);o.session.completePaymentMethodSelection(t.total,t.lineItems)},o.completeShippingContactSelection=function(e,t,n){e===ApplePaySession.STATUS_SUCCESS&&(o.cart=n||o.cart,o.nowShippingMethod=t||o.nowShippingMethod);var a=o.preparePaymentItems(o.cart.paymentItems,o.nowShippingMethod);o.session.completeShippingContactSelection(e,o.nowShippingMethod,a.total,a.lineItems)},o.completeShippingMethodSelection=function(e,t){e===ApplePaySession.STATUS_SUCCESS&&(o.cart=t||o.cart);var n=o.preparePaymentItems(o.cart.paymentItems,o.nowShippingMethod);o.session.completeShippingMethodSelection(e,n.total,n.lineItems)},o.completeMerchantValidation=function(e){o.session.completeMerchantValidation(e)},o.preparePaymentRequest=function(){var e=o.preparePaymentItems(o.cart.paymentItems,o.nowShippingMethod),t={};return t.countryCode=o.merchant.countryCode||"TW",t.currencyCode=o.merchant.currencyCode||"TWD",t.shippingMethods=o.merchant.shippingMethods,t.lineItems=e.lineItems,t.total=e.total,t.supportedNetworks=o.merchant.supportedNetworks,t.merchantCapabilities=o.merchant.merchantCapabilities,t.requiredShippingContactFields=o.consumer.requiredShippingContactFields,t.requiredBillingContactFields=o.consumer.requiredBillingContactFields,null!==o.consumer.billingContact&&(t.billingContact=o.consumer.billingContact),null!==o.consumer.shippingContact&&(t.shippingContact=o.consumer.shippingContact),t},o.preparePaymentItems=function(e){for(var t,n=0,a=[],i=0;i<e.length;i++)t=e[i],a.push(t),n+=parseInt(t.amount);if(null!==o.nowShippingMethod&&null!==o.nowShippingMethod.amount){var r={label:"Shipping",amount:o.nowShippingMethod.amount};a.push(r),n+=parseInt(r.amount)}return{lineItems:a,total:{label:o.merchant.merchantName,amount:n+""}}},o}(I,void 0),e.TPDirect.paymentRequestApi=function(n,o){return(o={}).paymentRequest=null,o.pay_with_google_options=null,o.apple_pay_options=null,o.androidPayTapPayMerchantID="",o.androidPayPublickKey="",o.checkAvailability=function(){var t=!1;return e.ApplePaySession?t=I.applePay.checkAvailability():e.PaymentRequest&&(t=!0),!1===t?(console.warn("[TapPay] Your Browser Did Not Support Payment Request and Apple Pay"),!1):"https:"!==location.protocol&&"localhost"!==e.location.hostname?(console.warn("[TapPay] Trying to call an PaymentRequest API from an insecure document or http://localhost."),!1):!b.a.msedge||(console.warn("[TapPay] Does not support PaymentRequest on Edge."),!1)},o.availableMethods=function(){return b.a.msedge?[]:I.applePay.checkAvailability()?["apple_pay"]:b.a.android&&b.a.check({chrome:"61"})?["card","pay_with_google","android_pay"]:b.a.android&&"undefined"!==e.PaymentRequest?["card","android_pay"]:"undefined"===e.PaymentRequest?[]:["card"]},o.setupTappayPaymentButton=function(t,n){if("string"==typeof t&&(t=document.querySelector(t)),!x(t))return console.error("[TapPay] TPDirect.paymentRequestApi.setupTappayPaymentButton: Missing element param");if("function"!=typeof n)return console.error("[TapPay] TPDirect.paymentRequestApi.setupTappayPaymentButton: Missing callback function");t.style.cursor="pointer";var a,i=!1,r=!1,s=e.TPDirect.paymentRequestApi.paymentRequest.supportedInstruments,p=s.find(function(e){return-1!==e.supportedMethods.indexOf("https://android.com/pay")}),c=s.find(function(e){return-1!==e.supportedMethods.indexOf("https://google.com/pay")});if(b.a.android&&b.a.check({chrome:"61"})&&c?i=!0:b.a.android&&"undefined"!==e.PaymentRequest&&p&&(r=!0),e.ApplePaySession)(a=document.createElement("div")).style.height="40px",a.style["-webkit-appearance"]="-apple-pay-button",a.style["-apple-pay-button-type"]=H.canMakePaymentWithActiveCard?"buy":"set-up",t.appendChild(a);else if(i){T(a=document.createElement("div"),"googlepay"),a.setAttribute("style","background-color: white;background-image: url('data:image/svg+xml,%3Csvg%20width%3D%22102%22%20height%3D%2217%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cg%20fill%3D%22none%22%20fill-rule%3D%22evenodd%22%3E%3Cpath%20d%3D%22M80.526%202.635v4.083h2.518c.6%200%201.096-.202%201.488-.605.403-.402.605-.882.605-1.437%200-.544-.202-1.018-.605-1.422-.392-.413-.888-.62-1.488-.62h-2.518zm0%205.52v4.736h-1.504V1.198h3.99c1.013%200%201.873.337%202.582%201.012.72.675%201.08%201.497%201.08%202.466%200%20.991-.36%201.819-1.08%202.482-.697.665-1.559.996-2.583.996h-2.485v.001zm7.668%202.287c0%20.392.166.718.499.98.332.26.722.391%201.168.391.633%200%201.196-.234%201.692-.701.497-.469.744-1.019.744-1.65-.469-.37-1.123-.555-1.962-.555-.61%200-1.12.148-1.528.442-.409.294-.613.657-.613%201.093m1.946-5.815c1.112%200%201.989.297%202.633.89.642.594.964%201.408.964%202.442v4.932h-1.439v-1.11h-.065c-.622.914-1.45%201.372-2.486%201.372-.882%200-1.621-.262-2.215-.784-.594-.523-.891-1.176-.891-1.96%200-.828.313-1.486.94-1.976s1.463-.735%202.51-.735c.892%200%201.629.163%202.206.49v-.344c0-.522-.207-.966-.621-1.33a2.132%202.132%200%200%200-1.455-.547c-.84%200-1.504.353-1.995%201.062l-1.324-.834c.73-1.045%201.81-1.568%203.238-1.568m11.853.262l-5.02%2011.53H95.42l1.864-4.034-3.302-7.496h1.635l2.387%205.749h.032l2.322-5.75z%22%20fill%3D%22%235F6368%22%2F%3E%3Cpath%20d%3D%22M74.448%207.134c0-.473-.04-.93-.116-1.366h-6.344v2.588h3.634a3.11%203.11%200%200%201-1.344%202.042v1.68h2.169c1.27-1.17%202.001-2.9%202.001-4.944%22%20fill%3D%22%234285F4%22%2F%3E%3Cpath%20d%3D%22M67.988%2013.7c1.816%200%203.344-.595%204.459-1.621l-2.169-1.681c-.603.406-1.38.643-2.29.643-1.754%200-3.244-1.182-3.776-2.774h-2.234v1.731a6.728%206.728%200%200%200%206.01%203.703%22%20fill%3D%22%2334A853%22%2F%3E%3Cpath%20d%3D%22M64.212%208.267a4.034%204.034%200%200%201%200-2.572V3.964h-2.234a6.678%206.678%200%200%200-.717%203.017c0%201.085.26%202.11.717%203.017l2.234-1.731z%22%20fill%3D%22%23FABB05%22%2F%3E%3Cpath%20d%3D%22M67.988%202.921c.992%200%201.88.34%202.58%201.008v.001l1.92-1.918c-1.165-1.084-2.685-1.75-4.5-1.75a6.728%206.728%200%200%200-6.01%203.702l2.234%201.731c.532-1.592%202.022-2.774%203.776-2.774%22%20fill%3D%22%23E94235%22%2F%3E%3Cpath%20d%3D%22M.148%202.976h3.766c.532%200%201.024.117%201.477.35.453.233.814.555%201.085.966.27.41.406.863.406%201.358%200%20.495-.124.924-.371%201.288s-.572.64-.973.826v.084c.504.177.912.471%201.225.882.313.41.469.891.469%201.442a2.6%202.6%200%200%201-.427%201.47c-.285.43-.667.763-1.148%201.001A3.5%203.5%200%200%201%204.082%2013H.148V2.976zm3.696%204.2c.448%200%20.81-.14%201.085-.42.275-.28.413-.602.413-.966s-.133-.684-.399-.959c-.266-.275-.614-.413-1.043-.413H1.716v2.758h2.128zm.238%204.368c.476%200%20.856-.15%201.141-.448.285-.299.427-.644.427-1.036%200-.401-.147-.749-.441-1.043-.294-.294-.688-.441-1.183-.441h-2.31v2.968h2.366zm5.379.903c-.453-.518-.679-1.239-.679-2.163V5.86h1.54v4.214c0%20.579.138%201.013.413%201.302.275.29.637.434%201.085.434.364%200%20.686-.096.966-.287.28-.191.495-.446.644-.763a2.37%202.37%200%200%200%20.224-1.022V5.86h1.54V13h-1.456v-.924h-.084c-.196.336-.5.611-.91.826-.41.215-.845.322-1.302.322-.868%200-1.528-.259-1.981-.777zm9.859.161L16.352%205.86h1.722l2.016%204.858h.056l1.96-4.858H23.8l-4.41%2010.164h-1.624l1.554-3.416zm8.266-6.748h1.666l1.442%205.11h.056l1.61-5.11h1.582l1.596%205.11h.056l1.442-5.11h1.638L36.392%2013h-1.624L33.13%207.876h-.042L31.464%2013h-1.596l-2.282-7.14zm12.379-1.337a1%201%200%200%201-.301-.735%201%201%200%200%201%20.301-.735%201%201%200%200%201%20.735-.301%201%201%200%200%201%20.735.301%201%201%200%200%201%20.301.735%201%201%200%200%201-.301.735%201%201%200%200%201-.735.301%201%201%200%200%201-.735-.301zM39.93%205.86h1.54V13h-1.54V5.86zm5.568%207.098a1.967%201.967%200%200%201-.686-.406c-.401-.401-.602-.947-.602-1.638V7.218h-1.246V5.86h1.246V3.844h1.54V5.86h1.736v1.358H45.75v3.36c0%20.383.075.653.224.812.14.187.383.28.728.28.159%200%20.299-.021.42-.063.121-.042.252-.11.392-.203v1.498c-.308.14-.681.21-1.12.21-.317%200-.616-.051-.896-.154zm3.678-9.982h1.54v2.73l-.07%201.092h.07c.205-.336.511-.614.917-.833.406-.22.842-.329%201.309-.329.868%200%201.53.254%201.988.763.457.509.686%201.202.686%202.079V13h-1.54V8.688c0-.541-.142-.947-.427-1.218-.285-.27-.656-.406-1.113-.406-.345%200-.656.098-.931.294a2.042%202.042%200%200%200-.651.777%202.297%202.297%200%200%200-.238%201.029V13h-1.54V2.976z%22%20fill%3D%22%233C4043%22%2F%3E%3Cpath%20d%3D%22M61%200h41.285v18H61z%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E');background-origin: content-box;background-position: center;background-repeat: no-repeat;background-size: contain;border: 0;border-radius: 4px;box-shadow: 0px 1px 3px 0px #6d6d6d;outline: 0;padding: 10px 8px;height: 40px;min-height: 40px;");var l=document.createElement("style"),u=".googlepay:focus {box-shadow: 0px 1px 3px 0px #6d6d6d, inset 0px 0px 0px 1px #a8abb3;} #pr-button:hover:enabled .googlepay {background-color: #f7f7f7;} .googlepay:active:enabled {background-color: #e7e8e8;} #pr-button:hover .googlepay {background-color: #f7f7f7 !important}";l.styleSheet?l.styleSheet.cssText=u:l.appendChild(document.createTextNode(u)),a.appendChild(l),t.appendChild(a)}else if(r)(a=document.createElement("div")).setAttribute("style","border-radius:5px; box-shadow:0px 1px 3px rgb(116,116,116);height: 100%;background-size:auto calc(60% + 2px);background-repeat:no-repeat;background-position:center;background-color:#fff;background-image:url(https://link-pay.tappaysdk.com/images/android_pay_logo.png)"),t.appendChild(a);else{(a=document.createElement("div")).setAttribute("style","display:flex;justify-content:center;color:rgb(61,64,67);background: #fff;border-radius:5px;box-shadow:0px 1px 3px rgb(116,116,116);height:100%;align-items:center;-webkit-tap-highlight-color: transparent;cursor: pointer;-webkit-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;font: 500 16px/21px -apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;font-weight: 500;-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;");var d=document.createElement("img");d.setAttribute("src","https://s3-ap-northeast-1.amazonaws.com/tappay-image-resource/favicon-32x32.png"),d.setAttribute("style","width: 20px; height: 20px; margin-right: 5px;");var m=document.createElement("span");m.textContent=R(),a.appendChild(d),a.appendChild(m),t.appendChild(a)}t.addEventListener("click",function(){o.getPrime(function(e){n(e)})},!1)},o.setupPaymentRequest=function(n,a){"function"!=typeof a&&(a=function(e){return e.browserSupportPaymentRequest?void(!e.canMakePaymentWithActiveCard&&console.log("[TapPay] User does not have support payment method.")):void console.log("[TapPay] Browser does not support PaymentRequest or Apple Pay")}),W=function(e){H=e,a(e)};var i=o.checkAvailability();if(!i)return W({browserSupportPaymentRequest:!1,canMakePaymentWithActiveCard:!1,canMakePaymentError:null});var r=b.a.android&&b.a.check({chrome:"61"}),s=-1===n.supportedMethods.indexOf("card")&&-1===n.supportedMethods.indexOf("basic-card"),p=void 0===e.ApplePaySession;s&&p&&!r&&(i=!1),1===n.supportedMethods.length&&("pay_with_google"===n.supportedMethods[0]||"https://google.com/pay"===n.supportedMethods[0])&&!r&&(i=!1),1===n.supportedMethods.length&&("apple_pay"===n.supportedMethods[0]||"https://apple.com/apple-pay"===n.supportedMethods[0])&&void 0===e.ApplePaySession&&(i=!1);var c=-1===n.supportedMethods.indexOf("apple_pay")&&-1===n.supportedMethods.indexOf("https://apple.com/apple-pay");if(e.ApplePaySession&&c&&(i=!1),i)if(o.preparePaymentRequest(n))if(e.ApplePaySession){if(!o.apple_pay_options)return void console.log("[TapPay]: You need to call `TPDirect.paymentRequestApi.setupApplePay` before `TPDirect.paymentRequestApi.setupPaymentRequest`");var l=o.apple_pay_options.merchantIdentifier;I.applePay.canMakePaymentsWithActiveCard(l,W)}else{if(b.a.ios&&b.a.chrome)return e.TPDirect.paymentRequestApi.iosChromeSetupPaymentRequest(),void e.TPDirect.paymentRequestApi.iosChromeCheckCanMakePaymentWithActiveCard();var u=function(){t({event:"setup_payment_request",paymentRequest:o.paymentRequest,androidPayTapPayMerchantID:o.androidPayTapPayMerchantID,androidPayPublickKey:o.androidPayPublickKey,pay_with_google_options:o.pay_with_google_options})};ie?u():re.push(u)}else console.log("[TapPay] Please check your paymentRequest");else W({browserSupportPaymentRequest:!1,canMakePaymentWithActiveCard:!1,canMakePaymentError:null})},o.setupAndroidPay=function(e,t){o.androidPayPublickKey=e,o.androidPayTapPayMerchantID=t},o.setupApplePay=function(e){e.merchantIdentifier&&"string"==typeof e.merchantIdentifier||(le({msg:"[TapPay] TPDirect.paymentRequestApi.setupApplePay: merchantIdentifier is required"},"TPDirect.paymentRequestApi.setupApplePay",g),console.error("[TapPay] TPDirect.paymentRequestApi.setupApplePay: merchantIdentifier is required")),!e.countryCode||"string"==typeof e.countryCode&&2===e.countryCode.length||(le({msg:"[TapPay] TPDirect.paymentRequestApi.setupApplePay: countryCode need to be two-letter ISO 3166 country code format."},"TPDirect.paymentRequestApi.setupApplePay",g),console.error("[TapPay] TPDirect.paymentRequestApi.setupApplePay: countryCode need to be two-letter ISO 3166 country code format.")),o.apple_pay_options=e},o.setupPayWithGoogle=function(e){e.allowedPaymentMethods&&e.allowedPaymentMethods.forEach(function(e){if(-1===["CARD","TOKENIZED_CARD"].indexOf(e)){var t="[TapPay] TPDirect.paymentRequestApi.setupPayWithGoogle: allowedPaymentMethods error: "+e;le({msg:t},"TPDirect.paymentRequestApi.setupPayWithGoogle",g),console.error(t)}});var t,n=k(e.allowPrepaidCards);-1===["boolean","undefined"].indexOf(n)&&(le({msg:t="[TapPay] TPDirect.paymentRequestApi.setupPayWithGoogle: allowPrepaidCards type error: "+n},"TPDirect.paymentRequestApi.setupPayWithGoogle",g),console.error(t));var a=k(e.billingAddressRequired);-1===["boolean","undefined"].indexOf(a)&&(le({msg:t="[TapPay] TPDirect.paymentRequestApi.setupPayWithGoogle: billingAddressRequired type error: "+a},"TPDirect.paymentRequestApi.setupPayWithGoogle",g),console.error(t)),e.billingAddressFormat&&-1===["FULL","MIN"].indexOf(e.billingAddressFormat)&&(t="[TapPay] TPDirect.paymentRequestApi.setupPayWithGoogle: billingAddressFormat error: "+e.billingAddressFormat,le({msg:t},"TPDirect.paymentRequestApi.setupPayWithGoogle",g),console.error(t)),e.allowedCountryCodes&&"[object Array]"!==Object.prototype.toString.call(e.allowedCountryCodes)&&(t="[TapPay] TPDirect.paymentRequestApi.setupPayWithGoogle: allowedCountryCodes error: "+e.allowedCountryCodes,le({msg:t},"TPDirect.paymentRequestApi.setupPayWithGoogle",g),console.error(t)),o.pay_with_google_options=e},o.preparePaymentItems=function(e){return e.hasOwnProperty("total")?{displayItems:e.displayItems,total:e.total,shippingOptions:e.shippingOptions||[]}:(console.error("[TapPay] You need to setup total in the paymentRequest"),!1)},o.preparePaymentOptions=function(e){var t={};return e.hasOwnProperty("options")&&(t=e.options),t},o.parseSupportMethod=function(e,t){var n=t.supportedNetworks,a=t.options||{},i={};if(-1===["card","android_pay","pay_with_google","apple_pay","basic-card","https://android.com/pay","https://google.com/pay","https://apple.com/apple-pay"].indexOf(e))return console.error("[TapPay] "+e+" is not supported, supportedMethods: card, android_pay, pay_with_google, apple_pay");if("card"===e||"basic-card"===e)i={supportedMethods:["basic-card"],data:{supportedNetworks:n.map(function(e){return e.toLowerCase()})}};else if("android_pay"===e||"https://android.com/pay"===e)i={supportedMethods:["https://android.com/pay"],data:{environment:"TEST",merchantId:"04234483533225200652",allowedCardNetworks:n,paymentMethodTokenizationParameters:{tokenizationType:"NETWORK_TOKEN",parameters:{publicKey:o.androidPayPublickKey}}}},"production"===I._type&&delete i.data.environment;else if("pay_with_google"===e||"https://google.com/pay"===e){var r=o.pay_with_google_options||{};i={supportedMethods:["https://google.com/pay"],data:{merchantId:"04234483533225200652",environment:"TEST",apiVersion:1,allowedPaymentMethods:r.allowedPaymentMethods||["CARD","TOKENIZED_CARD"],paymentMethodTokenizationParameters:{tokenizationType:"PAYMENT_GATEWAY",parameters:{gateway:"tappay",gatewayMerchantId:"tappay"}},cardRequirements:{allowedCardNetworks:n,allowPrepaidCards:r.allowPrepaidCards||!0,billingAddressRequired:r.billingAddressRequired||!1,billingAddressFormat:r.billingAddressFormat||"MIN"},phoneNumberRequired:a.requestPayerPhone||!1,emailRequired:a.requestPayerEmail||!1,shippingAddressRequired:a.requestShipping||!1,shippingAddressRequirements:{allowedCountryCodes:r.allowedCountryCodes||void 0}}},"production"===I._type&&delete i.data.environment}else if("apple_pay"===e||"https://apple.com/apple-pay"===e){var s=o.apple_pay_options||{};i={supportedMethods:["https://apple.com/apple-pay"],data:{supportedNetworks:o.convertToApplePayNetworks(n),countryCode:s.countryCode||"TW",merchantIdentifier:s.merchantIdentifier}}}return i},o.convertToApplePayNetworks=function(e){return e.map(function(e){var t=e.toLowerCase();return"amex"===t?"amex":"jcb"===t?null:"mastercard"===t?"masterCard":"visa"===t?"visa":null}).filter(function(e){return null!==e})},o.preparePaymentMethods=function(e){return e.hasOwnProperty("supportedMethods")?e.supportedMethods.map(function(t){return o.parseSupportMethod(t,e)}):(console.error('[TapPay] "supportedMthods" is not found in the paymentRequest, you need to setup the right name.'),!1)},o.preparePaymentRequest=function(e){var t=o.preparePaymentMethods(e),n=o.preparePaymentItems(e),a=o.preparePaymentOptions(e);return t&&n&&a?(o.paymentRequest={supportedInstruments:t,details:n,options:a},!0):(o.paymentRequest=null,!1)},o.getPrime=function(n){return"function"==typeof n?ee?o.paymentRequest?e.ApplePaySession?void o.applePayGetPrime(n):J?void o.iosChromeGetPrime(n):(j=n,void t({event:"payment_request_get_prime"})):console.error("[TapPay] You need to setup the complete payment request."):(le({msg:"[TapPay] body doesnt load pfirame yet"},"getPrime",g,!0),console.error("[TapPay] body doesnt load pfirame yet")):console.error("[TapPay] TPDirect.paymentRequestApi.getPrime(callback): callback is not a function")},o.iosChromeSetupPaymentRequest=function(){var t=e.TPDirect.paymentRequestApi.paymentRequest,n=t.supportedInstruments,o=t.details,a=t.options;"servicePickup"===a.shippingType&&(a.shippingType="pickup"),(J=new S.PaymentRequest(n,o,a)).addEventListener("shippingoptionchange",function(e){var n=JSON.parse(JSON.stringify(t.details));n.shippingOptions=n.shippingOptions.map(function(e){return J.shippingOption===e.id?(e.selected=!0,n.total.amount.value=(parseFloat(n.total.amount.value)+parseFloat(e.amount.value)).toString()):e.selected=!1,e}),e.updateWith(_.Promise.resolve(n))}),J.addEventListener("shippingaddresschange",function(e){e.updateWith(_.Promise.resolve(t.details))})},o.iosChromeCheckCanMakePaymentWithActiveCard=function(){var e=_.Promise.resolve(!0);J.canMakePayment&&(e=J.canMakePayment()),e.then(function(e){W({browserSupportPaymentRequest:!0,canMakePaymentWithActiveCard:e})}).catch(function(e){console.log("[TapPay] PaymentRequest.canMakePayment error (see https://developers.google.com/web/fundamentals/payments/deep-dive-into-payment-request#check_payment_method_availability): ",e),W({browserSupportPaymentRequest:!0,canMakePaymentWithActiveCard:!0,canMakePaymentError:e})})},o.iosChromeGetPrime=function(n){J.show().then(function(o){var a,i=e.TPDirect.paymentRequestApi.paymentRequest,r=i.details.shippingOptions,s=i.details.total.amount.value;if(!0===i.options.requestShipping&&r&&r.length){var p=r.find(function(e){return e.id===o.shippingOption}).amount.value;a=(parseFloat(s)+parseFloat(p)).toString()}else a=s;if("basic-card"===o.methodName||"basic_card"===o.methodName){var c=o.details.cardNumber,l=o.details.expiryMonth,u=o.details.expiryYear.slice(2),d=o.details.cardSecurityCode;U=function(e){0===e.status?(e.payer={email:o.payerEmail,name:o.payerName,phone:o.payerPhone},e.billingAddress=o.details.billingAddress,e.shippingAddress=o.shippingAddress,e.shippingOption=o.shippingOption,e.methodName="card",e.requestId=o.requestId,e.prime=e.card.prime,e.total_amount=a,o.complete("success")):o.complete("fail"),n(e)},t({event:"get_prime",card:{number:c,exp_month:l,exp_year:u,ccv:d}})}}).catch(function(t){var o={status:401,msg:t.message};n(o),e.TPDirect.paymentRequestApi.iosChromeSetupPaymentRequest()})},o.applePayGetPrime=function(n){j=n;var a=o.paymentRequest;"pickup"===a.options.shippingType&&(a.options.shippingType="storePickup");var i=new S.PaymentRequest(a.supportedInstruments,a.details,a.options);i.onvalidatemerchant=function(e){var a=e.validationURL,r=o.apple_pay_options.merchantIdentifier,s="appId="+I.appID+"&appKey="+I.appKey+"&appName="+F+"&appleMerchantId="+r+"&merchant_domain="+F+"&validationURL="+a+"&tappay_endpoint="+I.endPoint;K=function(e,t){return e?void n({status:401,msg:"[TapPay]: Apple Pay getSession error: "+e.status}):void i.completeMerchantValidation(t)},t({event:"apple_pay_get_session",paramsString:s})},i.onshippingoptionchange=function(t){var n=JSON.parse(JSON.stringify(e.TPDirect.paymentRequestApi.paymentRequest)).details;n.shippingOptions=n.shippingOptions.map(function(e){return i.shippingOption===e.id?(e.selected=!0,n.total.amount.value=(parseFloat(n.total.amount.value)+parseFloat(e.amount.value)).toString()):e.selected=!1,e}),t.updateWith(n)},i.onshippingaddresschange=function(e){var t=JSON.parse(JSON.stringify(o.paymentRequest.details));t.shippingOptions&&t.shippingOptions.length&&(t.total.amount.value=(parseFloat(t.total.amount.value)+parseFloat(t.shippingOptions[0].amount.value)).toString()),e.updateWith(t)},i.show().then(function(e){if(!D(e.applePayRaw))return n({status:402,msg:"Parsing Apple Pay result happen error"}),e.complete("fail");var a={app_id:I.appID,app_key:I.appKey,app_name:F,pay_token_data:e.applePayRaw.token.paymentData,apple_merchant_id:o.apple_pay_options.merchantIdentifier,platform_type:"2",fraud_id:I.getFraudId()},i=function(t){if(0===t.status){t.payer={email:e.payerEmail,name:e.payerName,phone:e.payerPhone},t.billingAddress=e.details.billingAddress,t.shippingAddress=e.shippingAddress,t.shippingOption=e.shippingOption,t.methodName="apple_pay";var a=e.applePayRaw.token.paymentMethod;t.card={lastfour:a.displayName.split(" ")[1],type:function(e){var t=e.toUpperCase();return void 0===d[t]?null:d[t]}(a.network),funding:function(e){var t=e.toUpperCase();return void 0===h[t]?null:h[t]}(a.type)};var i=o.paymentRequest,r=i.details.shippingOptions,s=i.details.total.amount.value;if(!0===i.options.requestShipping&&r&&r.length){var p=r.find(function(t){return t.id===e.shippingOption}).amount.value;t.total_amount=(parseFloat(s)+parseFloat(p)).toString()}else t.total_amount=s;e.complete("success")}else e.complete("fail");n(t)},r=function(t){n(t),e.complete("fail")};V=function(e,t){return e?void r(e):void i(t)},t({event:"payment_request_apple_pay_get_prime",parameter:a})}).catch(function(e){try{i.complete("fail")}catch(e){console.log(e)}e||(e={message:"[TapPay]: Apple Pay error"}),n({status:401,msg:e.message})})},o}(0,void 0),e.TPDirect.linePay=function(n,o){return(o={}).getPrime=function(e){return"function"==typeof e?ee?(B=function(t,n){0!==t.status&&le(t,n,v),e(t)},void t({event:"line_pay_get_prime",fraud_id:n.getFraudId()})):(le({msg:"[TapPay] body doesnt load pfirame yet"},"getPrime",g,!0),console.error("[TapPay] body doesnt load pfirame yet")):console.error("[TapPay] TPDirect.linePay.getPrime(callback): callback is not a function")},o.pay=function(t){return q(t)?void(e.location=t):console.error("[TapPay] Your payment url is not valid.")},o}(I,void 0),e.TPDirect.samsungPay=function(t,n){var o={has_setup_payment_request:!1,payment_request:{country_code:"tw"},MODAL_SHOWN_CLASS:"tappay-samsung-pay-shown"};return(n={}).setup=function(e){o.payment_request.country_code=e.country_code||"tw"},n.setupPaymentRequest=function(e){var t=e.total;return t&&t.label&&t.amount&&t.amount.currency&&parseFloat(t.amount.value)?o.validateSupportedNetworks(e.supportedNetworks)?(!1===o.has_setup_payment_request&&o.setupDisableScrollingStyle(),o.payment_request.allowed_brands=e.supportedNetworks,o.payment_request.merchant_name=t.label,o.payment_request.currency=t.amount.currency,o.payment_request.amount=parseFloat(t.amount.value),void(o.has_setup_payment_request=!0)):console.error("[TPDirect.samsungPay.setupPaymentRequest] Please check payment request format (supportedNetworks)"):console.error("[TPDirect.samsungPay.setupPaymentRequest] Please check payment request format")},n.getPrime=function(e){return"function"==typeof e?o.has_setup_payment_request?(G=e,void o.setupIframe()):e({status:-5,msg:"[TPDirect.samsungPay.getPrime] Setup Samsung Pay with TPDirect.samsungPay.setupPaymentRequest first"}):console.error("[TapPay] TPDirect.samsungPay.getPrime(callback): callback is not a function")},n.setupSamsungPayButton=function(e,t){if("string"==typeof e&&(e=document.querySelector(e)),!x(e))return console.warn("[TapPay] TPDirect.samsungPay.setupSamsungPayButton: No element to setup.");var n={color:"black",type:"pay",shape:"rectangular"};t||(t=n),t.color||(t.color=n.color),t.type||(t.type=n.type),t.shape||(t.shape=n.shape),-1===["black","white"].indexOf(t.color)&&(console.warn("[TapPay] TPDirect.samsungPay.setupSamsungPayButton: Unknown color option "+t.color),t.color=n.color),-1===["pay","buy"].indexOf(t.type)&&(console.warn("[TapPay] TPDirect.samsungPay.setupSamsungPayButton: Unknown type option "+t.type),t.type=n.type),-1===["rectangular","pill"].indexOf(t.shape)&&(console.warn("[TapPay] TPDirect.samsungPay.setupSamsungPayButton: Unknown shape option "+t.shape),t.shape=n.shape);var o=l+t.type+"_"+t.color+"_"+t.shape+".svg",a=document.createElement("div"),i="background-origin: content-box;background-position: center;background-repeat: no-repeat;background-size: contain;border: 0;outline: 0;height: 100%;min-height: 40px;width: 100%;cursor: pointer;";i+="background-image: url("+o+");",a.setAttribute("style",i),e.appendChild(a)},o.setupIframe=function(){var n={MODE:"",appKey:t.appKey,appID:t.appID,serverType:t._type,hostname:e.location.hostname,origin:e.location.origin,referrer:document.referrer,href:e.location.href,port:e.location.port,protocol:e.location.protocol,sdk_version:ae,payment_request:o.payment_request};(te=document.createElement("iframe")).setAttribute("frameborder","0"),te.setAttribute("allowtransparency","true"),te.setAttribute("style","z-index: 2147483647; display: block; background: rgba(0, 0, 0, 0.004); border: 0px none transparent; overflow-x: hidden; overflow-y: auto; margin: 0px; padding: 0px; -webkit-tap-highlight-color: transparent; position: fixed; left: 0px; top: 0px; width: 100%; height: 100%;"),te.src=c+"?"+encodeURIComponent(JSON.stringify(n)),"complete"===document.readyState||"loaded"===document.readyState||"interactive"===document.readyState?(document.body.appendChild(te),o.addModalShownClass()):document.addEventListener("DOMContentLoaded",function(){document.body.appendChild(te),o.addModalShownClass()})},Y=function(e){o.removeIframe();var t=o.createSDKGetPrimeResult(e);G(t)},o.removeIframe=function(){document.body.removeChild(te),o.removeModalShownClass()},o.setupDisableScrollingStyle=function(){!function(e){var t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e)),t.appendChild(n)}("body."+o.MODAL_SHOWN_CLASS+"{ height: auto; overflow-y: hidden; }html."+o.MODAL_SHOWN_CLASS+"{ height: auto; overflow-y: hidden; }")},o.addModalShownClass=function(){T(document.documentElement,o.MODAL_SHOWN_CLASS),T(document.body,o.MODAL_SHOWN_CLASS)},o.removeModalShownClass=function(){M(document.documentElement,o.MODAL_SHOWN_CLASS),M(document.body,o.MODAL_SHOWN_CLASS)},o.createSDKGetPrimeResult=function(e){return 0===e.status?{status:0,msg:e.msg,prime:e.prime,client_ip:e.client_ip,card:{lastfour:e.card_last_four,type:function(e){if(!e)return null;var t=e.toUpperCase();return void 0===m[t]?null:m[t]}(e.card_type)},total_amount:e.total_amount}:e},o.validateSupportedNetworks=function(e){if(void 0===e)return!0;if("[object Array]"!==Object.prototype.toString.call(e))return!1;if(0===e.length)return!1;for(var t=0;t<e.length;t++){var n=e[t];if(!("string"==typeof n||n instanceof String)||""===n)return!1}return!0},n}(I,void 0),e.TPDirect.googlePay=new A(I),e.TPDirect.validate=function(){var t={amex:/^3[47]\d{0,13}/,mastercard:/(^(5[1-5]|2[3-6])\d{0,14})|^(((222[1-9])|(2720))\d{0,12})|^(((22[3-9])|(27[0-1]))\d{0,13})/,jcb:/^(?:2131|1800|35\d{0,2})\d{0,12}/,visa:/^4\d{0,15}/},n={amex:"AMEX",mastercard:"MASTERCARD",jcb:"JCB",visa:"VISA"};return{cardNumber:function(e,t){return e=(e+"").replace(/\s+|-/g,""),void 0===t?/^\d{15,16}$/.test(e)&&this.luhnCheck(e):"AMEX"===t?/^\d{15}$/.test(e)&&this.luhnCheck(e):/^\d{16}$/.test(e)&&this.luhnCheck(e)},ccv:function(e,t){return void 0===t?/^\d{3,4}$/.test(e):"AMEX"===t?/^\d{4}$/.test(e):/^\d{3}$/.test(e)},expiry:function(e,t){var n,o,a=e;return t+="",!!/^\d+$/.test(a+="")&&!!/^\d+$/.test(t)&&1<=a&&12>=a&&(2===t.length&&(t=70>t?"20"+t:"19"+t),4===t.length&&(o=new Date(t,a),n=new Date,o.setMonth(o.getMonth()-1),o.setMonth(o.getMonth()+1,1),o>n))},luhnCheck:function(e){var t,n,o,a,i,r;for(o=!0,a=0,i=0,r=(n=(e+"").split("").reverse()).length;i<r;i++)t=n[i],t=parseInt(t,10),(o=!o)&&(t*=2),9<t&&(t-=9),a+=t;return 0==a%10},cardType:function(e){for(var o in t)if(!0===t[o].test(e))return n[o];return"Unknown"},sdkError:function(){return!e.TPDirect.isDoubleLoaded&&L}}}())}(window)}]);