Skip to content

Commit

Permalink
update getPayPalDomain function
Browse files Browse the repository at this point in the history
  • Loading branch information
yeul committed Sep 5, 2023
1 parent cffc963 commit 45f4e68
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/utils/sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,20 @@ export const isScriptBeingDestroyed = () => {
};

export function getPayPalDomain() {
const testEnviroment = window.__TEST_ENV__ ?? __MESSAGES__.__TEST_ENV__;
if (testEnviroment && getEnv() !== 'production' && getEnv() !== 'sandbox') {
return testEnviroment;
} else if (__MESSAGES__.__TARGET__ === 'SDK') {
if (getEnv() !== 'production' && getEnv() !== 'sandbox') {
const testEnviroment = window.__TEST_ENV__ ?? __MESSAGES__.__TEST_ENV__;

if (testEnviroment) {
return testEnviroment;
}

// eslint-disable-next-line security/detect-unsafe-regex
if (window.location.origin.match(/\.paypal\.com(:\d+)?$/)) {
return window.location.origin;
}
}

if (__MESSAGES__.__TARGET__ === 'SDK') {
return getSDKPayPalDomain();
} else {
const domain = __MESSAGES__.__DOMAIN__[`__${getEnv().toUpperCase()}__`];
Expand Down

0 comments on commit 45f4e68

Please sign in to comment.