Socket
Socket
Sign inDemoInstall

@paypal/react-paypal-js

Package Overview
Dependencies
9
Maintainers
22
Versions
62
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.8.3 to 8.0.0

154

dist/cjs/react-paypal-js.js
/*!
* react-paypal-js v7.8.3 (2023-03-27T21:19:05.517Z)
* react-paypal-js v8.0.0 (2023-06-12T18:08:48.704Z)
* Copyright 2020-present, PayPal, Inc. All rights reserved.

@@ -65,12 +65,41 @@ *

var __assign = function () {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
}
return t;
}
function __spreadArray(to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
}
/*********************************************
* Common reference to the script identifier *
*********************************************/
// keep this script id value in kebab-case format
var SCRIPT_ID = "data-react-paypal-script-id";
var SDK_SETTINGS = {
DATA_CLIENT_TOKEN: "data-client-token",
DATA_USER_ID_TOKEN: "data-user-id-token",
DATA_SDK_INTEGRATION_SOURCE: "data-sdk-integration-source",
DATA_CLIENT_TOKEN: "dataClientToken",
DATA_USER_ID_TOKEN: "dataUserIdToken",
DATA_SDK_INTEGRATION_SOURCE: "dataSdkIntegrationSource",
DATA_SDK_INTEGRATION_SOURCE_VALUE: "react-paypal-js",
DATA_NAMESPACE: "data-namespace",
DATA_NAMESPACE: "dataNamespace",
};

@@ -81,3 +110,3 @@ var LOAD_SCRIPT_ERROR = "Failed to load the PayPal JS SDK script.";

****************************/
var EMPTY_BRAINTREE_AUTHORIZATION_ERROR_MESSAGE = "Invalid authorization data. Use data-client-token or data-user-id-token to authorize.";
var EMPTY_BRAINTREE_AUTHORIZATION_ERROR_MESSAGE = "Invalid authorization data. Use dataClientToken or dataUserIdToken to authorize.";
var braintreeVersion = "3.84.0";

@@ -101,30 +130,2 @@ var BRAINTREE_SOURCE = "https://js.braintreegateway.com/web/".concat(braintreeVersion, "/js/client.min.js");

var __assign = function () {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
}
return t;
}
function __spreadArray(to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
}
/**

@@ -199,3 +200,5 @@ * Get the namespace from the window in the browser

function getScriptID(options) {
return "react-paypal-js-".concat(hashStr(JSON.stringify(options)));
// exclude the data-react-paypal-script-id value from the options hash
var _a = options, _b = SCRIPT_ID; _a[_b]; var paypalScriptOptions = __rest(_a, [_b + ""]);
return "react-paypal-js-".concat(hashStr(JSON.stringify(paypalScriptOptions)));
}

@@ -228,4 +231,2 @@ /**

destroySDKScript(state.options[SCRIPT_ID]);
// exclude the old data-react-paypal-script-id value from the hash generated by getScriptID()
delete action.value[SCRIPT_ID];
return __assign(__assign({}, state), { loadingStatus: exports.SCRIPT_LOADING_STATE.PENDING, options: __assign(__assign({}, action.value), (_a = {}, _a[SCRIPT_ID] = "".concat(getScriptID(action.value)), _a[SDK_SETTINGS.DATA_SDK_INTEGRATION_SOURCE] = SDK_SETTINGS.DATA_SDK_INTEGRATION_SOURCE_VALUE, _a)) });

@@ -256,9 +257,9 @@ case exports.DISPATCH_ACTION.SET_BRAINTREE_INSTANCE:

/**
* Check if the data-client-token or the data-user-id-token are
* Check if the dataClientToken or the dataUserIdToken are
* set in the options of the context.
* @type data-client-token is use to pass a client token
* @type data-user-id-token is use to pass a client tokenization key
* @type dataClientToken is use to pass a client token
* @type dataUserIdToken is use to pass a client tokenization key
*
* @param scriptContext the result of connecting to the context provider
* @throws an {@link Error} if both data-client-token and the data-user-id-token keys are null or undefine
* @throws an {@link Error} if both dataClientToken and the dataUserIdToken keys are null or undefined
* @returns strict context if one of the keys are defined

@@ -344,3 +345,3 @@ */

}
var paypalWindowNamespace = getPayPalWindowNamespace$1(options[SDK_SETTINGS.DATA_NAMESPACE]);
var paypalWindowNamespace = getPayPalWindowNamespace$1(options.dataNamespace);
// verify dependency on window object

