ngx-stripe
Advanced tools
Comparing version 0.6.1 to 0.7.0
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs/BehaviorSubject'), require('rxjs/Observable'), require('rxjs/add/observable/combineLatest'), require('rxjs/add/observable/fromPromise'), require('rxjs/add/operator/switchMap'), require('rxjs/add/operator/filter'), require('rxjs/add/operator/map'), require('rxjs/add/operator/publishLast')) : | ||
typeof define === 'function' && define.amd ? define(['exports', '@angular/core', 'rxjs/BehaviorSubject', 'rxjs/Observable', 'rxjs/add/observable/combineLatest', 'rxjs/add/observable/fromPromise', 'rxjs/add/operator/switchMap', 'rxjs/add/operator/filter', 'rxjs/add/operator/map', 'rxjs/add/operator/publishLast'], factory) : | ||
(factory((global.ng = global.ng || {}, global.ng.stripe = global.ng.stripe || {}),global.ng.core,global.Rx,global.Rx)); | ||
}(this, (function (exports,_angular_core,rxjs_BehaviorSubject,rxjs_Observable) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('rxjs/BehaviorSubject'), require('rxjs/Observable'), require('rxjs/add/observable/combineLatest'), require('rxjs/add/observable/fromPromise'), require('rxjs/add/observable/of'), require('rxjs/add/operator/switchMap'), require('rxjs/add/operator/filter'), require('rxjs/add/operator/first'), require('rxjs/add/operator/map')) : | ||
typeof define === 'function' && define.amd ? define(['exports', '@angular/core', '@angular/common', 'rxjs/BehaviorSubject', 'rxjs/Observable', 'rxjs/add/observable/combineLatest', 'rxjs/add/observable/fromPromise', 'rxjs/add/observable/of', 'rxjs/add/operator/switchMap', 'rxjs/add/operator/filter', 'rxjs/add/operator/first', 'rxjs/add/operator/map'], factory) : | ||
(factory((global.ng = global.ng || {}, global.ng.stripe = global.ng.stripe || {}),global.ng.core,global.ng.common,global.Rx,global.Rx)); | ||
}(this, (function (exports,_angular_core,_angular_common,rxjs_BehaviorSubject,rxjs_Observable) { 'use strict'; | ||
var WindowRef = (function () { | ||
function WindowRef() { | ||
/** | ||
* @param {?} platformId | ||
*/ | ||
function WindowRef(platformId) { | ||
this.platformId = platformId; | ||
} | ||
@@ -14,8 +18,24 @@ /** | ||
WindowRef.prototype.getNativeWindow = function () { | ||
return window; | ||
if (_angular_common.isPlatformBrowser(this.platformId)) { | ||
return window; | ||
} | ||
return ({}); | ||
}; | ||
return WindowRef; | ||
}()); | ||
WindowRef.decorators = [ | ||
{ type: _angular_core.Injectable }, | ||
]; | ||
/** | ||
* @nocollapse | ||
*/ | ||
WindowRef.ctorParameters = function () { return [ | ||
{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_core.PLATFORM_ID,] },] }, | ||
]; }; | ||
var DocumentRef = (function () { | ||
function DocumentRef() { | ||
/** | ||
* @param {?} platformId | ||
*/ | ||
function DocumentRef(platformId) { | ||
this.platformId = platformId; | ||
} | ||
@@ -26,12 +46,26 @@ /** | ||
DocumentRef.prototype.getNativeDocument = function () { | ||
return document; | ||
if (_angular_common.isPlatformBrowser(this.platformId)) { | ||
return document; | ||
} | ||
return ({}); | ||
}; | ||
return DocumentRef; | ||
}()); | ||
DocumentRef.decorators = [ | ||
{ type: _angular_core.Injectable }, | ||
]; | ||
/** | ||
* @nocollapse | ||
*/ | ||
DocumentRef.ctorParameters = function () { return [ | ||
{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_core.PLATFORM_ID,] },] }, | ||
]; }; | ||
var LazyStripeAPILoader = (function () { | ||
/** | ||
* @param {?} platformId | ||
* @param {?} window | ||
* @param {?} document | ||
*/ | ||
function LazyStripeAPILoader(window, document) { | ||
function LazyStripeAPILoader(platformId, window, document) { | ||
this.platformId = platformId; | ||
this.window = window; | ||
@@ -63,2 +97,5 @@ this.document = document; | ||
var _this = this; | ||
if (_angular_common.isPlatformServer(this.platformId)) { | ||
return; | ||
} | ||
var /** @type {?} */ status = this.status.getValue(); | ||
@@ -105,2 +142,3 @@ if (this.window.getNativeWindow().hasOwnProperty('Stripe')) { | ||
LazyStripeAPILoader.ctorParameters = function () { return [ | ||
{ type: undefined, decorators: [{ type: _angular_core.Inject, args: [_angular_core.PLATFORM_ID,] },] }, | ||
{ type: WindowRef, }, | ||
@@ -166,6 +204,13 @@ { type: DocumentRef, }, | ||
this.options = options; | ||
this.stripeObject().subscribe(function (Stripe) { | ||
_this.stripe = _this.options | ||
this.stripe$ = new rxjs_BehaviorSubject.BehaviorSubject(undefined); | ||
this.loader | ||
.asStream() | ||
.filter(function (status) { return status.loaded === true; }) | ||
.first() | ||
.map(function () { return _this.window.getNativeWindow().Stripe; }) | ||
.subscribe(function (Stripe) { | ||
var stripe = _this.options | ||
? Stripe(_this.key, _this.options) | ||
: Stripe(_this.key); | ||
_this.stripe$.next(stripe); | ||
}); | ||
@@ -177,3 +222,3 @@ } | ||
StripeInstance.prototype.getInstance = function () { | ||
return this.stripe; | ||
return this.stripe$.getValue(); | ||
}; | ||
@@ -185,4 +230,6 @@ /** | ||
StripeInstance.prototype.elements = function (options) { | ||
var _this = this; | ||
return this.stripeObject().map(function () { return _this.stripe.elements(options); }); | ||
return this.stripe$ | ||
.asObservable() | ||
.filter(function (stripe) { return Boolean(stripe); }) | ||
.map(function (stripe) { return ((stripe)).elements(options); }); | ||
}; | ||
@@ -195,11 +242,17 @@ /** | ||
StripeInstance.prototype.createToken = function (a, b) { | ||
if (isBankAccount(a) && isBankAccountData(b)) { | ||
return rxjs_Observable.Observable.fromPromise(this.stripe.createToken(a, b)); | ||
} | ||
else if (isPii(a) && isPiiData(b)) { | ||
return rxjs_Observable.Observable.fromPromise(this.stripe.createToken(a, b)); | ||
} | ||
else { | ||
return rxjs_Observable.Observable.fromPromise(this.stripe.createToken(/** @type {?} */ (a), /** @type {?} */ (b))); | ||
} | ||
return this.stripe$ | ||
.asObservable() | ||
.filter(function (stripe) { return Boolean(stripe); }) | ||
.switchMap(function (s) { | ||
var /** @type {?} */ stripe = (s); | ||
if (isBankAccount(a) && isBankAccountData(b)) { | ||
return rxjs_Observable.Observable.fromPromise(stripe.createToken(a, b)); | ||
} | ||
else if (isPii(a) && isPiiData(b)) { | ||
return rxjs_Observable.Observable.fromPromise(stripe.createToken(a, b)); | ||
} | ||
else { | ||
return rxjs_Observable.Observable.fromPromise(stripe.createToken(/** @type {?} */ (a), /** @type {?} */ (b))); | ||
} | ||
}); | ||
}; | ||
@@ -212,6 +265,12 @@ /** | ||
StripeInstance.prototype.createSource = function (a, b) { | ||
if (isSourceData(a)) { | ||
return rxjs_Observable.Observable.fromPromise(this.stripe.createSource(/** @type {?} */ (a))); | ||
} | ||
return rxjs_Observable.Observable.fromPromise(this.stripe.createSource(/** @type {?} */ (a), b)); | ||
return this.stripe$ | ||
.asObservable() | ||
.filter(function (stripe) { return Boolean(stripe); }) | ||
.switchMap(function (s) { | ||
var /** @type {?} */ stripe = (s); | ||
if (isSourceData(a)) { | ||
return rxjs_Observable.Observable.fromPromise(stripe.createSource(/** @type {?} */ (a))); | ||
} | ||
return rxjs_Observable.Observable.fromPromise(stripe.createSource(/** @type {?} */ (a), b)); | ||
}); | ||
}; | ||
@@ -223,3 +282,9 @@ /** | ||
StripeInstance.prototype.retrieveSource = function (source) { | ||
return rxjs_Observable.Observable.fromPromise(this.stripe.retrieveSource(source)); | ||
return this.stripe$ | ||
.asObservable() | ||
.filter(function (stripe) { return Boolean(stripe); }) | ||
.switchMap(function (s) { | ||
var /** @type {?} */ stripe = (s); | ||
return rxjs_Observable.Observable.fromPromise(stripe.retrieveSource(source)); | ||
}); | ||
}; | ||
@@ -231,14 +296,8 @@ /** | ||
StripeInstance.prototype.paymentRequest = function (options) { | ||
return this.stripe.paymentRequest(options); | ||
var /** @type {?} */ stripe = this.getInstance(); | ||
if (stripe) { | ||
return stripe.paymentRequest(options); | ||
} | ||
return undefined; | ||
}; | ||
/** | ||
* @return {?} | ||
*/ | ||
StripeInstance.prototype.stripeObject = function () { | ||
var _this = this; | ||
return this.loader | ||
.asStream() | ||
.filter(function (status) { return status.loaded === true; }) | ||
.map(function () { return ((_this.window.getNativeWindow())).Stripe; }); | ||
}; | ||
return StripeInstance; | ||
@@ -245,0 +304,0 @@ }()); |
@@ -1,2 +0,2 @@ | ||
!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports,require("@angular/core"),require("rxjs/BehaviorSubject"),require("rxjs/Observable"),require("rxjs/add/observable/combineLatest"),require("rxjs/add/observable/fromPromise"),require("rxjs/add/operator/switchMap"),require("rxjs/add/operator/filter"),require("rxjs/add/operator/map"),require("rxjs/add/operator/publishLast")):"function"==typeof define&&define.amd?define(["exports","@angular/core","rxjs/BehaviorSubject","rxjs/Observable","rxjs/add/observable/combineLatest","rxjs/add/observable/fromPromise","rxjs/add/operator/switchMap","rxjs/add/operator/filter","rxjs/add/operator/map","rxjs/add/operator/publishLast"],factory):factory((global.ng=global.ng||{},global.ng.stripe=global.ng.stripe||{}),global.ng.core,global.Rx,global.Rx)}(this,function(exports,_angular_core,rxjs_BehaviorSubject,rxjs_Observable){"use strict";function isSourceData(sourceData){return"type"in sourceData}function isBankAccount(account){return"bank_account"===account}function isBankAccountData(bankAccountData){return"country"in bankAccountData&&"currency"in bankAccountData&&"routing_number"in bankAccountData&&"account_number"in bankAccountData&&"account_holder_name"in bankAccountData&&"account_holder_type"in bankAccountData&&("individual"===bankAccountData.account_holder_type||"company"===bankAccountData.account_holder_type)}function isPii(pii){return"pii"===pii}function isPiiData(piiData){return"personal_id_number"in piiData}var WindowRef=function(){function WindowRef(){}return WindowRef.prototype.getNativeWindow=function(){return window},WindowRef}(),DocumentRef=function(){function DocumentRef(){}return DocumentRef.prototype.getNativeDocument=function(){return document},DocumentRef}(),LazyStripeAPILoader=function(){function LazyStripeAPILoader(window,document){this.window=window,this.document=document,this.status=new rxjs_BehaviorSubject.BehaviorSubject({error:!1,loaded:!1,loading:!1})}return LazyStripeAPILoader.prototype.asStream=function(){return this.load(),this.status.asObservable()},LazyStripeAPILoader.prototype.isReady=function(){return this.status.getValue().loaded},LazyStripeAPILoader.prototype.load=function(){var _this=this,status=this.status.getValue();if(this.window.getNativeWindow().hasOwnProperty("Stripe"))this.status.next({error:!1,loaded:!0,loading:!1});else if(!status.loaded&&!status.loading){this.status.next(Object.assign({},status,{loading:!0}));var script=this.document.getNativeDocument().createElement("script");script.type="text/javascript",script.async=!0,script.defer=!0,script.src="https://js.stripe.com/v3/",script.onload=function(){_this.status.next({error:!1,loaded:!0,loading:!1})},script.onerror=function(){_this.status.next({error:!0,loaded:!1,loading:!1})},this.document.getNativeDocument().body.appendChild(script)}},LazyStripeAPILoader}();LazyStripeAPILoader.decorators=[{type:_angular_core.Injectable}],LazyStripeAPILoader.ctorParameters=function(){return[{type:WindowRef},{type:DocumentRef}]};var STRIPE_PUBLISHABLE_KEY=new _angular_core.InjectionToken("Stripe Publishable Key"),STRIPE_OPTIONS=new _angular_core.InjectionToken("Stripe Options"),StripeInstance=function(){function StripeInstance(loader,window,key,options){var _this=this;this.loader=loader,this.window=window,this.key=key,this.options=options,this.stripeObject().subscribe(function(Stripe){_this.stripe=_this.options?Stripe(_this.key,_this.options):Stripe(_this.key)})}return StripeInstance.prototype.getInstance=function(){return this.stripe},StripeInstance.prototype.elements=function(options){var _this=this;return this.stripeObject().map(function(){return _this.stripe.elements(options)})},StripeInstance.prototype.createToken=function(a,b){return isBankAccount(a)&&isBankAccountData(b)?rxjs_Observable.Observable.fromPromise(this.stripe.createToken(a,b)):(isPii(a)&&isPiiData(b),rxjs_Observable.Observable.fromPromise(this.stripe.createToken(a,b)))},StripeInstance.prototype.createSource=function(a,b){return isSourceData(a)?rxjs_Observable.Observable.fromPromise(this.stripe.createSource(a)):rxjs_Observable.Observable.fromPromise(this.stripe.createSource(a,b))},StripeInstance.prototype.retrieveSource=function(source){return rxjs_Observable.Observable.fromPromise(this.stripe.retrieveSource(source))},StripeInstance.prototype.paymentRequest=function(options){return this.stripe.paymentRequest(options)},StripeInstance.prototype.stripeObject=function(){var _this=this;return this.loader.asStream().filter(function(status){return!0===status.loaded}).map(function(){return _this.window.getNativeWindow().Stripe})},StripeInstance}(),StripeService=function(){function StripeService(key,options,loader,window){this.key=key,this.options=options,this.loader=loader,this.window=window,key&&(this.stripe=new StripeInstance(this.loader,this.window,key,options))}return StripeService.prototype.getStripeReference=function(){var _this=this;return this.loader.asStream().filter(function(status){return!0===status.loaded}).map(function(){return _this.window.getNativeWindow().Stripe})},StripeService.prototype.getInstance=function(){return this.stripe.getInstance()},StripeService.prototype.setKey=function(key,options){return this.changeKey(key,options)},StripeService.prototype.changeKey=function(key,options){return this.stripe=new StripeInstance(this.loader,this.window,key,options),this.stripe},StripeService.prototype.elements=function(options){return this.stripe.elements(options)},StripeService.prototype.createToken=function(a,b){return this.stripe.createToken(a,b)},StripeService.prototype.createSource=function(a,b){return this.stripe.createSource(a,b)},StripeService.prototype.retrieveSource=function(source){return this.stripe.retrieveSource(source)},StripeService.prototype.paymentRequest=function(options){return this.stripe.paymentRequest(options)},StripeService}();StripeService.decorators=[{type:_angular_core.Injectable}],StripeService.ctorParameters=function(){return[{type:void 0,decorators:[{type:_angular_core.Inject,args:[STRIPE_PUBLISHABLE_KEY]}]},{type:void 0,decorators:[{type:_angular_core.Inject,args:[STRIPE_OPTIONS]}]},{type:LazyStripeAPILoader},{type:WindowRef}]};var StripeFactoryService=function(){function StripeFactoryService(baseKey,baseOptions,loader,window){this.baseKey=baseKey,this.baseOptions=baseOptions,this.loader=loader,this.window=window}return StripeFactoryService.prototype.create=function(key,options){return new StripeInstance(this.loader,this.window,key,options)},StripeFactoryService}();StripeFactoryService.decorators=[{type:_angular_core.Injectable}],StripeFactoryService.ctorParameters=function(){return[{type:void 0,decorators:[{type:_angular_core.Inject,args:[STRIPE_PUBLISHABLE_KEY]}]},{type:void 0,decorators:[{type:_angular_core.Inject,args:[STRIPE_OPTIONS]}]},{type:LazyStripeAPILoader},{type:WindowRef}]};var StripeCardComponent=function(){function StripeCardComponent(stripeService){this.stripeService=stripeService,this.card=new _angular_core.EventEmitter,this.on=new _angular_core.EventEmitter,this.options$=new rxjs_BehaviorSubject.BehaviorSubject({}),this.elementsOptions$=new rxjs_BehaviorSubject.BehaviorSubject({}),this.stripe$=new rxjs_BehaviorSubject.BehaviorSubject(null)}return Object.defineProperty(StripeCardComponent.prototype,"options",{set:function(optionsIn){this.options$.next(optionsIn)},enumerable:!0,configurable:!0}),Object.defineProperty(StripeCardComponent.prototype,"elementsOptions",{set:function(optionsIn){this.elementsOptions$.next(optionsIn)},enumerable:!0,configurable:!0}),Object.defineProperty(StripeCardComponent.prototype,"stripe",{set:function(stripeIn){this.stripe$.next(stripeIn)},enumerable:!0,configurable:!0}),StripeCardComponent.prototype.ngOnInit=function(){var _this=this,elements$=rxjs_Observable.Observable.combineLatest(this.elementsOptions$.asObservable(),this.stripe$.asObservable()).switchMap(function(_a){var options=_a[0],stripe=_a[1];return stripe?Object.keys(options).length>0?stripe.elements(options):stripe.elements():Object.keys(options).length>0?_this.stripeService.elements(options):_this.stripeService.elements()});rxjs_Observable.Observable.combineLatest(elements$,this.options$.asObservable().filter(function(options){return Boolean(options)})).subscribe(function(_a){var elements=_a[0],options=_a[1];_this.element=elements.create("card",options),_this.element.on("blur",function(ev){return _this.on.emit({event:ev,type:"blur"})}),_this.element.on("change",function(ev){return _this.on.emit({event:ev,type:"change"})}),_this.element.on("click",function(ev){return _this.on.emit({event:ev,type:"click"})}),_this.element.on("focus",function(ev){return _this.on.emit({event:ev,type:"focus"})}),_this.element.on("ready",function(ev){return _this.on.emit({event:ev,type:"ready"})}),_this.element.mount(_this.stripeCard.nativeElement),_this.card.emit(_this.element)})},StripeCardComponent.prototype.getCard=function(){return this.element},StripeCardComponent}();StripeCardComponent.decorators=[{type:_angular_core.Component,args:[{selector:"ngx-stripe-card",template:'<div class="field" #stripeCard></div>'}]}],StripeCardComponent.ctorParameters=function(){return[{type:StripeService}]},StripeCardComponent.propDecorators={card:[{type:_angular_core.Output}],on:[{type:_angular_core.Output}],stripeCard:[{type:_angular_core.ViewChild,args:["stripeCard"]}],options:[{type:_angular_core.Input}],elementsOptions:[{type:_angular_core.Input}],stripe:[{type:_angular_core.Input}]};var NgxStripeModule=function(){function NgxStripeModule(){}return NgxStripeModule.forRoot=function(publishableKey,options){return{ngModule:NgxStripeModule,providers:[LazyStripeAPILoader,StripeService,StripeFactoryService,WindowRef,DocumentRef,{provide:STRIPE_PUBLISHABLE_KEY,useValue:publishableKey},{provide:STRIPE_OPTIONS,useValue:options}]}},NgxStripeModule}();NgxStripeModule.decorators=[{type:_angular_core.NgModule,args:[{declarations:[StripeCardComponent],exports:[StripeCardComponent]}]}],NgxStripeModule.ctorParameters=function(){return[]},exports.NgxStripeModule=NgxStripeModule,exports.StripeCardComponent=StripeCardComponent,exports.StripeService=StripeService,exports.StripeFactoryService=StripeFactoryService,exports.StripeInstance=StripeInstance,exports.LazyStripeAPILoader=LazyStripeAPILoader,exports.WindowRef=WindowRef,exports.DocumentRef=DocumentRef,exports.isSourceData=isSourceData,exports.STRIPE_PUBLISHABLE_KEY=STRIPE_PUBLISHABLE_KEY,exports.STRIPE_OPTIONS=STRIPE_OPTIONS,exports.isBankAccount=isBankAccount,exports.isBankAccountData=isBankAccountData,exports.isPii=isPii,exports.isPiiData=isPiiData,Object.defineProperty(exports,"__esModule",{value:!0})}); | ||
!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports,require("@angular/core"),require("@angular/common"),require("rxjs/BehaviorSubject"),require("rxjs/Observable"),require("rxjs/add/observable/combineLatest"),require("rxjs/add/observable/fromPromise"),require("rxjs/add/observable/of"),require("rxjs/add/operator/switchMap"),require("rxjs/add/operator/filter"),require("rxjs/add/operator/first"),require("rxjs/add/operator/map")):"function"==typeof define&&define.amd?define(["exports","@angular/core","@angular/common","rxjs/BehaviorSubject","rxjs/Observable","rxjs/add/observable/combineLatest","rxjs/add/observable/fromPromise","rxjs/add/observable/of","rxjs/add/operator/switchMap","rxjs/add/operator/filter","rxjs/add/operator/first","rxjs/add/operator/map"],factory):factory((global.ng=global.ng||{},global.ng.stripe=global.ng.stripe||{}),global.ng.core,global.ng.common,global.Rx,global.Rx)}(this,function(exports,_angular_core,_angular_common,rxjs_BehaviorSubject,rxjs_Observable){"use strict";function isSourceData(sourceData){return"type"in sourceData}function isBankAccount(account){return"bank_account"===account}function isBankAccountData(bankAccountData){return"country"in bankAccountData&&"currency"in bankAccountData&&"routing_number"in bankAccountData&&"account_number"in bankAccountData&&"account_holder_name"in bankAccountData&&"account_holder_type"in bankAccountData&&("individual"===bankAccountData.account_holder_type||"company"===bankAccountData.account_holder_type)}function isPii(pii){return"pii"===pii}function isPiiData(piiData){return"personal_id_number"in piiData}var WindowRef=function(){function WindowRef(platformId){this.platformId=platformId}return WindowRef.prototype.getNativeWindow=function(){return _angular_common.isPlatformBrowser(this.platformId)?window:{}},WindowRef}();WindowRef.decorators=[{type:_angular_core.Injectable}],WindowRef.ctorParameters=function(){return[{type:void 0,decorators:[{type:_angular_core.Inject,args:[_angular_core.PLATFORM_ID]}]}]};var DocumentRef=function(){function DocumentRef(platformId){this.platformId=platformId}return DocumentRef.prototype.getNativeDocument=function(){return _angular_common.isPlatformBrowser(this.platformId)?document:{}},DocumentRef}();DocumentRef.decorators=[{type:_angular_core.Injectable}],DocumentRef.ctorParameters=function(){return[{type:void 0,decorators:[{type:_angular_core.Inject,args:[_angular_core.PLATFORM_ID]}]}]};var LazyStripeAPILoader=function(){function LazyStripeAPILoader(platformId,window,document){this.platformId=platformId,this.window=window,this.document=document,this.status=new rxjs_BehaviorSubject.BehaviorSubject({error:!1,loaded:!1,loading:!1})}return LazyStripeAPILoader.prototype.asStream=function(){return this.load(),this.status.asObservable()},LazyStripeAPILoader.prototype.isReady=function(){return this.status.getValue().loaded},LazyStripeAPILoader.prototype.load=function(){var _this=this;if(!_angular_common.isPlatformServer(this.platformId)){var status=this.status.getValue();if(this.window.getNativeWindow().hasOwnProperty("Stripe"))this.status.next({error:!1,loaded:!0,loading:!1});else if(!status.loaded&&!status.loading){this.status.next(Object.assign({},status,{loading:!0}));var script=this.document.getNativeDocument().createElement("script");script.type="text/javascript",script.async=!0,script.defer=!0,script.src="https://js.stripe.com/v3/",script.onload=function(){_this.status.next({error:!1,loaded:!0,loading:!1})},script.onerror=function(){_this.status.next({error:!0,loaded:!1,loading:!1})},this.document.getNativeDocument().body.appendChild(script)}}},LazyStripeAPILoader}();LazyStripeAPILoader.decorators=[{type:_angular_core.Injectable}],LazyStripeAPILoader.ctorParameters=function(){return[{type:void 0,decorators:[{type:_angular_core.Inject,args:[_angular_core.PLATFORM_ID]}]},{type:WindowRef},{type:DocumentRef}]};var STRIPE_PUBLISHABLE_KEY=new _angular_core.InjectionToken("Stripe Publishable Key"),STRIPE_OPTIONS=new _angular_core.InjectionToken("Stripe Options"),StripeInstance=function(){function StripeInstance(loader,window,key,options){var _this=this;this.loader=loader,this.window=window,this.key=key,this.options=options,this.stripe$=new rxjs_BehaviorSubject.BehaviorSubject(void 0),this.loader.asStream().filter(function(status){return!0===status.loaded}).first().map(function(){return _this.window.getNativeWindow().Stripe}).subscribe(function(Stripe){var stripe=_this.options?Stripe(_this.key,_this.options):Stripe(_this.key);_this.stripe$.next(stripe)})}return StripeInstance.prototype.getInstance=function(){return this.stripe$.getValue()},StripeInstance.prototype.elements=function(options){return this.stripe$.asObservable().filter(function(stripe){return Boolean(stripe)}).map(function(stripe){return stripe.elements(options)})},StripeInstance.prototype.createToken=function(a,b){return this.stripe$.asObservable().filter(function(stripe){return Boolean(stripe)}).switchMap(function(s){var stripe=s;return isBankAccount(a)&&isBankAccountData(b)?rxjs_Observable.Observable.fromPromise(stripe.createToken(a,b)):(isPii(a)&&isPiiData(b),rxjs_Observable.Observable.fromPromise(stripe.createToken(a,b)))})},StripeInstance.prototype.createSource=function(a,b){return this.stripe$.asObservable().filter(function(stripe){return Boolean(stripe)}).switchMap(function(s){var stripe=s;return isSourceData(a)?rxjs_Observable.Observable.fromPromise(stripe.createSource(a)):rxjs_Observable.Observable.fromPromise(stripe.createSource(a,b))})},StripeInstance.prototype.retrieveSource=function(source){return this.stripe$.asObservable().filter(function(stripe){return Boolean(stripe)}).switchMap(function(s){var stripe=s;return rxjs_Observable.Observable.fromPromise(stripe.retrieveSource(source))})},StripeInstance.prototype.paymentRequest=function(options){var stripe=this.getInstance();if(stripe)return stripe.paymentRequest(options)},StripeInstance}(),StripeService=function(){function StripeService(key,options,loader,window){this.key=key,this.options=options,this.loader=loader,this.window=window,key&&(this.stripe=new StripeInstance(this.loader,this.window,key,options))}return StripeService.prototype.getStripeReference=function(){var _this=this;return this.loader.asStream().filter(function(status){return!0===status.loaded}).map(function(){return _this.window.getNativeWindow().Stripe})},StripeService.prototype.getInstance=function(){return this.stripe.getInstance()},StripeService.prototype.setKey=function(key,options){return this.changeKey(key,options)},StripeService.prototype.changeKey=function(key,options){return this.stripe=new StripeInstance(this.loader,this.window,key,options),this.stripe},StripeService.prototype.elements=function(options){return this.stripe.elements(options)},StripeService.prototype.createToken=function(a,b){return this.stripe.createToken(a,b)},StripeService.prototype.createSource=function(a,b){return this.stripe.createSource(a,b)},StripeService.prototype.retrieveSource=function(source){return this.stripe.retrieveSource(source)},StripeService.prototype.paymentRequest=function(options){return this.stripe.paymentRequest(options)},StripeService}();StripeService.decorators=[{type:_angular_core.Injectable}],StripeService.ctorParameters=function(){return[{type:void 0,decorators:[{type:_angular_core.Inject,args:[STRIPE_PUBLISHABLE_KEY]}]},{type:void 0,decorators:[{type:_angular_core.Inject,args:[STRIPE_OPTIONS]}]},{type:LazyStripeAPILoader},{type:WindowRef}]};var StripeFactoryService=function(){function StripeFactoryService(baseKey,baseOptions,loader,window){this.baseKey=baseKey,this.baseOptions=baseOptions,this.loader=loader,this.window=window}return StripeFactoryService.prototype.create=function(key,options){return new StripeInstance(this.loader,this.window,key,options)},StripeFactoryService}();StripeFactoryService.decorators=[{type:_angular_core.Injectable}],StripeFactoryService.ctorParameters=function(){return[{type:void 0,decorators:[{type:_angular_core.Inject,args:[STRIPE_PUBLISHABLE_KEY]}]},{type:void 0,decorators:[{type:_angular_core.Inject,args:[STRIPE_OPTIONS]}]},{type:LazyStripeAPILoader},{type:WindowRef}]};var StripeCardComponent=function(){function StripeCardComponent(stripeService){this.stripeService=stripeService,this.card=new _angular_core.EventEmitter,this.on=new _angular_core.EventEmitter,this.options$=new rxjs_BehaviorSubject.BehaviorSubject({}),this.elementsOptions$=new rxjs_BehaviorSubject.BehaviorSubject({}),this.stripe$=new rxjs_BehaviorSubject.BehaviorSubject(null)}return Object.defineProperty(StripeCardComponent.prototype,"options",{set:function(optionsIn){this.options$.next(optionsIn)},enumerable:!0,configurable:!0}),Object.defineProperty(StripeCardComponent.prototype,"elementsOptions",{set:function(optionsIn){this.elementsOptions$.next(optionsIn)},enumerable:!0,configurable:!0}),Object.defineProperty(StripeCardComponent.prototype,"stripe",{set:function(stripeIn){this.stripe$.next(stripeIn)},enumerable:!0,configurable:!0}),StripeCardComponent.prototype.ngOnInit=function(){var _this=this,elements$=rxjs_Observable.Observable.combineLatest(this.elementsOptions$.asObservable(),this.stripe$.asObservable()).switchMap(function(_a){var options=_a[0],stripe=_a[1];return stripe?Object.keys(options).length>0?stripe.elements(options):stripe.elements():Object.keys(options).length>0?_this.stripeService.elements(options):_this.stripeService.elements()});rxjs_Observable.Observable.combineLatest(elements$,this.options$.asObservable().filter(function(options){return Boolean(options)})).subscribe(function(_a){var elements=_a[0],options=_a[1];_this.element=elements.create("card",options),_this.element.on("blur",function(ev){return _this.on.emit({event:ev,type:"blur"})}),_this.element.on("change",function(ev){return _this.on.emit({event:ev,type:"change"})}),_this.element.on("click",function(ev){return _this.on.emit({event:ev,type:"click"})}),_this.element.on("focus",function(ev){return _this.on.emit({event:ev,type:"focus"})}),_this.element.on("ready",function(ev){return _this.on.emit({event:ev,type:"ready"})}),_this.element.mount(_this.stripeCard.nativeElement),_this.card.emit(_this.element)})},StripeCardComponent.prototype.getCard=function(){return this.element},StripeCardComponent}();StripeCardComponent.decorators=[{type:_angular_core.Component,args:[{selector:"ngx-stripe-card",template:'<div class="field" #stripeCard></div>'}]}],StripeCardComponent.ctorParameters=function(){return[{type:StripeService}]},StripeCardComponent.propDecorators={card:[{type:_angular_core.Output}],on:[{type:_angular_core.Output}],stripeCard:[{type:_angular_core.ViewChild,args:["stripeCard"]}],options:[{type:_angular_core.Input}],elementsOptions:[{type:_angular_core.Input}],stripe:[{type:_angular_core.Input}]};var NgxStripeModule=function(){function NgxStripeModule(){}return NgxStripeModule.forRoot=function(publishableKey,options){return{ngModule:NgxStripeModule,providers:[LazyStripeAPILoader,StripeService,StripeFactoryService,WindowRef,DocumentRef,{provide:STRIPE_PUBLISHABLE_KEY,useValue:publishableKey},{provide:STRIPE_OPTIONS,useValue:options}]}},NgxStripeModule}();NgxStripeModule.decorators=[{type:_angular_core.NgModule,args:[{declarations:[StripeCardComponent],exports:[StripeCardComponent]}]}],NgxStripeModule.ctorParameters=function(){return[]},exports.NgxStripeModule=NgxStripeModule,exports.StripeCardComponent=StripeCardComponent,exports.StripeService=StripeService,exports.StripeFactoryService=StripeFactoryService,exports.StripeInstance=StripeInstance,exports.LazyStripeAPILoader=LazyStripeAPILoader,exports.WindowRef=WindowRef,exports.DocumentRef=DocumentRef,exports.isSourceData=isSourceData,exports.STRIPE_PUBLISHABLE_KEY=STRIPE_PUBLISHABLE_KEY,exports.STRIPE_OPTIONS=STRIPE_OPTIONS,exports.isBankAccount=isBankAccount,exports.isBankAccountData=isBankAccountData,exports.isPii=isPii,exports.isPiiData=isPiiData,Object.defineProperty(exports,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=ngx-stripe.umd.min.js.map |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":3,"metadata":{"NgxStripeModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"declarations":[{"__symbolic":"reference","name":"StripeCardComponent"}],"exports":[{"__symbolic":"reference","name":"StripeCardComponent"}]}]}],"members":{},"statics":{"forRoot":{"__symbolic":"function","parameters":["publishableKey","options"],"value":{"ngModule":{"__symbolic":"reference","name":"NgxStripeModule"},"providers":[{"__symbolic":"reference","name":"LazyStripeAPILoader"},{"__symbolic":"reference","name":"StripeService"},{"__symbolic":"reference","name":"StripeFactoryService"},{"__symbolic":"reference","name":"WindowRef"},{"__symbolic":"reference","name":"DocumentRef"},{"provide":{"__symbolic":"reference","name":"STRIPE_PUBLISHABLE_KEY"},"useValue":{"__symbolic":"reference","name":"publishableKey"}},{"provide":{"__symbolic":"reference","name":"STRIPE_OPTIONS"},"useValue":{"__symbolic":"reference","name":"options"}}]}}}},"StripeCardComponent":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component"},"arguments":[{"selector":"ngx-stripe-card","template":"<div class=\"field\" #stripeCard></div>"}]}],"members":{"card":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"}}]}],"on":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"}}]}],"stripeCard":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"ViewChild"},"arguments":["stripeCard"]}]}],"options":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"elementsOptions":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"stripe":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"StripeService"}]}],"ngOnInit":[{"__symbolic":"method"}],"getCard":[{"__symbolic":"method"}]}},"StripeService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject"},"arguments":[{"__symbolic":"reference","name":"STRIPE_PUBLISHABLE_KEY"}]}],[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject"},"arguments":[{"__symbolic":"reference","name":"STRIPE_OPTIONS"}]}],null,null],"parameters":[{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"Options"},{"__symbolic":"reference","name":"LazyStripeAPILoader"},{"__symbolic":"reference","name":"WindowRef"}]}],"getStripeReference":[{"__symbolic":"method"}],"getInstance":[{"__symbolic":"method"}],"setKey":[{"__symbolic":"method"}],"changeKey":[{"__symbolic":"method"}],"elements":[{"__symbolic":"method"}],"createToken":[{"__symbolic":"method"}],"createSource":[{"__symbolic":"method"}],"retrieveSource":[{"__symbolic":"method"}],"paymentRequest":[{"__symbolic":"method"}]}},"StripeFactoryService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject"},"arguments":[{"__symbolic":"reference","name":"STRIPE_PUBLISHABLE_KEY"}]}],[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject"},"arguments":[{"__symbolic":"reference","name":"STRIPE_OPTIONS"}]}],null,null],"parameters":[{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"LazyStripeAPILoader"},{"__symbolic":"reference","name":"WindowRef"}]}],"create":[{"__symbolic":"method"}]}},"StripeInstance":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"LazyStripeAPILoader"},{"__symbolic":"reference","name":"WindowRef"},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"Options"}]}],"getInstance":[{"__symbolic":"method"}],"elements":[{"__symbolic":"method"}],"createToken":[{"__symbolic":"method"}],"createSource":[{"__symbolic":"method"}],"retrieveSource":[{"__symbolic":"method"}],"paymentRequest":[{"__symbolic":"method"}],"stripeObject":[{"__symbolic":"method"}]}},"StripeServiceInterface":{"__symbolic":"interface"},"LazyStripeAPILoader":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"WindowRef"},{"__symbolic":"reference","name":"DocumentRef"}]}],"asStream":[{"__symbolic":"method"}],"isReady":[{"__symbolic":"method"}],"load":[{"__symbolic":"method"}]}},"WindowRef":{"__symbolic":"class","members":{"getNativeWindow":[{"__symbolic":"method"}]}},"DocumentRef":{"__symbolic":"class","members":{"getNativeDocument":[{"__symbolic":"method"}]}},"Element":{"__symbolic":"interface"},"ElementOptions":{"__symbolic":"interface"},"ElementStyleAttributes":{"__symbolic":"interface"},"Elements":{"__symbolic":"interface"},"ElementsOptions":{"__symbolic":"interface"},"Source":{"__symbolic":"interface"},"SourceParams":{"__symbolic":"interface"},"SourceData":{"__symbolic":"interface"},"isSourceData":{"__symbolic":"function","parameters":["sourceData"],"value":{"__symbolic":"binop","operator":"in","left":"type","right":{"__symbolic":"reference","name":"sourceData"}}},"SourceResult":{"__symbolic":"interface"},"STRIPE_PUBLISHABLE_KEY":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken"},"arguments":["Stripe Publishable Key"]},"STRIPE_OPTIONS":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken"},"arguments":["Stripe Options"]},"StripeJS":{"__symbolic":"interface"},"Options":{"__symbolic":"interface"},"Token":{"__symbolic":"interface"},"CardDataOptions":{"__symbolic":"interface"},"TokenResult":{"__symbolic":"interface"},"BankAccountData":{"__symbolic":"interface"},"PiiData":{"__symbolic":"interface"},"isBankAccount":{"__symbolic":"function","parameters":["account"],"value":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"reference","name":"account"},"right":"bank_account"}},"isBankAccountData":{"__symbolic":"function","parameters":["bankAccountData"],"value":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"in","left":"country","right":{"__symbolic":"reference","name":"bankAccountData"}},"right":{"__symbolic":"binop","operator":"in","left":"currency","right":{"__symbolic":"reference","name":"bankAccountData"}}},"right":{"__symbolic":"binop","operator":"in","left":"routing_number","right":{"__symbolic":"reference","name":"bankAccountData"}}},"right":{"__symbolic":"binop","operator":"in","left":"account_number","right":{"__symbolic":"reference","name":"bankAccountData"}}},"right":{"__symbolic":"binop","operator":"in","left":"account_holder_name","right":{"__symbolic":"reference","name":"bankAccountData"}}},"right":{"__symbolic":"binop","operator":"in","left":"account_holder_type","right":{"__symbolic":"reference","name":"bankAccountData"}}},"right":{"__symbolic":"binop","operator":"||","left":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"bankAccountData"},"member":"account_holder_type"},"right":"individual"},"right":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"bankAccountData"},"member":"account_holder_type"},"right":"company"}}}},"isPii":{"__symbolic":"function","parameters":["pii"],"value":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"reference","name":"pii"},"right":"pii"}},"isPiiData":{"__symbolic":"function","parameters":["piiData"],"value":{"__symbolic":"binop","operator":"in","left":"personal_id_number","right":{"__symbolic":"reference","name":"piiData"}}},"Error":{"__symbolic":"interface"},"Address":{"__symbolic":"interface"}},"origins":{"NgxStripeModule":"./src/modules/ngx-stripe.module","StripeCardComponent":"./src/components/stripe-card.component","StripeService":"./src/services/stripe.service","StripeFactoryService":"./src/services/stripe-factory.service","StripeInstance":"./src/services/stripe-instance.class","StripeServiceInterface":"./src/services/stripe-instance.interface","LazyStripeAPILoader":"./src/services/api-loader.service","WindowRef":"./src/services/window-ref","DocumentRef":"./src/services/document-ref","Element":"./src/interfaces/element","ElementEventType":"./src/interfaces/element","ElementType":"./src/interfaces/element","ElementOptions":"./src/interfaces/element","ElementStyleAttributes":"./src/interfaces/element","Elements":"./src/interfaces/elements","ElementsOptions":"./src/interfaces/elements","FontElement":"./src/interfaces/elements","Source":"./src/interfaces/sources","UsageTypes":"./src/interfaces/sources","FlowTypes":"./src/interfaces/sources","SourceParams":"./src/interfaces/sources","SourceData":"./src/interfaces/sources","isSourceData":"./src/interfaces/sources","SourceResult":"./src/interfaces/sources","STRIPE_PUBLISHABLE_KEY":"./src/interfaces/stripe","STRIPE_OPTIONS":"./src/interfaces/stripe","StripeJS":"./src/interfaces/stripe","Options":"./src/interfaces/stripe","Token":"./src/interfaces/token","FieldCheck":"./src/interfaces/token","CardDataOptions":"./src/interfaces/token","TokenResult":"./src/interfaces/token","BankAccount":"./src/interfaces/token","BankAccountData":"./src/interfaces/token","Pii":"./src/interfaces/token","PiiData":"./src/interfaces/token","isBankAccount":"./src/interfaces/token","isBankAccountData":"./src/interfaces/token","isPii":"./src/interfaces/token","isPiiData":"./src/interfaces/token","Error":"./src/interfaces/utils","Address":"./src/interfaces/utils"},"importAs":"ngx-stripe"} | ||
{"__symbolic":"module","version":3,"metadata":{"NgxStripeModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"declarations":[{"__symbolic":"reference","name":"StripeCardComponent"}],"exports":[{"__symbolic":"reference","name":"StripeCardComponent"}]}]}],"members":{},"statics":{"forRoot":{"__symbolic":"function","parameters":["publishableKey","options"],"value":{"ngModule":{"__symbolic":"reference","name":"NgxStripeModule"},"providers":[{"__symbolic":"reference","name":"LazyStripeAPILoader"},{"__symbolic":"reference","name":"StripeService"},{"__symbolic":"reference","name":"StripeFactoryService"},{"__symbolic":"reference","name":"WindowRef"},{"__symbolic":"reference","name":"DocumentRef"},{"provide":{"__symbolic":"reference","name":"STRIPE_PUBLISHABLE_KEY"},"useValue":{"__symbolic":"reference","name":"publishableKey"}},{"provide":{"__symbolic":"reference","name":"STRIPE_OPTIONS"},"useValue":{"__symbolic":"reference","name":"options"}}]}}}},"StripeCardComponent":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component"},"arguments":[{"selector":"ngx-stripe-card","template":"<div class=\"field\" #stripeCard></div>"}]}],"members":{"card":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"}}]}],"on":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Output"}}]}],"stripeCard":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"ViewChild"},"arguments":["stripeCard"]}]}],"options":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"elementsOptions":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"stripe":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"StripeService"}]}],"ngOnInit":[{"__symbolic":"method"}],"getCard":[{"__symbolic":"method"}]}},"StripeService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject"},"arguments":[{"__symbolic":"reference","name":"STRIPE_PUBLISHABLE_KEY"}]}],[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject"},"arguments":[{"__symbolic":"reference","name":"STRIPE_OPTIONS"}]}],null,null],"parameters":[{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"Options"},{"__symbolic":"reference","name":"LazyStripeAPILoader"},{"__symbolic":"reference","name":"WindowRef"}]}],"getStripeReference":[{"__symbolic":"method"}],"getInstance":[{"__symbolic":"method"}],"setKey":[{"__symbolic":"method"}],"changeKey":[{"__symbolic":"method"}],"elements":[{"__symbolic":"method"}],"createToken":[{"__symbolic":"method"}],"createSource":[{"__symbolic":"method"}],"retrieveSource":[{"__symbolic":"method"}],"paymentRequest":[{"__symbolic":"method"}]}},"StripeFactoryService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject"},"arguments":[{"__symbolic":"reference","name":"STRIPE_PUBLISHABLE_KEY"}]}],[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject"},"arguments":[{"__symbolic":"reference","name":"STRIPE_OPTIONS"}]}],null,null],"parameters":[{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"LazyStripeAPILoader"},{"__symbolic":"reference","name":"WindowRef"}]}],"create":[{"__symbolic":"method"}]}},"StripeInstance":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"LazyStripeAPILoader"},{"__symbolic":"reference","name":"WindowRef"},{"__symbolic":"reference","name":"string"},{"__symbolic":"reference","name":"Options"}]}],"getInstance":[{"__symbolic":"method"}],"elements":[{"__symbolic":"method"}],"createToken":[{"__symbolic":"method"}],"createSource":[{"__symbolic":"method"}],"retrieveSource":[{"__symbolic":"method"}],"paymentRequest":[{"__symbolic":"method"}]}},"StripeServiceInterface":{"__symbolic":"interface"},"LazyStripeAPILoader":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject"},"arguments":[{"__symbolic":"reference","module":"@angular/core","name":"PLATFORM_ID"}]}],null,null],"parameters":[{"__symbolic":"reference","name":"any"},{"__symbolic":"reference","name":"WindowRef"},{"__symbolic":"reference","name":"DocumentRef"}]}],"asStream":[{"__symbolic":"method"}],"isReady":[{"__symbolic":"method"}],"load":[{"__symbolic":"method"}]}},"WindowRef":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject"},"arguments":[{"__symbolic":"reference","module":"@angular/core","name":"PLATFORM_ID"}]}]],"parameters":[{"__symbolic":"reference","name":"any"}]}],"getNativeWindow":[{"__symbolic":"method"}]}},"DocumentRef":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject"},"arguments":[{"__symbolic":"reference","module":"@angular/core","name":"PLATFORM_ID"}]}]],"parameters":[{"__symbolic":"reference","name":"any"}]}],"getNativeDocument":[{"__symbolic":"method"}]}},"Element":{"__symbolic":"interface"},"ElementOptions":{"__symbolic":"interface"},"ElementStyleAttributes":{"__symbolic":"interface"},"Elements":{"__symbolic":"interface"},"ElementsOptions":{"__symbolic":"interface"},"Source":{"__symbolic":"interface"},"SourceParams":{"__symbolic":"interface"},"SourceData":{"__symbolic":"interface"},"isSourceData":{"__symbolic":"function","parameters":["sourceData"],"value":{"__symbolic":"binop","operator":"in","left":"type","right":{"__symbolic":"reference","name":"sourceData"}}},"SourceResult":{"__symbolic":"interface"},"STRIPE_PUBLISHABLE_KEY":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken"},"arguments":["Stripe Publishable Key"]},"STRIPE_OPTIONS":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken"},"arguments":["Stripe Options"]},"StripeJS":{"__symbolic":"interface"},"Options":{"__symbolic":"interface"},"Token":{"__symbolic":"interface"},"CardDataOptions":{"__symbolic":"interface"},"TokenResult":{"__symbolic":"interface"},"BankAccountData":{"__symbolic":"interface"},"PiiData":{"__symbolic":"interface"},"isBankAccount":{"__symbolic":"function","parameters":["account"],"value":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"reference","name":"account"},"right":"bank_account"}},"isBankAccountData":{"__symbolic":"function","parameters":["bankAccountData"],"value":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"binop","operator":"in","left":"country","right":{"__symbolic":"reference","name":"bankAccountData"}},"right":{"__symbolic":"binop","operator":"in","left":"currency","right":{"__symbolic":"reference","name":"bankAccountData"}}},"right":{"__symbolic":"binop","operator":"in","left":"routing_number","right":{"__symbolic":"reference","name":"bankAccountData"}}},"right":{"__symbolic":"binop","operator":"in","left":"account_number","right":{"__symbolic":"reference","name":"bankAccountData"}}},"right":{"__symbolic":"binop","operator":"in","left":"account_holder_name","right":{"__symbolic":"reference","name":"bankAccountData"}}},"right":{"__symbolic":"binop","operator":"in","left":"account_holder_type","right":{"__symbolic":"reference","name":"bankAccountData"}}},"right":{"__symbolic":"binop","operator":"||","left":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"bankAccountData"},"member":"account_holder_type"},"right":"individual"},"right":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"bankAccountData"},"member":"account_holder_type"},"right":"company"}}}},"isPii":{"__symbolic":"function","parameters":["pii"],"value":{"__symbolic":"binop","operator":"===","left":{"__symbolic":"reference","name":"pii"},"right":"pii"}},"isPiiData":{"__symbolic":"function","parameters":["piiData"],"value":{"__symbolic":"binop","operator":"in","left":"personal_id_number","right":{"__symbolic":"reference","name":"piiData"}}},"Error":{"__symbolic":"interface"},"Address":{"__symbolic":"interface"}},"origins":{"NgxStripeModule":"./src/modules/ngx-stripe.module","StripeCardComponent":"./src/components/stripe-card.component","StripeService":"./src/services/stripe.service","StripeFactoryService":"./src/services/stripe-factory.service","StripeInstance":"./src/services/stripe-instance.class","StripeServiceInterface":"./src/services/stripe-instance.interface","LazyStripeAPILoader":"./src/services/api-loader.service","WindowRef":"./src/services/window-ref.service","DocumentRef":"./src/services/document-ref.service","Element":"./src/interfaces/element","ElementEventType":"./src/interfaces/element","ElementType":"./src/interfaces/element","ElementOptions":"./src/interfaces/element","ElementStyleAttributes":"./src/interfaces/element","Elements":"./src/interfaces/elements","ElementsOptions":"./src/interfaces/elements","FontElement":"./src/interfaces/elements","Source":"./src/interfaces/sources","UsageTypes":"./src/interfaces/sources","FlowTypes":"./src/interfaces/sources","SourceParams":"./src/interfaces/sources","SourceData":"./src/interfaces/sources","isSourceData":"./src/interfaces/sources","SourceResult":"./src/interfaces/sources","STRIPE_PUBLISHABLE_KEY":"./src/interfaces/stripe","STRIPE_OPTIONS":"./src/interfaces/stripe","StripeJS":"./src/interfaces/stripe","Options":"./src/interfaces/stripe","Token":"./src/interfaces/token","FieldCheck":"./src/interfaces/token","CardDataOptions":"./src/interfaces/token","TokenResult":"./src/interfaces/token","BankAccount":"./src/interfaces/token","BankAccountData":"./src/interfaces/token","Pii":"./src/interfaces/token","PiiData":"./src/interfaces/token","isBankAccount":"./src/interfaces/token","isBankAccountData":"./src/interfaces/token","isPii":"./src/interfaces/token","isPiiData":"./src/interfaces/token","Error":"./src/interfaces/utils","Address":"./src/interfaces/utils"},"importAs":"ngx-stripe"} |
@@ -1,2 +0,3 @@ | ||
import { Component, EventEmitter, Inject, Injectable, InjectionToken, Input, NgModule, Output, ViewChild } from '@angular/core'; | ||
import { Component, EventEmitter, Inject, Injectable, InjectionToken, Input, NgModule, Output, PLATFORM_ID, ViewChild } from '@angular/core'; | ||
import { isPlatformBrowser, isPlatformServer } from '@angular/common'; | ||
import { BehaviorSubject } from 'rxjs/BehaviorSubject'; | ||
@@ -6,8 +7,13 @@ import { Observable } from 'rxjs/Observable'; | ||
import 'rxjs/add/observable/fromPromise'; | ||
import 'rxjs/add/observable/of'; | ||
import 'rxjs/add/operator/switchMap'; | ||
import 'rxjs/add/operator/filter'; | ||
import 'rxjs/add/operator/first'; | ||
import 'rxjs/add/operator/map'; | ||
import 'rxjs/add/operator/publishLast'; | ||
var WindowRef = (function () { | ||
function WindowRef() { | ||
/** | ||
* @param {?} platformId | ||
*/ | ||
function WindowRef(platformId) { | ||
this.platformId = platformId; | ||
} | ||
@@ -18,8 +24,24 @@ /** | ||
WindowRef.prototype.getNativeWindow = function () { | ||
return window; | ||
if (isPlatformBrowser(this.platformId)) { | ||
return window; | ||
} | ||
return ({}); | ||
}; | ||
return WindowRef; | ||
}()); | ||
WindowRef.decorators = [ | ||
{ type: Injectable }, | ||
]; | ||
/** | ||
* @nocollapse | ||
*/ | ||
WindowRef.ctorParameters = function () { return [ | ||
{ type: undefined, decorators: [{ type: Inject, args: [PLATFORM_ID,] },] }, | ||
]; }; | ||
var DocumentRef = (function () { | ||
function DocumentRef() { | ||
/** | ||
* @param {?} platformId | ||
*/ | ||
function DocumentRef(platformId) { | ||
this.platformId = platformId; | ||
} | ||
@@ -30,12 +52,26 @@ /** | ||
DocumentRef.prototype.getNativeDocument = function () { | ||
return document; | ||
if (isPlatformBrowser(this.platformId)) { | ||
return document; | ||
} | ||
return ({}); | ||
}; | ||
return DocumentRef; | ||
}()); | ||
DocumentRef.decorators = [ | ||
{ type: Injectable }, | ||
]; | ||
/** | ||
* @nocollapse | ||
*/ | ||
DocumentRef.ctorParameters = function () { return [ | ||
{ type: undefined, decorators: [{ type: Inject, args: [PLATFORM_ID,] },] }, | ||
]; }; | ||
var LazyStripeAPILoader = (function () { | ||
/** | ||
* @param {?} platformId | ||
* @param {?} window | ||
* @param {?} document | ||
*/ | ||
function LazyStripeAPILoader(window, document) { | ||
function LazyStripeAPILoader(platformId, window, document) { | ||
this.platformId = platformId; | ||
this.window = window; | ||
@@ -67,2 +103,5 @@ this.document = document; | ||
var _this = this; | ||
if (isPlatformServer(this.platformId)) { | ||
return; | ||
} | ||
var /** @type {?} */ status = this.status.getValue(); | ||
@@ -109,2 +148,3 @@ if (this.window.getNativeWindow().hasOwnProperty('Stripe')) { | ||
LazyStripeAPILoader.ctorParameters = function () { return [ | ||
{ type: undefined, decorators: [{ type: Inject, args: [PLATFORM_ID,] },] }, | ||
{ type: WindowRef, }, | ||
@@ -170,6 +210,13 @@ { type: DocumentRef, }, | ||
this.options = options; | ||
this.stripeObject().subscribe(function (Stripe) { | ||
_this.stripe = _this.options | ||
this.stripe$ = new BehaviorSubject(undefined); | ||
this.loader | ||
.asStream() | ||
.filter(function (status) { return status.loaded === true; }) | ||
.first() | ||
.map(function () { return _this.window.getNativeWindow().Stripe; }) | ||
.subscribe(function (Stripe) { | ||
var stripe = _this.options | ||
? Stripe(_this.key, _this.options) | ||
: Stripe(_this.key); | ||
_this.stripe$.next(stripe); | ||
}); | ||
@@ -181,3 +228,3 @@ } | ||
StripeInstance.prototype.getInstance = function () { | ||
return this.stripe; | ||
return this.stripe$.getValue(); | ||
}; | ||
@@ -189,4 +236,6 @@ /** | ||
StripeInstance.prototype.elements = function (options) { | ||
var _this = this; | ||
return this.stripeObject().map(function () { return _this.stripe.elements(options); }); | ||
return this.stripe$ | ||
.asObservable() | ||
.filter(function (stripe) { return Boolean(stripe); }) | ||
.map(function (stripe) { return ((stripe)).elements(options); }); | ||
}; | ||
@@ -199,11 +248,17 @@ /** | ||
StripeInstance.prototype.createToken = function (a, b) { | ||
if (isBankAccount(a) && isBankAccountData(b)) { | ||
return Observable.fromPromise(this.stripe.createToken(a, b)); | ||
} | ||
else if (isPii(a) && isPiiData(b)) { | ||
return Observable.fromPromise(this.stripe.createToken(a, b)); | ||
} | ||
else { | ||
return Observable.fromPromise(this.stripe.createToken(/** @type {?} */ (a), /** @type {?} */ (b))); | ||
} | ||
return this.stripe$ | ||
.asObservable() | ||
.filter(function (stripe) { return Boolean(stripe); }) | ||
.switchMap(function (s) { | ||
var /** @type {?} */ stripe = (s); | ||
if (isBankAccount(a) && isBankAccountData(b)) { | ||
return Observable.fromPromise(stripe.createToken(a, b)); | ||
} | ||
else if (isPii(a) && isPiiData(b)) { | ||
return Observable.fromPromise(stripe.createToken(a, b)); | ||
} | ||
else { | ||
return Observable.fromPromise(stripe.createToken(/** @type {?} */ (a), /** @type {?} */ (b))); | ||
} | ||
}); | ||
}; | ||
@@ -216,6 +271,12 @@ /** | ||
StripeInstance.prototype.createSource = function (a, b) { | ||
if (isSourceData(a)) { | ||
return Observable.fromPromise(this.stripe.createSource(/** @type {?} */ (a))); | ||
} | ||
return Observable.fromPromise(this.stripe.createSource(/** @type {?} */ (a), b)); | ||
return this.stripe$ | ||
.asObservable() | ||
.filter(function (stripe) { return Boolean(stripe); }) | ||
.switchMap(function (s) { | ||
var /** @type {?} */ stripe = (s); | ||
if (isSourceData(a)) { | ||
return Observable.fromPromise(stripe.createSource(/** @type {?} */ (a))); | ||
} | ||
return Observable.fromPromise(stripe.createSource(/** @type {?} */ (a), b)); | ||
}); | ||
}; | ||
@@ -227,3 +288,9 @@ /** | ||
StripeInstance.prototype.retrieveSource = function (source) { | ||
return Observable.fromPromise(this.stripe.retrieveSource(source)); | ||
return this.stripe$ | ||
.asObservable() | ||
.filter(function (stripe) { return Boolean(stripe); }) | ||
.switchMap(function (s) { | ||
var /** @type {?} */ stripe = (s); | ||
return Observable.fromPromise(stripe.retrieveSource(source)); | ||
}); | ||
}; | ||
@@ -235,14 +302,8 @@ /** | ||
StripeInstance.prototype.paymentRequest = function (options) { | ||
return this.stripe.paymentRequest(options); | ||
var /** @type {?} */ stripe = this.getInstance(); | ||
if (stripe) { | ||
return stripe.paymentRequest(options); | ||
} | ||
return undefined; | ||
}; | ||
/** | ||
* @return {?} | ||
*/ | ||
StripeInstance.prototype.stripeObject = function () { | ||
var _this = this; | ||
return this.loader | ||
.asStream() | ||
.filter(function (status) { return status.loaded === true; }) | ||
.map(function () { return ((_this.window.getNativeWindow())).Stripe; }); | ||
}; | ||
return StripeInstance; | ||
@@ -249,0 +310,0 @@ }()); |
@@ -1,2 +0,3 @@ | ||
import { Component, EventEmitter, Inject, Injectable, InjectionToken, Input, NgModule, Output, ViewChild } from '@angular/core'; | ||
import { Component, EventEmitter, Inject, Injectable, InjectionToken, Input, NgModule, Output, PLATFORM_ID, ViewChild } from '@angular/core'; | ||
import { isPlatformBrowser, isPlatformServer } from '@angular/common'; | ||
import { BehaviorSubject } from 'rxjs/BehaviorSubject'; | ||
@@ -6,31 +7,70 @@ import { Observable } from 'rxjs/Observable'; | ||
import 'rxjs/add/observable/fromPromise'; | ||
import 'rxjs/add/observable/of'; | ||
import 'rxjs/add/operator/switchMap'; | ||
import 'rxjs/add/operator/filter'; | ||
import 'rxjs/add/operator/first'; | ||
import 'rxjs/add/operator/map'; | ||
import 'rxjs/add/operator/publishLast'; | ||
class WindowRef { | ||
/** | ||
* @param {?} platformId | ||
*/ | ||
constructor(platformId) { | ||
this.platformId = platformId; | ||
} | ||
/** | ||
* @return {?} | ||
*/ | ||
getNativeWindow() { | ||
return window; | ||
if (isPlatformBrowser(this.platformId)) { | ||
return window; | ||
} | ||
return ({}); | ||
} | ||
} | ||
WindowRef.decorators = [ | ||
{ type: Injectable }, | ||
]; | ||
/** | ||
* @nocollapse | ||
*/ | ||
WindowRef.ctorParameters = () => [ | ||
{ type: undefined, decorators: [{ type: Inject, args: [PLATFORM_ID,] },] }, | ||
]; | ||
class DocumentRef { | ||
/** | ||
* @param {?} platformId | ||
*/ | ||
constructor(platformId) { | ||
this.platformId = platformId; | ||
} | ||
/** | ||
* @return {?} | ||
*/ | ||
getNativeDocument() { | ||
return document; | ||
if (isPlatformBrowser(this.platformId)) { | ||
return document; | ||
} | ||
return ({}); | ||
} | ||
} | ||
DocumentRef.decorators = [ | ||
{ type: Injectable }, | ||
]; | ||
/** | ||
* @nocollapse | ||
*/ | ||
DocumentRef.ctorParameters = () => [ | ||
{ type: undefined, decorators: [{ type: Inject, args: [PLATFORM_ID,] },] }, | ||
]; | ||
class LazyStripeAPILoader { | ||
/** | ||
* @param {?} platformId | ||
* @param {?} window | ||
* @param {?} document | ||
*/ | ||
constructor(window, document) { | ||
constructor(platformId, window, document) { | ||
this.platformId = platformId; | ||
this.window = window; | ||
@@ -61,2 +101,5 @@ this.document = document; | ||
load() { | ||
if (isPlatformServer(this.platformId)) { | ||
return; | ||
} | ||
const /** @type {?} */ status = this.status.getValue(); | ||
@@ -102,2 +145,3 @@ if (this.window.getNativeWindow().hasOwnProperty('Stripe')) { | ||
LazyStripeAPILoader.ctorParameters = () => [ | ||
{ type: undefined, decorators: [{ type: Inject, args: [PLATFORM_ID,] },] }, | ||
{ type: WindowRef, }, | ||
@@ -166,6 +210,13 @@ { type: DocumentRef, }, | ||
this.options = options; | ||
this.stripeObject().subscribe((Stripe) => { | ||
this.stripe = this.options | ||
this.stripe$ = new BehaviorSubject(undefined); | ||
this.loader | ||
.asStream() | ||
.filter((status) => status.loaded === true) | ||
.first() | ||
.map(() => this.window.getNativeWindow().Stripe) | ||
.subscribe((Stripe) => { | ||
const stripe = this.options | ||
? Stripe(this.key, this.options) | ||
: Stripe(this.key); | ||
this.stripe$.next(stripe); | ||
}); | ||
@@ -177,3 +228,3 @@ } | ||
getInstance() { | ||
return this.stripe; | ||
return this.stripe$.getValue(); | ||
} | ||
@@ -185,3 +236,6 @@ /** | ||
elements(options) { | ||
return this.stripeObject().map(() => this.stripe.elements(options)); | ||
return this.stripe$ | ||
.asObservable() | ||
.filter(stripe => Boolean(stripe)) | ||
.map(stripe => ((stripe)).elements(options)); | ||
} | ||
@@ -194,11 +248,17 @@ /** | ||
createToken(a, b) { | ||
if (isBankAccount(a) && isBankAccountData(b)) { | ||
return Observable.fromPromise(this.stripe.createToken(a, b)); | ||
} | ||
else if (isPii(a) && isPiiData(b)) { | ||
return Observable.fromPromise(this.stripe.createToken(a, b)); | ||
} | ||
else { | ||
return Observable.fromPromise(this.stripe.createToken(/** @type {?} */ (a), /** @type {?} */ (b))); | ||
} | ||
return this.stripe$ | ||
.asObservable() | ||
.filter(stripe => Boolean(stripe)) | ||
.switchMap(s => { | ||
const /** @type {?} */ stripe = (s); | ||
if (isBankAccount(a) && isBankAccountData(b)) { | ||
return Observable.fromPromise(stripe.createToken(a, b)); | ||
} | ||
else if (isPii(a) && isPiiData(b)) { | ||
return Observable.fromPromise(stripe.createToken(a, b)); | ||
} | ||
else { | ||
return Observable.fromPromise(stripe.createToken(/** @type {?} */ (a), /** @type {?} */ (b))); | ||
} | ||
}); | ||
} | ||
@@ -211,6 +271,12 @@ /** | ||
createSource(a, b) { | ||
if (isSourceData(a)) { | ||
return Observable.fromPromise(this.stripe.createSource(/** @type {?} */ (a))); | ||
} | ||
return Observable.fromPromise(this.stripe.createSource(/** @type {?} */ (a), b)); | ||
return this.stripe$ | ||
.asObservable() | ||
.filter(stripe => Boolean(stripe)) | ||
.switchMap(s => { | ||
const /** @type {?} */ stripe = (s); | ||
if (isSourceData(a)) { | ||
return Observable.fromPromise(stripe.createSource(/** @type {?} */ (a))); | ||
} | ||
return Observable.fromPromise(stripe.createSource(/** @type {?} */ (a), b)); | ||
}); | ||
} | ||
@@ -222,3 +288,9 @@ /** | ||
retrieveSource(source) { | ||
return Observable.fromPromise(this.stripe.retrieveSource(source)); | ||
return this.stripe$ | ||
.asObservable() | ||
.filter(stripe => Boolean(stripe)) | ||
.switchMap(s => { | ||
const /** @type {?} */ stripe = (s); | ||
return Observable.fromPromise(stripe.retrieveSource(source)); | ||
}); | ||
} | ||
@@ -230,13 +302,8 @@ /** | ||
paymentRequest(options) { | ||
return this.stripe.paymentRequest(options); | ||
const /** @type {?} */ stripe = this.getInstance(); | ||
if (stripe) { | ||
return stripe.paymentRequest(options); | ||
} | ||
return undefined; | ||
} | ||
/** | ||
* @return {?} | ||
*/ | ||
stripeObject() { | ||
return this.loader | ||
.asStream() | ||
.filter((status) => status.loaded === true) | ||
.map(() => ((this.window.getNativeWindow())).Stripe); | ||
} | ||
} | ||
@@ -243,0 +310,0 @@ |
{ | ||
"name": "ngx-stripe", | ||
"version": "0.6.1", | ||
"version": "0.7.0", | ||
"description": "Angular 2+ wrapper for StripeJS", | ||
@@ -5,0 +5,0 @@ "main": "./bundles/ngx-stripe.umd.js", |
@@ -50,3 +50,3 @@ import { Error, Address } from './utils'; | ||
export interface SourceData { | ||
type: string; | ||
type?: string; | ||
amount?: number; | ||
@@ -53,0 +53,0 @@ currency?: string; |
@@ -5,8 +5,9 @@ import { ModuleWithProviders } from '@angular/core'; | ||
import 'rxjs/add/observable/fromPromise'; | ||
import 'rxjs/add/observable/of'; | ||
import 'rxjs/add/operator/switchMap'; | ||
import 'rxjs/add/operator/filter'; | ||
import 'rxjs/add/operator/first'; | ||
import 'rxjs/add/operator/map'; | ||
import 'rxjs/add/operator/publishLast'; | ||
export declare class NgxStripeModule { | ||
static forRoot(publishableKey?: string, options?: Options): ModuleWithProviders; | ||
} |
@@ -8,4 +8,4 @@ export { NgxStripeModule } from './modules/ngx-stripe.module'; | ||
export { LazyStripeAPILoader } from './services/api-loader.service'; | ||
export { WindowRef } from './services/window-ref'; | ||
export { DocumentRef } from './services/document-ref'; | ||
export { WindowRef } from './services/window-ref.service'; | ||
export { DocumentRef } from './services/document-ref.service'; | ||
export { Element, ElementEventType, ElementType, ElementOptions, ElementStyleAttributes } from './interfaces/element'; | ||
@@ -12,0 +12,0 @@ export { Elements, ElementsOptions, FontElement } from './interfaces/elements'; |
import { Observable } from 'rxjs/Observable'; | ||
import { WindowRef } from './window-ref'; | ||
import { DocumentRef } from './document-ref'; | ||
import { WindowRef } from './window-ref.service'; | ||
import { DocumentRef } from './document-ref.service'; | ||
export interface Status { | ||
@@ -10,6 +10,7 @@ loaded: boolean; | ||
export declare class LazyStripeAPILoader { | ||
private platformId; | ||
private window; | ||
private document; | ||
private status; | ||
constructor(window: WindowRef, document: DocumentRef); | ||
constructor(platformId: any, window: WindowRef, document: DocumentRef); | ||
asStream(): Observable<Status>; | ||
@@ -16,0 +17,0 @@ isReady(): boolean; |
import { Options } from '../interfaces/stripe'; | ||
import { LazyStripeAPILoader } from './api-loader.service'; | ||
import { WindowRef } from './window-ref'; | ||
import { WindowRef } from './window-ref.service'; | ||
import { StripeInstance } from './stripe-instance.class'; | ||
@@ -5,0 +5,0 @@ export declare class StripeFactoryService { |
import { Observable } from 'rxjs/Observable'; | ||
import { WindowRef } from './window-ref'; | ||
import { WindowRef } from './window-ref.service'; | ||
import { LazyStripeAPILoader } from './api-loader.service'; | ||
@@ -16,5 +16,5 @@ import { StripeJS, Options } from '../interfaces/stripe'; | ||
private options; | ||
private stripe; | ||
private stripe$; | ||
constructor(loader: LazyStripeAPILoader, window: WindowRef, key: string, options?: Options); | ||
getInstance(): StripeJS; | ||
getInstance(): StripeJS | undefined; | ||
elements(options?: ElementsOptions): Observable<Elements>; | ||
@@ -25,3 +25,2 @@ createToken(a: Element | BankAccount | Pii, b: CardDataOptions | BankAccountData | PiiData | undefined): Observable<TokenResult>; | ||
paymentRequest(options: PaymentRequestOptions): any; | ||
private stripeObject(); | ||
} |
import { Observable } from 'rxjs/Observable'; | ||
import { WindowRef } from './window-ref'; | ||
import { WindowRef } from './window-ref.service'; | ||
import { LazyStripeAPILoader } from './api-loader.service'; | ||
@@ -20,3 +20,3 @@ import { StripeJS, Options } from '../interfaces/stripe'; | ||
getStripeReference(): Observable<any>; | ||
getInstance(): StripeJS; | ||
getInstance(): StripeJS | undefined; | ||
setKey(key: string, options?: Options): StripeInstance; | ||
@@ -23,0 +23,0 @@ changeKey(key: string, options?: Options): StripeInstance; |
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
277450
2273