react-payment-request
Version:
A Payment Request component for React.js
1 lines • 10.4 kB
JavaScript
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("react")):"function"==typeof define&&define.amd?define(["react"],n):e.ReactPaymentRequest=n(e.React)}(this,function(e){"use strict";function n(e){return e&&"object"==typeof e&&"default"in e?e.default:e}function t(e,n){return n={exports:{}},e(n,n.exports),n.exports}var r=t(function(e){function n(e){return function(){return e}}var t=function(){};t.thatReturns=n,t.thatReturnsFalse=n(!1),t.thatReturnsTrue=n(!0),t.thatReturnsNull=n(null),t.thatReturnsThis=function(){return this},t.thatReturnsArgument=function(e){return e},e.exports=t}),o=n(r),i=Object.freeze({default:o}),a=t(function(e){function n(e,n,r,o,i,a,u,s){if(t(n),!e){var c;if(void 0===n)c=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var f=[r,o,i,a,u,s],p=0;c=new Error(n.replace(/%s/g,function(){return f[p++]})),c.name="Invariant Violation"}throw c.framesToPop=1,c}}var t=function(e){};"production"!==process.env.NODE_ENV&&(t=function(e){if(void 0===e)throw new Error("invariant requires an error message argument")}),e.exports=n}),u=n(a),s=Object.freeze({default:u}),c=t(function(e){var t=n(i),r=t;"production"!==process.env.NODE_ENV&&function(){var e=function(e){for(var n=arguments,t=arguments.length,r=Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=n[o];var i=0,a="Warning: "+e.replace(/%s/g,function(){return r[i++]});"undefined"!=typeof console&&console.error(a);try{throw new Error(a)}catch(e){}};r=function(n,t){var r=arguments;if(void 0===t)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");if(0!==t.indexOf("Failed Composite propType: ")&&!n){for(var o=arguments.length,i=Array(o>2?o-2:0),a=2;a<o;a++)i[a-2]=r[a];e.apply(void 0,[t].concat(i))}}}(),e.exports=r}),f=n(c),p=Object.freeze({default:f}),l=t(function(e){e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}),d=n(l),y=Object.freeze({default:d}),h=t(function(e){function t(e,n,t,u,s){if("production"!==process.env.NODE_ENV)for(var c in e)if(e.hasOwnProperty(c)){var f;try{r("function"==typeof e[c],"%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.",u||"React class",t,c),f=e[c](n,c,u,t,null,i)}catch(e){f=e}if(o(!f||f instanceof Error,"%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",u||"React class",t,c,typeof f),f instanceof Error&&!(f.message in a)){a[f.message]=!0;var p=s?s():"";o(!1,"Failed %s type: %s%s",t,f.message,null!=p?p:"")}}}if("production"!==process.env.NODE_ENV)var r=n(s),o=n(p),i=n(y),a={};e.exports=t}),v=n(h),m=Object.freeze({default:v}),b=t(function(e){var t=n(i),r=n(s),o=n(p),a=n(y),u=n(m);e.exports=function(e,n){function i(e){var n=e&&(T&&e[T]||e[j]);if("function"==typeof n)return n}function s(e,n){return e===n?0!==e||1/e==1/n:e!==e&&n!==n}function c(e){this.message=e,this.stack=""}function f(e){function t(t,s,f,p,l,d,y){if(p=p||R,d=d||f,y!==a)if(n)r(!1,"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");else if("production"!==process.env.NODE_ENV&&"undefined"!=typeof console){var h=p+":"+f;!i[h]&&u<3&&(o(!1,"You are manually calling a React.PropTypes validation function for the `%s` prop on `%s`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details.",d,p),i[h]=!0,u++)}return null==s[f]?t?new c(null===s[f]?"The "+l+" `"+d+"` is marked as required in `"+p+"`, but its value is `null`.":"The "+l+" `"+d+"` is marked as required in `"+p+"`, but its value is `undefined`."):null:e(s,f,p,l,d)}if("production"!==process.env.NODE_ENV)var i={},u=0;var s=t.bind(null,!1);return s.isRequired=t.bind(null,!0),s}function p(e){function n(n,t,r,o,i,a){var u=n[t];if(O(u)!==e)return new c("Invalid "+o+" `"+i+"` of type `"+E(u)+"` supplied to `"+r+"`, expected `"+e+"`.");return null}return f(n)}function l(e){function n(n,t,r,o,i){if("function"!=typeof e)return new c("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside arrayOf.");var u=n[t];if(!Array.isArray(u)){return new c("Invalid "+o+" `"+i+"` of type `"+O(u)+"` supplied to `"+r+"`, expected an array.")}for(var s=0;s<u.length;s++){var f=e(u,s,r,o,i+"["+s+"]",a);if(f instanceof Error)return f}return null}return f(n)}function d(e){function n(n,t,r,o,i){if(!(n[t]instanceof e)){var a=e.name||R;return new c("Invalid "+o+" `"+i+"` of type `"+x(n[t])+"` supplied to `"+r+"`, expected instance of `"+a+"`.")}return null}return f(n)}function y(e){function n(n,t,r,o,i){for(var a=n[t],u=0;u<e.length;u++)if(s(a,e[u]))return null;return new c("Invalid "+o+" `"+i+"` of value `"+a+"` supplied to `"+r+"`, expected one of "+JSON.stringify(e)+".")}return Array.isArray(e)?f(n):("production"!==process.env.NODE_ENV&&o(!1,"Invalid argument supplied to oneOf, expected an instance of array."),t.thatReturnsNull)}function h(e){function n(n,t,r,o,i){if("function"!=typeof e)return new c("Property `"+i+"` of component `"+r+"` has invalid PropType notation inside objectOf.");var u=n[t],s=O(u);if("object"!==s)return new c("Invalid "+o+" `"+i+"` of type `"+s+"` supplied to `"+r+"`, expected an object.");for(var f in u)if(u.hasOwnProperty(f)){var p=e(u,f,r,o,i+"."+f,a);if(p instanceof Error)return p}return null}return f(n)}function v(e){function n(n,t,r,o,i){for(var u=0;u<e.length;u++){if(null==(0,e[u])(n,t,r,o,i,a))return null}return new c("Invalid "+o+" `"+i+"` supplied to `"+r+"`.")}if(!Array.isArray(e))return"production"!==process.env.NODE_ENV&&o(!1,"Invalid argument supplied to oneOfType, expected an instance of array."),t.thatReturnsNull;for(var r=0;r<e.length;r++){var i=e[r];if("function"!=typeof i)return o(!1,"Invalid argument supplid to oneOfType. Expected an array of check functions, but received %s at index %s.",w(i),r),t.thatReturnsNull}return f(n)}function m(e){function n(n,t,r,o,i){var u=n[t],s=O(u);if("object"!==s)return new c("Invalid "+o+" `"+i+"` of type `"+s+"` supplied to `"+r+"`, expected `object`.");for(var f in e){var p=e[f];if(p){var l=p(u,f,r,o,i+"."+f,a);if(l)return l}}return null}return f(n)}function b(n){switch(typeof n){case"number":case"string":case"undefined":return!0;case"boolean":return!n;case"object":if(Array.isArray(n))return n.every(b);if(null===n||e(n))return!0;var t=i(n);if(!t)return!1;var r,o=t.call(n);if(t!==n.entries){for(;!(r=o.next()).done;)if(!b(r.value))return!1}else for(;!(r=o.next()).done;){var a=r.value;if(a&&!b(a[1]))return!1}return!0;default:return!1}}function g(e,n){return"symbol"===e||("Symbol"===n["@@toStringTag"]||"function"==typeof Symbol&&n instanceof Symbol)}function O(e){var n=typeof e;return Array.isArray(e)?"array":e instanceof RegExp?"object":g(n,e)?"symbol":n}function E(e){if(void 0===e||null===e)return""+e;var n=O(e);if("object"===n){if(e instanceof Date)return"date";if(e instanceof RegExp)return"regexp"}return n}function w(e){var n=E(e);switch(n){case"array":case"object":return"an "+n;case"boolean":case"date":case"regexp":return"a "+n;default:return n}}function x(e){return e.constructor&&e.constructor.name?e.constructor.name:R}var T="function"==typeof Symbol&&Symbol.iterator,j="@@iterator",R="<<anonymous>>",N={array:p("array"),bool:p("boolean"),func:p("function"),number:p("number"),object:p("object"),string:p("string"),symbol:p("symbol"),any:function(){return f(t.thatReturnsNull)}(),arrayOf:l,element:function(){function n(n,t,r,o,i){var a=n[t];if(!e(a)){return new c("Invalid "+o+" `"+i+"` of type `"+O(a)+"` supplied to `"+r+"`, expected a single ReactElement.")}return null}return f(n)}(),instanceOf:d,node:function(){function e(e,n,t,r,o){return b(e[n])?null:new c("Invalid "+r+" `"+o+"` supplied to `"+t+"`, expected a ReactNode.")}return f(e)}(),objectOf:h,oneOf:y,oneOfType:v,shape:m};return c.prototype=Error.prototype,N.checkPropTypes=u,N.PropTypes=N,N}}),g=n(b),O=Object.freeze({default:g}),E=t(function(e){var t=n(i),r=n(s),o=n(y);e.exports=function(){function e(e,n,t,i,a,u){u!==o&&r(!1,"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")}function n(){return e}e.isRequired=e;var i={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:n,element:e,instanceOf:n,node:e,objectOf:n,oneOf:n,oneOfType:n,shape:n};return i.checkPropTypes=t,i.PropTypes=i,i}}),w=n(E),x=Object.freeze({default:w}),T=t(function(e){if("production"!==process.env.NODE_ENV){var t="function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,r=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t};e.exports=n(O)(r,!0)}else e.exports=n(x)()}),j=n(T),R=Object.freeze({default:j}),N=t(function(t){var r=n(e),o=n(R),i=function(e){var n=e.methodData,t=e.details,r=e.options;return new window.PaymentRequest(n,t,r)},a=function(e,n,t){e.addEventListener(n,function(n){var r=new Promise(function(n,r){return t(e,n,r)});n.updateWith(r)})},u=function(e){function n(n){e.call(this,n),this.handleClick=this.handleClick.bind(this)}return e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n,n.prototype.componentWillUnmount=function(){this.request&&this.request.abort()},n.prototype.handleClick=function(){var e=this;return this.request=i(this.props),a(this.request,"shippingaddresschange",this.props.onShippingAddressChange),a(this.request,"shippingoptionchange",this.props.onShippingOptionChange),this.request.show().then(function(n){return e.props.onSuccess(n)}).catch(function(n){return e.props.onError(n)})},n.prototype.render=function(){return window.PaymentRequest?r.createElement("div",{onClick:this.handleClick},this.props.children):null},n}(r.Component);u.propTypes={children:o.any,details:o.object,methodData:o.array,onError:o.func,onShippingAddressChange:o.func,onShippingOptionChange:o.func,onSuccess:o.func,options:o.object},t.exports=u}),P=n(N),_=Object.freeze({default:P});return n(t(function(e){var t=n(_);e.exports=t}))});