@@ -444,13 +445,14 @@ if (paypalWindowNamespace === undefined ||

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).filter(function (key) {
return typeof options[key] !== "undefined" && options[key] !== null && options[key] !== "";
var optionsWithStringIndex = options;
var _a = Object.keys(optionsWithStringIndex).filter(function (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;

@@ -467,7 +469,17 @@ } else {

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) {

@@ -499,27 +511,5 @@ 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;
}
function loadScript(options, PromisePonyfill) {
if (PromisePonyfill === void 0) {
PromisePonyfill = getDefaultPromiseImplementation();
PromisePonyfill = Promise;
}

@@ -549,3 +539,3 @@ validateArguments(options, PromisePonyfill);

if (PromisePonyfill === void 0) {
PromisePonyfill = getDefaultPromiseImplementation();
PromisePonyfill = Promise;
}

@@ -589,8 +579,2 @@ validateArguments(options, PromisePonyfill);

}
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) {

@@ -682,4 +666,4 @@ return window[namespace];

- To use the client token integration set the key `data-client-token` in the `PayPayScriptProvider` component's options.
- To use the tokenization key integration set the key `data-user-id-token` in the `PayPayScriptProvider` component's options.
- To use the client token integration set the key `dataClientToken` in the `PayPayScriptProvider` component's options.
- To use the tokenization key integration set the key `dataUserIdToken` in the `PayPayScriptProvider` component's options.
*/

@@ -843,3 +827,3 @@ var BraintreePayPalButtons = function (_a) {

var _b;
var _c = _a.options, options = _c === void 0 ? { "client-id": "test" } : _c, children = _a.children, _d = _a.deferLoading, deferLoading = _d === void 0 ? false : _d;
var _c = _a.options, options = _c === void 0 ? { clientId: "test" } : _c, children = _a.children, _d = _a.deferLoading, deferLoading = _d === void 0 ? false : _d;
var _e = React.useReducer(scriptReducer, {

@@ -846,0 +830,0 @@ options: __assign(__assign({}, options), (_b = {}, _b[SCRIPT_ID] = "".concat(getScriptID(options)), _b[SDK_SETTINGS.DATA_SDK_INTEGRATION_SOURCE] = SDK_SETTINGS.DATA_SDK_INTEGRATION_SOURCE_VALUE, _b)),

/*!
* react-paypal-js v7.8.3 (2023-03-27T21:19:05.517Z)
* react-paypal-js v8.0.0 (2023-06-12T18:08:48.704Z)
* Copyright 2020-present, PayPal, Inc. All rights reserved.

@@ -17,2 +17,2 @@ *

*/
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n,r,o,a=t(e);exports.SCRIPT_LOADING_STATE=void 0,(n=exports.SCRIPT_LOADING_STATE||(exports.SCRIPT_LOADING_STATE={})).INITIAL="initial",n.PENDING="pending",n.REJECTED="rejected",n.RESOLVED="resolved",exports.DISPATCH_ACTION=void 0,(r=exports.DISPATCH_ACTION||(exports.DISPATCH_ACTION={})).LOADING_STATUS="setLoadingStatus",r.RESET_OPTIONS="resetOptions",r.SET_BRAINTREE_INSTANCE="braintreeInstance",exports.PAYPAL_HOSTED_FIELDS_TYPES=void 0,(o=exports.PAYPAL_HOSTED_FIELDS_TYPES||(exports.PAYPAL_HOSTED_FIELDS_TYPES={})).NUMBER="number",o.CVV="cvv",o.EXPIRATION_DATE="expirationDate",o.EXPIRATION_MONTH="expirationMonth",o.EXPIRATION_YEAR="expirationYear",o.POSTAL_CODE="postalCode";var i="data-react-paypal-script-id",c="data-client-token",s="data-user-id-token",u="data-sdk-integration-source",l="react-paypal-js",d="data-namespace",p="https://js.braintreegateway.com/web/".concat("3.84.0","/js/client.min.js"),f="https://js.braintreegateway.com/web/".concat("3.84.0","/js/paypal-checkout.min.js"),P=function(){return(P=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function E(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function v(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}function h(e){return void 0===e&&(e="paypal"),window[e]}function S(e){var t=e.reactComponentName,n=e.sdkComponentKey,r=e.sdkRequestedComponents,o=void 0===r?"":r,a=e.sdkDataNamespace,i=void 0===a?"paypal":a,c=n.charAt(0).toUpperCase().concat(n.substring(1)),s="Unable to render <".concat(t," /> because window.").concat(i,".").concat(c," is undefined.");if(!o.includes(n)){var u=[o,n].filter(Boolean).join();s+="\nTo fix the issue, add '".concat(n,"' to the list of components passed to the parent PayPalScriptProvider:")+"\n`<PayPalScriptProvider options={{ components: '".concat(u,"'}}>`.")}return s}function T(e){return"react-paypal-js-".concat(function(e){for(var t="",n=0;n<e.length;n++){var r=e[n].charCodeAt(0)*n;e[n+1]&&(r+=e[n+1].charCodeAt(0)*(n-1)),t+=String.fromCharCode(97+Math.abs(r)%26)}return t}(JSON.stringify(e)))}function A(e){var t=self.document.querySelector("script[".concat(i,'="').concat(e,'"]'));(null==t?void 0:t.parentNode)&&t.parentNode.removeChild(t)}function m(e,t){var n;switch(t.type){case exports.DISPATCH_ACTION.LOADING_STATUS:return P(P({},e),{loadingStatus:t.value});case exports.DISPATCH_ACTION.RESET_OPTIONS:return A(e.options[i]),delete t.value[i],P(P({},e),{loadingStatus:exports.SCRIPT_LOADING_STATE.PENDING,options:P(P({},t.value),(n={},n[i]="".concat(T(t.value)),n[u]=l,n))});case exports.DISPATCH_ACTION.SET_BRAINTREE_INSTANCE:return P(P({},e),{braintreePayPalCheckoutInstance:t.value});default:return e}}var I=e.createContext(null);function y(e){if("function"==typeof(null==e?void 0:e.dispatch)&&0!==e.dispatch.length)return e;throw new Error("usePayPalScriptReducer must be used within a PayPalScriptProvider")}function N(){var t=y(e.useContext(I));return[P(P({},t),{isInitial:t.loadingStatus===exports.SCRIPT_LOADING_STATE.INITIAL,isPending:t.loadingStatus===exports.SCRIPT_LOADING_STATE.PENDING,isResolved:t.loadingStatus===exports.SCRIPT_LOADING_STATE.RESOLVED,isRejected:t.loadingStatus===exports.SCRIPT_LOADING_STATE.REJECTED}),t.dispatch]}function O(){var t=function(e){var t,n;if(!(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t[c])&&!(null===(n=null==e?void 0:e.options)||void 0===n?void 0:n[s]))throw new Error("Invalid authorization data. Use data-client-token or data-user-id-token to authorize.");return e}(y(e.useContext(I)));return[t,t.dispatch]}var C=e.createContext({});var R=function(t){var n=t.className,r=void 0===n?"":n,o=t.disabled,i=void 0!==o&&o,c=t.children,s=t.forceReRender,u=void 0===s?[]:s,l=E(t,["className","disabled","children","forceReRender"]),p=i?{opacity:.38}:{},f="".concat(r," ").concat(i?"paypal-buttons-disabled":"").trim(),T=e.useRef(null),A=e.useRef(null),m=N()[0],I=m.isResolved,y=m.options,O=e.useState(null),C=O[0],_=O[1],b=e.useState(!0),g=b[0],w=b[1],D=e.useState(null)[1];function x(){null!==A.current&&A.current.close().catch((function(){}))}return e.useEffect((function(){if(!1===I)return x;var e=h(y[d]);if(void 0===e||void 0===e.Buttons)return D((function(){throw new Error(S({reactComponentName:R.displayName,sdkComponentKey:"buttons",sdkRequestedComponents:y.components,sdkDataNamespace:y[d]}))})),x;try{A.current=e.Buttons(P(P({},l),{onInit:function(e,t){_(t),"function"==typeof l.onInit&&l.onInit(e,t)}}))}catch(e){return D((function(){throw new Error("Failed to render <PayPalButtons /> component. Failed to initialize: ".concat(e))}))}return!1===A.current.isEligible()?(w(!1),x):T.current?(A.current.render(T.current).catch((function(e){null!==T.current&&0!==T.current.children.length&&D((function(){throw new Error("Failed to render <PayPalButtons /> component. ".concat(e))}))})),x):x}),v(v([I],u,!0),[l.fundingSource],!1)),e.useEffect((function(){null!==C&&(!0===i?C.disable().catch((function(){})):C.enable().catch((function(){})))}),[i,C]),a.default.createElement(a.default.Fragment,null,g?a.default.createElement("div",{ref:T,style:p,className:f}):c)};function _(e){var t="https://www.paypal.com/sdk/js";e.sdkBaseURL&&(t=e.sdkBaseURL,delete e.sdkBaseURL),function(e){var t=e["merchant-id"],n=e["data-merchant-id"],r="",o="";Array.isArray(t)?t.length>1?(r="*",o=t.toString()):r=t.toString():"string"==typeof t&&t.length>0?r=t:"string"==typeof n&&n.length>0&&(r="*",o=n);e["merchant-id"]=r,e["data-merchant-id"]=o}(e);var n=Object.keys(e).filter((function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]})).reduce((function(t,n){var r=e[n].toString();return"data-"===n.substring(0,5)?t.dataAttributes[n]=r:t.queryParams[n]=r,t}),{queryParams:{},dataAttributes:{}}),r=n.queryParams,o=n.dataAttributes;return{url:"".concat(t,"?").concat(b(r)),dataAttributes:o}}function b(e){var t="";return Object.keys(e).forEach((function(n){0!==t.length&&(t+="&"),t+=n+"="+e[n]})),t}function g(e,t){void 0===t&&(t={});var n=document.createElement("script");return n.src=e,Object.keys(t).forEach((function(e){n.setAttribute(e,t[e]),"data-csp-nonce"===e&&n.setAttribute("nonce",t["data-csp-nonce"])})),n}function w(e,t){if(void 0===t&&(t=x()),k(e,t),"undefined"==typeof document)return t.resolve(null);var n=_(e),r=n.url,o=n.dataAttributes,a=o["data-namespace"]||"paypal",i=L(a);return function(e,t){var n=document.querySelector('script[src="'.concat(e,'"]'));if(null===n)return null;var r=g(e,t),o=n.cloneNode();if(delete o.dataset.uidAuto,Object.keys(o.dataset).length!==Object.keys(r.dataset).length)return null;var a=!0;return Object.keys(o.dataset).forEach((function(e){o.dataset[e]!==r.dataset[e]&&(a=!1)})),a?n:null}(r,o)&&i?t.resolve(i):D({url:r,attributes:o},t).then((function(){var e=L(a);if(e)return e;throw new Error("The window.".concat(a," global variable is not available."))}))}function D(e,t){void 0===t&&(t=x()),k(e,t);var n=e.url,r=e.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 t((function(e,t){if("undefined"==typeof document)return e();!function(e){var t=e.url,n=e.attributes,r=e.onSuccess,o=e.onError,a=g(t,n);a.onerror=o,a.onload=r,document.head.insertBefore(a,document.head.firstElementChild)}({url:n,attributes:r,onSuccess:function(){return e()},onError:function(){var e=new Error('The script "'.concat(n,'" failed to load.'));return window.fetch?fetch(n).then((function(n){return 200===n.status&&t(e),n.text()})).then((function(e){var n=function(e){var t=e.split("/* Original Error:")[1];return t?t.replace(/\n/g,"").replace("*/","").trim():e}(e);t(new Error(n))})).catch((function(e){t(e)})):t(e)}})}))}function x(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function L(e){return window[e]}function k(e,t){if("object"!=typeof e||null===e)throw new Error("Expected an options object.");if(void 0!==t&&"function"!=typeof t)throw new Error("Expected PromisePonyfill to be a function.")}R.displayName="PayPalButtons";var F=function(e){return e&&function(e){var t,n;if("function"!=typeof(null===(t=null==e?void 0:e.client)||void 0===t?void 0:t.create)&&"function"!=typeof(null===(n=null==e?void 0:e.paypalCheckout)||void 0===n?void 0:n.create))throw new Error("The braintreeNamespace property is not a valid BraintreeNamespace type.");return!0}(e)?Promise.resolve(e):Promise.all([D({url:p}),D({url:f})]).then((function(){return void 0===e&&(e="braintree"),window[e];var e}))},H=function(t){var n=t.className,r=void 0===n?"":n,o=t.children,i=E(t,["className","children"]),c=N()[0],s=c.isResolved,u=c.options,l=e.useRef(null),p=e.useState(!0),f=p[0],v=p[1],T=e.useState(null)[1];return e.useEffect((function(){if(!1!==s){var e=h(u[d]);if(void 0===e||void 0===e.Marks)return T((function(){throw new Error(S({reactComponentName:H.displayName,sdkComponentKey:"marks",sdkRequestedComponents:u.components,sdkDataNamespace:u[d]}))}));!function(e){var t=l.current;if(!t||!e.isEligible())return v(!1);t.firstChild&&t.removeChild(t.firstChild),e.render(t).catch((function(e){null!==t&&0!==t.children.length&&T((function(){throw new Error("Failed to render <PayPalMarks /> component. ".concat(e))}))}))}(e.Marks(P({},i)))}}),[s,i.fundingSource]),a.default.createElement(a.default.Fragment,null,f?a.default.createElement("div",{ref:l,className:r}):o)};H.displayName="PayPalMarks";var j=function(t){var n=t.className,r=void 0===n?"":n,o=t.forceReRender,i=void 0===o?[]:o,c=E(t,["className","forceReRender"]),s=N()[0],u=s.isResolved,l=s.options,p=e.useRef(null),f=e.useRef(null),T=e.useState(null)[1];return e.useEffect((function(){if(!1!==u){var e=h(l[d]);if(void 0===e||void 0===e.Messages)return T((function(){throw new Error(S({reactComponentName:j.displayName,sdkComponentKey:"messages",sdkRequestedComponents:l.components,sdkDataNamespace:l[d]}))}));f.current=e.Messages(P({},c)),f.current.render(p.current).catch((function(e){null!==p.current&&0!==p.current.children.length&&T((function(){throw new Error("Failed to render <PayPalMessages /> component. ".concat(e))}))}))}}),v([u],i,!0)),a.default.createElement("div",{ref:p,className:r})};j.displayName="PayPalMessages";var G=function(e){if(!e.includes(exports.PAYPAL_HOSTED_FIELDS_TYPES.NUMBER)||!e.includes(exports.PAYPAL_HOSTED_FIELDS_TYPES.CVV)||function(e){return!e.includes(exports.PAYPAL_HOSTED_FIELDS_TYPES.EXPIRATION_DATE)&&!e.includes(exports.PAYPAL_HOSTED_FIELDS_TYPES.EXPIRATION_MONTH)&&!e.includes(exports.PAYPAL_HOSTED_FIELDS_TYPES.EXPIRATION_YEAR)}(e))throw new Error("To use HostedFields you must use it with at least 3 children with types: [number, cvv, expirationDate] includes")},B=function(e){G(e),function(e){if(e.length!==new Set(e).size)throw new Error("Cannot use duplicate HostedFields as children")}(e)},Y={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",VERKKOPANKKI:"verkkopankki",PAYU:"payu",BLIK:"blik",TRUSTLY:"trustly",ZIMPLER:"zimpler",MAXIMA:"maxima",OXXO:"oxxo",BOLETO:"boleto",BOLETOBANCARIO:"boletobancario",WECHATPAY:"wechatpay",MERCADOPAGO:"mercadopago",MULTIBANCO:"multibanco"};exports.BraintreePayPalButtons=function(t){var n=t.className,r=void 0===n?"":n,o=t.disabled,i=void 0!==o&&o,u=t.children,l=t.forceReRender,d=void 0===l?[]:l,p=t.braintreeNamespace,f=t.merchantAccountId,v=E(t,["className","disabled","children","forceReRender","braintreeNamespace","merchantAccountId"]),h=e.useState(null)[1],S=O(),T=S[0],A=S[1];return e.useEffect((function(){F(p).then((function(e){var t=T.options[s],n=T.options[c];return e.client.create({authorization:t||n}).then((function(t){var n=f?{merchantAccountId:f}:{};return e.paypalCheckout.create(P(P({},n),{client:t}))})).then((function(e){A({type:exports.DISPATCH_ACTION.SET_BRAINTREE_INSTANCE,value:e})}))})).catch((function(e){h((function(){throw new Error("".concat("Failed to load the PayPal JS SDK script."," ").concat(e))}))}))}),[T.options]),a.default.createElement(a.default.Fragment,null,T.braintreePayPalCheckoutInstance&&a.default.createElement(R,P({className:r,disabled:i,forceReRender:d},function(e,t){var n=e.createOrder,r=e.createBillingAgreement,o=e.onApprove;return"function"==typeof n&&(e.createOrder=function(e,r){return n(e,P(P({},r),{braintree:t}))}),"function"==typeof r&&(e.createBillingAgreement=function(e,n){return r(e,P(P({},n),{braintree:t}))}),"function"==typeof o&&(e.onApprove=function(e,n){return o(e,P(P({},n),{braintree:t}))}),P({},e)}(v,T.braintreePayPalCheckoutInstance)),u))},exports.FUNDING=Y,exports.PayPalButtons=R,exports.PayPalHostedField=function(t){var n=t.hostedFieldType,r=t.options,o=E(t,["hostedFieldType","options"]),i=e.useContext(C);return e.useEffect((function(){var e;if(!(null==i?void 0:i.registerHostedField))throw new Error("The HostedField cannot be register in the PayPalHostedFieldsProvider parent component");i.registerHostedField(((e={})[n]={selector:r.selector,placeholder:r.placeholder,type:r.type,formatInput:r.formatInput,maskInput:r.maskInput,select:r.select,maxlength:r.maxlength,minlength:r.minlength,prefill:r.prefill,rejectUnsupportedCards:r.rejectUnsupportedCards},e))}),[]),a.default.createElement("div",P({},o))},exports.PayPalHostedFieldsProvider=function(t){var n=t.styles,r=t.createOrder,o=t.notEligibleError,i=t.children,c=t.installments,s=O()[0],u=s.options,l=s.loadingStatus,p=e.useState(!0),f=p[0],E=p[1],v=e.useState(),S=v[0],T=v[1],A=e.useState(null)[1],m=e.useRef(null),I=e.useRef(),y=function(t){void 0===t&&(t={});var n=e.useRef(t);return[n,function(e){n.current=P(P({},n.current),e)}]}(),N=y[0],R=y[1];return e.useEffect((function(){var e;if(B(Object.keys(N.current)),l===exports.SCRIPT_LOADING_STATE.RESOLVED){if(I.current=h(u[d]).HostedFields,!I.current)throw new Error(function(e){var t=e.components,n=void 0===t?"":t,r=e[d],o=void 0===r?"paypal":r,a=n?"".concat(n,",hosted-fields"):"hosted-fields",i="Unable to render <PayPalHostedFieldsProvider /> because window.".concat(o,".HostedFields is undefined.");return n.includes("hosted-fields")||(i+="\nTo fix the issue, add 'hosted-fields' to the list of components passed to the parent PayPalScriptProvider: <PayPalScriptProvider options={{ components: '".concat(a,"'}}>")),i}(((e={components:u.components})[d]=u[d],e)));if(!I.current.isEligible())return E(!1);S&&S.teardown(),I.current.render({createOrder:r,fields:N.current,installments:c,styles:n}).then((function(e){m.current&&T(e)})).catch((function(e){A((function(){throw new Error("Failed to render <PayPalHostedFieldsProvider /> component. ".concat(e))}))}))}}),[l,n]),a.default.createElement("div",{ref:m},f?a.default.createElement(C.Provider,{value:{cardFields:S,registerHostedField:R}},i):o)},exports.PayPalMarks=H,exports.PayPalMessages=j,exports.PayPalScriptProvider=function(t){var n,r=t.options,o=void 0===r?{"client-id":"test"}:r,c=t.children,s=t.deferLoading,d=void 0!==s&&s,p=e.useReducer(m,{options:P(P({},o),(n={},n[i]="".concat(T(o)),n[u]=l,n)),loadingStatus:d?exports.SCRIPT_LOADING_STATE.INITIAL:exports.SCRIPT_LOADING_STATE.PENDING}),f=p[0],E=p[1];return e.useEffect((function(){if(!1===d&&f.loadingStatus===exports.SCRIPT_LOADING_STATE.INITIAL)return E({type:exports.DISPATCH_ACTION.LOADING_STATUS,value:exports.SCRIPT_LOADING_STATE.PENDING});if(f.loadingStatus===exports.SCRIPT_LOADING_STATE.PENDING){var e=!0;return w(f.options).then((function(){e&&E({type:exports.DISPATCH_ACTION.LOADING_STATUS,value:exports.SCRIPT_LOADING_STATE.RESOLVED})})).catch((function(t){console.error("".concat("Failed to load the PayPal JS SDK script."," ").concat(t)),e&&E({type:exports.DISPATCH_ACTION.LOADING_STATUS,value:exports.SCRIPT_LOADING_STATE.REJECTED})})),function(){e=!1}}}),[f.options,d,f.loadingStatus]),a.default.createElement(I.Provider,{value:P(P({},f),{dispatch:E})},c)},exports.ScriptContext=I,exports.destroySDKScript=A,exports.getScriptID=T,exports.scriptReducer=m,exports.usePayPalHostedFields=function(){return e.useContext(C)},exports.usePayPalScriptReducer=N,exports.useScriptProviderContext=O;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n,r,o,a=t(e);exports.SCRIPT_LOADING_STATE=void 0,(n=exports.SCRIPT_LOADING_STATE||(exports.SCRIPT_LOADING_STATE={})).INITIAL="initial",n.PENDING="pending",n.REJECTED="rejected",n.RESOLVED="resolved",exports.DISPATCH_ACTION=void 0,(r=exports.DISPATCH_ACTION||(exports.DISPATCH_ACTION={})).LOADING_STATUS="setLoadingStatus",r.RESET_OPTIONS="resetOptions",r.SET_BRAINTREE_INSTANCE="braintreeInstance",exports.PAYPAL_HOSTED_FIELDS_TYPES=void 0,(o=exports.PAYPAL_HOSTED_FIELDS_TYPES||(exports.PAYPAL_HOSTED_FIELDS_TYPES={})).NUMBER="number",o.CVV="cvv",o.EXPIRATION_DATE="expirationDate",o.EXPIRATION_MONTH="expirationMonth",o.EXPIRATION_YEAR="expirationYear",o.POSTAL_CODE="postalCode";var i=function(){return(i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function c(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function s(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}var u="data-react-paypal-script-id",l="dataClientToken",d="dataUserIdToken",p="dataSdkIntegrationSource",f="react-paypal-js",P="dataNamespace",E="https://js.braintreegateway.com/web/".concat("3.84.0","/js/client.min.js"),v="https://js.braintreegateway.com/web/".concat("3.84.0","/js/paypal-checkout.min.js");function T(e){return void 0===e&&(e="paypal"),window[e]}function S(e){var t=e.reactComponentName,n=e.sdkComponentKey,r=e.sdkRequestedComponents,o=void 0===r?"":r,a=e.sdkDataNamespace,i=void 0===a?"paypal":a,c=n.charAt(0).toUpperCase().concat(n.substring(1)),s="Unable to render <".concat(t," /> because window.").concat(i,".").concat(c," is undefined.");if(!o.includes(n)){var u=[o,n].filter(Boolean).join();s+="\nTo fix the issue, add '".concat(n,"' to the list of components passed to the parent PayPalScriptProvider:")+"\n`<PayPalScriptProvider options={{ components: '".concat(u,"'}}>`.")}return s}function A(e){var t=e,n=u;t[n];var r=c(t,[n+""]);return"react-paypal-js-".concat(function(e){for(var t="",n=0;n<e.length;n++){var r=e[n].charCodeAt(0)*n;e[n+1]&&(r+=e[n+1].charCodeAt(0)*(n-1)),t+=String.fromCharCode(97+Math.abs(r)%26)}return t}(JSON.stringify(r)))}function h(e){var t=self.document.querySelector("script[".concat(u,'="').concat(e,'"]'));(null==t?void 0:t.parentNode)&&t.parentNode.removeChild(t)}function m(e,t){var n;switch(t.type){case exports.DISPATCH_ACTION.LOADING_STATUS:return i(i({},e),{loadingStatus:t.value});case exports.DISPATCH_ACTION.RESET_OPTIONS:return h(e.options[u]),i(i({},e),{loadingStatus:exports.SCRIPT_LOADING_STATE.PENDING,options:i(i({},t.value),(n={},n[u]="".concat(A(t.value)),n[p]=f,n))});case exports.DISPATCH_ACTION.SET_BRAINTREE_INSTANCE:return i(i({},e),{braintreePayPalCheckoutInstance:t.value});default:return e}}var I=e.createContext(null);function y(e){if("function"==typeof(null==e?void 0:e.dispatch)&&0!==e.dispatch.length)return e;throw new Error("usePayPalScriptReducer must be used within a PayPalScriptProvider")}function N(){var t=y(e.useContext(I));return[i(i({},t),{isInitial:t.loadingStatus===exports.SCRIPT_LOADING_STATE.INITIAL,isPending:t.loadingStatus===exports.SCRIPT_LOADING_STATE.PENDING,isResolved:t.loadingStatus===exports.SCRIPT_LOADING_STATE.RESOLVED,isRejected:t.loadingStatus===exports.SCRIPT_LOADING_STATE.REJECTED}),t.dispatch]}function O(){var t=function(e){var t,n;if(!(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t[l])&&!(null===(n=null==e?void 0:e.options)||void 0===n?void 0:n[d]))throw new Error("Invalid authorization data. Use dataClientToken or dataUserIdToken to authorize.");return e}(y(e.useContext(I)));return[t,t.dispatch]}var C=e.createContext({});var _=function(t){var n=t.className,r=void 0===n?"":n,o=t.disabled,u=void 0!==o&&o,l=t.children,d=t.forceReRender,p=void 0===d?[]:d,f=c(t,["className","disabled","children","forceReRender"]),E=u?{opacity:.38}:{},v="".concat(r," ").concat(u?"paypal-buttons-disabled":"").trim(),A=e.useRef(null),h=e.useRef(null),m=N()[0],I=m.isResolved,y=m.options,O=e.useState(null),C=O[0],b=O[1],R=e.useState(!0),w=R[0],D=R[1],x=e.useState(null)[1];function g(){null!==h.current&&h.current.close().catch((function(){}))}return e.useEffect((function(){if(!1===I)return g;var e=T(y.dataNamespace);if(void 0===e||void 0===e.Buttons)return x((function(){throw new Error(S({reactComponentName:_.displayName,sdkComponentKey:"buttons",sdkRequestedComponents:y.components,sdkDataNamespace:y[P]}))})),g;try{h.current=e.Buttons(i(i({},f),{onInit:function(e,t){b(t),"function"==typeof f.onInit&&f.onInit(e,t)}}))}catch(e){return x((function(){throw new Error("Failed to render <PayPalButtons /> component. Failed to initialize: ".concat(e))}))}return!1===h.current.isEligible()?(D(!1),g):A.current?(h.current.render(A.current).catch((function(e){null!==A.current&&0!==A.current.children.length&&x((function(){throw new Error("Failed to render <PayPalButtons /> component. ".concat(e))}))})),g):g}),s(s([I],p,!0),[f.fundingSource],!1)),e.useEffect((function(){null!==C&&(!0===u?C.disable().catch((function(){})):C.enable().catch((function(){})))}),[u,C]),a.default.createElement(a.default.Fragment,null,w?a.default.createElement("div",{ref:A,style:E,className:v}):l)};function b(e){var t="";return Object.keys(e).forEach((function(n){0!==t.length&&(t+="&"),t+=n+"="+e[n]})),t}function R(e,t){void 0===t&&(t={});var n=document.createElement("script");return n.src=e,Object.keys(t).forEach((function(e){n.setAttribute(e,t[e]),"data-csp-nonce"===e&&n.setAttribute("nonce",t["data-csp-nonce"])})),n}function w(e,t){if(void 0===t&&(t=Promise),g(e,t),"undefined"==typeof document)return t.resolve(null);var n=function(e){var t="https://www.paypal.com/sdk/js";e.sdkBaseUrl&&(t=e.sdkBaseUrl,delete e.sdkBaseUrl);var n=e,r=Object.keys(n).filter((function(e){return void 0!==n[e]&&null!==n[e]&&""!==n[e]})).reduce((function(e,t){var r,o=n[t].toString();return r=function(e,t){return(t?"-":"")+e.toLowerCase()},"data"===(t=t.replace(/[A-Z]+(?![a-z])|[A-Z]/g,r)).substring(0,4)?e.dataAttributes[t]=o:e.queryParams[t]=o,e}),{queryParams:{},dataAttributes:{}}),o=r.queryParams,a=r.dataAttributes;return o["merchant-id"]&&-1!==o["merchant-id"].indexOf(",")&&(a["data-merchant-id"]=o["merchant-id"],o["merchant-id"]="*"),{url:"".concat(t,"?").concat(b(o)),dataAttributes:a}}(e),r=n.url,o=n.dataAttributes,a=o["data-namespace"]||"paypal",i=x(a);return function(e,t){var n=document.querySelector('script[src="'.concat(e,'"]'));if(null===n)return null;var r=R(e,t),o=n.cloneNode();if(delete o.dataset.uidAuto,Object.keys(o.dataset).length!==Object.keys(r.dataset).length)return null;var a=!0;return Object.keys(o.dataset).forEach((function(e){o.dataset[e]!==r.dataset[e]&&(a=!1)})),a?n:null}(r,o)&&i?t.resolve(i):D({url:r,attributes:o},t).then((function(){var e=x(a);if(e)return e;throw new Error("The window.".concat(a," global variable is not available."))}))}function D(e,t){void 0===t&&(t=Promise),g(e,t);var n=e.url,r=e.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 t((function(e,t){if("undefined"==typeof document)return e();!function(e){var t=e.url,n=e.attributes,r=e.onSuccess,o=e.onError,a=R(t,n);a.onerror=o,a.onload=r,document.head.insertBefore(a,document.head.firstElementChild)}({url:n,attributes:r,onSuccess:function(){return e()},onError:function(){var e=new Error('The script "'.concat(n,'" failed to load.'));return window.fetch?fetch(n).then((function(n){return 200===n.status&&t(e),n.text()})).then((function(e){var n=function(e){var t=e.split("/* Original Error:")[1];return t?t.replace(/\n/g,"").replace("*/","").trim():e}(e);t(new Error(n))})).catch((function(e){t(e)})):t(e)}})}))}function x(e){return window[e]}function g(e,t){if("object"!=typeof e||null===e)throw new Error("Expected an options object.");if(void 0!==t&&"function"!=typeof t)throw new Error("Expected PromisePonyfill to be a function.")}_.displayName="PayPalButtons";var L=function(e){return e&&function(e){var t,n;if("function"!=typeof(null===(t=null==e?void 0:e.client)||void 0===t?void 0:t.create)&&"function"!=typeof(null===(n=null==e?void 0:e.paypalCheckout)||void 0===n?void 0:n.create))throw new Error("The braintreeNamespace property is not a valid BraintreeNamespace type.");return!0}(e)?Promise.resolve(e):Promise.all([D({url:E}),D({url:v})]).then((function(){return void 0===e&&(e="braintree"),window[e];var e}))},k=function(t){var n=t.className,r=void 0===n?"":n,o=t.children,s=c(t,["className","children"]),u=N()[0],l=u.isResolved,d=u.options,p=e.useRef(null),f=e.useState(!0),E=f[0],v=f[1],A=e.useState(null)[1];return e.useEffect((function(){if(!1!==l){var e=T(d[P]);if(void 0===e||void 0===e.Marks)return A((function(){throw new Error(S({reactComponentName:k.displayName,sdkComponentKey:"marks",sdkRequestedComponents:d.components,sdkDataNamespace:d[P]}))}));!function(e){var t=p.current;if(!t||!e.isEligible())return v(!1);t.firstChild&&t.removeChild(t.firstChild),e.render(t).catch((function(e){null!==t&&0!==t.children.length&&A((function(){throw new Error("Failed to render <PayPalMarks /> component. ".concat(e))}))}))}(e.Marks(i({},s)))}}),[l,s.fundingSource]),a.default.createElement(a.default.Fragment,null,E?a.default.createElement("div",{ref:p,className:r}):o)};k.displayName="PayPalMarks";var F=function(t){var n=t.className,r=void 0===n?"":n,o=t.forceReRender,u=void 0===o?[]:o,l=c(t,["className","forceReRender"]),d=N()[0],p=d.isResolved,f=d.options,E=e.useRef(null),v=e.useRef(null),A=e.useState(null)[1];return e.useEffect((function(){if(!1!==p){var e=T(f[P]);if(void 0===e||void 0===e.Messages)return A((function(){throw new Error(S({reactComponentName:F.displayName,sdkComponentKey:"messages",sdkRequestedComponents:f.components,sdkDataNamespace:f[P]}))}));v.current=e.Messages(i({},l)),v.current.render(E.current).catch((function(e){null!==E.current&&0!==E.current.children.length&&A((function(){throw new Error("Failed to render <PayPalMessages /> component. ".concat(e))}))}))}}),s([p],u,!0)),a.default.createElement("div",{ref:E,className:r})};F.displayName="PayPalMessages";var H=function(e){if(!e.includes(exports.PAYPAL_HOSTED_FIELDS_TYPES.NUMBER)||!e.includes(exports.PAYPAL_HOSTED_FIELDS_TYPES.CVV)||function(e){return!e.includes(exports.PAYPAL_HOSTED_FIELDS_TYPES.EXPIRATION_DATE)&&!e.includes(exports.PAYPAL_HOSTED_FIELDS_TYPES.EXPIRATION_MONTH)&&!e.includes(exports.PAYPAL_HOSTED_FIELDS_TYPES.EXPIRATION_YEAR)}(e))throw new Error("To use HostedFields you must use it with at least 3 children with types: [number, cvv, expirationDate] includes")},j=function(e){H(e),function(e){if(e.length!==new Set(e).size)throw new Error("Cannot use duplicate HostedFields as children")}(e)},G={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",VERKKOPANKKI:"verkkopankki",PAYU:"payu",BLIK:"blik",TRUSTLY:"trustly",ZIMPLER:"zimpler",MAXIMA:"maxima",OXXO:"oxxo",BOLETO:"boleto",BOLETOBANCARIO:"boletobancario",WECHATPAY:"wechatpay",MERCADOPAGO:"mercadopago",MULTIBANCO:"multibanco"};exports.BraintreePayPalButtons=function(t){var n=t.className,r=void 0===n?"":n,o=t.disabled,s=void 0!==o&&o,u=t.children,p=t.forceReRender,f=void 0===p?[]:p,P=t.braintreeNamespace,E=t.merchantAccountId,v=c(t,["className","disabled","children","forceReRender","braintreeNamespace","merchantAccountId"]),T=e.useState(null)[1],S=O(),A=S[0],h=S[1];return e.useEffect((function(){L(P).then((function(e){var t=A.options[d],n=A.options[l];return e.client.create({authorization:t||n}).then((function(t){var n=E?{merchantAccountId:E}:{};return e.paypalCheckout.create(i(i({},n),{client:t}))})).then((function(e){h({type:exports.DISPATCH_ACTION.SET_BRAINTREE_INSTANCE,value:e})}))})).catch((function(e){T((function(){throw new Error("".concat("Failed to load the PayPal JS SDK script."," ").concat(e))}))}))}),[A.options]),a.default.createElement(a.default.Fragment,null,A.braintreePayPalCheckoutInstance&&a.default.createElement(_,i({className:r,disabled:s,forceReRender:f},function(e,t){var n=e.createOrder,r=e.createBillingAgreement,o=e.onApprove;return"function"==typeof n&&(e.createOrder=function(e,r){return n(e,i(i({},r),{braintree:t}))}),"function"==typeof r&&(e.createBillingAgreement=function(e,n){return r(e,i(i({},n),{braintree:t}))}),"function"==typeof o&&(e.onApprove=function(e,n){return o(e,i(i({},n),{braintree:t}))}),i({},e)}(v,A.braintreePayPalCheckoutInstance)),u))},exports.FUNDING=G,exports.PayPalButtons=_,exports.PayPalHostedField=function(t){var n=t.hostedFieldType,r=t.options,o=c(t,["hostedFieldType","options"]),s=e.useContext(C);return e.useEffect((function(){var e;if(!(null==s?void 0:s.registerHostedField))throw new Error("The HostedField cannot be register in the PayPalHostedFieldsProvider parent component");s.registerHostedField(((e={})[n]={selector:r.selector,placeholder:r.placeholder,type:r.type,formatInput:r.formatInput,maskInput:r.maskInput,select:r.select,maxlength:r.maxlength,minlength:r.minlength,prefill:r.prefill,rejectUnsupportedCards:r.rejectUnsupportedCards},e))}),[]),a.default.createElement("div",i({},o))},exports.PayPalHostedFieldsProvider=function(t){var n=t.styles,r=t.createOrder,o=t.notEligibleError,c=t.children,s=t.installments,u=O()[0],l=u.options,d=u.loadingStatus,p=e.useState(!0),f=p[0],E=p[1],v=e.useState(),S=v[0],A=v[1],h=e.useState(null)[1],m=e.useRef(null),I=e.useRef(),y=function(t){void 0===t&&(t={});var n=e.useRef(t);return[n,function(e){n.current=i(i({},n.current),e)}]}(),N=y[0],_=y[1];return e.useEffect((function(){var e;if(j(Object.keys(N.current)),d===exports.SCRIPT_LOADING_STATE.RESOLVED){if(I.current=T(l[P]).HostedFields,!I.current)throw new Error(function(e){var t=e.components,n=void 0===t?"":t,r=e[P],o=void 0===r?"paypal":r,a=n?"".concat(n,",hosted-fields"):"hosted-fields",i="Unable to render <PayPalHostedFieldsProvider /> because window.".concat(o,".HostedFields is undefined.");return n.includes("hosted-fields")||(i+="\nTo fix the issue, add 'hosted-fields' to the list of components passed to the parent PayPalScriptProvider: <PayPalScriptProvider options={{ components: '".concat(a,"'}}>")),i}(((e={components:l.components})[P]=l[P],e)));if(!I.current.isEligible())return E(!1);S&&S.teardown(),I.current.render({createOrder:r,fields:N.current,installments:s,styles:n}).then((function(e){m.current&&A(e)})).catch((function(e){h((function(){throw new Error("Failed to render <PayPalHostedFieldsProvider /> component. ".concat(e))}))}))}}),[d,n]),a.default.createElement("div",{ref:m},f?a.default.createElement(C.Provider,{value:{cardFields:S,registerHostedField:_}},c):o)},exports.PayPalMarks=k,exports.PayPalMessages=F,exports.PayPalScriptProvider=function(t){var n,r=t.options,o=void 0===r?{clientId:"test"}:r,c=t.children,s=t.deferLoading,l=void 0!==s&&s,d=e.useReducer(m,{options:i(i({},o),(n={},n[u]="".concat(A(o)),n[p]=f,n)),loadingStatus:l?exports.SCRIPT_LOADING_STATE.INITIAL:exports.SCRIPT_LOADING_STATE.PENDING}),P=d[0],E=d[1];return e.useEffect((function(){if(!1===l&&P.loadingStatus===exports.SCRIPT_LOADING_STATE.INITIAL)return E({type:exports.DISPATCH_ACTION.LOADING_STATUS,value:exports.SCRIPT_LOADING_STATE.PENDING});if(P.loadingStatus===exports.SCRIPT_LOADING_STATE.PENDING){var e=!0;return w(P.options).then((function(){e&&E({type:exports.DISPATCH_ACTION.LOADING_STATUS,value:exports.SCRIPT_LOADING_STATE.RESOLVED})})).catch((function(t){console.error("".concat("Failed to load the PayPal JS SDK script."," ").concat(t)),e&&E({type:exports.DISPATCH_ACTION.LOADING_STATUS,value:exports.SCRIPT_LOADING_STATE.REJECTED})})),function(){e=!1}}}),[P.options,l,P.loadingStatus]),a.default.createElement(I.Provider,{value:i(i({},P),{dispatch:E})},c)},exports.ScriptContext=I,exports.destroySDKScript=h,exports.getScriptID=A,exports.scriptReducer=m,exports.usePayPalHostedFields=function(){return e.useContext(C)},exports.usePayPalScriptReducer=N,exports.useScriptProviderContext=O;
/*!
* react-paypal-js v7.8.3 (2023-03-27T21:19:05.517Z)
* react-paypal-js v8.0.0 (2023-06-12T18:08:48.704Z)
* Copyright 2020-present, PayPal, Inc. All rights reserved.

@@ -63,42 +63,3 @@ *

})(PAYPAL_HOSTED_FIELDS_TYPES || (PAYPAL_HOSTED_FIELDS_TYPES = {}));
/*********************************************
* Common reference to the script identifier *
*********************************************/
var SCRIPT_ID = "data-react-paypal-script-id";
var SDK_SETTINGS = {
DATA_CLIENT_TOKEN: "data-client-token",
DATA_USER_ID_TOKEN: "data-user-id-token",
DATA_SDK_INTEGRATION_SOURCE: "data-sdk-integration-source",
DATA_SDK_INTEGRATION_SOURCE_VALUE: "react-paypal-js",
DATA_NAMESPACE: "data-namespace"
};
var LOAD_SCRIPT_ERROR = "Failed to load the PayPal JS SDK script.";
/****************************
* Braintree error messages *
****************************/
var EMPTY_BRAINTREE_AUTHORIZATION_ERROR_MESSAGE = "Invalid authorization data. Use data-client-token or data-user-id-token to authorize.";
var braintreeVersion = "3.84.0";
var BRAINTREE_SOURCE = "https://js.braintreegateway.com/web/".concat(braintreeVersion, "/js/client.min.js");
var BRAINTREE_PAYPAL_CHECKOUT_SOURCE = "https://js.braintreegateway.com/web/".concat(braintreeVersion, "/js/paypal-checkout.min.js");
/*********************
* PayPal namespaces *
*********************/
var DEFAULT_PAYPAL_NAMESPACE = "paypal";
var DEFAULT_BRAINTREE_NAMESPACE = "braintree";
/*****************
* Hosted Fields *
*****************/
var HOSTED_FIELDS_CHILDREN_ERROR = "To use HostedFields you must use it with at least 3 children with types: [number, cvv, expirationDate] includes";
var HOSTED_FIELDS_DUPLICATE_CHILDREN_ERROR = "Cannot use duplicate HostedFields as children";
/*******************
* Script Provider *
*******************/
var SCRIPT_PROVIDER_REDUCER_ERROR = "usePayPalScriptReducer must be used within a PayPalScriptProvider";
var __assign = function () {

@@ -138,2 +99,42 @@ __assign = Object.assign || function __assign(t) {

}
/*********************************************
* Common reference to the script identifier *
*********************************************/
// keep this script id value in kebab-case format
var SCRIPT_ID = "data-react-paypal-script-id";
var SDK_SETTINGS = {
DATA_CLIENT_TOKEN: "dataClientToken",
DATA_USER_ID_TOKEN: "dataUserIdToken",
DATA_SDK_INTEGRATION_SOURCE: "dataSdkIntegrationSource",
DATA_SDK_INTEGRATION_SOURCE_VALUE: "react-paypal-js",
DATA_NAMESPACE: "dataNamespace"
};
var LOAD_SCRIPT_ERROR = "Failed to load the PayPal JS SDK script.";
/****************************
* Braintree error messages *
****************************/
var EMPTY_BRAINTREE_AUTHORIZATION_ERROR_MESSAGE = "Invalid authorization data. Use dataClientToken or dataUserIdToken to authorize.";
var braintreeVersion = "3.84.0";
var BRAINTREE_SOURCE = "https://js.braintreegateway.com/web/".concat(braintreeVersion, "/js/client.min.js");
var BRAINTREE_PAYPAL_CHECKOUT_SOURCE = "https://js.braintreegateway.com/web/".concat(braintreeVersion, "/js/paypal-checkout.min.js");
/*********************
* PayPal namespaces *
*********************/
var DEFAULT_PAYPAL_NAMESPACE = "paypal";
var DEFAULT_BRAINTREE_NAMESPACE = "braintree";
/*****************
* Hosted Fields *
*****************/
var HOSTED_FIELDS_CHILDREN_ERROR = "To use HostedFields you must use it with at least 3 children with types: [number, cvv, expirationDate] includes";
var HOSTED_FIELDS_DUPLICATE_CHILDREN_ERROR = "Cannot use duplicate HostedFields as children";
/*******************
* Script Provider *
*******************/
var SCRIPT_PROVIDER_REDUCER_ERROR = "usePayPalScriptReducer must be used within a PayPalScriptProvider";
/**

@@ -148,3 +149,2 @@ * Get the namespace from the window in the browser

function getPayPalWindowNamespace$1(namespace) {

@@ -226,3 +226,10 @@ if (namespace === void 0) {

function getScriptID(options) {
return "react-paypal-js-".concat(hashStr(JSON.stringify(options)));
// exclude the data-react-paypal-script-id value from the options hash
var _a = options,
_b = SCRIPT_ID;
_a[_b];
var paypalScriptOptions = __rest(_a, [_b + ""]);
return "react-paypal-js-".concat(hashStr(JSON.stringify(paypalScriptOptions)));
}

@@ -263,5 +270,3 @@ /**

// destroy existing script to make sure only one script loads at a time
destroySDKScript(state.options[SCRIPT_ID]); // exclude the old data-react-paypal-script-id value from the hash generated by getScriptID()
delete action.value[SCRIPT_ID];
destroySDKScript(state.options[SCRIPT_ID]);
return __assign(__assign({}, state), {

@@ -301,9 +306,9 @@ loadingStatus: SCRIPT_LOADING_STATE.PENDING,

/**
* Check if the data-client-token or the data-user-id-token are
* Check if the dataClientToken or the dataUserIdToken are
* set in the options of the context.
* @type data-client-token is use to pass a client token
* @type data-user-id-token is use to pass a client tokenization key
* @type dataClientToken is use to pass a client token
* @type dataUserIdToken is use to pass a client tokenization key
*
* @param scriptContext the result of connecting to the context provider
* @throws an {@link Error} if both data-client-token and the data-user-id-token keys are null or undefine
* @throws an {@link Error} if both dataClientToken and the dataUserIdToken keys are null or undefined
* @returns strict context if one of the keys are defined

@@ -419,3 +424,3 @@ */

var paypalWindowNamespace = getPayPalWindowNamespace$1(options[SDK_SETTINGS.DATA_NAMESPACE]); // verify dependency on window object
var paypalWindowNamespace = getPayPalWindowNamespace$1(options.dataNamespace); // verify dependency on window object

@@ -531,17 +536,18 @@ if (paypalWindowNamespace === undefined || paypalWindowNamespace.Buttons === undefined) {

function processOptions(options) {
var sdkBaseURL = "https://www.paypal.com/sdk/js";
var sdkBaseUrl = "https://www.paypal.com/sdk/js";
if (options.sdkBaseURL) {
sdkBaseURL = options.sdkBaseURL;
delete options.sdkBaseURL;
if (options.sdkBaseUrl) {
sdkBaseUrl = options.sdkBaseUrl;
delete options.sdkBaseUrl;
}
processMerchantID(options);
var optionsWithStringIndex = options;
var _a = Object.keys(options).filter(function (key) {
return typeof options[key] !== "undefined" && options[key] !== null && options[key] !== "";
var _a = Object.keys(optionsWithStringIndex).filter(function (key) {
return typeof optionsWithStringIndex[key] !== "undefined" && optionsWithStringIndex[key] !== null && optionsWithStringIndex[key] !== "";
}).reduce(function (accumulator, key) {
var value = options[key].toString();
var value = optionsWithStringIndex[key].toString();
key = camelCaseToKebabCase(key);
if (key.substring(0, 5) === "data-") {
if (key.substring(0, 4) === "data") {
accumulator.dataAttributes[key] = value;

@@ -560,4 +566,9 @@ } else {

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

@@ -567,2 +578,10 @@ };

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) {

@@ -599,30 +618,5 @@ 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;
}
function loadScript(options, PromisePonyfill) {
if (PromisePonyfill === void 0) {
PromisePonyfill = getDefaultPromiseImplementation();
PromisePonyfill = Promise;
}

@@ -660,3 +654,3 @@

if (PromisePonyfill === void 0) {
PromisePonyfill = getDefaultPromiseImplementation();
PromisePonyfill = Promise;
}

@@ -708,10 +702,2 @@

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) {

@@ -824,4 +810,4 @@ return window[namespace];

- To use the client token integration set the key `data-client-token` in the `PayPayScriptProvider` component's options.
- To use the tokenization key integration set the key `data-user-id-token` in the `PayPayScriptProvider` component's options.
- To use the client token integration set the key `dataClientToken` in the `PayPayScriptProvider` component's options.
- To use the tokenization key integration set the key `dataUserIdToken` in the `PayPayScriptProvider` component's options.
*/

@@ -1039,3 +1025,3 @@

options = _c === void 0 ? {
"client-id": "test"
clientId: "test"
} : _c,

@@ -1042,0 +1028,0 @@ children = _a.children,

/*!
* react-paypal-js v7.8.3 (2023-03-27T21:19:05.517Z)
* react-paypal-js v8.0.0 (2023-06-12T18:08:48.704Z)
* Copyright 2020-present, PayPal, Inc. All rights reserved.

@@ -17,2 +17,2 @@ *

*/
import e,{createContext as t,useContext as n,useRef as r,useState as o,useEffect as a,useReducer as i}from"react";var c,l,u;!function(e){e.INITIAL="initial",e.PENDING="pending",e.REJECTED="rejected",e.RESOLVED="resolved"}(c||(c={})),function(e){e.LOADING_STATUS="setLoadingStatus",e.RESET_OPTIONS="resetOptions",e.SET_BRAINTREE_INSTANCE="braintreeInstance"}(l||(l={})),function(e){e.NUMBER="number",e.CVV="cvv",e.EXPIRATION_DATE="expirationDate",e.EXPIRATION_MONTH="expirationMonth",e.EXPIRATION_YEAR="expirationYear",e.POSTAL_CODE="postalCode"}(u||(u={}));var s="data-react-paypal-script-id",d="data-client-token",f="data-user-id-token",p="data-sdk-integration-source",v="react-paypal-js",h="data-namespace",m="https://js.braintreegateway.com/web/".concat("3.84.0","/js/client.min.js"),y="https://js.braintreegateway.com/web/".concat("3.84.0","/js/paypal-checkout.min.js"),E=function(){return(E=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function P(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function b(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}function N(e){return void 0===e&&(e="paypal"),window[e]}function g(e){var t=e.reactComponentName,n=e.sdkComponentKey,r=e.sdkRequestedComponents,o=void 0===r?"":r,a=e.sdkDataNamespace,i=void 0===a?"paypal":a,c=n.charAt(0).toUpperCase().concat(n.substring(1)),l="Unable to render <".concat(t," /> because window.").concat(i,".").concat(c," is undefined.");if(!o.includes(n)){var u=[o,n].filter(Boolean).join();l+="\nTo fix the issue, add '".concat(n,"' to the list of components passed to the parent PayPalScriptProvider:")+"\n`<PayPalScriptProvider options={{ components: '".concat(u,"'}}>`.")}return l}function w(e){return"react-paypal-js-".concat(function(e){for(var t="",n=0;n<e.length;n++){var r=e[n].charCodeAt(0)*n;e[n+1]&&(r+=e[n+1].charCodeAt(0)*(n-1)),t+=String.fromCharCode(97+Math.abs(r)%26)}return t}(JSON.stringify(e)))}function A(e){var t=self.document.querySelector("script[".concat(s,'="').concat(e,'"]'));(null==t?void 0:t.parentNode)&&t.parentNode.removeChild(t)}function I(e,t){var n;switch(t.type){case l.LOADING_STATUS:return E(E({},e),{loadingStatus:t.value});case l.RESET_OPTIONS:return A(e.options[s]),delete t.value[s],E(E({},e),{loadingStatus:c.PENDING,options:E(E({},t.value),(n={},n[s]="".concat(w(t.value)),n[p]=v,n))});case l.SET_BRAINTREE_INSTANCE:return E(E({},e),{braintreePayPalCheckoutInstance:t.value});default:return e}}var O=t(null);function S(e){if("function"==typeof(null==e?void 0:e.dispatch)&&0!==e.dispatch.length)return e;throw new Error("usePayPalScriptReducer must be used within a PayPalScriptProvider")}function T(){var e=S(n(O));return[E(E({},e),{isInitial:e.loadingStatus===c.INITIAL,isPending:e.loadingStatus===c.PENDING,isResolved:e.loadingStatus===c.RESOLVED,isRejected:e.loadingStatus===c.REJECTED}),e.dispatch]}function R(){var e=function(e){var t,n;if(!(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t[d])&&!(null===(n=null==e?void 0:e.options)||void 0===n?void 0:n[f]))throw new Error("Invalid authorization data. Use data-client-token or data-user-id-token to authorize.");return e}(S(n(O)));return[e,e.dispatch]}var C=t({});function k(){return n(C)}var D=function(t){var n=t.className,i=void 0===n?"":n,c=t.disabled,l=void 0!==c&&c,u=t.children,s=t.forceReRender,d=void 0===s?[]:s,f=P(t,["className","disabled","children","forceReRender"]),p=l?{opacity:.38}:{},v="".concat(i," ").concat(l?"paypal-buttons-disabled":"").trim(),m=r(null),y=r(null),w=T()[0],A=w.isResolved,I=w.options,O=o(null),S=O[0],R=O[1],C=o(!0),k=C[0],j=C[1],L=o(null)[1];function F(){null!==y.current&&y.current.close().catch((function(){}))}return a((function(){if(!1===A)return F;var e=N(I[h]);if(void 0===e||void 0===e.Buttons)return L((function(){throw new Error(g({reactComponentName:D.displayName,sdkComponentKey:"buttons",sdkRequestedComponents:I.components,sdkDataNamespace:I[h]}))})),F;try{y.current=e.Buttons(E(E({},f),{onInit:function(e,t){R(t),"function"==typeof f.onInit&&f.onInit(e,t)}}))}catch(e){return L((function(){throw new Error("Failed to render <PayPalButtons /> component. Failed to initialize: ".concat(e))}))}return!1===y.current.isEligible()?(j(!1),F):m.current?(y.current.render(m.current).catch((function(e){null!==m.current&&0!==m.current.children.length&&L((function(){throw new Error("Failed to render <PayPalButtons /> component. ".concat(e))}))})),F):F}),b(b([A],d,!0),[f.fundingSource],!1)),a((function(){null!==S&&(!0===l?S.disable().catch((function(){})):S.enable().catch((function(){})))}),[l,S]),e.createElement(e.Fragment,null,k?e.createElement("div",{ref:m,style:p,className:v}):u)};function j(e){var t="https://www.paypal.com/sdk/js";e.sdkBaseURL&&(t=e.sdkBaseURL,delete e.sdkBaseURL),function(e){var t=e["merchant-id"],n=e["data-merchant-id"],r="",o="";Array.isArray(t)?t.length>1?(r="*",o=t.toString()):r=t.toString():"string"==typeof t&&t.length>0?r=t:"string"==typeof n&&n.length>0&&(r="*",o=n);e["merchant-id"]=r,e["data-merchant-id"]=o}(e);var n=Object.keys(e).filter((function(t){return void 0!==e[t]&&null!==e[t]&&""!==e[t]})).reduce((function(t,n){var r=e[n].toString();return"data-"===n.substring(0,5)?t.dataAttributes[n]=r:t.queryParams[n]=r,t}),{queryParams:{},dataAttributes:{}}),r=n.queryParams,o=n.dataAttributes;return{url:"".concat(t,"?").concat(L(r)),dataAttributes:o}}function L(e){var t="";return Object.keys(e).forEach((function(n){0!==t.length&&(t+="&"),t+=n+"="+e[n]})),t}function F(e,t){void 0===t&&(t={});var n=document.createElement("script");return n.src=e,Object.keys(t).forEach((function(e){n.setAttribute(e,t[e]),"data-csp-nonce"===e&&n.setAttribute("nonce",t["data-csp-nonce"])})),n}function B(e,t){if(void 0===t&&(t=U()),x(e,t),"undefined"==typeof document)return t.resolve(null);var n=j(e),r=n.url,o=n.dataAttributes,a=o["data-namespace"]||"paypal",i=_(a);return function(e,t){var n=document.querySelector('script[src="'.concat(e,'"]'));if(null===n)return null;var r=F(e,t),o=n.cloneNode();if(delete o.dataset.uidAuto,Object.keys(o.dataset).length!==Object.keys(r.dataset).length)return null;var a=!0;return Object.keys(o.dataset).forEach((function(e){o.dataset[e]!==r.dataset[e]&&(a=!1)})),a?n:null}(r,o)&&i?t.resolve(i):M({url:r,attributes:o},t).then((function(){var e=_(a);if(e)return e;throw new Error("The window.".concat(a," global variable is not available."))}))}function M(e,t){void 0===t&&(t=U()),x(e,t);var n=e.url,r=e.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 t((function(e,t){if("undefined"==typeof document)return e();!function(e){var t=e.url,n=e.attributes,r=e.onSuccess,o=e.onError,a=F(t,n);a.onerror=o,a.onload=r,document.head.insertBefore(a,document.head.firstElementChild)}({url:n,attributes:r,onSuccess:function(){return e()},onError:function(){var e=new Error('The script "'.concat(n,'" failed to load.'));return window.fetch?fetch(n).then((function(n){return 200===n.status&&t(e),n.text()})).then((function(e){var n=function(e){var t=e.split("/* Original Error:")[1];return t?t.replace(/\n/g,"").replace("*/","").trim():e}(e);t(new Error(n))})).catch((function(e){t(e)})):t(e)}})}))}function U(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function _(e){return window[e]}function x(e,t){if("object"!=typeof e||null===e)throw new Error("Expected an options object.");if(void 0!==t&&"function"!=typeof t)throw new Error("Expected PromisePonyfill to be a function.")}D.displayName="PayPalButtons";var H=function(e){return e&&function(e){var t,n;if("function"!=typeof(null===(t=null==e?void 0:e.client)||void 0===t?void 0:t.create)&&"function"!=typeof(null===(n=null==e?void 0:e.paypalCheckout)||void 0===n?void 0:n.create))throw new Error("The braintreeNamespace property is not a valid BraintreeNamespace type.");return!0}(e)?Promise.resolve(e):Promise.all([M({url:m}),M({url:y})]).then((function(){return void 0===e&&(e="braintree"),window[e];var e}))},G=function(t){var n=t.className,r=void 0===n?"":n,i=t.disabled,c=void 0!==i&&i,u=t.children,s=t.forceReRender,p=void 0===s?[]:s,v=t.braintreeNamespace,h=t.merchantAccountId,m=P(t,["className","disabled","children","forceReRender","braintreeNamespace","merchantAccountId"]),y=o(null)[1],b=R(),N=b[0],g=b[1];return a((function(){H(v).then((function(e){var t=N.options[f],n=N.options[d];return e.client.create({authorization:t||n}).then((function(t){var n=h?{merchantAccountId:h}:{};return e.paypalCheckout.create(E(E({},n),{client:t}))})).then((function(e){g({type:l.SET_BRAINTREE_INSTANCE,value:e})}))})).catch((function(e){y((function(){throw new Error("".concat("Failed to load the PayPal JS SDK script."," ").concat(e))}))}))}),[N.options]),e.createElement(e.Fragment,null,N.braintreePayPalCheckoutInstance&&e.createElement(D,E({className:r,disabled:c,forceReRender:p},function(e,t){var n=e.createOrder,r=e.createBillingAgreement,o=e.onApprove;return"function"==typeof n&&(e.createOrder=function(e,r){return n(e,E(E({},r),{braintree:t}))}),"function"==typeof r&&(e.createBillingAgreement=function(e,n){return r(e,E(E({},n),{braintree:t}))}),"function"==typeof o&&(e.onApprove=function(e,n){return o(e,E(E({},n),{braintree:t}))}),E({},e)}(m,N.braintreePayPalCheckoutInstance)),u))},K=function(t){var n=t.className,i=void 0===n?"":n,c=t.children,l=P(t,["className","children"]),u=T()[0],s=u.isResolved,d=u.options,f=r(null),p=o(!0),v=p[0],m=p[1],y=o(null)[1];return a((function(){if(!1!==s){var e=N(d[h]);if(void 0===e||void 0===e.Marks)return y((function(){throw new Error(g({reactComponentName:K.displayName,sdkComponentKey:"marks",sdkRequestedComponents:d.components,sdkDataNamespace:d[h]}))}));!function(e){var t=f.current;if(!t||!e.isEligible())return m(!1);t.firstChild&&t.removeChild(t.firstChild),e.render(t).catch((function(e){null!==t&&0!==t.children.length&&y((function(){throw new Error("Failed to render <PayPalMarks /> component. ".concat(e))}))}))}(e.Marks(E({},l)))}}),[s,l.fundingSource]),e.createElement(e.Fragment,null,v?e.createElement("div",{ref:f,className:i}):c)};K.displayName="PayPalMarks";var Y=function(t){var n=t.className,i=void 0===n?"":n,c=t.forceReRender,l=void 0===c?[]:c,u=P(t,["className","forceReRender"]),s=T()[0],d=s.isResolved,f=s.options,p=r(null),v=r(null),m=o(null)[1];return a((function(){if(!1!==d){var e=N(f[h]);if(void 0===e||void 0===e.Messages)return m((function(){throw new Error(g({reactComponentName:Y.displayName,sdkComponentKey:"messages",sdkRequestedComponents:f.components,sdkDataNamespace:f[h]}))}));v.current=e.Messages(E({},u)),v.current.render(p.current).catch((function(e){null!==p.current&&0!==p.current.children.length&&m((function(){throw new Error("Failed to render <PayPalMessages /> component. ".concat(e))}))}))}}),b([d],l,!0)),e.createElement("div",{ref:p,className:i})};Y.displayName="PayPalMessages";var V=function(t){var n,r=t.options,o=void 0===r?{"client-id":"test"}:r,u=t.children,d=t.deferLoading,f=void 0!==d&&d,h=i(I,{options:E(E({},o),(n={},n[s]="".concat(w(o)),n[p]=v,n)),loadingStatus:f?c.INITIAL:c.PENDING}),m=h[0],y=h[1];return a((function(){if(!1===f&&m.loadingStatus===c.INITIAL)return y({type:l.LOADING_STATUS,value:c.PENDING});if(m.loadingStatus===c.PENDING){var e=!0;return B(m.options).then((function(){e&&y({type:l.LOADING_STATUS,value:c.RESOLVED})})).catch((function(t){console.error("".concat("Failed to load the PayPal JS SDK script."," ").concat(t)),e&&y({type:l.LOADING_STATUS,value:c.REJECTED})})),function(){e=!1}}}),[m.options,f,m.loadingStatus]),e.createElement(O.Provider,{value:E(E({},m),{dispatch:y})},u)},q=function(e){if(!e.includes(u.NUMBER)||!e.includes(u.CVV)||function(e){return!e.includes(u.EXPIRATION_DATE)&&!e.includes(u.EXPIRATION_MONTH)&&!e.includes(u.EXPIRATION_YEAR)}(e))throw new Error("To use HostedFields you must use it with at least 3 children with types: [number, cvv, expirationDate] includes")},X=function(e){q(e),function(e){if(e.length!==new Set(e).size)throw new Error("Cannot use duplicate HostedFields as children")}(e)},z=function(t){var n=t.styles,i=t.createOrder,l=t.notEligibleError,u=t.children,s=t.installments,d=R()[0],f=d.options,p=d.loadingStatus,v=o(!0),m=v[0],y=v[1],P=o(),b=P[0],g=P[1],w=o(null)[1],A=r(null),I=r(),O=function(e){void 0===e&&(e={});var t=r(e);return[t,function(e){t.current=E(E({},t.current),e)}]}(),S=O[0],T=O[1];return a((function(){var e;if(X(Object.keys(S.current)),p===c.RESOLVED){if(I.current=N(f[h]).HostedFields,!I.current)throw new Error(function(e){var t=e.components,n=void 0===t?"":t,r=e[h],o=void 0===r?"paypal":r,a=n?"".concat(n,",hosted-fields"):"hosted-fields",i="Unable to render <PayPalHostedFieldsProvider /> because window.".concat(o,".HostedFields is undefined.");return n.includes("hosted-fields")||(i+="\nTo fix the issue, add 'hosted-fields' to the list of components passed to the parent PayPalScriptProvider: <PayPalScriptProvider options={{ components: '".concat(a,"'}}>")),i}(((e={components:f.components})[h]=f[h],e)));if(!I.current.isEligible())return y(!1);b&&b.teardown(),I.current.render({createOrder:i,fields:S.current,installments:s,styles:n}).then((function(e){A.current&&g(e)})).catch((function(e){w((function(){throw new Error("Failed to render <PayPalHostedFieldsProvider /> component. ".concat(e))}))}))}}),[p,n]),e.createElement("div",{ref:A},m?e.createElement(C.Provider,{value:{cardFields:b,registerHostedField:T}},u):l)},J=function(t){var r=t.hostedFieldType,o=t.options,i=P(t,["hostedFieldType","options"]),c=n(C);return a((function(){var e;if(!(null==c?void 0:c.registerHostedField))throw new Error("The HostedField cannot be register in the PayPalHostedFieldsProvider parent component");c.registerHostedField(((e={})[r]={selector:o.selector,placeholder:o.placeholder,type:o.type,formatInput:o.formatInput,maskInput:o.maskInput,select:o.select,maxlength:o.maxlength,minlength:o.minlength,prefill:o.prefill,rejectUnsupportedCards:o.rejectUnsupportedCards},e))}),[]),e.createElement("div",E({},i))},W={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",VERKKOPANKKI:"verkkopankki",PAYU:"payu",BLIK:"blik",TRUSTLY:"trustly",ZIMPLER:"zimpler",MAXIMA:"maxima",OXXO:"oxxo",BOLETO:"boleto",BOLETOBANCARIO:"boletobancario",WECHATPAY:"wechatpay",MERCADOPAGO:"mercadopago",MULTIBANCO:"multibanco"};export{G as BraintreePayPalButtons,l as DISPATCH_ACTION,W as FUNDING,u as PAYPAL_HOSTED_FIELDS_TYPES,D as PayPalButtons,J as PayPalHostedField,z as PayPalHostedFieldsProvider,K as PayPalMarks,Y as PayPalMessages,V as PayPalScriptProvider,c as SCRIPT_LOADING_STATE,O as ScriptContext,A as destroySDKScript,w as getScriptID,I as scriptReducer,k as usePayPalHostedFields,T as usePayPalScriptReducer,R as useScriptProviderContext};
import e,{createContext as t,useContext as n,useRef as r,useState as o,useEffect as a,useReducer as i}from"react";var c,l,u;!function(e){e.INITIAL="initial",e.PENDING="pending",e.REJECTED="rejected",e.RESOLVED="resolved"}(c||(c={})),function(e){e.LOADING_STATUS="setLoadingStatus",e.RESET_OPTIONS="resetOptions",e.SET_BRAINTREE_INSTANCE="braintreeInstance"}(l||(l={})),function(e){e.NUMBER="number",e.CVV="cvv",e.EXPIRATION_DATE="expirationDate",e.EXPIRATION_MONTH="expirationMonth",e.EXPIRATION_YEAR="expirationYear",e.POSTAL_CODE="postalCode"}(u||(u={}));var s=function(){return(s=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function d(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}function p(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}var f="data-react-paypal-script-id",v="dataClientToken",h="dataUserIdToken",m="dataSdkIntegrationSource",E="react-paypal-js",y="dataNamespace",P="https://js.braintreegateway.com/web/".concat("3.84.0","/js/client.min.js"),N="https://js.braintreegateway.com/web/".concat("3.84.0","/js/paypal-checkout.min.js");function b(e){return void 0===e&&(e="paypal"),window[e]}function w(e){var t=e.reactComponentName,n=e.sdkComponentKey,r=e.sdkRequestedComponents,o=void 0===r?"":r,a=e.sdkDataNamespace,i=void 0===a?"paypal":a,c=n.charAt(0).toUpperCase().concat(n.substring(1)),l="Unable to render <".concat(t," /> because window.").concat(i,".").concat(c," is undefined.");if(!o.includes(n)){var u=[o,n].filter(Boolean).join();l+="\nTo fix the issue, add '".concat(n,"' to the list of components passed to the parent PayPalScriptProvider:")+"\n`<PayPalScriptProvider options={{ components: '".concat(u,"'}}>`.")}return l}function A(e){var t=e,n=f;t[n];var r=d(t,[n+""]);return"react-paypal-js-".concat(function(e){for(var t="",n=0;n<e.length;n++){var r=e[n].charCodeAt(0)*n;e[n+1]&&(r+=e[n+1].charCodeAt(0)*(n-1)),t+=String.fromCharCode(97+Math.abs(r)%26)}return t}(JSON.stringify(r)))}function I(e){var t=self.document.querySelector("script[".concat(f,'="').concat(e,'"]'));(null==t?void 0:t.parentNode)&&t.parentNode.removeChild(t)}function g(e,t){var n;switch(t.type){case l.LOADING_STATUS:return s(s({},e),{loadingStatus:t.value});case l.RESET_OPTIONS:return I(e.options[f]),s(s({},e),{loadingStatus:c.PENDING,options:s(s({},t.value),(n={},n[f]="".concat(A(t.value)),n[m]=E,n))});case l.SET_BRAINTREE_INSTANCE:return s(s({},e),{braintreePayPalCheckoutInstance:t.value});default:return e}}var O=t(null);function T(e){if("function"==typeof(null==e?void 0:e.dispatch)&&0!==e.dispatch.length)return e;throw new Error("usePayPalScriptReducer must be used within a PayPalScriptProvider")}function S(){var e=T(n(O));return[s(s({},e),{isInitial:e.loadingStatus===c.INITIAL,isPending:e.loadingStatus===c.PENDING,isResolved:e.loadingStatus===c.RESOLVED,isRejected:e.loadingStatus===c.REJECTED}),e.dispatch]}function R(){var e=function(e){var t,n;if(!(null===(t=null==e?void 0:e.options)||void 0===t?void 0:t[v])&&!(null===(n=null==e?void 0:e.options)||void 0===n?void 0:n[h]))throw new Error("Invalid authorization data. Use dataClientToken or dataUserIdToken to authorize.");return e}(T(n(O)));return[e,e.dispatch]}var C=t({});function k(){return n(C)}var D=function(t){var n=t.className,i=void 0===n?"":n,c=t.disabled,l=void 0!==c&&c,u=t.children,f=t.forceReRender,v=void 0===f?[]:f,h=d(t,["className","disabled","children","forceReRender"]),m=l?{opacity:.38}:{},E="".concat(i," ").concat(l?"paypal-buttons-disabled":"").trim(),P=r(null),N=r(null),A=S()[0],I=A.isResolved,g=A.options,O=o(null),T=O[0],R=O[1],C=o(!0),k=C[0],j=C[1],L=o(null)[1];function F(){null!==N.current&&N.current.close().catch((function(){}))}return a((function(){if(!1===I)return F;var e=b(g.dataNamespace);if(void 0===e||void 0===e.Buttons)return L((function(){throw new Error(w({reactComponentName:D.displayName,sdkComponentKey:"buttons",sdkRequestedComponents:g.components,sdkDataNamespace:g[y]}))})),F;try{N.current=e.Buttons(s(s({},h),{onInit:function(e,t){R(t),"function"==typeof h.onInit&&h.onInit(e,t)}}))}catch(e){return L((function(){throw new Error("Failed to render <PayPalButtons /> component. Failed to initialize: ".concat(e))}))}return!1===N.current.isEligible()?(j(!1),F):P.current?(N.current.render(P.current).catch((function(e){null!==P.current&&0!==P.current.children.length&&L((function(){throw new Error("Failed to render <PayPalButtons /> component. ".concat(e))}))})),F):F}),p(p([I],v,!0),[h.fundingSource],!1)),a((function(){null!==T&&(!0===l?T.disable().catch((function(){})):T.enable().catch((function(){})))}),[l,T]),e.createElement(e.Fragment,null,k?e.createElement("div",{ref:P,style:m,className:E}):u)};function j(e){var t="";return Object.keys(e).forEach((function(n){0!==t.length&&(t+="&"),t+=n+"="+e[n]})),t}function L(e,t){void 0===t&&(t={});var n=document.createElement("script");return n.src=e,Object.keys(t).forEach((function(e){n.setAttribute(e,t[e]),"data-csp-nonce"===e&&n.setAttribute("nonce",t["data-csp-nonce"])})),n}function F(e,t){if(void 0===t&&(t=Promise),M(e,t),"undefined"==typeof document)return t.resolve(null);var n=function(e){var t="https://www.paypal.com/sdk/js";e.sdkBaseUrl&&(t=e.sdkBaseUrl,delete e.sdkBaseUrl);var n=e,r=Object.keys(n).filter((function(e){return void 0!==n[e]&&null!==n[e]&&""!==n[e]})).reduce((function(e,t){var r,o=n[t].toString();return r=function(e,t){return(t?"-":"")+e.toLowerCase()},"data"===(t=t.replace(/[A-Z]+(?![a-z])|[A-Z]/g,r)).substring(0,4)?e.dataAttributes[t]=o:e.queryParams[t]=o,e}),{queryParams:{},dataAttributes:{}}),o=r.queryParams,a=r.dataAttributes;return o["merchant-id"]&&-1!==o["merchant-id"].indexOf(",")&&(a["data-merchant-id"]=o["merchant-id"],o["merchant-id"]="*"),{url:"".concat(t,"?").concat(j(o)),dataAttributes:a}}(e),r=n.url,o=n.dataAttributes,a=o["data-namespace"]||"paypal",i=U(a);return function(e,t){var n=document.querySelector('script[src="'.concat(e,'"]'));if(null===n)return null;var r=L(e,t),o=n.cloneNode();if(delete o.dataset.uidAuto,Object.keys(o.dataset).length!==Object.keys(r.dataset).length)return null;var a=!0;return Object.keys(o.dataset).forEach((function(e){o.dataset[e]!==r.dataset[e]&&(a=!1)})),a?n:null}(r,o)&&i?t.resolve(i):B({url:r,attributes:o},t).then((function(){var e=U(a);if(e)return e;throw new Error("The window.".concat(a," global variable is not available."))}))}function B(e,t){void 0===t&&(t=Promise),M(e,t);var n=e.url,r=e.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 t((function(e,t){if("undefined"==typeof document)return e();!function(e){var t=e.url,n=e.attributes,r=e.onSuccess,o=e.onError,a=L(t,n);a.onerror=o,a.onload=r,document.head.insertBefore(a,document.head.firstElementChild)}({url:n,attributes:r,onSuccess:function(){return e()},onError:function(){var e=new Error('The script "'.concat(n,'" failed to load.'));return window.fetch?fetch(n).then((function(n){return 200===n.status&&t(e),n.text()})).then((function(e){var n=function(e){var t=e.split("/* Original Error:")[1];return t?t.replace(/\n/g,"").replace("*/","").trim():e}(e);t(new Error(n))})).catch((function(e){t(e)})):t(e)}})}))}function U(e){return window[e]}function M(e,t){if("object"!=typeof e||null===e)throw new Error("Expected an options object.");if(void 0!==t&&"function"!=typeof t)throw new Error("Expected PromisePonyfill to be a function.")}D.displayName="PayPalButtons";var _=function(e){return e&&function(e){var t,n;if("function"!=typeof(null===(t=null==e?void 0:e.client)||void 0===t?void 0:t.create)&&"function"!=typeof(null===(n=null==e?void 0:e.paypalCheckout)||void 0===n?void 0:n.create))throw new Error("The braintreeNamespace property is not a valid BraintreeNamespace type.");return!0}(e)?Promise.resolve(e):Promise.all([B({url:P}),B({url:N})]).then((function(){return void 0===e&&(e="braintree"),window[e];var e}))},x=function(t){var n=t.className,r=void 0===n?"":n,i=t.disabled,c=void 0!==i&&i,u=t.children,p=t.forceReRender,f=void 0===p?[]:p,m=t.braintreeNamespace,E=t.merchantAccountId,y=d(t,["className","disabled","children","forceReRender","braintreeNamespace","merchantAccountId"]),P=o(null)[1],N=R(),b=N[0],w=N[1];return a((function(){_(m).then((function(e){var t=b.options[h],n=b.options[v];return e.client.create({authorization:t||n}).then((function(t){var n=E?{merchantAccountId:E}:{};return e.paypalCheckout.create(s(s({},n),{client:t}))})).then((function(e){w({type:l.SET_BRAINTREE_INSTANCE,value:e})}))})).catch((function(e){P((function(){throw new Error("".concat("Failed to load the PayPal JS SDK script."," ").concat(e))}))}))}),[b.options]),e.createElement(e.Fragment,null,b.braintreePayPalCheckoutInstance&&e.createElement(D,s({className:r,disabled:c,forceReRender:f},function(e,t){var n=e.createOrder,r=e.createBillingAgreement,o=e.onApprove;return"function"==typeof n&&(e.createOrder=function(e,r){return n(e,s(s({},r),{braintree:t}))}),"function"==typeof r&&(e.createBillingAgreement=function(e,n){return r(e,s(s({},n),{braintree:t}))}),"function"==typeof o&&(e.onApprove=function(e,n){return o(e,s(s({},n),{braintree:t}))}),s({},e)}(y,b.braintreePayPalCheckoutInstance)),u))},H=function(t){var n=t.className,i=void 0===n?"":n,c=t.children,l=d(t,["className","children"]),u=S()[0],p=u.isResolved,f=u.options,v=r(null),h=o(!0),m=h[0],E=h[1],P=o(null)[1];return a((function(){if(!1!==p){var e=b(f[y]);if(void 0===e||void 0===e.Marks)return P((function(){throw new Error(w({reactComponentName:H.displayName,sdkComponentKey:"marks",sdkRequestedComponents:f.components,sdkDataNamespace:f[y]}))}));!function(e){var t=v.current;if(!t||!e.isEligible())return E(!1);t.firstChild&&t.removeChild(t.firstChild),e.render(t).catch((function(e){null!==t&&0!==t.children.length&&P((function(){throw new Error("Failed to render <PayPalMarks /> component. ".concat(e))}))}))}(e.Marks(s({},l)))}}),[p,l.fundingSource]),e.createElement(e.Fragment,null,m?e.createElement("div",{ref:v,className:i}):c)};H.displayName="PayPalMarks";var G=function(t){var n=t.className,i=void 0===n?"":n,c=t.forceReRender,l=void 0===c?[]:c,u=d(t,["className","forceReRender"]),f=S()[0],v=f.isResolved,h=f.options,m=r(null),E=r(null),P=o(null)[1];return a((function(){if(!1!==v){var e=b(h[y]);if(void 0===e||void 0===e.Messages)return P((function(){throw new Error(w({reactComponentName:G.displayName,sdkComponentKey:"messages",sdkRequestedComponents:h.components,sdkDataNamespace:h[y]}))}));E.current=e.Messages(s({},u)),E.current.render(m.current).catch((function(e){null!==m.current&&0!==m.current.children.length&&P((function(){throw new Error("Failed to render <PayPalMessages /> component. ".concat(e))}))}))}}),p([v],l,!0)),e.createElement("div",{ref:m,className:i})};G.displayName="PayPalMessages";var K=function(t){var n,r=t.options,o=void 0===r?{clientId:"test"}:r,u=t.children,d=t.deferLoading,p=void 0!==d&&d,v=i(g,{options:s(s({},o),(n={},n[f]="".concat(A(o)),n[m]=E,n)),loadingStatus:p?c.INITIAL:c.PENDING}),h=v[0],y=v[1];return a((function(){if(!1===p&&h.loadingStatus===c.INITIAL)return y({type:l.LOADING_STATUS,value:c.PENDING});if(h.loadingStatus===c.PENDING){var e=!0;return F(h.options).then((function(){e&&y({type:l.LOADING_STATUS,value:c.RESOLVED})})).catch((function(t){console.error("".concat("Failed to load the PayPal JS SDK script."," ").concat(t)),e&&y({type:l.LOADING_STATUS,value:c.REJECTED})})),function(){e=!1}}}),[h.options,p,h.loadingStatus]),e.createElement(O.Provider,{value:s(s({},h),{dispatch:y})},u)},Y=function(e){if(!e.includes(u.NUMBER)||!e.includes(u.CVV)||function(e){return!e.includes(u.EXPIRATION_DATE)&&!e.includes(u.EXPIRATION_MONTH)&&!e.includes(u.EXPIRATION_YEAR)}(e))throw new Error("To use HostedFields you must use it with at least 3 children with types: [number, cvv, expirationDate] includes")},V=function(e){Y(e),function(e){if(e.length!==new Set(e).size)throw new Error("Cannot use duplicate HostedFields as children")}(e)},q=function(t){var n=t.styles,i=t.createOrder,l=t.notEligibleError,u=t.children,d=t.installments,p=R()[0],f=p.options,v=p.loadingStatus,h=o(!0),m=h[0],E=h[1],P=o(),N=P[0],w=P[1],A=o(null)[1],I=r(null),g=r(),O=function(e){void 0===e&&(e={});var t=r(e);return[t,function(e){t.current=s(s({},t.current),e)}]}(),T=O[0],S=O[1];return a((function(){var e;if(V(Object.keys(T.current)),v===c.RESOLVED){if(g.current=b(f[y]).HostedFields,!g.current)throw new Error(function(e){var t=e.components,n=void 0===t?"":t,r=e[y],o=void 0===r?"paypal":r,a=n?"".concat(n,",hosted-fields"):"hosted-fields",i="Unable to render <PayPalHostedFieldsProvider /> because window.".concat(o,".HostedFields is undefined.");return n.includes("hosted-fields")||(i+="\nTo fix the issue, add 'hosted-fields' to the list of components passed to the parent PayPalScriptProvider: <PayPalScriptProvider options={{ components: '".concat(a,"'}}>")),i}(((e={components:f.components})[y]=f[y],e)));if(!g.current.isEligible())return E(!1);N&&N.teardown(),g.current.render({createOrder:i,fields:T.current,installments:d,styles:n}).then((function(e){I.current&&w(e)})).catch((function(e){A((function(){throw new Error("Failed to render <PayPalHostedFieldsProvider /> component. ".concat(e))}))}))}}),[v,n]),e.createElement("div",{ref:I},m?e.createElement(C.Provider,{value:{cardFields:N,registerHostedField:S}},u):l)},X=function(t){var r=t.hostedFieldType,o=t.options,i=d(t,["hostedFieldType","options"]),c=n(C);return a((function(){var e;if(!(null==c?void 0:c.registerHostedField))throw new Error("The HostedField cannot be register in the PayPalHostedFieldsProvider parent component");c.registerHostedField(((e={})[r]={selector:o.selector,placeholder:o.placeholder,type:o.type,formatInput:o.formatInput,maskInput:o.maskInput,select:o.select,maxlength:o.maxlength,minlength:o.minlength,prefill:o.prefill,rejectUnsupportedCards:o.rejectUnsupportedCards},e))}),[]),e.createElement("div",s({},i))},z={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",VERKKOPANKKI:"verkkopankki",PAYU:"payu",BLIK:"blik",TRUSTLY:"trustly",ZIMPLER:"zimpler",MAXIMA:"maxima",OXXO:"oxxo",BOLETO:"boleto",BOLETOBANCARIO:"boletobancario",WECHATPAY:"wechatpay",MERCADOPAGO:"mercadopago",MULTIBANCO:"multibanco"};export{x as BraintreePayPalButtons,l as DISPATCH_ACTION,z as FUNDING,u as PAYPAL_HOSTED_FIELDS_TYPES,D as PayPalButtons,X as PayPalHostedField,q as PayPalHostedFieldsProvider,H as PayPalMarks,G as PayPalMessages,K as PayPalScriptProvider,c as SCRIPT_LOADING_STATE,O as ScriptContext,I as destroySDKScript,A as getScriptID,g as scriptReducer,k as usePayPalHostedFields,S as usePayPalScriptReducer,R as useScriptProviderContext};

@@ -9,5 +9,5 @@ import type { FC } from "react";

- To use the client token integration set the key `data-client-token` in the `PayPayScriptProvider` component's options.
- To use the tokenization key integration set the key `data-user-id-token` in the `PayPayScriptProvider` component's options.
- To use the client token integration set the key `dataClientToken` in the `PayPayScriptProvider` component's options.
- To use the tokenization key integration set the key `dataUserIdToken` in the `PayPayScriptProvider` component's options.
*/
export declare const BraintreePayPalButtons: FC<BraintreePayPalButtonsComponentProps>;

@@ -16,3 +16,3 @@ /*********************************************

****************************/
export declare const EMPTY_BRAINTREE_AUTHORIZATION_ERROR_MESSAGE = "Invalid authorization data. Use data-client-token or data-user-id-token to authorize.";
export declare const EMPTY_BRAINTREE_AUTHORIZATION_ERROR_MESSAGE = "Invalid authorization data. Use dataClientToken or dataUserIdToken to authorize.";
export declare const BRAINTREE_SOURCE: string;

@@ -19,0 +19,0 @@ export declare const BRAINTREE_PAYPAL_CHECKOUT_SOURCE: string;

/// <reference types="react" />
import type { PayPalScriptOptions } from "@paypal/paypal-js";
import type { ScriptContextState, ScriptReducerAction } from "../types";
import type { ScriptContextState, ReactPayPalScriptOptions, ScriptReducerAction } from "../types";
/**

@@ -9,3 +8,3 @@ * Generate a new random identifier for react-paypal-js

*/
export declare function getScriptID(options: PayPalScriptOptions): string;
export declare function getScriptID(options: ReactPayPalScriptOptions): string;
/**

@@ -16,3 +15,3 @@ * Destroy the PayPal SDK from the document page

*/
export declare function destroySDKScript(reactPayPalScriptID: string): void;
export declare function destroySDKScript(reactPayPalScriptID?: string): void;
/**

@@ -19,0 +18,0 @@ * Reducer function to handle complex state changes on the context

@@ -10,11 +10,11 @@ import type { ScriptContextState } from "../types";

/**
* Check if the data-client-token or the data-user-id-token are
* Check if the dataClientToken or the dataUserIdToken are
* set in the options of the context.
* @type data-client-token is use to pass a client token
* @type data-user-id-token is use to pass a client tokenization key
* @type dataClientToken is use to pass a client token
* @type dataUserIdToken is use to pass a client tokenization key
*
* @param scriptContext the result of connecting to the context provider
* @throws an {@link Error} if both data-client-token and the data-user-id-token keys are null or undefine
* @throws an {@link Error} if both dataClientToken and the dataUserIdToken keys are null or undefined
* @returns strict context if one of the keys are defined
*/
export declare const validateBraintreeAuthorizationData: (scriptContext: ScriptContextState | null) => ScriptContextState;

@@ -1,2 +0,1 @@

import { SCRIPT_ID } from "../constants";
import { BraintreePayPalCheckout } from "./braintree/paypalCheckout";

@@ -7,3 +6,3 @@ import { DISPATCH_ACTION, SCRIPT_LOADING_STATE } from "./enums";

export interface ReactPayPalScriptOptions extends PayPalScriptOptions {
[SCRIPT_ID]: string;
[key: string]: any;
}

@@ -15,3 +14,3 @@ export declare type ScriptReducerAction = {

type: `${DISPATCH_ACTION.RESET_OPTIONS}`;
value: PayPalScriptOptions | ReactPayPalScriptOptions;
value: ReactPayPalScriptOptions;
} | {

@@ -38,5 +37,5 @@ type: `${DISPATCH_ACTION.SET_BRAINTREE_INSTANCE}`;

export interface ScriptProviderProps {
options: PayPalScriptOptions;
options: ReactPayPalScriptOptions;
children?: ReactNode;
deferLoading?: boolean;
}
{
"name": "@paypal/react-paypal-js",
"version": "7.8.3",
"version": "8.0.0",
"description": "React components for the PayPal JS SDK",

@@ -48,3 +48,3 @@ "keywords": [

"dependencies": {
"@paypal/paypal-js": "^5.1.6",
"@paypal/paypal-js": "^6.0.0",
"@paypal/sdk-constants": "^1.0.122"

@@ -105,4 +105,4 @@ },

"peerDependencies": {
"react": ">=16.3.0",
"react-dom": ">=16.3.0"
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
},

@@ -109,0 +109,0 @@ "jest": {

@@ -60,3 +60,3 @@ # react-paypal-js

return (
<PayPalScriptProvider options={{ "client-id": "test" }}>
<PayPalScriptProvider options={{ clientId: "test" }}>
<PayPalButtons style={{ layout: "horizontal" }} />

@@ -72,10 +72,9 @@ </PayPalScriptProvider>

Use the PayPalScriptProvider `options` prop to configure the JS SDK. It accepts an object for passing query parameters and data attributes to the JS SDK script.
Use the PayPalScriptProvider `options` prop to configure the JS SDK. It accepts an object for passing query parameters and data attributes to the JS SDK script. Use camelCase for the object keys (clientId, dataClientToken, dataNamespace, etc...).
```jsx
const initialOptions = {
"client-id": "test",
clientId: "test",
currency: "USD",
intent: "capture",
"data-client-token": "abc123xyz==",
};

@@ -180,3 +179,3 @@

return (
<PayPalScriptProvider options={{ "client-id": "test" }}>
<PayPalScriptProvider options={{ clientId: "test" }}>
<PayPalButtons

@@ -223,4 +222,4 @@ createOrder={(data, actions) => {

options={{
"client-id": "test",
"data-client-token": "abc123xyz==",
clientId: "test",
dataClientToken: "abc123xyz==",
}}

@@ -302,4 +301,4 @@ >

options={{
"client-id": "your-client-id",
"data-client-token": "your-data-client-token",
clientId: "your-client-id",
dataClientToken: "your-data-client-token",
}}

@@ -306,0 +305,0 @@ >

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc