@paypal/paypal-js
Advanced tools
Comparing version 5.1.6 to 6.0.0
/*! | ||
* paypal-js v5.1.6 (2023-03-27T20:51:02.623Z) | ||
* paypal-js v6.0.0 (2023-06-02T19:54:59.307Z) | ||
* Copyright 2020-present, PayPal, Inc. All rights reserved. | ||
@@ -49,17 +49,18 @@ * | ||
function processOptions(options) { | ||
var sdkBaseURL = "https://www.paypal.com/sdk/js"; | ||
if (options.sdkBaseURL) { | ||
sdkBaseURL = options.sdkBaseURL; | ||
delete options.sdkBaseURL; | ||
var sdkBaseUrl = "https://www.paypal.com/sdk/js"; | ||
if (options.sdkBaseUrl) { | ||
sdkBaseUrl = options.sdkBaseUrl; | ||
delete options.sdkBaseUrl; | ||
} | ||
processMerchantID(options); | ||
var _a = Object.keys(options) | ||
var optionsWithStringIndex = options; | ||
var _a = Object.keys(optionsWithStringIndex) | ||
.filter(function (key) { | ||
return (typeof options[key] !== "undefined" && | ||
options[key] !== null && | ||
options[key] !== ""); | ||
return (typeof optionsWithStringIndex[key] !== "undefined" && | ||
optionsWithStringIndex[key] !== null && | ||
optionsWithStringIndex[key] !== ""); | ||
}) | ||
.reduce(function (accumulator, key) { | ||
var value = options[key].toString(); | ||
if (key.substring(0, 5) === "data-") { | ||
var value = optionsWithStringIndex[key].toString(); | ||
key = camelCaseToKebabCase(key); | ||
if (key.substring(0, 4) === "data") { | ||
accumulator.dataAttributes[key] = value; | ||
@@ -75,7 +76,18 @@ } | ||
}), queryParams = _a.queryParams, dataAttributes = _a.dataAttributes; | ||
if (queryParams["merchant-id"] && | ||
queryParams["merchant-id"].indexOf(",") !== -1) { | ||
dataAttributes["data-merchant-id"] = queryParams["merchant-id"]; | ||
queryParams["merchant-id"] = "*"; | ||
} | ||
return { | ||
url: "".concat(sdkBaseURL, "?").concat(objectToQueryString(queryParams)), | ||
url: "".concat(sdkBaseUrl, "?").concat(objectToQueryString(queryParams)), | ||
dataAttributes: dataAttributes, | ||
}; | ||
} | ||
function camelCaseToKebabCase(str) { | ||
var replacer = function (match, indexOfMatch) { | ||
return (indexOfMatch ? "-" : "") + match.toLowerCase(); | ||
}; | ||
return str.replace(/[A-Z]+(?![a-z])|[A-Z]/g, replacer); | ||
} | ||
function objectToQueryString(params) { | ||
@@ -116,27 +128,2 @@ var queryString = ""; | ||
} | ||
function processMerchantID(options) { | ||
var merchantID = options["merchant-id"], dataMerchantID = options["data-merchant-id"]; | ||
var newMerchantID = ""; | ||
var newDataMerchantID = ""; | ||
if (Array.isArray(merchantID)) { | ||
if (merchantID.length > 1) { | ||
newMerchantID = "*"; | ||
newDataMerchantID = merchantID.toString(); | ||
} | ||
else { | ||
newMerchantID = merchantID.toString(); | ||
} | ||
} | ||
else if (typeof merchantID === "string" && merchantID.length > 0) { | ||
newMerchantID = merchantID; | ||
} | ||
else if (typeof dataMerchantID === "string" && | ||
dataMerchantID.length > 0) { | ||
newMerchantID = "*"; | ||
newDataMerchantID = dataMerchantID; | ||
} | ||
options["merchant-id"] = newMerchantID; | ||
options["data-merchant-id"] = newDataMerchantID; | ||
return options; | ||
} | ||
@@ -151,3 +138,3 @@ /** | ||
function loadScript(options, PromisePonyfill) { | ||
if (PromisePonyfill === void 0) { PromisePonyfill = getDefaultPromiseImplementation(); } | ||
if (PromisePonyfill === void 0) { PromisePonyfill = Promise; } | ||
validateArguments(options, PromisePonyfill); | ||
@@ -183,3 +170,3 @@ // resolve with null when running in Node or Deno | ||
function loadCustomScript(options, PromisePonyfill) { | ||
if (PromisePonyfill === void 0) { PromisePonyfill = getDefaultPromiseImplementation(); } | ||
if (PromisePonyfill === void 0) { PromisePonyfill = Promise; } | ||
validateArguments(options, PromisePonyfill); | ||
@@ -225,8 +212,2 @@ var url = options.url, attributes = options.attributes; | ||
} | ||
function getDefaultPromiseImplementation() { | ||
if (typeof Promise === "undefined") { | ||
throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill."); | ||
} | ||
return Promise; | ||
} | ||
function getPayPalWindowNamespace(namespace) { | ||
@@ -247,3 +228,3 @@ // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
// replaced with the package.json version at build time | ||
var version = "5.1.6"; | ||
var version = "6.0.0"; | ||
@@ -250,0 +231,0 @@ exports.loadCustomScript = loadCustomScript; |
/*! | ||
* paypal-js v5.1.6 (2023-03-27T20:51:02.623Z) | ||
* paypal-js v6.0.0 (2023-06-02T19:54:59.307Z) | ||
* Copyright 2020-present, PayPal, Inc. All rights reserved. | ||
@@ -17,2 +17,2 @@ * | ||
*/ | ||
"use strict";function t(t){var r="https://www.paypal.com/sdk/js";t.sdkBaseURL&&(r=t.sdkBaseURL,delete t.sdkBaseURL),function(t){var e=t["merchant-id"],r=t["data-merchant-id"],n="",o="";Array.isArray(e)?e.length>1?(n="*",o=e.toString()):n=e.toString():"string"==typeof e&&e.length>0?n=e:"string"==typeof r&&r.length>0&&(n="*",o=r);t["merchant-id"]=n,t["data-merchant-id"]=o}(t);var n=Object.keys(t).filter((function(e){return void 0!==t[e]&&null!==t[e]&&""!==t[e]})).reduce((function(e,r){var n=t[r].toString();return"data-"===r.substring(0,5)?e.dataAttributes[r]=n:e.queryParams[r]=n,e}),{queryParams:{},dataAttributes:{}}),o=n.queryParams,a=n.dataAttributes;return{url:"".concat(r,"?").concat(e(o)),dataAttributes:a}}function e(t){var e="";return Object.keys(t).forEach((function(r){0!==e.length&&(e+="&"),e+=r+"="+t[r]})),e}function r(t,e){void 0===e&&(e={});var r=document.createElement("script");return r.src=t,Object.keys(e).forEach((function(t){r.setAttribute(t,e[t]),"data-csp-nonce"===t&&r.setAttribute("nonce",e["data-csp-nonce"])})),r}function n(t,e){void 0===e&&(e=o()),i(t,e);var n=t.url,a=t.attributes;if("string"!=typeof n||0===n.length)throw new Error("Invalid url.");if(void 0!==a&&"object"!=typeof a)throw new Error("Expected attributes to be an object.");return new e((function(t,e){if("undefined"==typeof document)return t();!function(t){var e=t.url,n=t.attributes,o=t.onSuccess,a=t.onError,i=r(e,n);i.onerror=a,i.onload=o,document.head.insertBefore(i,document.head.firstElementChild)}({url:n,attributes:a,onSuccess:function(){return t()},onError:function(){var t=new Error('The script "'.concat(n,'" failed to load.'));return window.fetch?fetch(n).then((function(r){return 200===r.status&&e(t),r.text()})).then((function(t){var r=function(t){var e=t.split("/* Original Error:")[1];return e?e.replace(/\n/g,"").replace("*/","").trim():t}(t);e(new Error(r))})).catch((function(t){e(t)})):e(t)}})}))}function o(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function a(t){return window[t]}function i(t,e){if("object"!=typeof t||null===t)throw new Error("Expected an options object.");if(void 0!==e&&"function"!=typeof e)throw new Error("Expected PromisePonyfill to be a function.")}exports.loadCustomScript=n,exports.loadScript=function(e,u){if(void 0===u&&(u=o()),i(e,u),"undefined"==typeof document)return u.resolve(null);var c=t(e),s=c.url,d=c.dataAttributes,l=d["data-namespace"]||"paypal",f=a(l);return function(t,e){var n=document.querySelector('script[src="'.concat(t,'"]'));if(null===n)return null;var o=r(t,e),a=n.cloneNode();if(delete a.dataset.uidAuto,Object.keys(a.dataset).length!==Object.keys(o.dataset).length)return null;var i=!0;return Object.keys(a.dataset).forEach((function(t){a.dataset[t]!==o.dataset[t]&&(i=!1)})),i?n:null}(s,d)&&f?u.resolve(f):n({url:s,attributes:d},u).then((function(){var t=a(l);if(t)return t;throw new Error("The window.".concat(l," global variable is not available."))}))},exports.version="5.1.6"; | ||
"use strict";function t(t){var e="";return Object.keys(t).forEach((function(r){0!==e.length&&(e+="&"),e+=r+"="+t[r]})),e}function e(t,e){void 0===e&&(e={});var r=document.createElement("script");return r.src=t,Object.keys(e).forEach((function(t){r.setAttribute(t,e[t]),"data-csp-nonce"===t&&r.setAttribute("nonce",e["data-csp-nonce"])})),r}function r(t,r){void 0===r&&(r=Promise),o(t,r);var n=t.url,a=t.attributes;if("string"!=typeof n||0===n.length)throw new Error("Invalid url.");if(void 0!==a&&"object"!=typeof a)throw new Error("Expected attributes to be an object.");return new r((function(t,r){if("undefined"==typeof document)return t();!function(t){var r=t.url,n=t.attributes,o=t.onSuccess,a=t.onError,c=e(r,n);c.onerror=a,c.onload=o,document.head.insertBefore(c,document.head.firstElementChild)}({url:n,attributes:a,onSuccess:function(){return t()},onError:function(){var t=new Error('The script "'.concat(n,'" failed to load.'));return window.fetch?fetch(n).then((function(e){return 200===e.status&&r(t),e.text()})).then((function(t){var e=function(t){var e=t.split("/* Original Error:")[1];return e?e.replace(/\n/g,"").replace("*/","").trim():t}(t);r(new Error(e))})).catch((function(t){r(t)})):r(t)}})}))}function n(t){return window[t]}function o(t,e){if("object"!=typeof t||null===t)throw new Error("Expected an options object.");if(void 0!==e&&"function"!=typeof e)throw new Error("Expected PromisePonyfill to be a function.")}exports.loadCustomScript=r,exports.loadScript=function(a,c){if(void 0===c&&(c=Promise),o(a,c),"undefined"==typeof document)return c.resolve(null);var i=function(e){var r="https://www.paypal.com/sdk/js";e.sdkBaseUrl&&(r=e.sdkBaseUrl,delete e.sdkBaseUrl);var n=e,o=Object.keys(n).filter((function(t){return void 0!==n[t]&&null!==n[t]&&""!==n[t]})).reduce((function(t,e){var r,o=n[e].toString();return r=function(t,e){return(e?"-":"")+t.toLowerCase()},"data"===(e=e.replace(/[A-Z]+(?![a-z])|[A-Z]/g,r)).substring(0,4)?t.dataAttributes[e]=o:t.queryParams[e]=o,t}),{queryParams:{},dataAttributes:{}}),a=o.queryParams,c=o.dataAttributes;return a["merchant-id"]&&-1!==a["merchant-id"].indexOf(",")&&(c["data-merchant-id"]=a["merchant-id"],a["merchant-id"]="*"),{url:"".concat(r,"?").concat(t(a)),dataAttributes:c}}(a),u=i.url,s=i.dataAttributes,d=s["data-namespace"]||"paypal",l=n(d);return function(t,r){var n=document.querySelector('script[src="'.concat(t,'"]'));if(null===n)return null;var o=e(t,r),a=n.cloneNode();if(delete a.dataset.uidAuto,Object.keys(a.dataset).length!==Object.keys(o.dataset).length)return null;var c=!0;return Object.keys(a.dataset).forEach((function(t){a.dataset[t]!==o.dataset[t]&&(c=!1)})),c?n:null}(u,s)&&l?c.resolve(l):r({url:u,attributes:s},c).then((function(){var t=n(d);if(t)return t;throw new Error("The window.".concat(d," global variable is not available."))}))},exports.version="6.0.0"; |
/*! | ||
* paypal-js v5.1.6 (2023-03-27T20:51:02.623Z) | ||
* paypal-js v6.0.0 (2023-06-02T19:54:59.307Z) | ||
* Copyright 2020-present, PayPal, Inc. All rights reserved. | ||
@@ -47,17 +47,18 @@ * | ||
function processOptions(options) { | ||
var sdkBaseURL = "https://www.paypal.com/sdk/js"; | ||
if (options.sdkBaseURL) { | ||
sdkBaseURL = options.sdkBaseURL; | ||
delete options.sdkBaseURL; | ||
var sdkBaseUrl = "https://www.paypal.com/sdk/js"; | ||
if (options.sdkBaseUrl) { | ||
sdkBaseUrl = options.sdkBaseUrl; | ||
delete options.sdkBaseUrl; | ||
} | ||
processMerchantID(options); | ||
var _a = Object.keys(options) | ||
var optionsWithStringIndex = options; | ||
var _a = Object.keys(optionsWithStringIndex) | ||
.filter(function (key) { | ||
return (typeof options[key] !== "undefined" && | ||
options[key] !== null && | ||
options[key] !== ""); | ||
return (typeof optionsWithStringIndex[key] !== "undefined" && | ||
optionsWithStringIndex[key] !== null && | ||
optionsWithStringIndex[key] !== ""); | ||
}) | ||
.reduce(function (accumulator, key) { | ||
var value = options[key].toString(); | ||
if (key.substring(0, 5) === "data-") { | ||
var value = optionsWithStringIndex[key].toString(); | ||
key = camelCaseToKebabCase(key); | ||
if (key.substring(0, 4) === "data") { | ||
accumulator.dataAttributes[key] = value; | ||
@@ -73,7 +74,18 @@ } | ||
}), queryParams = _a.queryParams, dataAttributes = _a.dataAttributes; | ||
if (queryParams["merchant-id"] && | ||
queryParams["merchant-id"].indexOf(",") !== -1) { | ||
dataAttributes["data-merchant-id"] = queryParams["merchant-id"]; | ||
queryParams["merchant-id"] = "*"; | ||
} | ||
return { | ||
url: "".concat(sdkBaseURL, "?").concat(objectToQueryString(queryParams)), | ||
url: "".concat(sdkBaseUrl, "?").concat(objectToQueryString(queryParams)), | ||
dataAttributes: dataAttributes, | ||
}; | ||
} | ||
function camelCaseToKebabCase(str) { | ||
var replacer = function (match, indexOfMatch) { | ||
return (indexOfMatch ? "-" : "") + match.toLowerCase(); | ||
}; | ||
return str.replace(/[A-Z]+(?![a-z])|[A-Z]/g, replacer); | ||
} | ||
function objectToQueryString(params) { | ||
@@ -114,27 +126,2 @@ var queryString = ""; | ||
} | ||
function processMerchantID(options) { | ||
var merchantID = options["merchant-id"], dataMerchantID = options["data-merchant-id"]; | ||
var newMerchantID = ""; | ||
var newDataMerchantID = ""; | ||
if (Array.isArray(merchantID)) { | ||
if (merchantID.length > 1) { | ||
newMerchantID = "*"; | ||
newDataMerchantID = merchantID.toString(); | ||
} | ||
else { | ||
newMerchantID = merchantID.toString(); | ||
} | ||
} | ||
else if (typeof merchantID === "string" && merchantID.length > 0) { | ||
newMerchantID = merchantID; | ||
} | ||
else if (typeof dataMerchantID === "string" && | ||
dataMerchantID.length > 0) { | ||
newMerchantID = "*"; | ||
newDataMerchantID = dataMerchantID; | ||
} | ||
options["merchant-id"] = newMerchantID; | ||
options["data-merchant-id"] = newDataMerchantID; | ||
return options; | ||
} | ||
@@ -149,3 +136,3 @@ /** | ||
function loadScript(options, PromisePonyfill) { | ||
if (PromisePonyfill === void 0) { PromisePonyfill = getDefaultPromiseImplementation(); } | ||
if (PromisePonyfill === void 0) { PromisePonyfill = Promise; } | ||
validateArguments(options, PromisePonyfill); | ||
@@ -181,3 +168,3 @@ // resolve with null when running in Node or Deno | ||
function loadCustomScript(options, PromisePonyfill) { | ||
if (PromisePonyfill === void 0) { PromisePonyfill = getDefaultPromiseImplementation(); } | ||
if (PromisePonyfill === void 0) { PromisePonyfill = Promise; } | ||
validateArguments(options, PromisePonyfill); | ||
@@ -223,8 +210,2 @@ var url = options.url, attributes = options.attributes; | ||
} | ||
function getDefaultPromiseImplementation() { | ||
if (typeof Promise === "undefined") { | ||
throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill."); | ||
} | ||
return Promise; | ||
} | ||
function getPayPalWindowNamespace(namespace) { | ||
@@ -245,4 +226,4 @@ // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
// replaced with the package.json version at build time | ||
var version = "5.1.6"; | ||
var version = "6.0.0"; | ||
export { loadCustomScript, loadScript, version }; |
/*! | ||
* paypal-js v5.1.6 (2023-03-27T20:51:02.623Z) | ||
* paypal-js v6.0.0 (2023-06-02T19:54:59.307Z) | ||
* Copyright 2020-present, PayPal, Inc. All rights reserved. | ||
@@ -17,2 +17,2 @@ * | ||
*/ | ||
function t(t){var r="https://www.paypal.com/sdk/js";t.sdkBaseURL&&(r=t.sdkBaseURL,delete t.sdkBaseURL),function(t){var e=t["merchant-id"],r=t["data-merchant-id"],n="",o="";Array.isArray(e)?e.length>1?(n="*",o=e.toString()):n=e.toString():"string"==typeof e&&e.length>0?n=e:"string"==typeof r&&r.length>0&&(n="*",o=r);t["merchant-id"]=n,t["data-merchant-id"]=o}(t);var n=Object.keys(t).filter((function(e){return void 0!==t[e]&&null!==t[e]&&""!==t[e]})).reduce((function(e,r){var n=t[r].toString();return"data-"===r.substring(0,5)?e.dataAttributes[r]=n:e.queryParams[r]=n,e}),{queryParams:{},dataAttributes:{}}),o=n.queryParams,a=n.dataAttributes;return{url:"".concat(r,"?").concat(e(o)),dataAttributes:a}}function e(t){var e="";return Object.keys(t).forEach((function(r){0!==e.length&&(e+="&"),e+=r+"="+t[r]})),e}function r(t,e){void 0===e&&(e={});var r=document.createElement("script");return r.src=t,Object.keys(e).forEach((function(t){r.setAttribute(t,e[t]),"data-csp-nonce"===t&&r.setAttribute("nonce",e["data-csp-nonce"])})),r}function n(e,n){if(void 0===n&&(n=a()),u(e,n),"undefined"==typeof document)return n.resolve(null);var c=t(e),s=c.url,d=c.dataAttributes,f=d["data-namespace"]||"paypal",l=i(f);return function(t,e){var n=document.querySelector('script[src="'.concat(t,'"]'));if(null===n)return null;var o=r(t,e),a=n.cloneNode();if(delete a.dataset.uidAuto,Object.keys(a.dataset).length!==Object.keys(o.dataset).length)return null;var i=!0;return Object.keys(a.dataset).forEach((function(t){a.dataset[t]!==o.dataset[t]&&(i=!1)})),i?n:null}(s,d)&&l?n.resolve(l):o({url:s,attributes:d},n).then((function(){var t=i(f);if(t)return t;throw new Error("The window.".concat(f," global variable is not available."))}))}function o(t,e){void 0===e&&(e=a()),u(t,e);var n=t.url,o=t.attributes;if("string"!=typeof n||0===n.length)throw new Error("Invalid url.");if(void 0!==o&&"object"!=typeof o)throw new Error("Expected attributes to be an object.");return new e((function(t,e){if("undefined"==typeof document)return t();!function(t){var e=t.url,n=t.attributes,o=t.onSuccess,a=t.onError,i=r(e,n);i.onerror=a,i.onload=o,document.head.insertBefore(i,document.head.firstElementChild)}({url:n,attributes:o,onSuccess:function(){return t()},onError:function(){var t=new Error('The script "'.concat(n,'" failed to load.'));return window.fetch?fetch(n).then((function(r){return 200===r.status&&e(t),r.text()})).then((function(t){var r=function(t){var e=t.split("/* Original Error:")[1];return e?e.replace(/\n/g,"").replace("*/","").trim():t}(t);e(new Error(r))})).catch((function(t){e(t)})):e(t)}})}))}function a(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function i(t){return window[t]}function u(t,e){if("object"!=typeof t||null===t)throw new Error("Expected an options object.");if(void 0!==e&&"function"!=typeof e)throw new Error("Expected PromisePonyfill to be a function.")}var c="5.1.6";export{o as loadCustomScript,n as loadScript,c as version}; | ||
function t(t){var e="";return Object.keys(t).forEach((function(r){0!==e.length&&(e+="&"),e+=r+"="+t[r]})),e}function e(t,e){void 0===e&&(e={});var r=document.createElement("script");return r.src=t,Object.keys(e).forEach((function(t){r.setAttribute(t,e[t]),"data-csp-nonce"===t&&r.setAttribute("nonce",e["data-csp-nonce"])})),r}function r(r,c){if(void 0===c&&(c=Promise),a(r,c),"undefined"==typeof document)return c.resolve(null);var u=function(e){var r="https://www.paypal.com/sdk/js";e.sdkBaseUrl&&(r=e.sdkBaseUrl,delete e.sdkBaseUrl);var n=e,o=Object.keys(n).filter((function(t){return void 0!==n[t]&&null!==n[t]&&""!==n[t]})).reduce((function(t,e){var r,o=n[e].toString();return r=function(t,e){return(e?"-":"")+t.toLowerCase()},"data"===(e=e.replace(/[A-Z]+(?![a-z])|[A-Z]/g,r)).substring(0,4)?t.dataAttributes[e]=o:t.queryParams[e]=o,t}),{queryParams:{},dataAttributes:{}}),a=o.queryParams,c=o.dataAttributes;return a["merchant-id"]&&-1!==a["merchant-id"].indexOf(",")&&(c["data-merchant-id"]=a["merchant-id"],a["merchant-id"]="*"),{url:"".concat(r,"?").concat(t(a)),dataAttributes:c}}(r),i=u.url,s=u.dataAttributes,d=s["data-namespace"]||"paypal",l=o(d);return function(t,r){var n=document.querySelector('script[src="'.concat(t,'"]'));if(null===n)return null;var o=e(t,r),a=n.cloneNode();if(delete a.dataset.uidAuto,Object.keys(a.dataset).length!==Object.keys(o.dataset).length)return null;var c=!0;return Object.keys(a.dataset).forEach((function(t){a.dataset[t]!==o.dataset[t]&&(c=!1)})),c?n:null}(i,s)&&l?c.resolve(l):n({url:i,attributes:s},c).then((function(){var t=o(d);if(t)return t;throw new Error("The window.".concat(d," global variable is not available."))}))}function n(t,r){void 0===r&&(r=Promise),a(t,r);var n=t.url,o=t.attributes;if("string"!=typeof n||0===n.length)throw new Error("Invalid url.");if(void 0!==o&&"object"!=typeof o)throw new Error("Expected attributes to be an object.");return new r((function(t,r){if("undefined"==typeof document)return t();!function(t){var r=t.url,n=t.attributes,o=t.onSuccess,a=t.onError,c=e(r,n);c.onerror=a,c.onload=o,document.head.insertBefore(c,document.head.firstElementChild)}({url:n,attributes:o,onSuccess:function(){return t()},onError:function(){var t=new Error('The script "'.concat(n,'" failed to load.'));return window.fetch?fetch(n).then((function(e){return 200===e.status&&r(t),e.text()})).then((function(t){var e=function(t){var e=t.split("/* Original Error:")[1];return e?e.replace(/\n/g,"").replace("*/","").trim():t}(t);r(new Error(e))})).catch((function(t){r(t)})):r(t)}})}))}function o(t){return window[t]}function a(t,e){if("object"!=typeof t||null===t)throw new Error("Expected an options object.");if(void 0!==e&&"function"!=typeof e)throw new Error("Expected PromisePonyfill to be a function.")}var c="6.0.0";export{n as loadCustomScript,r as loadScript,c as version}; |
/*! | ||
* paypal-js v5.1.6 (2023-03-27T20:51:02.623Z) | ||
* paypal-js v6.0.0 (2023-06-02T19:54:59.307Z) | ||
* Copyright 2020-present, PayPal, Inc. All rights reserved. | ||
@@ -50,17 +50,18 @@ * | ||
function processOptions(options) { | ||
var sdkBaseURL = "https://www.paypal.com/sdk/js"; | ||
if (options.sdkBaseURL) { | ||
sdkBaseURL = options.sdkBaseURL; | ||
delete options.sdkBaseURL; | ||
var sdkBaseUrl = "https://www.paypal.com/sdk/js"; | ||
if (options.sdkBaseUrl) { | ||
sdkBaseUrl = options.sdkBaseUrl; | ||
delete options.sdkBaseUrl; | ||
} | ||
processMerchantID(options); | ||
var _a = Object.keys(options) | ||
var optionsWithStringIndex = options; | ||
var _a = Object.keys(optionsWithStringIndex) | ||
.filter(function (key) { | ||
return (typeof options[key] !== "undefined" && | ||
options[key] !== null && | ||
options[key] !== ""); | ||
return (typeof optionsWithStringIndex[key] !== "undefined" && | ||
optionsWithStringIndex[key] !== null && | ||
optionsWithStringIndex[key] !== ""); | ||
}) | ||
.reduce(function (accumulator, key) { | ||
var value = options[key].toString(); | ||
if (key.substring(0, 5) === "data-") { | ||
var value = optionsWithStringIndex[key].toString(); | ||
key = camelCaseToKebabCase(key); | ||
if (key.substring(0, 4) === "data") { | ||
accumulator.dataAttributes[key] = value; | ||
@@ -76,7 +77,18 @@ } | ||
}), queryParams = _a.queryParams, dataAttributes = _a.dataAttributes; | ||
if (queryParams["merchant-id"] && | ||
queryParams["merchant-id"].indexOf(",") !== -1) { | ||
dataAttributes["data-merchant-id"] = queryParams["merchant-id"]; | ||
queryParams["merchant-id"] = "*"; | ||
} | ||
return { | ||
url: "".concat(sdkBaseURL, "?").concat(objectToQueryString(queryParams)), | ||
url: "".concat(sdkBaseUrl, "?").concat(objectToQueryString(queryParams)), | ||
dataAttributes: dataAttributes, | ||
}; | ||
} | ||
function camelCaseToKebabCase(str) { | ||
var replacer = function (match, indexOfMatch) { | ||
return (indexOfMatch ? "-" : "") + match.toLowerCase(); | ||
}; | ||
return str.replace(/[A-Z]+(?![a-z])|[A-Z]/g, replacer); | ||
} | ||
function objectToQueryString(params) { | ||
@@ -117,27 +129,2 @@ var queryString = ""; | ||
} | ||
function processMerchantID(options) { | ||
var merchantID = options["merchant-id"], dataMerchantID = options["data-merchant-id"]; | ||
var newMerchantID = ""; | ||
var newDataMerchantID = ""; | ||
if (Array.isArray(merchantID)) { | ||
if (merchantID.length > 1) { | ||
newMerchantID = "*"; | ||
newDataMerchantID = merchantID.toString(); | ||
} | ||
else { | ||
newMerchantID = merchantID.toString(); | ||
} | ||
} | ||
else if (typeof merchantID === "string" && merchantID.length > 0) { | ||
newMerchantID = merchantID; | ||
} | ||
else if (typeof dataMerchantID === "string" && | ||
dataMerchantID.length > 0) { | ||
newMerchantID = "*"; | ||
newDataMerchantID = dataMerchantID; | ||
} | ||
options["merchant-id"] = newMerchantID; | ||
options["data-merchant-id"] = newDataMerchantID; | ||
return options; | ||
} | ||
@@ -152,3 +139,3 @@ /** | ||
function loadScript(options, PromisePonyfill) { | ||
if (PromisePonyfill === void 0) { PromisePonyfill = getDefaultPromiseImplementation(); } | ||
if (PromisePonyfill === void 0) { PromisePonyfill = Promise; } | ||
validateArguments(options, PromisePonyfill); | ||
@@ -184,3 +171,3 @@ // resolve with null when running in Node or Deno | ||
function loadCustomScript(options, PromisePonyfill) { | ||
if (PromisePonyfill === void 0) { PromisePonyfill = getDefaultPromiseImplementation(); } | ||
if (PromisePonyfill === void 0) { PromisePonyfill = Promise; } | ||
validateArguments(options, PromisePonyfill); | ||
@@ -226,8 +213,2 @@ var url = options.url, attributes = options.attributes; | ||
} | ||
function getDefaultPromiseImplementation() { | ||
if (typeof Promise === "undefined") { | ||
throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill."); | ||
} | ||
return Promise; | ||
} | ||
function getPayPalWindowNamespace(namespace) { | ||
@@ -248,3 +229,3 @@ // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
// replaced with the package.json version at build time | ||
var version = "5.1.6"; | ||
var version = "6.0.0"; | ||
@@ -251,0 +232,0 @@ exports.loadCustomScript = loadCustomScript; |
/*! | ||
* paypal-js v5.1.6 (2023-03-27T20:51:02.623Z) | ||
* paypal-js v6.0.0 (2023-06-02T19:54:59.307Z) | ||
* Copyright 2020-present, PayPal, Inc. All rights reserved. | ||
@@ -415,17 +415,18 @@ * | ||
function processOptions(options) { | ||
var sdkBaseURL = "https://www.paypal.com/sdk/js"; | ||
if (options.sdkBaseURL) { | ||
sdkBaseURL = options.sdkBaseURL; | ||
delete options.sdkBaseURL; | ||
var sdkBaseUrl = "https://www.paypal.com/sdk/js"; | ||
if (options.sdkBaseUrl) { | ||
sdkBaseUrl = options.sdkBaseUrl; | ||
delete options.sdkBaseUrl; | ||
} | ||
processMerchantID(options); | ||
var _a = Object.keys(options) | ||
var optionsWithStringIndex = options; | ||
var _a = Object.keys(optionsWithStringIndex) | ||
.filter(function (key) { | ||
return (typeof options[key] !== "undefined" && | ||
options[key] !== null && | ||
options[key] !== ""); | ||
return (typeof optionsWithStringIndex[key] !== "undefined" && | ||
optionsWithStringIndex[key] !== null && | ||
optionsWithStringIndex[key] !== ""); | ||
}) | ||
.reduce(function (accumulator, key) { | ||
var value = options[key].toString(); | ||
if (key.substring(0, 5) === "data-") { | ||
var value = optionsWithStringIndex[key].toString(); | ||
key = camelCaseToKebabCase(key); | ||
if (key.substring(0, 4) === "data") { | ||
accumulator.dataAttributes[key] = value; | ||
@@ -441,7 +442,18 @@ } | ||
}), queryParams = _a.queryParams, dataAttributes = _a.dataAttributes; | ||
if (queryParams["merchant-id"] && | ||
queryParams["merchant-id"].indexOf(",") !== -1) { | ||
dataAttributes["data-merchant-id"] = queryParams["merchant-id"]; | ||
queryParams["merchant-id"] = "*"; | ||
} | ||
return { | ||
url: "".concat(sdkBaseURL, "?").concat(objectToQueryString(queryParams)), | ||
url: "".concat(sdkBaseUrl, "?").concat(objectToQueryString(queryParams)), | ||
dataAttributes: dataAttributes, | ||
}; | ||
} | ||
function camelCaseToKebabCase(str) { | ||
var replacer = function (match, indexOfMatch) { | ||
return (indexOfMatch ? "-" : "") + match.toLowerCase(); | ||
}; | ||
return str.replace(/[A-Z]+(?![a-z])|[A-Z]/g, replacer); | ||
} | ||
function objectToQueryString(params) { | ||
@@ -482,27 +494,2 @@ var queryString = ""; | ||
} | ||
function processMerchantID(options) { | ||
var merchantID = options["merchant-id"], dataMerchantID = options["data-merchant-id"]; | ||
var newMerchantID = ""; | ||
var newDataMerchantID = ""; | ||
if (Array.isArray(merchantID)) { | ||
if (merchantID.length > 1) { | ||
newMerchantID = "*"; | ||
newDataMerchantID = merchantID.toString(); | ||
} | ||
else { | ||
newMerchantID = merchantID.toString(); | ||
} | ||
} | ||
else if (typeof merchantID === "string" && merchantID.length > 0) { | ||
newMerchantID = merchantID; | ||
} | ||
else if (typeof dataMerchantID === "string" && | ||
dataMerchantID.length > 0) { | ||
newMerchantID = "*"; | ||
newDataMerchantID = dataMerchantID; | ||
} | ||
options["merchant-id"] = newMerchantID; | ||
options["data-merchant-id"] = newDataMerchantID; | ||
return options; | ||
} | ||
@@ -517,3 +504,3 @@ /** | ||
function loadScript$1(options, PromisePonyfill) { | ||
if (PromisePonyfill === void 0) { PromisePonyfill = getDefaultPromiseImplementation(); } | ||
if (PromisePonyfill === void 0) { PromisePonyfill = Promise; } | ||
validateArguments(options, PromisePonyfill); | ||
@@ -549,3 +536,3 @@ // resolve with null when running in Node or Deno | ||
function loadCustomScript$1(options, PromisePonyfill) { | ||
if (PromisePonyfill === void 0) { PromisePonyfill = getDefaultPromiseImplementation(); } | ||
if (PromisePonyfill === void 0) { PromisePonyfill = Promise; } | ||
validateArguments(options, PromisePonyfill); | ||
@@ -591,8 +578,2 @@ var url = options.url, attributes = options.attributes; | ||
} | ||
function getDefaultPromiseImplementation() { | ||
if (typeof Promise === "undefined") { | ||
throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill."); | ||
} | ||
return Promise; | ||
} | ||
function getPayPalWindowNamespace(namespace) { | ||
@@ -619,3 +600,3 @@ // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
// replaced with the package.json version at build time | ||
var version = "5.1.6"; | ||
var version = "6.0.0"; | ||
@@ -622,0 +603,0 @@ exports.loadCustomScript = loadCustomScript; |
/*! | ||
* paypal-js v5.1.6 (2023-03-27T20:51:02.623Z) | ||
* paypal-js v6.0.0 (2023-06-02T19:54:59.307Z) | ||
* Copyright 2020-present, PayPal, Inc. All rights reserved. | ||
@@ -17,2 +17,2 @@ * | ||
*/ | ||
var paypalLoadScript=function(t){"use strict";function e(t,e){this.name="AggregateError",this.errors=t,this.message=e||""}e.prototype=Error.prototype;var n=setTimeout;function r(t){return Boolean(t&&void 0!==t.length)}function o(){}function i(t){if(!(this instanceof i))throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],l(t,this)}function a(t,e){for(;3===t._state;)t=t._value;0!==t._state?(t._handled=!0,i._immediateFn((function(){var n=1===t._state?e.onFulfilled:e.onRejected;if(null!==n){var r;try{r=n(t._value)}catch(t){return void c(e.promise,t)}u(e.promise,r)}else(1===t._state?u:c)(e.promise,t._value)}))):t._deferreds.push(e)}function u(t,e){try{if(e===t)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var n=e.then;if(e instanceof i)return t._state=3,t._value=e,void f(t);if("function"==typeof n)return void l((r=n,o=e,function(){r.apply(o,arguments)}),t)}t._state=1,t._value=e,f(t)}catch(e){c(t,e)}var r,o}function c(t,e){t._state=2,t._value=e,f(t)}function f(t){2===t._state&&0===t._deferreds.length&&i._immediateFn((function(){t._handled||i._unhandledRejectionFn(t._value)}));for(var e=0,n=t._deferreds.length;e<n;e++)a(t,t._deferreds[e]);t._deferreds=null}function s(t,e,n){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof e?e:null,this.promise=n}function l(t,e){var n=!1;try{t((function(t){n||(n=!0,u(e,t))}),(function(t){n||(n=!0,c(e,t))}))}catch(t){if(n)return;n=!0,c(e,t)}}function d(t){var e="https://www.paypal.com/sdk/js";t.sdkBaseURL&&(e=t.sdkBaseURL,delete t.sdkBaseURL),function(t){var e=t["merchant-id"],n=t["data-merchant-id"],r="",o="";Array.isArray(e)?e.length>1?(r="*",o=e.toString()):r=e.toString():"string"==typeof e&&e.length>0?r=e:"string"==typeof n&&n.length>0&&(r="*",o=n);t["merchant-id"]=r,t["data-merchant-id"]=o}(t);var n=Object.keys(t).filter((function(e){return void 0!==t[e]&&null!==t[e]&&""!==t[e]})).reduce((function(e,n){var r=t[n].toString();return"data-"===n.substring(0,5)?e.dataAttributes[n]=r:e.queryParams[n]=r,e}),{queryParams:{},dataAttributes:{}}),r=n.queryParams,o=n.dataAttributes;return{url:"".concat(e,"?").concat(p(r)),dataAttributes:o}}function p(t){var e="";return Object.keys(t).forEach((function(n){0!==e.length&&(e+="&"),e+=n+"="+t[n]})),e}function h(t,e){void 0===e&&(e={});var n=document.createElement("script");return n.src=t,Object.keys(e).forEach((function(t){n.setAttribute(t,e[t]),"data-csp-nonce"===t&&n.setAttribute("nonce",e["data-csp-nonce"])})),n}function y(t,e){if(void 0===e&&(e=m()),b(t,e),"undefined"==typeof document)return e.resolve(null);var n=d(t),r=n.url,o=n.dataAttributes,i=o["data-namespace"]||"paypal",a=w(i);return function(t,e){var n=document.querySelector('script[src="'.concat(t,'"]'));if(null===n)return null;var r=h(t,e),o=n.cloneNode();if(delete o.dataset.uidAuto,Object.keys(o.dataset).length!==Object.keys(r.dataset).length)return null;var i=!0;return Object.keys(o.dataset).forEach((function(t){o.dataset[t]!==r.dataset[t]&&(i=!1)})),i?n:null}(r,o)&&a?e.resolve(a):v({url:r,attributes:o},e).then((function(){var t=w(i);if(t)return t;throw new Error("The window.".concat(i," global variable is not available."))}))}function v(t,e){void 0===e&&(e=m()),b(t,e);var n=t.url,r=t.attributes;if("string"!=typeof n||0===n.length)throw new Error("Invalid url.");if(void 0!==r&&"object"!=typeof r)throw new Error("Expected attributes to be an object.");return new e((function(t,e){if("undefined"==typeof document)return t();!function(t){var e=t.url,n=t.attributes,r=t.onSuccess,o=t.onError,i=h(e,n);i.onerror=o,i.onload=r,document.head.insertBefore(i,document.head.firstElementChild)}({url:n,attributes:r,onSuccess:function(){return t()},onError:function(){var t=new Error('The script "'.concat(n,'" failed to load.'));return window.fetch?fetch(n).then((function(n){return 200===n.status&&e(t),n.text()})).then((function(t){var n=function(t){var e=t.split("/* Original Error:")[1];return e?e.replace(/\n/g,"").replace("*/","").trim():t}(t);e(new Error(n))})).catch((function(t){e(t)})):e(t)}})}))}function m(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function w(t){return window[t]}function b(t,e){if("object"!=typeof t||null===t)throw new Error("Expected an options object.");if(void 0!==e&&"function"!=typeof e)throw new Error("Expected PromisePonyfill to be a function.")}i.prototype.catch=function(t){return this.then(null,t)},i.prototype.then=function(t,e){var n=new this.constructor(o);return a(this,new s(t,e,n)),n},i.prototype.finally=function(t){var e=this.constructor;return this.then((function(n){return e.resolve(t()).then((function(){return n}))}),(function(n){return e.resolve(t()).then((function(){return e.reject(n)}))}))},i.all=function(t){return new i((function(e,n){if(!r(t))return n(new TypeError("Promise.all accepts an array"));var o=Array.prototype.slice.call(t);if(0===o.length)return e([]);var i=o.length;function a(t,r){try{if(r&&("object"==typeof r||"function"==typeof r)){var u=r.then;if("function"==typeof u)return void u.call(r,(function(e){a(t,e)}),n)}o[t]=r,0==--i&&e(o)}catch(t){n(t)}}for(var u=0;u<o.length;u++)a(u,o[u])}))},i.any=function(t){var n=this;return new n((function(r,o){if(!t||void 0===t.length)return o(new TypeError("Promise.any accepts an array"));var i=Array.prototype.slice.call(t);if(0===i.length)return o();for(var a=[],u=0;u<i.length;u++)try{n.resolve(i[u]).then(r).catch((function(t){a.push(t),a.length===i.length&&o(new e(a,"All promises were rejected"))}))}catch(t){o(t)}}))},i.allSettled=function(t){return new this((function(e,n){if(!t||void 0===t.length)return n(new TypeError(typeof t+" "+t+" is not iterable(cannot read property Symbol(Symbol.iterator))"));var r=Array.prototype.slice.call(t);if(0===r.length)return e([]);var o=r.length;function i(t,n){if(n&&("object"==typeof n||"function"==typeof n)){var a=n.then;if("function"==typeof a)return void a.call(n,(function(e){i(t,e)}),(function(n){r[t]={status:"rejected",reason:n},0==--o&&e(r)}))}r[t]={status:"fulfilled",value:n},0==--o&&e(r)}for(var a=0;a<r.length;a++)i(a,r[a])}))},i.resolve=function(t){return t&&"object"==typeof t&&t.constructor===i?t:new i((function(e){e(t)}))},i.reject=function(t){return new i((function(e,n){n(t)}))},i.race=function(t){return new i((function(e,n){if(!r(t))return n(new TypeError("Promise.race accepts an array"));for(var o=0,a=t.length;o<a;o++)i.resolve(t[o]).then(e,n)}))},i._immediateFn="function"==typeof setImmediate&&function(t){setImmediate(t)}||function(t){n(t,0)},i._unhandledRejectionFn=function(t){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",t)};return t.loadCustomScript=function(t){return v(t,i)},t.loadScript=function(t){return y(t,i)},t.version="5.1.6",t}({});window.paypalLoadCustomScript=paypalLoadScript.loadCustomScript,window.paypalLoadScript=paypalLoadScript.loadScript; | ||
var paypalLoadScript=function(t){"use strict";function e(t,e){this.name="AggregateError",this.errors=t,this.message=e||""}e.prototype=Error.prototype;var n=setTimeout;function r(t){return Boolean(t&&void 0!==t.length)}function o(){}function i(t){if(!(this instanceof i))throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],l(t,this)}function a(t,e){for(;3===t._state;)t=t._value;0!==t._state?(t._handled=!0,i._immediateFn((function(){var n=1===t._state?e.onFulfilled:e.onRejected;if(null!==n){var r;try{r=n(t._value)}catch(t){return void u(e.promise,t)}c(e.promise,r)}else(1===t._state?c:u)(e.promise,t._value)}))):t._deferreds.push(e)}function c(t,e){try{if(e===t)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var n=e.then;if(e instanceof i)return t._state=3,t._value=e,void f(t);if("function"==typeof n)return void l((r=n,o=e,function(){r.apply(o,arguments)}),t)}t._state=1,t._value=e,f(t)}catch(e){u(t,e)}var r,o}function u(t,e){t._state=2,t._value=e,f(t)}function f(t){2===t._state&&0===t._deferreds.length&&i._immediateFn((function(){t._handled||i._unhandledRejectionFn(t._value)}));for(var e=0,n=t._deferreds.length;e<n;e++)a(t,t._deferreds[e]);t._deferreds=null}function s(t,e,n){this.onFulfilled="function"==typeof t?t:null,this.onRejected="function"==typeof e?e:null,this.promise=n}function l(t,e){var n=!1;try{t((function(t){n||(n=!0,c(e,t))}),(function(t){n||(n=!0,u(e,t))}))}catch(t){if(n)return;n=!0,u(e,t)}}function d(t){var e="";return Object.keys(t).forEach((function(n){0!==e.length&&(e+="&"),e+=n+"="+t[n]})),e}function p(t,e){void 0===e&&(e={});var n=document.createElement("script");return n.src=t,Object.keys(e).forEach((function(t){n.setAttribute(t,e[t]),"data-csp-nonce"===t&&n.setAttribute("nonce",e["data-csp-nonce"])})),n}function h(t,e){if(void 0===e&&(e=Promise),m(t,e),"undefined"==typeof document)return e.resolve(null);var n=function(t){var e="https://www.paypal.com/sdk/js";t.sdkBaseUrl&&(e=t.sdkBaseUrl,delete t.sdkBaseUrl);var n=t,r=Object.keys(n).filter((function(t){return void 0!==n[t]&&null!==n[t]&&""!==n[t]})).reduce((function(t,e){var r,o=n[e].toString();return r=function(t,e){return(e?"-":"")+t.toLowerCase()},"data"===(e=e.replace(/[A-Z]+(?![a-z])|[A-Z]/g,r)).substring(0,4)?t.dataAttributes[e]=o:t.queryParams[e]=o,t}),{queryParams:{},dataAttributes:{}}),o=r.queryParams,i=r.dataAttributes;return o["merchant-id"]&&-1!==o["merchant-id"].indexOf(",")&&(i["data-merchant-id"]=o["merchant-id"],o["merchant-id"]="*"),{url:"".concat(e,"?").concat(d(o)),dataAttributes:i}}(t),r=n.url,o=n.dataAttributes,i=o["data-namespace"]||"paypal",a=y(i);return function(t,e){var n=document.querySelector('script[src="'.concat(t,'"]'));if(null===n)return null;var r=p(t,e),o=n.cloneNode();if(delete o.dataset.uidAuto,Object.keys(o.dataset).length!==Object.keys(r.dataset).length)return null;var i=!0;return Object.keys(o.dataset).forEach((function(t){o.dataset[t]!==r.dataset[t]&&(i=!1)})),i?n:null}(r,o)&&a?e.resolve(a):v({url:r,attributes:o},e).then((function(){var t=y(i);if(t)return t;throw new Error("The window.".concat(i," global variable is not available."))}))}function v(t,e){void 0===e&&(e=Promise),m(t,e);var n=t.url,r=t.attributes;if("string"!=typeof n||0===n.length)throw new Error("Invalid url.");if(void 0!==r&&"object"!=typeof r)throw new Error("Expected attributes to be an object.");return new e((function(t,e){if("undefined"==typeof document)return t();!function(t){var e=t.url,n=t.attributes,r=t.onSuccess,o=t.onError,i=p(e,n);i.onerror=o,i.onload=r,document.head.insertBefore(i,document.head.firstElementChild)}({url:n,attributes:r,onSuccess:function(){return t()},onError:function(){var t=new Error('The script "'.concat(n,'" failed to load.'));return window.fetch?fetch(n).then((function(n){return 200===n.status&&e(t),n.text()})).then((function(t){var n=function(t){var e=t.split("/* Original Error:")[1];return e?e.replace(/\n/g,"").replace("*/","").trim():t}(t);e(new Error(n))})).catch((function(t){e(t)})):e(t)}})}))}function y(t){return window[t]}function m(t,e){if("object"!=typeof t||null===t)throw new Error("Expected an options object.");if(void 0!==e&&"function"!=typeof e)throw new Error("Expected PromisePonyfill to be a function.")}i.prototype.catch=function(t){return this.then(null,t)},i.prototype.then=function(t,e){var n=new this.constructor(o);return a(this,new s(t,e,n)),n},i.prototype.finally=function(t){var e=this.constructor;return this.then((function(n){return e.resolve(t()).then((function(){return n}))}),(function(n){return e.resolve(t()).then((function(){return e.reject(n)}))}))},i.all=function(t){return new i((function(e,n){if(!r(t))return n(new TypeError("Promise.all accepts an array"));var o=Array.prototype.slice.call(t);if(0===o.length)return e([]);var i=o.length;function a(t,r){try{if(r&&("object"==typeof r||"function"==typeof r)){var c=r.then;if("function"==typeof c)return void c.call(r,(function(e){a(t,e)}),n)}o[t]=r,0==--i&&e(o)}catch(t){n(t)}}for(var c=0;c<o.length;c++)a(c,o[c])}))},i.any=function(t){var n=this;return new n((function(r,o){if(!t||void 0===t.length)return o(new TypeError("Promise.any accepts an array"));var i=Array.prototype.slice.call(t);if(0===i.length)return o();for(var a=[],c=0;c<i.length;c++)try{n.resolve(i[c]).then(r).catch((function(t){a.push(t),a.length===i.length&&o(new e(a,"All promises were rejected"))}))}catch(t){o(t)}}))},i.allSettled=function(t){return new this((function(e,n){if(!t||void 0===t.length)return n(new TypeError(typeof t+" "+t+" is not iterable(cannot read property Symbol(Symbol.iterator))"));var r=Array.prototype.slice.call(t);if(0===r.length)return e([]);var o=r.length;function i(t,n){if(n&&("object"==typeof n||"function"==typeof n)){var a=n.then;if("function"==typeof a)return void a.call(n,(function(e){i(t,e)}),(function(n){r[t]={status:"rejected",reason:n},0==--o&&e(r)}))}r[t]={status:"fulfilled",value:n},0==--o&&e(r)}for(var a=0;a<r.length;a++)i(a,r[a])}))},i.resolve=function(t){return t&&"object"==typeof t&&t.constructor===i?t:new i((function(e){e(t)}))},i.reject=function(t){return new i((function(e,n){n(t)}))},i.race=function(t){return new i((function(e,n){if(!r(t))return n(new TypeError("Promise.race accepts an array"));for(var o=0,a=t.length;o<a;o++)i.resolve(t[o]).then(e,n)}))},i._immediateFn="function"==typeof setImmediate&&function(t){setImmediate(t)}||function(t){n(t,0)},i._unhandledRejectionFn=function(t){"undefined"!=typeof console&&console&&console.warn("Possible Unhandled Promise Rejection:",t)};return t.loadCustomScript=function(t){return v(t,i)},t.loadScript=function(t){return h(t,i)},t.version="6.0.0",t}({});window.paypalLoadCustomScript=paypalLoadScript.loadCustomScript,window.paypalLoadScript=paypalLoadScript.loadScript; |
/*! | ||
* paypal-js v5.1.6 (2023-03-27T20:51:02.623Z) | ||
* paypal-js v6.0.0 (2023-06-02T19:54:59.307Z) | ||
* Copyright 2020-present, PayPal, Inc. All rights reserved. | ||
@@ -17,2 +17,2 @@ * | ||
*/ | ||
var paypalLoadScript=function(t){"use strict";function r(t){var r="https://www.paypal.com/sdk/js";t.sdkBaseURL&&(r=t.sdkBaseURL,delete t.sdkBaseURL),function(t){var r=t["merchant-id"],e=t["data-merchant-id"],n="",o="";Array.isArray(r)?r.length>1?(n="*",o=r.toString()):n=r.toString():"string"==typeof r&&r.length>0?n=r:"string"==typeof e&&e.length>0&&(n="*",o=e);t["merchant-id"]=n,t["data-merchant-id"]=o}(t);var n=Object.keys(t).filter((function(r){return void 0!==t[r]&&null!==t[r]&&""!==t[r]})).reduce((function(r,e){var n=t[e].toString();return"data-"===e.substring(0,5)?r.dataAttributes[e]=n:r.queryParams[e]=n,r}),{queryParams:{},dataAttributes:{}}),o=n.queryParams,a=n.dataAttributes;return{url:"".concat(r,"?").concat(e(o)),dataAttributes:a}}function e(t){var r="";return Object.keys(t).forEach((function(e){0!==r.length&&(r+="&"),r+=e+"="+t[e]})),r}function n(t,r){void 0===r&&(r={});var e=document.createElement("script");return e.src=t,Object.keys(r).forEach((function(t){e.setAttribute(t,r[t]),"data-csp-nonce"===t&&e.setAttribute("nonce",r["data-csp-nonce"])})),e}function o(t,r){void 0===r&&(r=a()),u(t,r);var e=t.url,o=t.attributes;if("string"!=typeof e||0===e.length)throw new Error("Invalid url.");if(void 0!==o&&"object"!=typeof o)throw new Error("Expected attributes to be an object.");return new r((function(t,r){if("undefined"==typeof document)return t();!function(t){var r=t.url,e=t.attributes,o=t.onSuccess,a=t.onError,i=n(r,e);i.onerror=a,i.onload=o,document.head.insertBefore(i,document.head.firstElementChild)}({url:e,attributes:o,onSuccess:function(){return t()},onError:function(){var t=new Error('The script "'.concat(e,'" failed to load.'));return window.fetch?fetch(e).then((function(e){return 200===e.status&&r(t),e.text()})).then((function(t){var e=function(t){var r=t.split("/* Original Error:")[1];return r?r.replace(/\n/g,"").replace("*/","").trim():t}(t);r(new Error(e))})).catch((function(t){r(t)})):r(t)}})}))}function a(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function i(t){return window[t]}function u(t,r){if("object"!=typeof t||null===t)throw new Error("Expected an options object.");if(void 0!==r&&"function"!=typeof r)throw new Error("Expected PromisePonyfill to be a function.")}return t.loadCustomScript=o,t.loadScript=function(t,e){if(void 0===e&&(e=a()),u(t,e),"undefined"==typeof document)return e.resolve(null);var c=r(t),s=c.url,d=c.dataAttributes,l=d["data-namespace"]||"paypal",f=i(l);return function(t,r){var e=document.querySelector('script[src="'.concat(t,'"]'));if(null===e)return null;var o=n(t,r),a=e.cloneNode();if(delete a.dataset.uidAuto,Object.keys(a.dataset).length!==Object.keys(o.dataset).length)return null;var i=!0;return Object.keys(a.dataset).forEach((function(t){a.dataset[t]!==o.dataset[t]&&(i=!1)})),i?e:null}(s,d)&&f?e.resolve(f):o({url:s,attributes:d},e).then((function(){var t=i(l);if(t)return t;throw new Error("The window.".concat(l," global variable is not available."))}))},t.version="5.1.6",t}({});window.paypalLoadCustomScript=paypalLoadScript.loadCustomScript,window.paypalLoadScript=paypalLoadScript.loadScript; | ||
var paypalLoadScript=function(t){"use strict";function r(t){var r="";return Object.keys(t).forEach((function(e){0!==r.length&&(r+="&"),r+=e+"="+t[e]})),r}function e(t,r){void 0===r&&(r={});var e=document.createElement("script");return e.src=t,Object.keys(r).forEach((function(t){e.setAttribute(t,r[t]),"data-csp-nonce"===t&&e.setAttribute("nonce",r["data-csp-nonce"])})),e}function n(t,r){void 0===r&&(r=Promise),o(t,r);var n=t.url,a=t.attributes;if("string"!=typeof n||0===n.length)throw new Error("Invalid url.");if(void 0!==a&&"object"!=typeof a)throw new Error("Expected attributes to be an object.");return new r((function(t,r){if("undefined"==typeof document)return t();!function(t){var r=t.url,n=t.attributes,a=t.onSuccess,o=t.onError,i=e(r,n);i.onerror=o,i.onload=a,document.head.insertBefore(i,document.head.firstElementChild)}({url:n,attributes:a,onSuccess:function(){return t()},onError:function(){var t=new Error('The script "'.concat(n,'" failed to load.'));return window.fetch?fetch(n).then((function(e){return 200===e.status&&r(t),e.text()})).then((function(t){var e=function(t){var r=t.split("/* Original Error:")[1];return r?r.replace(/\n/g,"").replace("*/","").trim():t}(t);r(new Error(e))})).catch((function(t){r(t)})):r(t)}})}))}function a(t){return window[t]}function o(t,r){if("object"!=typeof t||null===t)throw new Error("Expected an options object.");if(void 0!==r&&"function"!=typeof r)throw new Error("Expected PromisePonyfill to be a function.")}return t.loadCustomScript=n,t.loadScript=function(t,i){if(void 0===i&&(i=Promise),o(t,i),"undefined"==typeof document)return i.resolve(null);var c=function(t){var e="https://www.paypal.com/sdk/js";t.sdkBaseUrl&&(e=t.sdkBaseUrl,delete t.sdkBaseUrl);var n=t,a=Object.keys(n).filter((function(t){return void 0!==n[t]&&null!==n[t]&&""!==n[t]})).reduce((function(t,r){var e,a=n[r].toString();return e=function(t,r){return(r?"-":"")+t.toLowerCase()},"data"===(r=r.replace(/[A-Z]+(?![a-z])|[A-Z]/g,e)).substring(0,4)?t.dataAttributes[r]=a:t.queryParams[r]=a,t}),{queryParams:{},dataAttributes:{}}),o=a.queryParams,i=a.dataAttributes;return o["merchant-id"]&&-1!==o["merchant-id"].indexOf(",")&&(i["data-merchant-id"]=o["merchant-id"],o["merchant-id"]="*"),{url:"".concat(e,"?").concat(r(o)),dataAttributes:i}}(t),u=c.url,d=c.dataAttributes,s=d["data-namespace"]||"paypal",l=a(s);return function(t,r){var n=document.querySelector('script[src="'.concat(t,'"]'));if(null===n)return null;var a=e(t,r),o=n.cloneNode();if(delete o.dataset.uidAuto,Object.keys(o.dataset).length!==Object.keys(a.dataset).length)return null;var i=!0;return Object.keys(o.dataset).forEach((function(t){o.dataset[t]!==a.dataset[t]&&(i=!1)})),i?n:null}(u,d)&&l?i.resolve(l):n({url:u,attributes:d},i).then((function(){var t=a(s);if(t)return t;throw new Error("The window.".concat(s," global variable is not available."))}))},t.version="6.0.0",t}({});window.paypalLoadCustomScript=paypalLoadScript.loadCustomScript,window.paypalLoadScript=paypalLoadScript.loadScript; |
{ | ||
"name": "@paypal/paypal-js", | ||
"version": "5.1.6", | ||
"version": "6.0.0", | ||
"description": "Loading wrapper and TypeScript types for the PayPal JS SDK", | ||
@@ -18,4 +18,4 @@ "main": "index.js", | ||
"postrelease": "git push && git push --follow-tags && npm run build && npm publish", | ||
"test": "jest src", | ||
"test:bundle": "jest bundle-tests/**", | ||
"test": "vitest src", | ||
"test:bundle": "vitest bundle-tests/**", | ||
"test:e2e": "playwright test", | ||
@@ -25,3 +25,3 @@ "test:e2e:debug": "PWDEBUG=1 playwright test --project=\"chromium\"", | ||
"typecheck": "tsc --noEmit", | ||
"validate": "npm run check-node-version && npm run format:check && npm run typecheck && npm run build && npm run lint && npm test -- --coverage && npm run test:bundle" | ||
"validate": "npm run check-node-version && npm run format:check && npm run typecheck && npm run build && npm run lint && npm test -- --coverage --watch=false && npm run test:bundle -- --watch=false" | ||
}, | ||
@@ -49,28 +49,27 @@ "files": [ | ||
"devDependencies": { | ||
"@commitlint/cli": "17.5.0", | ||
"@commitlint/config-conventional": "17.4.4", | ||
"@playwright/test": "^1.32.1", | ||
"@rollup/plugin-commonjs": "24.0.1", | ||
"@rollup/plugin-node-resolve": "15.0.1", | ||
"@commitlint/cli": "17.6.5", | ||
"@commitlint/config-conventional": "17.6.5", | ||
"@playwright/test": "^1.34.3", | ||
"@rollup/plugin-commonjs": "25.0.0", | ||
"@rollup/plugin-node-resolve": "15.1.0", | ||
"@rollup/plugin-replace": "5.0.2", | ||
"@rollup/plugin-terser": "^0.4.0", | ||
"@rollup/plugin-typescript": "11.0.0", | ||
"@types/jest": "29.5.0", | ||
"@types/node": "^18.15.10", | ||
"@rollup/plugin-terser": "^0.4.3", | ||
"@rollup/plugin-typescript": "11.1.1", | ||
"@types/node": "^20.2.5", | ||
"@types/promise-polyfill": "6.0.4", | ||
"@typescript-eslint/eslint-plugin": "5.57.0", | ||
"@typescript-eslint/parser": "5.57.0", | ||
"eslint": "8.36.0", | ||
"filesize": "10.0.6", | ||
"@typescript-eslint/eslint-plugin": "5.59.8", | ||
"@typescript-eslint/parser": "5.59.8", | ||
"@vitest/coverage-c8": "^0.31.4", | ||
"eslint": "8.41.0", | ||
"filesize": "10.0.7", | ||
"husky": "8.0.3", | ||
"jest": "29.5.0", | ||
"jest-environment-jsdom": "29.5.0", | ||
"lint-staged": "13.2.0", | ||
"prettier": "2.8.7", | ||
"rollup": "3.20.2", | ||
"semver": "7.3.8", | ||
"jsdom": "^22.1.0", | ||
"lint-staged": "13.2.2", | ||
"prettier": "2.8.8", | ||
"rollup": "3.23.0", | ||
"semver": "7.5.1", | ||
"standard-version": "9.5.0", | ||
"ts-jest": "29.0.5", | ||
"tslib": "2.5.0", | ||
"typescript": "5.0.2" | ||
"tslib": "2.5.2", | ||
"typescript": "5.1.3", | ||
"vitest": "^0.31.4" | ||
}, | ||
@@ -77,0 +76,0 @@ "dependencies": { |
@@ -67,3 +67,3 @@ # paypal-js | ||
try { | ||
paypal = await loadScript({ "client-id": "test" }); | ||
paypal = await loadScript({ clientId: "test" }); | ||
} catch (error) { | ||
@@ -87,3 +87,3 @@ console.error("failed to load the PayPal JS SDK script", error); | ||
loadScript({ "client-id": "test" }) | ||
loadScript({ clientId: "test" }) | ||
.then((paypal) => { | ||
@@ -104,3 +104,3 @@ paypal | ||
The `loadScript` function accepts an object for configuring the JS SDK. It's used for setting query parameters and script attributes. | ||
The `loadScript` function accepts an object for configuring the JS SDK. It's used for setting query parameters and script attributes. It accepts parameters in camelCase or kebab-case. | ||
@@ -112,3 +112,3 @@ #### Query Parameters | ||
```js | ||
loadScript({ "client-id": "YOUR_CLIENT_ID", currency: "EUR" }); | ||
loadScript({ clientId: "YOUR_CLIENT_ID", currency: "EUR" }); | ||
``` | ||
@@ -126,3 +126,3 @@ | ||
loadScript({ | ||
"client-id": "YOUR_CLIENT_ID", | ||
clientId: "YOUR_CLIENT_ID", | ||
components: "buttons,marks,messages", | ||
@@ -142,8 +142,8 @@ }); | ||
All options prefixed with `data-` are considered attributes. The following example adds `data-page-type` as an attribute: | ||
All options prefixed with `data` are considered attributes. The following example adds `data-page-type` as an attribute: | ||
```js | ||
loadScript({ | ||
"client-id": "YOUR_CLIENT_ID", | ||
"data-page-type": "checkout", | ||
clientId: "YOUR_CLIENT_ID", | ||
dataPageType: "checkout", | ||
}); | ||
@@ -163,12 +163,12 @@ ``` | ||
#### Merchant ID Array | ||
#### Merchant Id Array | ||
The `merchant-id` option accepts an array to simplify the implementation for Multi-Seller Payments. With this approach the caller doesn't have to worry about managing the two different merchant id values (`data-merchant-id` and `merchant-id`). | ||
The `merchantId` option accepts an array to simplify the implementation for Multi-Seller Payments. With this approach the caller doesn't have to worry about managing the two different merchant id values (`data-merchant-id` and `merchant-id`). | ||
**Here's an example with multiple `merchant-id` values:** | ||
**Here's an example with multiple `merchantId` values:** | ||
```js | ||
loadScript({ | ||
"client-id": "YOUR_CLIENT_ID", | ||
"merchant-id": ["123", "456", "789"], | ||
clientId: "YOUR_CLIENT_ID", | ||
merchantId: ["123", "456", "789"], | ||
}); | ||
@@ -190,4 +190,4 @@ ``` | ||
loadScript({ | ||
"client-id": "YOUR_CLIENT_ID", | ||
"merchant-id": ["123"], | ||
clientId: "YOUR_CLIENT_ID", | ||
merchantId: ["123"], | ||
}); | ||
@@ -202,10 +202,10 @@ ``` | ||
#### sdkBaseURL | ||
#### sdkBaseUrl | ||
For local development, the `sdkBaseURL` option can be used to set the base url of the JS SDK: | ||
For local development, the `sdkBaseUrl` option can be used to set the base url of the JS SDK: | ||
```js | ||
loadScript({ | ||
"client-id": "YOUR_CLIENT_ID", | ||
sdkBaseURL: "http://localhost.paypal.com:8000/sdk/js", | ||
clientId: "YOUR_CLIENT_ID", | ||
sdkBaseUrl: "http://localhost.paypal.com:8000/sdk/js", | ||
}); | ||
@@ -233,3 +233,3 @@ ``` | ||
```html | ||
<script src="https://unpkg.com/@paypal/paypal-js@5.1.6/dist/iife/paypal-js.legacy.min.js"></script> | ||
<script src="https://unpkg.com/@paypal/paypal-js@6.0.0/dist/iife/paypal-js.legacy.min.js"></script> | ||
``` | ||
@@ -245,3 +245,3 @@ | ||
<head> | ||
<script src="https://unpkg.com/@paypal/paypal-js@5.1.6/dist/iife/paypal-js.min.js"></script> | ||
<script src="https://unpkg.com/@paypal/paypal-js@6.0.0/dist/iife/paypal-js.min.js"></script> | ||
</head> | ||
@@ -251,3 +251,3 @@ <body> | ||
<script> | ||
window.paypalLoadScript({ "client-id": "test" }).then((paypal) => { | ||
window.paypalLoadScript({ clientId: "test" }).then((paypal) => { | ||
paypal.Buttons().render("#paypal-buttons"); | ||
@@ -254,0 +254,0 @@ }); |
@@ -238,2 +238,18 @@ import type { Address, AmountWithCurrencyCode } from "./commons"; | ||
export type UpdateOrderOperation = | ||
| { | ||
op: "add" | "replace" | "copy" | "test"; | ||
/** | ||
* The JSON Pointer to the target document location at which to complete the operation. | ||
*/ | ||
path: string; | ||
value: Record<string, unknown>; | ||
} | ||
| { | ||
op: "remove"; | ||
path: string; | ||
}; | ||
export type UpdateOrderRequestBody = UpdateOrderOperation[]; | ||
export type OrderResponseBodyMinimal = { | ||
@@ -240,0 +256,0 @@ /** |
@@ -1,3 +0,7 @@ | ||
import type { CreateOrderRequestBody, OrderResponseBody } from "../apis/orders"; | ||
import type { | ||
CreateOrderRequestBody, | ||
OrderResponseBody, | ||
UpdateOrderRequestBody, | ||
} from "../apis/orders"; | ||
import type { | ||
CreateSubscriptionRequestBody, | ||
@@ -103,3 +107,3 @@ ReviseSubscriptionRequestBody, | ||
order: { | ||
patch: () => Promise<void>; | ||
patch: (options: UpdateOrderRequestBody) => Promise<void>; | ||
}; | ||
@@ -106,0 +110,0 @@ }; |
interface PayPalScriptQueryParameters { | ||
"buyer-country"?: string; | ||
"client-id": string; | ||
buyerCountry?: string; | ||
clientId: string; | ||
commit?: boolean; | ||
@@ -8,6 +8,5 @@ components?: string; | ||
debug?: boolean | string; | ||
"disable-card"?: string; | ||
"disable-funding"?: string; | ||
"enable-funding"?: string; | ||
"integration-date"?: string; | ||
disableFunding?: string; | ||
enableFunding?: string; | ||
integrationDate?: string; | ||
intent?: string; | ||
@@ -17,3 +16,3 @@ locale?: string; | ||
// to the correct merchant-id and data-merchant-id string values | ||
"merchant-id"?: string[] | string; | ||
merchantId?: string[] | string; | ||
vault?: boolean | string; | ||
@@ -23,12 +22,12 @@ } | ||
interface PayPalScriptDataAttributes { | ||
"data-client-token"?: string; | ||
"data-csp-nonce"?: string; | ||
"data-client-metadata-id"?: string; | ||
"data-merchant-id"?: string; | ||
"data-namespace"?: string; | ||
"data-page-type"?: string; | ||
"data-partner-attribution-id"?: string; | ||
"data-sdk-integration-source"?: string; | ||
"data-uid"?: string; | ||
"data-user-id-token"?: string; | ||
dataClientToken?: string; | ||
dataCspNonce?: string; | ||
dataClientMetadataId?: string; | ||
dataMerchantId?: string; | ||
dataNamespace?: string; | ||
dataPageType?: string; | ||
dataPartnerAttributionId?: string; | ||
dataSdkIntegrationSource?: string; | ||
dataUid?: string; | ||
dataUserIdToken?: string; | ||
} | ||
@@ -39,5 +38,3 @@ | ||
PayPalScriptDataAttributes { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
[key: string]: any; | ||
sdkBaseURL?: string; | ||
sdkBaseUrl?: string; | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25
173192
3528