ngx-stripe
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -182,14 +182,6 @@ (function (global, factory) { | ||
StripeService.prototype.changeKey = function (key, options) { | ||
var _this = this; | ||
var /** @type {?} */ obs = this.stripeObject() | ||
.map(function (Stripe) { | ||
_this.stripe = options | ||
? ((Stripe(key, options))) | ||
: ((Stripe(key))); | ||
return _this.stripe; | ||
}) | ||
.publishLast() | ||
.refCount(); | ||
obs.subscribe(); | ||
return obs; | ||
this.key = key; | ||
if (options) { | ||
this.options = options; | ||
} | ||
}; | ||
@@ -196,0 +188,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"),StripeService=function(){function StripeService(key,options,loader,window){var _this=this;this.key=key,this.options=options,this.loader=loader,this.window=window,this.stripeObject().subscribe(function(Stripe){_this.stripe=_this.options?Stripe(_this.key,_this.options):Stripe(_this.key)})}return StripeService.prototype.elements=function(options){var _this=this;return this.stripeObject().map(function(){return _this.stripe.elements(options)})},StripeService.prototype.changeKey=function(key,options){var _this=this,obs=this.stripeObject().map(function(Stripe){return _this.stripe=options?Stripe(key,options):Stripe(key),_this.stripe}).publishLast().refCount();return obs.subscribe(),obs},StripeService.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)))},StripeService.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))},StripeService.prototype.retrieveSource=function(source){return rxjs_Observable.Observable.fromPromise(this.stripe.retrieveSource(source))},StripeService.prototype.stripeObject=function(){var _this=this;return this.loader.asStream().filter(function(status){return!0===status.loaded}).map(function(){return _this.window.getNativeWindow().Stripe})},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 StripeCardComponent=function(){function StripeCardComponent(stripeService){this.stripeService=stripeService,this.onCard=new _angular_core.EventEmitter,this.options$=new rxjs_BehaviorSubject.BehaviorSubject({}),this.elementsOptions$=new rxjs_BehaviorSubject.BehaviorSubject({})}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}),StripeCardComponent.prototype.ngOnInit=function(){var _this=this,elements$=this.elementsOptions$.asObservable().switchMap(function(options){return 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.mount(_this.card.nativeElement),_this.onCard.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" #card></div>'}]}],StripeCardComponent.ctorParameters=function(){return[{type:StripeService}]},StripeCardComponent.propDecorators={onCard:[{type:_angular_core.Output}],card:[{type:_angular_core.ViewChild,args:["card"]}],options:[{type:_angular_core.Input}],elementsOptions:[{type:_angular_core.Input}]};var NgxStripeModule=function(){function NgxStripeModule(){}return NgxStripeModule.forRoot=function(publishableKey,options){return{ngModule:NgxStripeModule,providers:[LazyStripeAPILoader,StripeService,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.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("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"),StripeService=function(){function StripeService(key,options,loader,window){var _this=this;this.key=key,this.options=options,this.loader=loader,this.window=window,this.stripeObject().subscribe(function(Stripe){_this.stripe=_this.options?Stripe(_this.key,_this.options):Stripe(_this.key)})}return StripeService.prototype.elements=function(options){var _this=this;return this.stripeObject().map(function(){return _this.stripe.elements(options)})},StripeService.prototype.changeKey=function(key,options){this.key=key,options&&(this.options=options)},StripeService.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)))},StripeService.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))},StripeService.prototype.retrieveSource=function(source){return rxjs_Observable.Observable.fromPromise(this.stripe.retrieveSource(source))},StripeService.prototype.stripeObject=function(){var _this=this;return this.loader.asStream().filter(function(status){return!0===status.loaded}).map(function(){return _this.window.getNativeWindow().Stripe})},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 StripeCardComponent=function(){function StripeCardComponent(stripeService){this.stripeService=stripeService,this.onCard=new _angular_core.EventEmitter,this.options$=new rxjs_BehaviorSubject.BehaviorSubject({}),this.elementsOptions$=new rxjs_BehaviorSubject.BehaviorSubject({})}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}),StripeCardComponent.prototype.ngOnInit=function(){var _this=this,elements$=this.elementsOptions$.asObservable().switchMap(function(options){return 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.mount(_this.card.nativeElement),_this.onCard.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" #card></div>'}]}],StripeCardComponent.ctorParameters=function(){return[{type:StripeService}]},StripeCardComponent.propDecorators={onCard:[{type:_angular_core.Output}],card:[{type:_angular_core.ViewChild,args:["card"]}],options:[{type:_angular_core.Input}],elementsOptions:[{type:_angular_core.Input}]};var NgxStripeModule=function(){function NgxStripeModule(){}return NgxStripeModule.forRoot=function(publishableKey,options){return{ngModule:NgxStripeModule,providers:[LazyStripeAPILoader,StripeService,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.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 |
@@ -185,14 +185,6 @@ import { Component, EventEmitter, Inject, Injectable, InjectionToken, Input, NgModule, Output, ViewChild } from '@angular/core'; | ||
StripeService.prototype.changeKey = function (key, options) { | ||
var _this = this; | ||
var /** @type {?} */ obs = this.stripeObject() | ||
.map(function (Stripe) { | ||
_this.stripe = options | ||
? ((Stripe(key, options))) | ||
: ((Stripe(key))); | ||
return _this.stripe; | ||
}) | ||
.publishLast() | ||
.refCount(); | ||
obs.subscribe(); | ||
return obs; | ||
this.key = key; | ||
if (options) { | ||
this.options = options; | ||
} | ||
}; | ||
@@ -199,0 +191,0 @@ /** |
@@ -182,13 +182,6 @@ import { Component, EventEmitter, Inject, Injectable, InjectionToken, Input, NgModule, Output, ViewChild } from '@angular/core'; | ||
changeKey(key, options) { | ||
const /** @type {?} */ obs = this.stripeObject() | ||
.map((Stripe) => { | ||
this.stripe = options | ||
? ((Stripe(key, options))) | ||
: ((Stripe(key))); | ||
return this.stripe; | ||
}) | ||
.publishLast() | ||
.refCount(); | ||
obs.subscribe(); | ||
return obs; | ||
this.key = key; | ||
if (options) { | ||
this.options = options; | ||
} | ||
} | ||
@@ -195,0 +188,0 @@ /** |
{ | ||
"name": "ngx-stripe", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Angular 2+ wrapper for StripeJS", | ||
@@ -5,0 +5,0 @@ "main": "./bundles/ngx-stripe.umd.js", |
import { Observable } from 'rxjs/Observable'; | ||
import { WindowRef } from './window-ref'; | ||
import { LazyStripeAPILoader } from './api-loader.service'; | ||
import { StripeJS } from '../interfaces/stripe'; | ||
import { Element } from '../interfaces/element'; | ||
@@ -17,3 +16,3 @@ import { Elements, ElementsOptions } from '../interfaces/elements'; | ||
elements(options?: ElementsOptions): Observable<Elements>; | ||
changeKey(key: string, options?: string): Observable<StripeJS>; | ||
changeKey(key: string, options?: string): void; | ||
createToken(a: Element | BankAccount | Pii, b: CardDataOptions | BankAccountData | PiiData | undefined): Observable<TokenResult>; | ||
@@ -20,0 +19,0 @@ createSource(a: Element | SourceData, b?: SourceData | undefined): Observable<SourceResult>; |
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
178789
1469