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.3.2 to 2.4.0

4

dist/react-stripe.esm.js

@@ -304,3 +304,3 @@ import React from 'react';

name: 'react-stripe-js',
version: "2.3.2"
version: "2.4.0"
});

@@ -310,3 +310,3 @@

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

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

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

name: 'react-stripe-js',
version: "2.3.2"
version: "2.4.0"
});

@@ -316,3 +316,3 @@

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

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

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

name: 'react-stripe-js',
version: "2.3.2"
version: "2.4.0"
});

@@ -393,3 +393,3 @@

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

@@ -396,0 +396,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.3.2"}),e.registerAppInfo({name:"react-stripe-js",version:"2.3.2",url:"https://stripe.com/docs/stripe-js/react"}))},b=["on","session"],S=t.createContext(null);S.displayName="CustomCheckoutSdkContext";var O=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},P=t.createContext(null);P.displayName="CustomCheckoutContext";var w=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 O=f(n);t.useEffect((function(){null!==O&&O!==n&&console.warn("Unsupported prop change on CustomCheckoutProvider: You cannot change the `stripe` prop after setting it.")}),[O,n]);var w=f(o);t.useEffect((function(){var e,t;if(h.customCheckoutSdk){!o.clientSecret||d(w)||y(o.clientSecret,w.clientSecret)||console.warn("Unsupported prop change: options.client_secret is not a mutable property.");var n=null==w||null===(e=w.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,w,h.customCheckoutSdk]),t.useEffect((function(){k(h.stripe)}),[h.stripe]);var j=t.useMemo((function(){return function(e,t){if(!e)return null;e.on,e.session;var n=c(e,b);return r(r({},n),t||e.session())}(h.customCheckoutSdk,l)}),[h.customCheckoutSdk,l]);return h.customCheckoutSdk?t.createElement(S.Provider,{value:h},t.createElement(P.Provider,{value:j},u)):null};w.propTypes={stripe:p.any,options:p.shape({clientSecret:p.string.isRequired,elementsOptions:p.object}).isRequired};var j=function(e){var n=t.useContext(S),r=t.useContext(x);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?O(n,e):A(r,e)},x=t.createContext(null);x.displayName="ElementsContext";var A=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=t.createContext(null);R.displayName="CartElementContext";var N=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},I=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(x.Provider,{value:h},t.createElement(R.Provider,{value:{cart:a,setCart:s,cartState:p,setCartState:d}},o))};I.propTypes={stripe:p.any,options:p.object};var T=function(e){var n=t.useContext(x);return A(n,e)},_={cart:null,cartState:null,setCart:function(){},setCartState:function(){}},B=function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=t.useContext(R);return n?_:N(r,e)},M=function(e){return(0,e.children)(T("mounts <ElementsConsumer>"))};M.propTypes={children:p.func.isRequired};var U=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])},L=function(e,n){var r,o="".concat((r=e).charAt(0).toUpperCase()+r.slice(1),"Element"),u=n?function(e){var n=j("mounts <".concat(o,">"));B("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,x=j("mounts <".concat(o,">")),A="elements"in x?x.elements:null,R="customCheckoutSdk"in x?x.customCheckoutSdk:null,N=i(t.useState(null),2),I=N[0],T=N[1],_=t.useRef(null),M=t.useRef(null),L=B("mounts <".concat(o,">"),"customCheckoutSdk"in x),Y=L.setCart,q=L.setCartState;U(I,"blur",l),U(I,"focus",p),U(I,"escape",h),U(I,"click",y),U(I,"loaderror",v),U(I,"loaderstart",g),U(I,"networkschange",E),U(I,"lineitemclick",b),U(I,"confirm",S),U(I,"cancel",O),U(I,"shippingaddresschange",P),U(I,"shippingratechange",w),"cart"===e?r=function(e){q(e),d&&d(e)}:d&&(r="expressCheckout"===e?d:function(){d(I)}),U(I,"ready",r),U(I,"change","cart"===e?function(e){q(e),m&&m(e)}:m),U(I,"checkout","cart"===e?function(e){q(e),k&&k(e)}:k),t.useLayoutEffect((function(){if(null===_.current&&null!==M.current&&(A||R)){var t=null;R?t=R.createElement(e,s):A&&(t=A.create(e,s)),"cart"===e&&Y&&Y(t),_.current=t,T(t),t&&t.mount(M.current)}}),[A,R,s,Y]);var W=f(s);return t.useEffect((function(){if(_.current){var e=C(s,W,["paymentRequest"]);e&&_.current.update(e)}}),[s,W]),t.useLayoutEffect((function(){return function(){if(_.current&&"function"==typeof _.current.destroy)try{_.current.destroy(),_.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=w,e.Elements=I,e.ElementsConsumer=M,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 B("calls useCartElement()").cart},e.useCartElementState=function(){return B("calls useCartElementState()").cartState},e.useCustomCheckout=function(){!function(e){var n=t.useContext(S);O(n,e)}("calls useCustomCheckout()");var e=t.useContext(P);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 T("calls useElements()").elements},e.useStripe=function(){return j("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=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.4.0"}),e.registerAppInfo({name:"react-stripe-js",version:"2.4.0",url:"https://stripe.com/docs/stripe-js/react"}))},b=["on","session"],S=t.createContext(null);S.displayName="CustomCheckoutSdkContext";var O=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},P=t.createContext(null);P.displayName="CustomCheckoutContext";var w=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 O=f(n);t.useEffect((function(){null!==O&&O!==n&&console.warn("Unsupported prop change on CustomCheckoutProvider: You cannot change the `stripe` prop after setting it.")}),[O,n]);var w=f(o);t.useEffect((function(){var e,t;if(h.customCheckoutSdk){!o.clientSecret||d(w)||y(o.clientSecret,w.clientSecret)||console.warn("Unsupported prop change: options.client_secret is not a mutable property.");var n=null==w||null===(e=w.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,w,h.customCheckoutSdk]),t.useEffect((function(){k(h.stripe)}),[h.stripe]);var j=t.useMemo((function(){return function(e,t){if(!e)return null;e.on,e.session;var n=c(e,b);return r(r({},n),t||e.session())}(h.customCheckoutSdk,l)}),[h.customCheckoutSdk,l]);return h.customCheckoutSdk?t.createElement(S.Provider,{value:h},t.createElement(P.Provider,{value:j},u)):null};w.propTypes={stripe:p.any,options:p.shape({clientSecret:p.string.isRequired,elementsOptions:p.object}).isRequired};var j=function(e){var n=t.useContext(S),r=t.useContext(x);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?O(n,e):A(r,e)},x=t.createContext(null);x.displayName="ElementsContext";var A=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=t.createContext(null);R.displayName="CartElementContext";var N=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},I=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(x.Provider,{value:h},t.createElement(R.Provider,{value:{cart:a,setCart:s,cartState:p,setCartState:d}},o))};I.propTypes={stripe:p.any,options:p.object};var T=function(e){var n=t.useContext(x);return A(n,e)},_={cart:null,cartState:null,setCart:function(){},setCartState:function(){}},B=function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=t.useContext(R);return n?_:N(r,e)},M=function(e){return(0,e.children)(T("mounts <ElementsConsumer>"))};M.propTypes={children:p.func.isRequired};var U=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])},L=function(e,n){var r,o="".concat((r=e).charAt(0).toUpperCase()+r.slice(1),"Element"),u=n?function(e){var n=j("mounts <".concat(o,">"));B("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,x=j("mounts <".concat(o,">")),A="elements"in x?x.elements:null,R="customCheckoutSdk"in x?x.customCheckoutSdk:null,N=i(t.useState(null),2),I=N[0],T=N[1],_=t.useRef(null),M=t.useRef(null),L=B("mounts <".concat(o,">"),"customCheckoutSdk"in x),Y=L.setCart,q=L.setCartState;U(I,"blur",l),U(I,"focus",p),U(I,"escape",h),U(I,"click",y),U(I,"loaderror",v),U(I,"loaderstart",g),U(I,"networkschange",E),U(I,"lineitemclick",b),U(I,"confirm",S),U(I,"cancel",O),U(I,"shippingaddresschange",P),U(I,"shippingratechange",w),"cart"===e?r=function(e){q(e),d&&d(e)}:d&&(r="expressCheckout"===e?d:function(){d(I)}),U(I,"ready",r),U(I,"change","cart"===e?function(e){q(e),m&&m(e)}:m),U(I,"checkout","cart"===e?function(e){q(e),k&&k(e)}:k),t.useLayoutEffect((function(){if(null===_.current&&null!==M.current&&(A||R)){var t=null;R?t=R.createElement(e,s):A&&(t=A.create(e,s)),"cart"===e&&Y&&Y(t),_.current=t,T(t),t&&t.mount(M.current)}}),[A,R,s,Y]);var W=f(s);return t.useEffect((function(){if(_.current){var e=C(s,W,["paymentRequest"]);e&&_.current.update(e)}}),[s,W]),t.useLayoutEffect((function(){return function(){if(_.current&&"function"==typeof _.current.destroy)try{_.current.destroy(),_.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=w,e.Elements=I,e.ElementsConsumer=M,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 B("calls useCartElement()").cart},e.useCartElementState=function(){return B("calls useCartElementState()").cartState},e.useCustomCheckout=function(){!function(e){var n=t.useContext(S);O(n,e)}("calls useCustomCheckout()");var e=t.useContext(P);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 T("calls useElements()").elements},e.useStripe=function(){return j("calls useStripe()").stripe},Object.defineProperty(e,"__esModule",{value:!0})}));
{
"name": "@stripe/react-stripe-js",
"version": "2.3.2",
"version": "2.4.0",
"description": "React components for Stripe.js and Stripe Elements",

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

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

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

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