From 2a9545decbb000b4608861bd75cd25267acb902f Mon Sep 17 00:00:00 2001 From: Mervin Choun Date: Wed, 9 Oct 2024 15:37:51 -0400 Subject: [PATCH 01/10] chore: prettier --- src/zoid/card-fields/component.jsx | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/zoid/card-fields/component.jsx b/src/zoid/card-fields/component.jsx index 6620432e4..349107a29 100644 --- a/src/zoid/card-fields/component.jsx +++ b/src/zoid/card-fields/component.jsx @@ -48,11 +48,11 @@ const CARD_FIELD_TYPE = { }; type InstallmentsConfiguration = {| - financingCountryCode : string, - currencyCode : string, - billingCountryCode : string, - amount : string, - includeBuyerInstallments ? : boolean + financingCountryCode: string, + currencyCode: string, + billingCountryCode: string, + amount: string, + includeBuyerInstallments?: boolean, |}; type CardFieldsProps = {| @@ -109,10 +109,12 @@ type CardFieldsProps = {| hcfSessionID: string, partnerAttributionID: string, merchantID: $ReadOnlyArray, - installments? : {| - onInstallmentsRequested : () => InstallmentsConfiguration | ZalgoPromise, - onInstallmentsAvailable : (Object) => void, - onInstallmentsError? : (Object) => void + installments?: {| + onInstallmentsRequested: () => + | InstallmentsConfiguration + | ZalgoPromise, + onInstallmentsAvailable: (Object) => void, + onInstallmentsError?: (Object) => void, |}, |}; @@ -445,7 +447,7 @@ export const getCardFieldsComponent: () => CardFieldsComponent = memoize( installments: { type: "object", required: false, - value: ({ props }) => props.parent.props.installments + value: ({ props }) => props.parent.props.installments, }, }, }); From dd3c570a1220eb14174bc934e463b8b6197e5ef3 Mon Sep 17 00:00:00 2001 From: Mervin Choun Date: Thu, 10 Oct 2024 15:21:05 -0400 Subject: [PATCH 02/10] allow three-domain-secure component --- __sdk__.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/__sdk__.js b/__sdk__.js index b80858180..e40a140f3 100644 --- a/__sdk__.js +++ b/__sdk__.js @@ -93,4 +93,7 @@ module.exports = { "shopper-insights": { entry: "./src/shopper-insights/interface", }, + "three-domain-secure": { + entry: "./src/three-domain-secure/interface", + }, }; From 673d98dc88c3714320b2c2f82b331c1794186ce2 Mon Sep 17 00:00:00 2001 From: Mervin Choun Date: Tue, 15 Oct 2024 14:08:38 -0400 Subject: [PATCH 03/10] refactor threedomainsecure component to class --- src/three-domain-secure/component.jsx | 70 ++++++++++++++++++--------- src/three-domain-secure/interface.js | 23 ++++++--- 2 files changed, 63 insertions(+), 30 deletions(-) diff --git a/src/three-domain-secure/component.jsx b/src/three-domain-secure/component.jsx index 164b06af4..a160570f1 100644 --- a/src/three-domain-secure/component.jsx +++ b/src/three-domain-secure/component.jsx @@ -1,30 +1,52 @@ /* @flow */ -import { getLogger, getSDKToken } from "@paypal/sdk-client/src"; +import { type LoggerType } from "@krakenjs/beaver-logger/src"; import { FPTI_KEY } from "@paypal/sdk-constants/src"; import { ValidationError } from "../lib"; -export const getThreeDomainSecure = (): Function => { - const sdkToken = getSDKToken(); - const ThreeDomainSecureAuth = () => { - if (sdkToken) { - // eslint-disable-next-line no-console - console.log("Three Domain Secure Called"); - // Make a Zoid component and introduce methods here - // onSuccess - // onCancel - // onClose - getLogger() - .info("three domain secure v2 invoked") - .track({ - [FPTI_KEY.TRANSITION]: "three_DS_auth_v2", - }); - } else { - throw new ValidationError( - `script data attribute sdk-client-token is required but was not passed` - ); - } - }; - - return ThreeDomainSecureAuth; +type SdkConfig = {| + sdkToken: ?string, +|}; + +const parseSdkConfig = ({ sdkConfig, logger }): SdkConfig => { + if (!sdkConfig.sdkToken) { + throw new ValidationError( + `script data attribute sdk-client-token is required but was not passed` + ); + } + + logger.info("three domain secure v2 invoked").track({ + [FPTI_KEY.TRANSITION]: "three_DS_auth_v2", + }); + + return sdkConfig; }; +export interface ThreeDomainSecureComponentInterface { + isEligibile(): void; + show(): void; +} +export class ThreeDomainSecureComponent { + logger: LoggerType; + sdkConfig: SdkConfig; + + constructor({ + logger, + sdkConfig, + }: {| + logger: LoggerType, + sdkConfig: SdkConfig, + |}) { + this.logger = logger; + this.sdkConfig = parseSdkConfig({ sdkConfig, logger }); + } + + isEligibile() { + // eslint-disable-next-line no-console + console.log("Eligble"); + } + + show() { + // eslint-disable-next-line no-console + console.log("show"); + } +} diff --git a/src/three-domain-secure/interface.js b/src/three-domain-secure/interface.js index 479321e0c..0f029a778 100644 --- a/src/three-domain-secure/interface.js +++ b/src/three-domain-secure/interface.js @@ -1,13 +1,24 @@ /* @flow */ +import { getLogger, getSDKToken } from "@paypal/sdk-client/src"; import { type ZoidComponent } from "@krakenjs/zoid/src"; import type { LazyExport } from "../types"; import { protectedExport } from "../lib"; -import { getThreeDomainSecure } from "./component"; +import { + ThreeDomainSecureComponent, + type ThreeDomainSecureComponentInterface, +} from "./component"; -type ThreeDomainSecureAuth = ZoidComponent; - -export const ThreeDomainSecureComponent: LazyExport = { - __get__: () => protectedExport(getThreeDomainSecure()), -}; +export const ThreeDomainSecureClient: LazyExport = + { + __get__: () => + protectedExport( + new ThreeDomainSecureComponent({ + logger: getLogger(), + sdkConfig: { + sdkToken: getSDKToken(), + }, + }) + ), + }; From 71c81273c1b1648b5ad42487ab008e93f34262f6 Mon Sep 17 00:00:00 2001 From: Mervin Choun Date: Wed, 16 Oct 2024 14:58:35 -0400 Subject: [PATCH 04/10] correct typo --- src/three-domain-secure/component.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/three-domain-secure/component.jsx b/src/three-domain-secure/component.jsx index a160570f1..ac01adc09 100644 --- a/src/three-domain-secure/component.jsx +++ b/src/three-domain-secure/component.jsx @@ -22,7 +22,7 @@ const parseSdkConfig = ({ sdkConfig, logger }): SdkConfig => { return sdkConfig; }; export interface ThreeDomainSecureComponentInterface { - isEligibile(): void; + isEligible(): void; show(): void; } export class ThreeDomainSecureComponent { @@ -40,9 +40,9 @@ export class ThreeDomainSecureComponent { this.sdkConfig = parseSdkConfig({ sdkConfig, logger }); } - isEligibile() { + isEligible() { // eslint-disable-next-line no-console - console.log("Eligble"); + console.log("eligible"); } show() { From 62afa53b4064d82ea2a9e2e69cd58ccd9d10d965 Mon Sep 17 00:00:00 2001 From: Mervin Choun Date: Wed, 16 Oct 2024 16:30:00 -0400 Subject: [PATCH 05/10] refactor test for class component --- src/three-domain-secure/component.test.js | 78 ++++++++++++++--------- 1 file changed, 48 insertions(+), 30 deletions(-) diff --git a/src/three-domain-secure/component.test.js b/src/three-domain-secure/component.test.js index 92f503314..748d1a011 100644 --- a/src/three-domain-secure/component.test.js +++ b/src/three-domain-secure/component.test.js @@ -4,41 +4,59 @@ import { getSDKToken } from "@paypal/sdk-client/src"; import { ValidationError } from "../lib"; -import { getThreeDomainSecure } from "./component"; +import { + ThreeDomainSecureComponent, + type ThreeDomainSecureComponentInterface, +} from "./component"; -vi.mock("@paypal/sdk-client/src", () => ({ - getSDKToken: vi.fn(), - getLogger: vi.fn(() => ({ +const defaultSdkConfig = { + sdkToken: "sdk-client-token", +}; + +const createThreeDomainSecureComponent = ( + sdkConfig = defaultSdkConfig, + logger = { info: vi.fn().mockReturnThis(), + warn: vi.fn().mockReturnThis(), + error: vi.fn().mockReturnThis(), track: vi.fn().mockReturnThis(), - flush: vi.fn().mockReturnThis(), - })), -})); -vi.mock("../lib", () => ({ - ValidationError: vi.fn(), -})); -describe("getThreeDomainSecure returns ThreeDomainSecureComponent", () => { - it("should throw an error if sdkToken is not present", () => { - // $FlowFixMe prop missing error - getSDKToken.mockReturnValue(undefined); - const ThreeDomainSecureComponent = getThreeDomainSecure(); - expect(() => ThreeDomainSecureComponent()).toThrowError(ValidationError); - expect(ValidationError).toHaveBeenCalledWith( - `script data attribute sdk-client-token is required but was not passed` - ); + metricCounter: vi.fn().mockReturnThis(), + } +) => + new ThreeDomainSecureComponent({ + sdkConfig, + logger, + }); + +describe("three domain secure component - isEligible method", () => { + test("should console log eligible", () => { + const consoleSpy = vi.spyOn(console, "log"); + const threeDomainSecuretClient = createThreeDomainSecureComponent(); + threeDomainSecuretClient.isEligible(); + expect(consoleSpy).toHaveBeenCalledWith("eligible"); }); - it("should return the ThreeDomainSecure component and log the correct message", async () => { - // eslint-disable-next-line no-empty-function - const consoleSpy = vi.spyOn(console, "log").mockImplementation(() => {}); - // $FlowFixMe prop missing error - getSDKToken.mockReturnValue("84ghb8984"); - const ThreeDomainSecureComponent = getThreeDomainSecure(); - expect(typeof ThreeDomainSecureComponent).toBe("function"); +}); - // Call the returned component and check the console log - await ThreeDomainSecureComponent(); - expect(consoleSpy).toHaveBeenCalledWith("Three Domain Secure Called"); +describe("three domain descure component - show method", () => { + test("should console log show", () => { + const consoleSpy = vi.spyOn(console, "log"); + const threeDomainSecuretClient = createThreeDomainSecureComponent(); + threeDomainSecuretClient.show(); + expect(consoleSpy).toHaveBeenCalledWith("show"); + }); +}); - consoleSpy.mockRestore(); +describe("three domain secure component - initialization", () => { + test("should throw an error if sdkToken is not present", () => { + expect(() => + createThreeDomainSecureComponent({ + sdkConfig: { + ...defaultSdkConfig, + sdkToken: "", + }, + }) + ).toThrowError( + `script data attribute sdk-client-token is required but was not passed` + ); }); }); From 89020d4f075ee245d9b1f970260347fd12884d99 Mon Sep 17 00:00:00 2001 From: Mervin Choun Date: Wed, 16 Oct 2024 16:57:28 -0400 Subject: [PATCH 06/10] chore: fix lint --- dist/button.js | 2 +- dist/test/button.js | 2 +- src/three-domain-secure/component.test.js | 10 ++-------- src/three-domain-secure/interface.js | 1 - 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/dist/button.js b/dist/button.js index 85dea6b5a..4c3a4b1fc 100644 --- a/dist/button.js +++ b/dist/button.js @@ -1,2 +1,2 @@ /*! For license information please see button.js.LICENSE.txt */ -module.exports=function(n){var e={};function t(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return n[o].call(r.exports,r,r.exports,t),r.l=!0,r.exports}return t.m=n,t.c=e,t.d=function(n,e,o){t.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:o})},t.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},t.t=function(n,e){if(1&e&&(n=t(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var o=Object.create(null);if(t.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var r in n)t.d(o,r,function(e){return n[e]}.bind(null,r));return o},t.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(e,"a",e),e},t.o=function(n,e){return{}.hasOwnProperty.call(n,e)},t.p="",t(t.s=14)}([function(n,e,t){"use strict";n.exports=function(n){var e=[];return e.toString=function(){return this.map((function(e){var t=function(n,e){var t,o,r=n[1]||"",l=n[3];if(!l)return r;if(e&&"function"==typeof btoa){var a=(t=btoa(unescape(encodeURIComponent(JSON.stringify(l)))),o="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(t),"/*# ".concat(o," */")),i=l.sources.map((function(n){return"/*# sourceURL=".concat(l.sourceRoot||"").concat(n," */")}));return[r].concat(i).concat([a]).join("\n")}return[r].join("\n")}(e,n);return e[2]?"@media ".concat(e[2]," {").concat(t,"}"):t})).join("")},e.i=function(n,t,o){"string"==typeof n&&(n=[[null,n,""]]);var r={};if(o)for(var l=0;l1?new l(e):void 0}(this.component(this.props,this.children));if(e)return e.render(n)},e.render=function(n){return n(this)},e.renderChildren=function(n){return o(this.children,n)},n}();function u(n){for(var e=[],t=0;t2?t-2:0),l=2;l=0||(r[t]=n[t]);return r}var w={br:!0};function T(n){return n.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")}function O(n){var e=n.css,t=n.nonce,o=n.children;return s(f,null,s("style",{innerHTML:"string"==typeof e?e:e._getCss(),nonce:t}),o)}var M={PAYPAL:"paypal",VENMO:"venmo",APPLEPAY:"applepay",ITAU:"itau",CREDIT:"credit",PAYLATER:"paylater",CARD:"card",IDEAL:"ideal",SEPA:"sepa",BANCONTACT:"bancontact",GIROPAY:"giropay",SOFORT:"sofort",EPS:"eps",MYBANK:"mybank",P24:"p24",PAYU:"payu",BLIK:"blik",TRUSTLY:"trustly",OXXO:"oxxo",BOLETO:"boleto",BOLETOBANCARIO:"boletobancario",WECHATPAY:"wechatpay",MERCADOPAGO:"mercadopago",MULTIBANCO:"multibanco",SATISPAY:"satispay",PAIDY:"paidy",ZIMPLER:"zimpler",MAXIMA:"maxima"},E=[M.IDEAL,M.BANCONTACT,M.GIROPAY,M.SOFORT,M.EPS,M.MYBANK,M.P24,M.PAYU,M.BLIK,M.TRUSTLY,M.OXXO,M.BOLETO,M.BOLETOBANCARIO,M.WECHATPAY,M.MERCADOPAGO,M.MULTIBANCO,M.SATISPAY,M.PAIDY,M.MAXIMA,M.ZIMPLER],A={AD:"AD",AE:"AE",AG:"AG",AI:"AI",AL:"AL",AM:"AM",AN:"AN",AO:"AO",AR:"AR",AT:"AT",AU:"AU",AW:"AW",AZ:"AZ",BA:"BA",BB:"BB",BE:"BE",BF:"BF",BG:"BG",BH:"BH",BI:"BI",BJ:"BJ",BM:"BM",BN:"BN",BO:"BO",BR:"BR",BS:"BS",BT:"BT",BW:"BW",BY:"BY",BZ:"BZ",CA:"CA",CD:"CD",CG:"CG",CH:"CH",CI:"CI",CK:"CK",CL:"CL",CM:"CM",CN:"CN",CO:"CO",CR:"CR",CV:"CV",CY:"CY",CZ:"CZ",DE:"DE",DJ:"DJ",DK:"DK",DM:"DM",DO:"DO",DZ:"DZ",EC:"EC",EE:"EE",EG:"EG",ER:"ER",ES:"ES",ET:"ET",FI:"FI",FJ:"FJ",FK:"FK",FM:"FM",FO:"FO",FR:"FR",GA:"GA",GB:"GB",GD:"GD",GE:"GE",GF:"GF",GI:"GI",GL:"GL",GM:"GM",GN:"GN",GP:"GP",GR:"GR",GT:"GT",GW:"GW",GY:"GY",HK:"HK",HN:"HN",HR:"HR",HU:"HU",ID:"ID",IE:"IE",IL:"IL",IN:"IN",IS:"IS",IT:"IT",JM:"JM",JO:"JO",JP:"JP",KE:"KE",KG:"KG",KH:"KH",KI:"KI",KM:"KM",KN:"KN",KR:"KR",KW:"KW",KY:"KY",KZ:"KZ",LA:"LA",LC:"LC",LI:"LI",LK:"LK",LS:"LS",LT:"LT",LU:"LU",LV:"LV",MA:"MA",MC:"MC",MD:"MD",ME:"ME",MG:"MG",MH:"MH",MK:"MK",ML:"ML",MN:"MN",MQ:"MQ",MR:"MR",MS:"MS",MT:"MT",MU:"MU",MV:"MV",MW:"MW",MX:"MX",MY:"MY",MZ:"MZ",NA:"NA",NC:"NC",NE:"NE",NF:"NF",NG:"NG",NI:"NI",NL:"NL",NO:"NO",NP:"NP",NR:"NR",NU:"NU",NZ:"NZ",OM:"OM",PA:"PA",PE:"PE",PF:"PF",PG:"PG",PH:"PH",PL:"PL",PM:"PM",PN:"PN",PT:"PT",PW:"PW",PY:"PY",QA:"QA",RE:"RE",RO:"RO",RS:"RS",RU:"RU",RW:"RW",SA:"SA",SB:"SB",SC:"SC",SE:"SE",SG:"SG",SH:"SH",SI:"SI",SJ:"SJ",SK:"SK",SL:"SL",SM:"SM",SN:"SN",SO:"SO",SR:"SR",ST:"ST",SV:"SV",SZ:"SZ",TC:"TC",TD:"TD",TG:"TG",TH:"TH",TJ:"TJ",TM:"TM",TN:"TN",TO:"TO",TR:"TR",TT:"TT",TV:"TV",TW:"TW",TZ:"TZ",UA:"UA",UG:"UG",US:"US",UY:"UY",VA:"VA",VC:"VC",VE:"VE",VG:"VG",VN:"VN",VU:"VU",WF:"WF",WS:"WS",YE:"YE",YT:"YT",ZA:"ZA",ZM:"ZM",ZW:"ZW"},x={AD:["en","fr","es","zh"],AE:["en","fr","es","zh","ar"],AG:["en","fr","es","zh"],AI:["en","fr","es","zh"],AL:["sq","en"],AM:["en","fr","es","zh"],AN:["en","fr","es","zh"],AO:["en","fr","es","zh"],AR:["es","en"],AT:["de","en"],AU:["en"],AW:["en","fr","es","zh"],AZ:["en","fr","es","zh"],BA:["en"],BB:["en","fr","es","zh"],BE:["en","nl","fr"],BF:["fr","en","es","zh"],BG:["bg","en"],BH:["ar","en","fr","es","zh"],BI:["fr","en","es","zh"],BJ:["fr","en","es","zh"],BM:["en","fr","es","zh"],BN:["ms","en"],BO:["es","en","fr","zh"],BR:["pt","en"],BS:["en","fr","es","zh"],BT:["en"],BW:["en","fr","es","zh"],BY:["en"],BZ:["en","es","fr","zh"],CA:["en","fr"],CD:["fr","en","es","zh"],CG:["en","fr","es","zh"],CH:["de","fr","en"],CI:["fr","en"],CK:["en","fr","es","zh"],CL:["es","en","fr","zh"],CM:["fr","en"],CN:["zh"],CO:["es","en","fr","zh"],CR:["es","en","fr","zh"],CV:["en","fr","es","zh"],CY:["en"],CZ:["cs","en"],DE:["de","en"],DJ:["fr","en","es","zh"],DK:["da","en"],DM:["en","fr","es","zh"],DO:["es","en","fr","zh"],DZ:["ar","en","fr","es","zh"],EC:["es","en","fr","zh"],EE:["et","en","ru"],EG:["ar","en","fr","es","zh"],ER:["en","fr","es","zh"],ES:["es","en"],ET:["en","fr","es","zh"],FI:["fi","en"],FJ:["en","fr","es","zh"],FK:["en","fr","es","zh"],FM:["en"],FO:["da","en","fr","es","zh"],FR:["fr","en"],GA:["fr","en","es","zh"],GB:["en"],GD:["en","fr","es","zh"],GE:["en","fr","es","zh"],GF:["en","fr","es","zh"],GI:["en","fr","es","zh"],GL:["da","en","fr","es","zh"],GM:["en","fr","es","zh"],GN:["fr","en","es","zh"],GP:["en","fr","es","zh"],GR:["el","en"],GT:["es","en","fr","zh"],GW:["en","fr","es","zh"],GY:["en","fr","es","zh"],HK:["en","zh_Hant","zh"],HN:["es","en","fr","zh"],HR:["en"],HU:["hu","en"],ID:["id","en"],IE:["en","fr","es","zh"],IL:["he","en"],IN:["en"],IS:["en"],IT:["it","en"],JM:["en","es","fr","zh"],JO:["ar","en","fr","es","zh"],JP:["ja","en"],KE:["en","fr","es","zh"],KG:["en","fr","es","zh"],KH:["en"],KI:["en","fr","es","zh"],KM:["fr","en","es","zh"],KN:["en","fr","es","zh"],KR:["ko","en"],KW:["ar","en","fr","es","zh"],KY:["en","fr","es","zh"],KZ:["en","fr","es","zh"],LA:["en"],LC:["en","fr","es","zh"],LI:["en","fr","es","zh"],LK:["si","en"],LS:["en","fr","es","zh"],LT:["lt","en","ru","zh"],LU:["en","de","fr","es","zh"],LV:["lv","en","ru"],MA:["ar","en","fr","es","zh"],MC:["fr","en"],MD:["en"],ME:["en"],MG:["en","fr","es","zh"],MH:["en","fr","es","zh"],MK:["en"],ML:["fr","en","es","zh"],MN:["en"],MQ:["en","fr","es","zh"],MR:["en","fr","es","zh"],MS:["en","fr","es","zh"],MT:["en"],MU:["en","fr","es","zh"],MV:["en"],MW:["en","fr","es","zh"],MX:["es","en"],MY:["ms","en"],MZ:["en","fr","es","zh"],NA:["en","fr","es","zh"],NC:["en","fr","es","zh"],NE:["fr","en","es","zh"],NF:["en","fr","es","zh"],NG:["en"],NI:["es","en","fr","zh"],NL:["nl","en"],NO:["no","en"],NP:["en"],NR:["en","fr","es","zh"],NU:["en","fr","es","zh"],NZ:["en","fr","es","zh"],OM:["ar","en","fr","es","zh"],PA:["es","en","fr","zh"],PE:["es","en","fr","zh"],PF:["en","fr","es","zh"],PG:["en","fr","es","zh"],PH:["tl","en"],PL:["pl","en"],PM:["en","fr","es","zh"],PN:["en","fr","es","zh"],PT:["pt","en"],PW:["en","fr","es","zh"],PY:["es","en"],QA:["en","fr","es","zh","ar"],RE:["en","fr","es","zh"],RO:["ro","en"],RS:["en","fr","es","zh"],RU:["ru","en"],RW:["fr","en","es","zh"],SA:["ar","en","fr","es","zh"],SB:["en","fr","es","zh"],SC:["fr","en","es","zh"],SE:["sv","en"],SG:["en"],SH:["en","fr","es","zh"],SI:["sl","en"],SJ:["en","fr","es","zh"],SK:["sk","en"],SL:["en","fr","es","zh"],SM:["en","fr","es","zh"],SN:["fr","en","es","zh"],SO:["en","fr","es","zh"],SR:["en","fr","es","zh"],ST:["en","fr","es","zh"],SV:["es","en","fr","zh"],SZ:["en","fr","es","zh"],TC:["en","fr","es","zh"],TD:["fr","en","es","zh"],TG:["fr","en","es","zh"],TH:["th","en"],TJ:["en","fr","es","zh"],TM:["en","fr","es","zh"],TN:["ar","en","fr","es","zh"],TO:["en"],TR:["tr","en"],TT:["en","fr","es","zh"],TV:["en","fr","es","zh"],TW:["zh_Hant","zh","en"],TZ:["en","fr","es","zh"],UA:["en","ru","fr","es","zh"],UG:["en","fr","es","zh"],US:["en","fr","es","zh"],UY:["es","en","fr","zh"],VA:["en","fr","es","zh"],VC:["en","fr","es","zh"],VE:["es","en","fr","zh"],VG:["en","fr","es","zh"],VN:["vi","en"],VU:["en","fr","es","zh"],WF:["en","fr","es","zh"],WS:["en"],YE:["ar","en","fr","es","zh"],YT:["en","fr","es","zh"],ZA:["en","fr","es","zh"],ZM:["en","fr","es","zh"],ZW:["en"]},H={LOCAL:"local",STAGE:"stage",SANDBOX:"sandbox",PRODUCTION:"production",TEST:"test"},N={DESKTOP:"desktop",MOBILE:"mobile"};function B(n,e){return(B=Object.setPrototypeOf||function(n,e){return n.__proto__=e,n})(n,e)}function F(n,e){n.prototype=Object.create(e.prototype),n.prototype.constructor=n,B(n,e)}function V(n){try{if(!n)return!1;if("undefined"!=typeof Promise&&n instanceof Promise)return!0;if("undefined"!=typeof window&&"function"==typeof window.Window&&n instanceof window.Window)return!1;if("undefined"!=typeof window&&"function"==typeof window.constructor&&n instanceof window.constructor)return!1;var e={}.toString;if(e){var t=e.call(n);if("[object Window]"===t||"[object global]"===t||"[object DOMWindow]"===t)return!1}if("function"==typeof n.then)return!0}catch(n){return!1}return!1}var S,R=[],P=[],k=0;function Z(){if(!k&&S){var n=S;S=null,n.resolve()}}function _(){k+=1}function U(){k-=1,Z()}var I=function(){function n(n){var e=this;if(this.resolved=void 0,this.rejected=void 0,this.errorHandled=void 0,this.value=void 0,this.error=void 0,this.handlers=void 0,this.dispatching=void 0,this.stack=void 0,this.resolved=!1,this.rejected=!1,this.errorHandled=!1,this.handlers=[],n){var t,o,r=!1,l=!1,a=!1;_();try{n((function(n){a?e.resolve(n):(r=!0,t=n)}),(function(n){a?e.reject(n):(l=!0,o=n)}))}catch(n){return U(),void this.reject(n)}U(),a=!0,r?this.resolve(t):l&&this.reject(o)}}var e=n.prototype;return e.resolve=function(n){if(this.resolved||this.rejected)return this;if(V(n))throw new Error("Can not resolve promise with another promise");return this.resolved=!0,this.value=n,this.dispatch(),this},e.reject=function(n){var e=this;if(this.resolved||this.rejected)return this;if(V(n))throw new Error("Can not reject promise with another promise");if(!n){var t=n&&"function"==typeof n.toString?n.toString():{}.toString.call(n);n=new Error("Expected reject to be called with Error, got "+t)}return this.rejected=!0,this.error=n,this.errorHandled||setTimeout((function(){e.errorHandled||function(n,e){if(-1===R.indexOf(n)){R.push(n),setTimeout((function(){throw n}),1);for(var t=0;t>>0)+"__",function(){if("undefined"==typeof WeakMap)return!1;if(void 0===Object.freeze)return!1;try{var n=new WeakMap,e={};return Object.freeze(e),n.set(e,"__testvalue__"),"__testvalue__"===n.get(e)}catch(n){return!1}}())try{this.weakmap=new WeakMap}catch(n){}this.keys=[],this.values=[]}var e=n.prototype;return e._cleanupClosedWindows=function(){for(var n=this.weakmap,e=this.keys,t=0;t=3)return"stringifyError stack overflow";try{if(!e)return"";if("string"==typeof e)return e;if(e instanceof Error){var o=e&&e.stack,r=e&&e.message;if(o&&r)return-1!==o.indexOf(r)?o:r+"\n"+o;if(o)return o;if(r)return r}return e&&e.toString&&"function"==typeof e.toString?e.toString():{}.toString.call(e)}catch(e){return"Error while stringifying error: "+n(e,t+1)}}(t):"";return new Error('PayPal Payments SDK script not found on page! Expected to find