@stripe/react-stripe-js
Advanced tools
Comparing version 2.5.1 to 2.6.0
@@ -704,3 +704,4 @@ /// <reference types="react" /> | ||
declare const ElementsConsumer: FunctionComponent<ElementsConsumerProps>; | ||
interface CustomCheckoutContextValue extends stripeJs.StripeCustomCheckoutActions, stripeJs.StripeCustomCheckoutSession { | ||
type StripeCustomCheckoutActions = Omit<Omit<stripeJs.StripeCustomCheckout, "session">, "on">; | ||
interface CustomCheckoutContextValue extends StripeCustomCheckoutActions, stripeJs.StripeCustomCheckoutSession { | ||
} | ||
@@ -745,7 +746,9 @@ interface CustomCheckoutProviderProps { | ||
* Embedded Checkout configuration options. | ||
* You can initially pass in `null` as `options.clientSecret` if you are | ||
* performing an initial server-side render or when generating a static site. | ||
* You can initially pass in `null` to `options.clientSecret` or | ||
* `options.fetchClientSecret` if you are performing an initial server-side | ||
* render or when generating a static site. | ||
*/ | ||
options: { | ||
clientSecret: string | null; | ||
clientSecret?: string | null; | ||
fetchClientSecret?: (() => Promise<string>) | null; | ||
onComplete?: () => void; | ||
@@ -752,0 +755,0 @@ }; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var React = require('react'); | ||
var PropTypes = require('prop-types'); | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
var React = _interopDefault(require('react')); | ||
var PropTypes = _interopDefault(require('prop-types')); | ||
function ownKeys(object, enumerableOnly) { | ||
@@ -263,3 +259,3 @@ var keys = Object.keys(object); | ||
var INVALID_STRIPE_ERROR = 'Invalid prop `stripe` supplied to `Elements`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.'; // We are using types to enforce the `stripe` prop in this lib, but in a real | ||
var INVALID_STRIPE_ERROR$2 = 'Invalid prop `stripe` supplied to `Elements`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.'; // We are using types to enforce the `stripe` prop in this lib, but in a real | ||
// integration `stripe` could be anything, so we need to do some sanity | ||
@@ -269,3 +265,3 @@ // validation to prevent type errors. | ||
var validateStripe = function validateStripe(maybeStripe) { | ||
var errorMsg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : INVALID_STRIPE_ERROR; | ||
var errorMsg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : INVALID_STRIPE_ERROR$2; | ||
@@ -280,3 +276,3 @@ if (maybeStripe === null || isStripe(maybeStripe)) { | ||
var parseStripeProp = function parseStripeProp(raw) { | ||
var errorMsg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : INVALID_STRIPE_ERROR; | ||
var errorMsg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : INVALID_STRIPE_ERROR$2; | ||
@@ -313,3 +309,3 @@ if (isPromise(raw)) { | ||
name: 'react-stripe-js', | ||
version: "2.5.1" | ||
version: "2.6.0" | ||
}); | ||
@@ -319,3 +315,3 @@ | ||
name: 'react-stripe-js', | ||
version: "2.5.1", | ||
version: "2.6.0", | ||
url: 'https://stripe.com/docs/stripe-js/react' | ||
@@ -562,5 +558,5 @@ }); | ||
var _on = customCheckoutSdk.on, | ||
_session = customCheckoutSdk.session, | ||
actions = _objectWithoutProperties(customCheckoutSdk, _excluded); | ||
customCheckoutSdk.on; | ||
customCheckoutSdk.session; | ||
var actions = _objectWithoutProperties(customCheckoutSdk, _excluded); | ||
@@ -922,3 +918,3 @@ if (!sessionState) { | ||
}; | ||
var INVALID_STRIPE_ERROR$2 = 'Invalid prop `stripe` supplied to `EmbeddedCheckoutProvider`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.'; | ||
var INVALID_STRIPE_ERROR = 'Invalid prop `stripe` supplied to `EmbeddedCheckoutProvider`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.'; | ||
var EmbeddedCheckoutProvider = function EmbeddedCheckoutProvider(_ref) { | ||
@@ -929,3 +925,3 @@ var rawStripeProp = _ref.stripe, | ||
var parsed = React.useMemo(function () { | ||
return parseStripeProp(rawStripeProp, INVALID_STRIPE_ERROR$2); | ||
return parseStripeProp(rawStripeProp, INVALID_STRIPE_ERROR); | ||
}, [rawStripeProp]); | ||
@@ -959,3 +955,3 @@ var embeddedCheckoutPromise = React.useRef(null); | ||
if (parsed.tag === 'async' && !loadedStripe.current && options.clientSecret) { | ||
if (parsed.tag === 'async' && !loadedStripe.current && (options.clientSecret || options.fetchClientSecret)) { | ||
parsed.stripePromise.then(function (stripe) { | ||
@@ -966,3 +962,3 @@ if (stripe) { | ||
}); | ||
} else if (parsed.tag === 'sync' && !loadedStripe.current && options.clientSecret) { | ||
} else if (parsed.tag === 'sync' && !loadedStripe.current && (options.clientSecret || options.fetchClientSecret)) { | ||
// Or, handle a sync stripe instance going from null -> populated | ||
@@ -1018,2 +1014,6 @@ setStripeAndInitEmbeddedCheckout(parsed.stripe); | ||
if (options.clientSecret === undefined && options.fetchClientSecret === undefined) { | ||
console.warn('Invalid props passed to EmbeddedCheckoutProvider: You must provide one of either `options.fetchClientSecret` or `options.clientSecret`.'); | ||
} | ||
if (prevOptions.clientSecret != null && options.clientSecret !== prevOptions.clientSecret) { | ||
@@ -1023,2 +1023,6 @@ console.warn('Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the client secret after setting it. Unmount and create a new instance of EmbeddedCheckoutProvider instead.'); | ||
if (prevOptions.fetchClientSecret != null && options.fetchClientSecret !== prevOptions.fetchClientSecret) { | ||
console.warn('Unsupported prop change on EmbeddedCheckoutProvider: You cannot change fetchClientSecret after setting it. Unmount and create a new instance of EmbeddedCheckoutProvider instead.'); | ||
} | ||
if (prevOptions.onComplete != null && options.onComplete !== prevOptions.onComplete) { | ||
@@ -1025,0 +1029,0 @@ console.warn('Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the onComplete option after setting it.'); |
@@ -704,3 +704,4 @@ /// <reference types="react" /> | ||
declare const ElementsConsumer: FunctionComponent<ElementsConsumerProps>; | ||
interface CustomCheckoutContextValue extends stripeJs.StripeCustomCheckoutActions, stripeJs.StripeCustomCheckoutSession { | ||
type StripeCustomCheckoutActions = Omit<Omit<stripeJs.StripeCustomCheckout, "session">, "on">; | ||
interface CustomCheckoutContextValue extends StripeCustomCheckoutActions, stripeJs.StripeCustomCheckoutSession { | ||
} | ||
@@ -745,7 +746,9 @@ interface CustomCheckoutProviderProps { | ||
* Embedded Checkout configuration options. | ||
* You can initially pass in `null` as `options.clientSecret` if you are | ||
* performing an initial server-side render or when generating a static site. | ||
* You can initially pass in `null` to `options.clientSecret` or | ||
* `options.fetchClientSecret` if you are performing an initial server-side | ||
* render or when generating a static site. | ||
*/ | ||
options: { | ||
clientSecret: string | null; | ||
clientSecret?: string | null; | ||
fetchClientSecret?: (() => Promise<string>) | null; | ||
onComplete?: () => void; | ||
@@ -752,0 +755,0 @@ }; |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) : | ||
(global = global || self, factory(global.ReactStripe = {}, global.React)); | ||
}(this, (function (exports, React) { 'use strict'; | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactStripe = {}, global.React)); | ||
})(this, (function (exports, React) { 'use strict'; | ||
React = React && Object.prototype.hasOwnProperty.call(React, 'default') ? React['default'] : React; | ||
function ownKeys(object, enumerableOnly) { | ||
@@ -173,6 +171,8 @@ var keys = Object.keys(object); | ||
function createCommonjsModule(fn, module) { | ||
return module = { exports: {} }, fn(module, module.exports), module.exports; | ||
function getDefaultExportFromCjs (x) { | ||
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; | ||
} | ||
var propTypes = {exports: {}}; | ||
/** | ||
@@ -184,57 +184,82 @@ * Copyright (c) 2013-present, Facebook, Inc. | ||
*/ | ||
var ReactPropTypesSecret_1; | ||
var hasRequiredReactPropTypesSecret; | ||
var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; | ||
var ReactPropTypesSecret_1 = ReactPropTypesSecret; | ||
function requireReactPropTypesSecret() { | ||
if (hasRequiredReactPropTypesSecret) return ReactPropTypesSecret_1; | ||
hasRequiredReactPropTypesSecret = 1; | ||
function emptyFunction() {} | ||
var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; | ||
ReactPropTypesSecret_1 = ReactPropTypesSecret; | ||
return ReactPropTypesSecret_1; | ||
} | ||
function emptyFunctionWithReset() {} | ||
/** | ||
* Copyright (c) 2013-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
var factoryWithThrowingShims; | ||
var hasRequiredFactoryWithThrowingShims; | ||
emptyFunctionWithReset.resetWarningCache = emptyFunction; | ||
function requireFactoryWithThrowingShims() { | ||
if (hasRequiredFactoryWithThrowingShims) return factoryWithThrowingShims; | ||
hasRequiredFactoryWithThrowingShims = 1; | ||
var factoryWithThrowingShims = function () { | ||
function shim(props, propName, componentName, location, propFullName, secret) { | ||
if (secret === ReactPropTypesSecret_1) { | ||
// It is still safe when called from React. | ||
return; | ||
var ReactPropTypesSecret = requireReactPropTypesSecret(); | ||
function emptyFunction() {} | ||
function emptyFunctionWithReset() {} | ||
emptyFunctionWithReset.resetWarningCache = emptyFunction; | ||
factoryWithThrowingShims = function () { | ||
function shim(props, propName, componentName, location, propFullName, secret) { | ||
if (secret === ReactPropTypesSecret) { | ||
// It is still safe when called from React. | ||
return; | ||
} | ||
var err = new Error('Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use PropTypes.checkPropTypes() to call them. ' + 'Read more at http://fb.me/use-check-prop-types'); | ||
err.name = 'Invariant Violation'; | ||
throw err; | ||
} | ||
shim.isRequired = shim; | ||
var err = new Error('Calling PropTypes validators directly is not supported by the `prop-types` package. ' + 'Use PropTypes.checkPropTypes() to call them. ' + 'Read more at http://fb.me/use-check-prop-types'); | ||
err.name = 'Invariant Violation'; | ||
throw err; | ||
} | ||
shim.isRequired = shim; | ||
function getShim() { | ||
return shim; | ||
} | ||
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`. | ||
function getShim() { | ||
return shim; | ||
} | ||
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`. | ||
var ReactPropTypes = { | ||
array: shim, | ||
bool: shim, | ||
func: shim, | ||
number: shim, | ||
object: shim, | ||
string: shim, | ||
symbol: shim, | ||
any: shim, | ||
arrayOf: getShim, | ||
element: shim, | ||
elementType: shim, | ||
instanceOf: getShim, | ||
node: shim, | ||
objectOf: getShim, | ||
oneOf: getShim, | ||
oneOfType: getShim, | ||
shape: getShim, | ||
exact: getShim, | ||
checkPropTypes: emptyFunctionWithReset, | ||
resetWarningCache: emptyFunction | ||
var ReactPropTypes = { | ||
array: shim, | ||
bool: shim, | ||
func: shim, | ||
number: shim, | ||
object: shim, | ||
string: shim, | ||
symbol: shim, | ||
any: shim, | ||
arrayOf: getShim, | ||
element: shim, | ||
elementType: shim, | ||
instanceOf: getShim, | ||
node: shim, | ||
objectOf: getShim, | ||
oneOf: getShim, | ||
oneOfType: getShim, | ||
shape: getShim, | ||
exact: getShim, | ||
checkPropTypes: emptyFunctionWithReset, | ||
resetWarningCache: emptyFunction | ||
}; | ||
ReactPropTypes.PropTypes = ReactPropTypes; | ||
return ReactPropTypes; | ||
}; | ||
ReactPropTypes.PropTypes = ReactPropTypes; | ||
return ReactPropTypes; | ||
}; | ||
var propTypes = createCommonjsModule(function (module) { | ||
return factoryWithThrowingShims; | ||
} | ||
/** | ||
@@ -246,9 +271,12 @@ * Copyright (c) 2013-present, Facebook, Inc. | ||
*/ | ||
{ | ||
// By explicitly using `prop-types` you are opting into new production behavior. | ||
// http://fb.me/prop-types-in-prod | ||
module.exports = factoryWithThrowingShims(); | ||
propTypes.exports = requireFactoryWithThrowingShims()(); | ||
} | ||
}); | ||
var propTypesExports = propTypes.exports; | ||
var PropTypes = /*@__PURE__*/getDefaultExportFromCjs(propTypesExports); | ||
var usePrevious = function usePrevious(value) { | ||
@@ -343,3 +371,3 @@ var ref = React.useRef(value); | ||
var INVALID_STRIPE_ERROR = 'Invalid prop `stripe` supplied to `Elements`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.'; // We are using types to enforce the `stripe` prop in this lib, but in a real | ||
var INVALID_STRIPE_ERROR$2 = 'Invalid prop `stripe` supplied to `Elements`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.'; // We are using types to enforce the `stripe` prop in this lib, but in a real | ||
// integration `stripe` could be anything, so we need to do some sanity | ||
@@ -349,3 +377,3 @@ // validation to prevent type errors. | ||
var validateStripe = function validateStripe(maybeStripe) { | ||
var errorMsg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : INVALID_STRIPE_ERROR; | ||
var errorMsg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : INVALID_STRIPE_ERROR$2; | ||
@@ -360,3 +388,3 @@ if (maybeStripe === null || isStripe(maybeStripe)) { | ||
var parseStripeProp = function parseStripeProp(raw) { | ||
var errorMsg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : INVALID_STRIPE_ERROR; | ||
var errorMsg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : INVALID_STRIPE_ERROR$2; | ||
@@ -393,3 +421,3 @@ if (isPromise(raw)) { | ||
name: 'react-stripe-js', | ||
version: "2.5.1" | ||
version: "2.6.0" | ||
}); | ||
@@ -399,3 +427,3 @@ | ||
name: 'react-stripe-js', | ||
version: "2.5.1", | ||
version: "2.6.0", | ||
url: 'https://stripe.com/docs/stripe-js/react' | ||
@@ -532,4 +560,4 @@ }); | ||
Elements.propTypes = { | ||
stripe: propTypes.any, | ||
options: propTypes.object | ||
stripe: PropTypes.any, | ||
options: PropTypes.object | ||
}; | ||
@@ -597,3 +625,3 @@ var useElementsContextWithUseCase = function useElementsContextWithUseCase(useCaseMessage) { | ||
ElementsConsumer.propTypes = { | ||
children: propTypes.func.isRequired | ||
children: PropTypes.func.isRequired | ||
}; | ||
@@ -644,5 +672,5 @@ | ||
var _on = customCheckoutSdk.on, | ||
_session = customCheckoutSdk.session, | ||
actions = _objectWithoutProperties(customCheckoutSdk, _excluded); | ||
customCheckoutSdk.on; | ||
customCheckoutSdk.session; | ||
var actions = _objectWithoutProperties(customCheckoutSdk, _excluded); | ||
@@ -772,6 +800,6 @@ if (!sessionState) { | ||
CustomCheckoutProvider.propTypes = { | ||
stripe: propTypes.any, | ||
options: propTypes.shape({ | ||
clientSecret: propTypes.string.isRequired, | ||
elementsOptions: propTypes.object | ||
stripe: PropTypes.any, | ||
options: PropTypes.shape({ | ||
clientSecret: PropTypes.string.isRequired, | ||
elementsOptions: PropTypes.object | ||
}).isRequired | ||
@@ -968,20 +996,20 @@ }; | ||
Element.propTypes = { | ||
id: propTypes.string, | ||
className: propTypes.string, | ||
onChange: propTypes.func, | ||
onBlur: propTypes.func, | ||
onFocus: propTypes.func, | ||
onReady: propTypes.func, | ||
onEscape: propTypes.func, | ||
onClick: propTypes.func, | ||
onLoadError: propTypes.func, | ||
onLoaderStart: propTypes.func, | ||
onNetworksChange: propTypes.func, | ||
onCheckout: propTypes.func, | ||
onLineItemClick: propTypes.func, | ||
onConfirm: propTypes.func, | ||
onCancel: propTypes.func, | ||
onShippingAddressChange: propTypes.func, | ||
onShippingRateChange: propTypes.func, | ||
options: propTypes.object | ||
id: PropTypes.string, | ||
className: PropTypes.string, | ||
onChange: PropTypes.func, | ||
onBlur: PropTypes.func, | ||
onFocus: PropTypes.func, | ||
onReady: PropTypes.func, | ||
onEscape: PropTypes.func, | ||
onClick: PropTypes.func, | ||
onLoadError: PropTypes.func, | ||
onLoaderStart: PropTypes.func, | ||
onNetworksChange: PropTypes.func, | ||
onCheckout: PropTypes.func, | ||
onLineItemClick: PropTypes.func, | ||
onConfirm: PropTypes.func, | ||
onCancel: PropTypes.func, | ||
onShippingAddressChange: PropTypes.func, | ||
onShippingRateChange: PropTypes.func, | ||
options: PropTypes.object | ||
}; | ||
@@ -1006,3 +1034,3 @@ Element.displayName = displayName; | ||
}; | ||
var INVALID_STRIPE_ERROR$2 = 'Invalid prop `stripe` supplied to `EmbeddedCheckoutProvider`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.'; | ||
var INVALID_STRIPE_ERROR = 'Invalid prop `stripe` supplied to `EmbeddedCheckoutProvider`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.'; | ||
var EmbeddedCheckoutProvider = function EmbeddedCheckoutProvider(_ref) { | ||
@@ -1013,3 +1041,3 @@ var rawStripeProp = _ref.stripe, | ||
var parsed = React.useMemo(function () { | ||
return parseStripeProp(rawStripeProp, INVALID_STRIPE_ERROR$2); | ||
return parseStripeProp(rawStripeProp, INVALID_STRIPE_ERROR); | ||
}, [rawStripeProp]); | ||
@@ -1043,3 +1071,3 @@ var embeddedCheckoutPromise = React.useRef(null); | ||
if (parsed.tag === 'async' && !loadedStripe.current && options.clientSecret) { | ||
if (parsed.tag === 'async' && !loadedStripe.current && (options.clientSecret || options.fetchClientSecret)) { | ||
parsed.stripePromise.then(function (stripe) { | ||
@@ -1050,3 +1078,3 @@ if (stripe) { | ||
}); | ||
} else if (parsed.tag === 'sync' && !loadedStripe.current && options.clientSecret) { | ||
} else if (parsed.tag === 'sync' && !loadedStripe.current && (options.clientSecret || options.fetchClientSecret)) { | ||
// Or, handle a sync stripe instance going from null -> populated | ||
@@ -1102,2 +1130,6 @@ setStripeAndInitEmbeddedCheckout(parsed.stripe); | ||
if (options.clientSecret === undefined && options.fetchClientSecret === undefined) { | ||
console.warn('Invalid props passed to EmbeddedCheckoutProvider: You must provide one of either `options.fetchClientSecret` or `options.clientSecret`.'); | ||
} | ||
if (prevOptions.clientSecret != null && options.clientSecret !== prevOptions.clientSecret) { | ||
@@ -1107,2 +1139,6 @@ console.warn('Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the client secret after setting it. Unmount and create a new instance of EmbeddedCheckoutProvider instead.'); | ||
if (prevOptions.fetchClientSecret != null && options.fetchClientSecret !== prevOptions.fetchClientSecret) { | ||
console.warn('Unsupported prop change on EmbeddedCheckoutProvider: You cannot change fetchClientSecret after setting it. Unmount and create a new instance of EmbeddedCheckoutProvider instead.'); | ||
} | ||
if (prevOptions.onComplete != null && options.onComplete !== prevOptions.onComplete) { | ||
@@ -1317,4 +1353,2 @@ console.warn('Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the onComplete option after setting it.'); | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
}))); | ||
})); |
@@ -704,3 +704,4 @@ /// <reference types="react" /> | ||
declare const ElementsConsumer: FunctionComponent<ElementsConsumerProps>; | ||
interface CustomCheckoutContextValue extends stripeJs.StripeCustomCheckoutActions, stripeJs.StripeCustomCheckoutSession { | ||
type StripeCustomCheckoutActions = Omit<Omit<stripeJs.StripeCustomCheckout, "session">, "on">; | ||
interface CustomCheckoutContextValue extends StripeCustomCheckoutActions, stripeJs.StripeCustomCheckoutSession { | ||
} | ||
@@ -745,7 +746,9 @@ interface CustomCheckoutProviderProps { | ||
* Embedded Checkout configuration options. | ||
* You can initially pass in `null` as `options.clientSecret` if you are | ||
* performing an initial server-side render or when generating a static site. | ||
* You can initially pass in `null` to `options.clientSecret` or | ||
* `options.fetchClientSecret` if you are performing an initial server-side | ||
* render or when generating a static site. | ||
*/ | ||
options: { | ||
clientSecret: string | null; | ||
clientSecret?: string | null; | ||
fetchClientSecret?: (() => Promise<string>) | null; | ||
onComplete?: () => void; | ||
@@ -752,0 +755,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e=e||self).ReactStripe={},e.React)}(this,(function(e,t){"use strict";function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function r(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach((function(t){u(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},u=Object.keys(e);for(r=0;r<u.length;r++)n=u[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(e);for(r=0;r<u.length;r++)n=u[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==n)return;var r,o,u=[],c=!0,i=!1;try{for(n=n.call(e);!(c=(r=n.next()).done)&&(u.push(r.value),!t||u.length!==t);c=!0);}catch(e){i=!0,o=e}finally{try{c||null==n.return||n.return()}finally{if(i)throw o}}return u}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return a(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;function s(){}function l(){}l.resetWarningCache=s;var p=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e){e.exports=function(){function e(e,t,n,r,o,u){if("SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"!==u){var c=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw c.name="Invariant Violation",c}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:l,resetWarningCache:s};return n.PropTypes=n,n}()})),f=function(e){var n=t.useRef(e);return t.useEffect((function(){n.current=e}),[e]),n.current},d=function(e){return null!==e&&"object"===o(e)},m=function(e){return d(e)&&"function"==typeof e.then},h=function(e){return d(e)&&"function"==typeof e.elements&&"function"==typeof e.createToken&&"function"==typeof e.createPaymentMethod&&"function"==typeof e.confirmCardPayment},y=function e(t,n){if(!d(t)||!d(n))return t===n;var r=Array.isArray(t);if(r!==Array.isArray(n))return!1;var o="[object Object]"===Object.prototype.toString.call(t);if(o!==("[object Object]"===Object.prototype.toString.call(n)))return!1;if(!o&&!r)return t===n;var u=Object.keys(t),c=Object.keys(n);if(u.length!==c.length)return!1;for(var i={},a=0;a<u.length;a+=1)i[u[a]]=!0;for(var s=0;s<c.length;s+=1)i[c[s]]=!0;var l=Object.keys(i);if(l.length!==u.length)return!1;var p=t,f=n;return l.every((function(t){return e(p[t],f[t])}))},C=function(e,t,n){return d(e)?Object.keys(e).reduce((function(o,c){var i=!d(t)||!y(e[c],t[c]);return n.includes(c)?(i&&console.warn("Unsupported prop change: options.".concat(c," is not a mutable property.")),o):i?r(r({},o||{}),{},u({},c,e[c])):o}),null):null},v="Invalid prop `stripe` supplied to `Elements`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.",g=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:v;if(null===e||h(e))return e;throw new Error(t)},E=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:v;if(m(e))return{tag:"async",stripePromise:Promise.resolve(e).then((function(e){return g(e,t)}))};var n=g(e,t);return null===n?{tag:"empty"}:{tag:"sync",stripe:n}},k=function(e){e&&e._registerWrapper&&e.registerAppInfo&&(e._registerWrapper({name:"react-stripe-js",version:"2.5.1"}),e.registerAppInfo({name:"react-stripe-js",version:"2.5.1",url:"https://stripe.com/docs/stripe-js/react"}))},b=t.createContext(null);b.displayName="ElementsContext";var S=function(e,t){if(!e)throw new Error("Could not find Elements context; You need to wrap the part of your app that ".concat(t," in an <Elements> provider."));return e},O=t.createContext(null);O.displayName="CartElementContext";var P=function(e,t){if(!e)throw new Error("Could not find Elements context; You need to wrap the part of your app that ".concat(t," in an <Elements> provider."));return e},w=function(e){var n=e.stripe,r=e.options,o=e.children,u=t.useMemo((function(){return E(n)}),[n]),c=i(t.useState(null),2),a=c[0],s=c[1],l=i(t.useState(null),2),p=l[0],d=l[1],m=i(t.useState((function(){return{stripe:"sync"===u.tag?u.stripe:null,elements:"sync"===u.tag?u.stripe.elements(r):null}})),2),h=m[0],y=m[1];t.useEffect((function(){var e=!0,t=function(e){y((function(t){return t.stripe?t:{stripe:e,elements:e.elements(r)}}))};return"async"!==u.tag||h.stripe?"sync"!==u.tag||h.stripe||t(u.stripe):u.stripePromise.then((function(n){n&&e&&t(n)})),function(){e=!1}}),[u,h,r]);var v=f(n);t.useEffect((function(){null!==v&&v!==n&&console.warn("Unsupported prop change on Elements: You cannot change the `stripe` prop after setting it.")}),[v,n]);var g=f(r);return t.useEffect((function(){if(h.elements){var e=C(r,g,["clientSecret","fonts"]);e&&h.elements.update(e)}}),[r,g,h.elements]),t.useEffect((function(){k(h.stripe)}),[h.stripe]),t.createElement(b.Provider,{value:h},t.createElement(O.Provider,{value:{cart:a,setCart:s,cartState:p,setCartState:d}},o))};w.propTypes={stripe:p.any,options:p.object};var j=function(e){var n=t.useContext(b);return S(n,e)},x={cart:null,cartState:null,setCart:function(){},setCartState:function(){}},A=function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=t.useContext(O);return n?x:P(r,e)},R=function(e){return(0,e.children)(j("mounts <ElementsConsumer>"))};R.propTypes={children:p.func.isRequired};var N=function(e,n,r){var o=!!r,u=t.useRef(r);t.useEffect((function(){u.current=r}),[r]),t.useEffect((function(){if(!o||!e)return function(){};var t=function(){u.current&&u.current.apply(u,arguments)};return e.on(n,t),function(){e.off(n,t)}}),[o,n,e,u])},I=["on","session"],T=t.createContext(null);T.displayName="CustomCheckoutSdkContext";var _=function(e,t){if(!e)throw new Error("Could not find CustomCheckoutProvider context; You need to wrap the part of your app that ".concat(t," in an <CustomCheckoutProvider> provider."));return e},B=t.createContext(null);B.displayName="CustomCheckoutContext";var M=function(e){var n=e.stripe,o=e.options,u=e.children,a=t.useMemo((function(){return E(n,"Invalid prop `stripe` supplied to `CustomCheckoutProvider`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.")}),[n]),s=i(t.useState(null),2),l=s[0],p=s[1],m=i(t.useState((function(){return{stripe:"sync"===a.tag?a.stripe:null,customCheckoutSdk:null}})),2),h=m[0],C=m[1],v=function(e,t){C((function(n){return n.stripe&&n.customCheckoutSdk?n:{stripe:e,customCheckoutSdk:t}}))},g=t.useRef(!1);t.useEffect((function(){var e=!0;return"async"!==a.tag||h.stripe?"sync"===a.tag&&a.stripe&&!g.current&&(g.current=!0,a.stripe.initCustomCheckout(o).then((function(e){e&&(v(a.stripe,e),e.on("change",p))}))):a.stripePromise.then((function(t){t&&e&&!g.current&&(g.current=!0,t.initCustomCheckout(o).then((function(e){e&&(v(t,e),e.on("change",p))})))})),function(){e=!1}}),[a,h,o,p]);var b=f(n);t.useEffect((function(){null!==b&&b!==n&&console.warn("Unsupported prop change on CustomCheckoutProvider: You cannot change the `stripe` prop after setting it.")}),[b,n]);var S=f(o);t.useEffect((function(){var e,t;if(h.customCheckoutSdk){!o.clientSecret||d(S)||y(o.clientSecret,S.clientSecret)||console.warn("Unsupported prop change: options.client_secret is not a mutable property.");var n=null==S||null===(e=S.elementsOptions)||void 0===e?void 0:e.appearance,r=null==o||null===(t=o.elementsOptions)||void 0===t?void 0:t.appearance;r&&!y(r,n)&&h.customCheckoutSdk.changeAppearance(r)}}),[o,S,h.customCheckoutSdk]),t.useEffect((function(){k(h.stripe)}),[h.stripe]);var O=t.useMemo((function(){return function(e,t){if(!e)return null;e.on,e.session;var n=c(e,I);return r(r({},n),t||e.session())}(h.customCheckoutSdk,l)}),[h.customCheckoutSdk,l]);return h.customCheckoutSdk?t.createElement(T.Provider,{value:h},t.createElement(B.Provider,{value:O},u)):null};M.propTypes={stripe:p.any,options:p.shape({clientSecret:p.string.isRequired,elementsOptions:p.object}).isRequired};var U=function(e){var n=t.useContext(T),r=t.useContext(b);if(n&&r)throw new Error("You cannot wrap the part of your app that ".concat(e," in both <CustomCheckoutProvider> and <Elements> providers."));return n?_(n,e):S(r,e)},L=function(e,n){var r,o="".concat((r=e).charAt(0).toUpperCase()+r.slice(1),"Element"),u=n?function(e){var n=U("mounts <".concat(o,">"));A("mounts <".concat(o,">"),"customCheckoutSdk"in n);var r=e.id,u=e.className;return t.createElement("div",{id:r,className:u})}:function(n){var r,u=n.id,c=n.className,a=n.options,s=void 0===a?{}:a,l=n.onBlur,p=n.onFocus,d=n.onReady,m=n.onChange,h=n.onEscape,y=n.onClick,v=n.onLoadError,g=n.onLoaderStart,E=n.onNetworksChange,k=n.onCheckout,b=n.onLineItemClick,S=n.onConfirm,O=n.onCancel,P=n.onShippingAddressChange,w=n.onShippingRateChange,j=U("mounts <".concat(o,">")),x="elements"in j?j.elements:null,R="customCheckoutSdk"in j?j.customCheckoutSdk:null,I=i(t.useState(null),2),T=I[0],_=I[1],B=t.useRef(null),M=t.useRef(null),L=A("mounts <".concat(o,">"),"customCheckoutSdk"in j),Y=L.setCart,q=L.setCartState;N(T,"blur",l),N(T,"focus",p),N(T,"escape",h),N(T,"click",y),N(T,"loaderror",v),N(T,"loaderstart",g),N(T,"networkschange",E),N(T,"lineitemclick",b),N(T,"confirm",S),N(T,"cancel",O),N(T,"shippingaddresschange",P),N(T,"shippingratechange",w),"cart"===e?r=function(e){q(e),d&&d(e)}:d&&(r="expressCheckout"===e?d:function(){d(T)}),N(T,"ready",r),N(T,"change","cart"===e?function(e){q(e),m&&m(e)}:m),N(T,"checkout","cart"===e?function(e){q(e),k&&k(e)}:k),t.useLayoutEffect((function(){if(null===B.current&&null!==M.current&&(x||R)){var t=null;R?t=R.createElement(e,s):x&&(t=x.create(e,s)),"cart"===e&&Y&&Y(t),B.current=t,_(t),t&&t.mount(M.current)}}),[x,R,s,Y]);var W=f(s);return t.useEffect((function(){if(B.current){var e=C(s,W,["paymentRequest"]);e&&B.current.update(e)}}),[s,W]),t.useLayoutEffect((function(){return function(){if(B.current&&"function"==typeof B.current.destroy)try{B.current.destroy(),B.current=null}catch(e){}}}),[]),t.createElement("div",{id:u,className:c,ref:M})};return u.propTypes={id:p.string,className:p.string,onChange:p.func,onBlur:p.func,onFocus:p.func,onReady:p.func,onEscape:p.func,onClick:p.func,onLoadError:p.func,onLoaderStart:p.func,onNetworksChange:p.func,onCheckout:p.func,onLineItemClick:p.func,onConfirm:p.func,onCancel:p.func,onShippingAddressChange:p.func,onShippingRateChange:p.func,options:p.object},u.displayName=o,u.__elementType=e,u},Y="undefined"==typeof window,q=t.createContext(null);q.displayName="EmbeddedCheckoutProviderContext";var W=function(){var e=t.useContext(q);if(!e)throw new Error("<EmbeddedCheckout> must be used within <EmbeddedCheckoutProvider>");return e},D=Y?function(e){var n=e.id,r=e.className;return W(),t.createElement("div",{id:n,className:r})}:function(e){var n=e.id,r=e.className,o=W().embeddedCheckout,u=t.useRef(!1),c=t.useRef(null);return t.useLayoutEffect((function(){return!u.current&&o&&null!==c.current&&(o.mount(c.current),u.current=!0),function(){if(u.current&&o)try{o.unmount(),u.current=!1}catch(e){}}}),[o]),t.createElement("div",{ref:c,id:n,className:r})},F=L("auBankAccount",Y),H=L("card",Y),V=L("cardNumber",Y),$=L("cardExpiry",Y),z=L("cardCvc",Y),G=L("fpxBank",Y),J=L("iban",Y),K=L("idealBank",Y),Q=L("p24Bank",Y),X=L("epsBank",Y),Z=L("payment",Y),ee=L("expressCheckout",Y),te=L("paymentRequestButton",Y),ne=L("linkAuthentication",Y),re=L("address",Y),oe=L("shippingAddress",Y),ue=L("cart",Y),ce=L("paymentMethodMessaging",Y),ie=L("affirmMessage",Y),ae=L("afterpayClearpayMessage",Y);e.AddressElement=re,e.AffirmMessageElement=ie,e.AfterpayClearpayMessageElement=ae,e.AuBankAccountElement=F,e.CardCvcElement=z,e.CardElement=H,e.CardExpiryElement=$,e.CardNumberElement=V,e.CartElement=ue,e.CustomCheckoutProvider=M,e.Elements=w,e.ElementsConsumer=R,e.EmbeddedCheckout=D,e.EmbeddedCheckoutProvider=function(e){var n=e.stripe,r=e.options,o=e.children,u=t.useMemo((function(){return E(n,"Invalid prop `stripe` supplied to `EmbeddedCheckoutProvider`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.")}),[n]),c=t.useRef(null),a=t.useRef(null),s=i(t.useState({embeddedCheckout:null}),2),l=s[0],p=s[1];t.useEffect((function(){if(!a.current&&!c.current){var e=function(e){a.current||c.current||(a.current=e,c.current=a.current.initEmbeddedCheckout(r).then((function(e){p({embeddedCheckout:e})})))};"async"===u.tag&&!a.current&&r.clientSecret?u.stripePromise.then((function(t){t&&e(t)})):"sync"===u.tag&&!a.current&&r.clientSecret&&e(u.stripe)}}),[u,r,l,a]),t.useEffect((function(){return function(){l.embeddedCheckout?(c.current=null,l.embeddedCheckout.destroy()):c.current&&c.current.then((function(){c.current=null,l.embeddedCheckout&&l.embeddedCheckout.destroy()}))}}),[l.embeddedCheckout]),t.useEffect((function(){k(a)}),[a]);var d=f(n);t.useEffect((function(){null!==d&&d!==n&&console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the `stripe` prop after setting it.")}),[d,n]);var m=f(r);return t.useEffect((function(){null!=m&&(null!=r?(null!=m.clientSecret&&r.clientSecret!==m.clientSecret&&console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the client secret after setting it. Unmount and create a new instance of EmbeddedCheckoutProvider instead."),null!=m.onComplete&&r.onComplete!==m.onComplete&&console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the onComplete option after setting it.")):console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot unset options after setting them."))}),[m,r]),t.createElement(q.Provider,{value:l},o)},e.EpsBankElement=X,e.ExpressCheckoutElement=ee,e.FpxBankElement=G,e.IbanElement=J,e.IdealBankElement=K,e.LinkAuthenticationElement=ne,e.P24BankElement=Q,e.PaymentElement=Z,e.PaymentMethodMessagingElement=ce,e.PaymentRequestButtonElement=te,e.ShippingAddressElement=oe,e.useCartElement=function(){return A("calls useCartElement()").cart},e.useCartElementState=function(){return A("calls useCartElementState()").cartState},e.useCustomCheckout=function(){!function(e){var n=t.useContext(T);_(n,e)}("calls useCustomCheckout()");var e=t.useContext(B);if(!e)throw new Error("Could not find CustomCheckout Context; You need to wrap the part of your app that calls useCustomCheckout() in an <CustomCheckoutProvider> provider.");return e},e.useElements=function(){return j("calls useElements()").elements},e.useStripe=function(){return U("calls useStripe()").stripe},Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactStripe={},e.React)}(this,(function(e,t){"use strict";function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function r(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach((function(t){u(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},u=Object.keys(e);for(r=0;r<u.length;r++)n=u[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var u=Object.getOwnPropertySymbols(e);for(r=0;r<u.length;r++)n=u[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==n)return;var r,o,u=[],c=!0,i=!1;try{for(n=n.call(e);!(c=(r=n.next()).done)&&(u.push(r.value),!t||u.length!==t);c=!0);}catch(e){i=!0,o=e}finally{try{c||null==n.return||n.return()}finally{if(i)throw o}}return u}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return a(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function s(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var l,p,f,d,m={exports:{}};m.exports=function(){if(d)return f;d=1;var e=p?l:(p=1,l="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");function t(){}function n(){}return n.resetWarningCache=t,f=function(){function r(t,n,r,o,u,c){if(c!==e){var i=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw i.name="Invariant Violation",i}}function o(){return r}r.isRequired=r;var u={array:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:o,element:r,elementType:r,instanceOf:o,node:r,objectOf:o,oneOf:o,oneOfType:o,shape:o,exact:o,checkPropTypes:n,resetWarningCache:t};return u.PropTypes=u,u}}()();var h=s(m.exports),y=function(e){var n=t.useRef(e);return t.useEffect((function(){n.current=e}),[e]),n.current},C=function(e){return null!==e&&"object"===o(e)},v="[object Object]",g=function e(t,n){if(!C(t)||!C(n))return t===n;var r=Array.isArray(t);if(r!==Array.isArray(n))return!1;var o=Object.prototype.toString.call(t)===v;if(o!==(Object.prototype.toString.call(n)===v))return!1;if(!o&&!r)return t===n;var u=Object.keys(t),c=Object.keys(n);if(u.length!==c.length)return!1;for(var i={},a=0;a<u.length;a+=1)i[u[a]]=!0;for(var s=0;s<c.length;s+=1)i[c[s]]=!0;var l=Object.keys(i);if(l.length!==u.length)return!1;var p=t,f=n;return l.every((function(t){return e(p[t],f[t])}))},E=function(e,t,n){return C(e)?Object.keys(e).reduce((function(o,c){var i=!C(t)||!g(e[c],t[c]);return n.includes(c)?(i&&console.warn("Unsupported prop change: options.".concat(c," is not a mutable property.")),o):i?r(r({},o||{}),{},u({},c,e[c])):o}),null):null},k="Invalid prop `stripe` supplied to `Elements`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.",b=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:k;if(null===e||C(t=e)&&"function"==typeof t.elements&&"function"==typeof t.createToken&&"function"==typeof t.createPaymentMethod&&"function"==typeof t.confirmCardPayment)return e;throw new Error(n)},S=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:k;if(function(e){return C(e)&&"function"==typeof e.then}(e))return{tag:"async",stripePromise:Promise.resolve(e).then((function(e){return b(e,t)}))};var n=b(e,t);return null===n?{tag:"empty"}:{tag:"sync",stripe:n}},w=function(e){e&&e._registerWrapper&&e.registerAppInfo&&(e._registerWrapper({name:"react-stripe-js",version:"2.6.0"}),e.registerAppInfo({name:"react-stripe-js",version:"2.6.0",url:"https://stripe.com/docs/stripe-js/react"}))},P=t.createContext(null);P.displayName="ElementsContext";var O=function(e,t){if(!e)throw new Error("Could not find Elements context; You need to wrap the part of your app that ".concat(t," in an <Elements> provider."));return e},j=t.createContext(null);j.displayName="CartElementContext";var x=function(e){var n=e.stripe,r=e.options,o=e.children,u=t.useMemo((function(){return S(n)}),[n]),c=i(t.useState(null),2),a=c[0],s=c[1],l=i(t.useState(null),2),p=l[0],f=l[1],d=i(t.useState((function(){return{stripe:"sync"===u.tag?u.stripe:null,elements:"sync"===u.tag?u.stripe.elements(r):null}})),2),m=d[0],h=d[1];t.useEffect((function(){var e=!0,t=function(e){h((function(t){return t.stripe?t:{stripe:e,elements:e.elements(r)}}))};return"async"!==u.tag||m.stripe?"sync"!==u.tag||m.stripe||t(u.stripe):u.stripePromise.then((function(n){n&&e&&t(n)})),function(){e=!1}}),[u,m,r]);var C=y(n);t.useEffect((function(){null!==C&&C!==n&&console.warn("Unsupported prop change on Elements: You cannot change the `stripe` prop after setting it.")}),[C,n]);var v=y(r);return t.useEffect((function(){if(m.elements){var e=E(r,v,["clientSecret","fonts"]);e&&m.elements.update(e)}}),[r,v,m.elements]),t.useEffect((function(){w(m.stripe)}),[m.stripe]),t.createElement(P.Provider,{value:m},t.createElement(j.Provider,{value:{cart:a,setCart:s,cartState:p,setCartState:f}},o))};x.propTypes={stripe:h.any,options:h.object};var A=function(e){var n=t.useContext(P);return O(n,e)},R={cart:null,cartState:null,setCart:function(){},setCartState:function(){}},N=function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=t.useContext(j);return n?R:function(e,t){if(!e)throw new Error("Could not find Elements context; You need to wrap the part of your app that ".concat(t," in an <Elements> provider."));return e}(r,e)},T=function(e){return(0,e.children)(A("mounts <ElementsConsumer>"))};T.propTypes={children:h.func.isRequired};var I=function(e,n,r){var o=!!r,u=t.useRef(r);t.useEffect((function(){u.current=r}),[r]),t.useEffect((function(){if(!o||!e)return function(){};var t=function(){u.current&&u.current.apply(u,arguments)};return e.on(n,t),function(){e.off(n,t)}}),[o,n,e,u])},_=["on","session"],B=t.createContext(null);B.displayName="CustomCheckoutSdkContext";var M=function(e,t){if(!e)throw new Error("Could not find CustomCheckoutProvider context; You need to wrap the part of your app that ".concat(t," in an <CustomCheckoutProvider> provider."));return e},U=t.createContext(null);U.displayName="CustomCheckoutContext";var Y=function(e){var n=e.stripe,o=e.options,u=e.children,a=t.useMemo((function(){return S(n,"Invalid prop `stripe` supplied to `CustomCheckoutProvider`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.")}),[n]),s=i(t.useState(null),2),l=s[0],p=s[1],f=i(t.useState((function(){return{stripe:"sync"===a.tag?a.stripe:null,customCheckoutSdk:null}})),2),d=f[0],m=f[1],h=function(e,t){m((function(n){return n.stripe&&n.customCheckoutSdk?n:{stripe:e,customCheckoutSdk:t}}))},v=t.useRef(!1);t.useEffect((function(){var e=!0;return"async"!==a.tag||d.stripe?"sync"===a.tag&&a.stripe&&!v.current&&(v.current=!0,a.stripe.initCustomCheckout(o).then((function(e){e&&(h(a.stripe,e),e.on("change",p))}))):a.stripePromise.then((function(t){t&&e&&!v.current&&(v.current=!0,t.initCustomCheckout(o).then((function(e){e&&(h(t,e),e.on("change",p))})))})),function(){e=!1}}),[a,d,o,p]);var E=y(n);t.useEffect((function(){null!==E&&E!==n&&console.warn("Unsupported prop change on CustomCheckoutProvider: You cannot change the `stripe` prop after setting it.")}),[E,n]);var k=y(o);t.useEffect((function(){var e,t;if(d.customCheckoutSdk){!o.clientSecret||C(k)||g(o.clientSecret,k.clientSecret)||console.warn("Unsupported prop change: options.client_secret is not a mutable property.");var n=null==k||null===(e=k.elementsOptions)||void 0===e?void 0:e.appearance,r=null==o||null===(t=o.elementsOptions)||void 0===t?void 0:t.appearance;r&&!g(r,n)&&d.customCheckoutSdk.changeAppearance(r)}}),[o,k,d.customCheckoutSdk]),t.useEffect((function(){w(d.stripe)}),[d.stripe]);var b=t.useMemo((function(){return e=d.customCheckoutSdk,t=l,e?(e.on,e.session,r(r({},c(e,_)),t||e.session())):null;var e,t}),[d.customCheckoutSdk,l]);return d.customCheckoutSdk?t.createElement(B.Provider,{value:d},t.createElement(U.Provider,{value:b},u)):null};Y.propTypes={stripe:h.any,options:h.shape({clientSecret:h.string.isRequired,elementsOptions:h.object}).isRequired};var L=function(e){var n=t.useContext(B),r=t.useContext(P);if(n&&r)throw new Error("You cannot wrap the part of your app that ".concat(e," in both <CustomCheckoutProvider> and <Elements> providers."));return n?M(n,e):O(r,e)},q=function(e,n){var r,o="".concat((r=e).charAt(0).toUpperCase()+r.slice(1),"Element"),u=n?function(e){var n=L("mounts <".concat(o,">"));N("mounts <".concat(o,">"),"customCheckoutSdk"in n);var r=e.id,u=e.className;return t.createElement("div",{id:r,className:u})}:function(n){var r,u=n.id,c=n.className,a=n.options,s=void 0===a?{}:a,l=n.onBlur,p=n.onFocus,f=n.onReady,d=n.onChange,m=n.onEscape,h=n.onClick,C=n.onLoadError,v=n.onLoaderStart,g=n.onNetworksChange,k=n.onCheckout,b=n.onLineItemClick,S=n.onConfirm,w=n.onCancel,P=n.onShippingAddressChange,O=n.onShippingRateChange,j=L("mounts <".concat(o,">")),x="elements"in j?j.elements:null,A="customCheckoutSdk"in j?j.customCheckoutSdk:null,R=i(t.useState(null),2),T=R[0],_=R[1],B=t.useRef(null),M=t.useRef(null),U=N("mounts <".concat(o,">"),"customCheckoutSdk"in j),Y=U.setCart,q=U.setCartState;I(T,"blur",l),I(T,"focus",p),I(T,"escape",m),I(T,"click",h),I(T,"loaderror",C),I(T,"loaderstart",v),I(T,"networkschange",g),I(T,"lineitemclick",b),I(T,"confirm",S),I(T,"cancel",w),I(T,"shippingaddresschange",P),I(T,"shippingratechange",O),"cart"===e?r=function(e){q(e),f&&f(e)}:f&&(r="expressCheckout"===e?f:function(){f(T)}),I(T,"ready",r),I(T,"change","cart"===e?function(e){q(e),d&&d(e)}:d),I(T,"checkout","cart"===e?function(e){q(e),k&&k(e)}:k),t.useLayoutEffect((function(){if(null===B.current&&null!==M.current&&(x||A)){var t=null;A?t=A.createElement(e,s):x&&(t=x.create(e,s)),"cart"===e&&Y&&Y(t),B.current=t,_(t),t&&t.mount(M.current)}}),[x,A,s,Y]);var W=y(s);return t.useEffect((function(){if(B.current){var e=E(s,W,["paymentRequest"]);e&&B.current.update(e)}}),[s,W]),t.useLayoutEffect((function(){return function(){if(B.current&&"function"==typeof B.current.destroy)try{B.current.destroy(),B.current=null}catch(e){}}}),[]),t.createElement("div",{id:u,className:c,ref:M})};return u.propTypes={id:h.string,className:h.string,onChange:h.func,onBlur:h.func,onFocus:h.func,onReady:h.func,onEscape:h.func,onClick:h.func,onLoadError:h.func,onLoaderStart:h.func,onNetworksChange:h.func,onCheckout:h.func,onLineItemClick:h.func,onConfirm:h.func,onCancel:h.func,onShippingAddressChange:h.func,onShippingRateChange:h.func,options:h.object},u.displayName=o,u.__elementType=e,u},W="undefined"==typeof window,D=t.createContext(null);D.displayName="EmbeddedCheckoutProviderContext";var F=function(){var e=t.useContext(D);if(!e)throw new Error("<EmbeddedCheckout> must be used within <EmbeddedCheckoutProvider>");return e},H=W?function(e){var n=e.id,r=e.className;return F(),t.createElement("div",{id:n,className:r})}:function(e){var n=e.id,r=e.className,o=F().embeddedCheckout,u=t.useRef(!1),c=t.useRef(null);return t.useLayoutEffect((function(){return!u.current&&o&&null!==c.current&&(o.mount(c.current),u.current=!0),function(){if(u.current&&o)try{o.unmount(),u.current=!1}catch(e){}}}),[o]),t.createElement("div",{ref:c,id:n,className:r})},V=q("auBankAccount",W),$=q("card",W),z=q("cardNumber",W),G=q("cardExpiry",W),J=q("cardCvc",W),K=q("fpxBank",W),Q=q("iban",W),X=q("idealBank",W),Z=q("p24Bank",W),ee=q("epsBank",W),te=q("payment",W),ne=q("expressCheckout",W),re=q("paymentRequestButton",W),oe=q("linkAuthentication",W),ue=q("address",W),ce=q("shippingAddress",W),ie=q("cart",W),ae=q("paymentMethodMessaging",W),se=q("affirmMessage",W),le=q("afterpayClearpayMessage",W);e.AddressElement=ue,e.AffirmMessageElement=se,e.AfterpayClearpayMessageElement=le,e.AuBankAccountElement=V,e.CardCvcElement=J,e.CardElement=$,e.CardExpiryElement=G,e.CardNumberElement=z,e.CartElement=ie,e.CustomCheckoutProvider=Y,e.Elements=x,e.ElementsConsumer=T,e.EmbeddedCheckout=H,e.EmbeddedCheckoutProvider=function(e){var n=e.stripe,r=e.options,o=e.children,u=t.useMemo((function(){return S(n,"Invalid prop `stripe` supplied to `EmbeddedCheckoutProvider`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.")}),[n]),c=t.useRef(null),a=t.useRef(null),s=i(t.useState({embeddedCheckout:null}),2),l=s[0],p=s[1];t.useEffect((function(){if(!a.current&&!c.current){var e=function(e){a.current||c.current||(a.current=e,c.current=a.current.initEmbeddedCheckout(r).then((function(e){p({embeddedCheckout:e})})))};"async"!==u.tag||a.current||!r.clientSecret&&!r.fetchClientSecret?"sync"!==u.tag||a.current||!r.clientSecret&&!r.fetchClientSecret||e(u.stripe):u.stripePromise.then((function(t){t&&e(t)}))}}),[u,r,l,a]),t.useEffect((function(){return function(){l.embeddedCheckout?(c.current=null,l.embeddedCheckout.destroy()):c.current&&c.current.then((function(){c.current=null,l.embeddedCheckout&&l.embeddedCheckout.destroy()}))}}),[l.embeddedCheckout]),t.useEffect((function(){w(a)}),[a]);var f=y(n);t.useEffect((function(){null!==f&&f!==n&&console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the `stripe` prop after setting it.")}),[f,n]);var d=y(r);return t.useEffect((function(){null!=d&&(null!=r?(void 0===r.clientSecret&&void 0===r.fetchClientSecret&&console.warn("Invalid props passed to EmbeddedCheckoutProvider: You must provide one of either `options.fetchClientSecret` or `options.clientSecret`."),null!=d.clientSecret&&r.clientSecret!==d.clientSecret&&console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the client secret after setting it. Unmount and create a new instance of EmbeddedCheckoutProvider instead."),null!=d.fetchClientSecret&&r.fetchClientSecret!==d.fetchClientSecret&&console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot change fetchClientSecret after setting it. Unmount and create a new instance of EmbeddedCheckoutProvider instead."),null!=d.onComplete&&r.onComplete!==d.onComplete&&console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the onComplete option after setting it.")):console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot unset options after setting them."))}),[d,r]),t.createElement(D.Provider,{value:l},o)},e.EpsBankElement=ee,e.ExpressCheckoutElement=ne,e.FpxBankElement=K,e.IbanElement=Q,e.IdealBankElement=X,e.LinkAuthenticationElement=oe,e.P24BankElement=Z,e.PaymentElement=te,e.PaymentMethodMessagingElement=ae,e.PaymentRequestButtonElement=re,e.ShippingAddressElement=ce,e.useCartElement=function(){return N("calls useCartElement()").cart},e.useCartElementState=function(){return N("calls useCartElementState()").cartState},e.useCustomCheckout=function(){!function(e){var n=t.useContext(B);M(n,e)}("calls useCustomCheckout()");var e=t.useContext(U);if(!e)throw new Error("Could not find CustomCheckout Context; You need to wrap the part of your app that calls useCustomCheckout() in an <CustomCheckoutProvider> provider.");return e},e.useElements=function(){return A("calls useElements()").elements},e.useStripe=function(){return L("calls useStripe()").stripe}})); |
{ | ||
"name": "@stripe/react-stripe-js", | ||
"version": "2.5.1", | ||
"version": "2.6.0", | ||
"description": "React components for Stripe.js and Stripe Elements", | ||
"main": "dist/react-stripe.js", | ||
"module": "dist/react-stripe.esm.js", | ||
"jsnext:main": "dist/react-stripe.esm.js", | ||
"module": "dist/react-stripe.esm.mjs", | ||
"jsnext:main": "dist/react-stripe.esm.mjs", | ||
"browser:min": "dist/react-stripe.umd.min.js", | ||
@@ -17,3 +17,3 @@ "browser": "dist/react-stripe.umd.js", | ||
"typecheck": "tsc", | ||
"build": "yarn run clean && yarn run rollup -c && yarn checkimport", | ||
"build": "yarn run clean && yarn run rollup -c --bundleConfigAsCjs && yarn checkimport", | ||
"checkimport": "scripts/check-imports", | ||
@@ -65,4 +65,9 @@ "clean": "rimraf dist", | ||
"@babel/preset-react": "^7.7.0", | ||
"@rollup/plugin-babel": "^6.0.4", | ||
"@rollup/plugin-commonjs": "^25.0.7", | ||
"@rollup/plugin-node-resolve": "^15.2.3", | ||
"@rollup/plugin-replace": "^5.0.5", | ||
"@rollup/plugin-terser": "^0.4.4", | ||
"@storybook/react": "^6.5.0-beta.8", | ||
"@stripe/stripe-js": "^2.2.0", | ||
"@stripe/stripe-js": "^3.0.7", | ||
"@testing-library/jest-dom": "^5.16.4", | ||
@@ -76,3 +81,2 @@ "@testing-library/react": "^13.1.1", | ||
"@typescript-eslint/parser": "^2.18.0", | ||
"@wessberg/rollup-plugin-ts": "^1.2.15", | ||
"babel-eslint": "^10.0.3", | ||
@@ -98,11 +102,7 @@ "babel-jest": "^24.9.0", | ||
"rimraf": "^2.6.2", | ||
"rollup": "^1.27.0", | ||
"rollup-plugin-babel": "^4.3.3", | ||
"rollup-plugin-commonjs": "^10.1.0", | ||
"rollup-plugin-node-resolve": "^5.2.0", | ||
"rollup-plugin-replace": "^2.2.0", | ||
"rollup-plugin-terser": "^5.1.2", | ||
"rollup": "^4.12.0", | ||
"rollup-plugin-ts": "^3.4.5", | ||
"ts-jest": "^25.1.0", | ||
"ts-loader": "^6.2.1", | ||
"typescript": "^3.7.5" | ||
"typescript": "^4.1.2" | ||
}, | ||
@@ -109,0 +109,0 @@ "resolutions": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
529937
10767