forked from tobyn/angular-stripe-checkout
-
Notifications
You must be signed in to change notification settings - Fork 0
/
angular-stripe-checkout.min.js
1 lines (1 loc) · 2.28 KB
/
angular-stripe-checkout.min.js
1
(function(){"use strict";var e="stripe.checkout";var t="https://checkout.stripe.com/checkout.js";var a={amount:"data-amount",currency:"data-currency",description:"data-description",email:"data-email",image:"data-image",key:"data-key",label:"data-label",locale:"data-locale",name:"data-name",panelLabel:"data-panel-label",zipCode:"data-zip-code"};var n={address:"data-address",alipay:"data-alipay",alipayReusable:"data-alipay-reusable",allowRememberMe:"data-allow-remember-me",billingAddress:"data-billing-address",bitcoin:"data-bitcoin",shippingAddress:"data-shipping-address"};var i;if(typeof module!=="undefined"&&typeof module.exports==="object"){i=require("angular");module.exports=e}else{i=window.angular}var o=i.extend;i.module(e,[]).directive("stripeCheckout",r).provider("StripeCheckout",c);r.$inject=["$parse","StripeCheckout"];function r(e,t){return{link:i};function i(a,n,i){var r;t.load().then(function(){r=t.configure(o(n))});n.on("click",function(){if(r)r.open(o(n)).then(function(t){var n=e(i.stripeCheckout)(a);if(typeof n==="function")n.apply(null,t)})})}function o(e){var t,i,o={};for(t in a){i=e.attr(a[t]);if(typeof i!=="undefined")o[t]=i}for(t in n){i=e.attr(n[t]);if(typeof i==="string")o[t]=i.toLowerCase()==="true"}return o}}function c(){var e={};this.defaults=function(t){o(e,t)};this.load=function(e){return e.load()};this.load.$inject=["StripeCheckout"];this.$get=function(t,a){return new d(t,a,e)};this.$get.$inject=["$document","$q"]}function d(e,t,a){var n={},i;this.configure=function(e){return new l(t,o({},a,n,e))};this.load=function(){if(!i)i=u(e,t);return i};this.defaults=function(e){o(n,e)}}function l(e,t){var a,n;var i=StripeCheckout.configure(o({},t,{token:function(e,i){if(t.token)t.token(e,i);n=true;a.resolve([e,i])},closed:function(){if(t.closed)t.closed();if(!n)a.reject()}}));this.open=function(t){a=e.defer();n=false;i.open(t);return a.promise};this.close=function(){n=false;i.close();if(t.closed)t.closed();if(a)a.reject()}}function u(e,a){var n=a.defer();var i=e[0],o=i.createElement("script");o.src=t;o.onload=function(){n.resolve()};o.onreadystatechange=function(){var e=this.readyState;if(e==="loaded"||e==="complete")n.resolve()};o.onerror=function(){n.reject(new Error("Unable to load checkout.js"))};var r=i.getElementsByTagName("head")[0];r.appendChild(o);return n.promise}})();