Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@stripe/react-stripe-js

Package Overview
Dependencies
Maintainers
17
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stripe/react-stripe-js - npm Package Compare versions

Comparing version 2.6.0 to 2.6.1

4

dist/react-stripe.js

@@ -306,3 +306,3 @@ 'use strict';

name: 'react-stripe-js',
version: "2.6.0"
version: "2.6.1"
});

@@ -312,3 +312,3 @@

name: 'react-stripe-js',
version: "2.6.0",
version: "2.6.1",
url: 'https://stripe.com/docs/stripe-js/react'

@@ -315,0 +315,0 @@ });

@@ -415,3 +415,3 @@ (function (global, factory) {

name: 'react-stripe-js',
version: "2.6.0"
version: "2.6.1"
});

@@ -421,3 +421,3 @@

name: 'react-stripe-js',
version: "2.6.0",
version: "2.6.1",
url: 'https://stripe.com/docs/stripe-js/react'

@@ -424,0 +424,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="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}}));
!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.1"}),e.registerAppInfo({name:"react-stripe-js",version:"2.6.1",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.6.0",
"version": "2.6.1",
"description": "React components for Stripe.js and Stripe Elements",

@@ -70,3 +70,3 @@ "main": "dist/react-stripe.js",

"@storybook/react": "^6.5.0-beta.8",
"@stripe/stripe-js": "^3.0.7",
"@stripe/stripe-js": "^3.0.9",
"@testing-library/jest-dom": "^5.16.4",

@@ -73,0 +73,0 @@ "@testing-library/react": "^13.1.1",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc