ngx-stripe
Version:
Collect Payments with Stripe: The Angular Way
1,133 lines (1,121 loc) • 183 kB
JavaScript
import * as i3 from '@angular/common';
import { isPlatformBrowser, isPlatformServer, CommonModule } from '@angular/common';
import * as i0 from '@angular/core';
import { Directive, InjectionToken, PLATFORM_ID, Injectable, Inject, EventEmitter, Input, Output, TemplateRef, Component, Optional, ContentChild, ViewChild, makeEnvironmentProviders, NgModule, inject } from '@angular/core';
import { filter, first, map, switchMap } from 'rxjs/operators';
import { BehaviorSubject, from } from 'rxjs';
class NgxStripeElementLoadingTemplateDirective {
templateRef;
constructor(templateRef) {
this.templateRef = templateRef;
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: NgxStripeElementLoadingTemplateDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.1", type: NgxStripeElementLoadingTemplateDirective, isStandalone: true, selector: "[ngxStripeLoadingTemplate]", ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: NgxStripeElementLoadingTemplateDirective, decorators: [{
type: Directive,
args: [{
selector: '[ngxStripeLoadingTemplate]',
standalone: true
}]
}], ctorParameters: () => [{ type: i0.TemplateRef }] });
const STRIPE_PUBLISHABLE_KEY = new InjectionToken('Stripe Publishable Key');
const STRIPE_OPTIONS = new InjectionToken('Stripe Options');
const NGX_STRIPE_VERSION = new InjectionToken('NGX_STRIPE_VERSION');
class StripeInstance {
version;
loader;
window;
key;
options;
stripe$ = new BehaviorSubject(undefined);
stripe = this.stripe$.asObservable().pipe(filter((stripe) => Boolean(stripe)));
constructor(version, loader, window, key, options) {
this.version = version;
this.loader = loader;
this.window = window;
this.key = key;
this.options = options;
this.loader
.asStream()
.pipe(filter((status) => status.loaded === true), first(), map(() => this.window.getNativeWindow().Stripe))
.subscribe((stripeInstance) => {
const stripe = this.options
? stripeInstance(this.key, this.options)
: stripeInstance(this.key);
stripe.registerAppInfo(this.getNgxStripeAppInfo(this.version));
this.stripe$.next(stripe);
});
}
getInstance() {
return this.stripe$.getValue();
}
elements(options) {
return this.stripe.pipe(map((stripe) => stripe.elements(options)), first());
}
redirectToCheckout(options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.redirectToCheckout(options))), first());
}
confirmPayment(options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmPayment(options))), first());
}
confirmAcssDebitPayment(clientSecret, data, options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmAcssDebitPayment(clientSecret, data, options))), first());
}
confirmUsBankAccountPayment(clientSecret, data) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmUsBankAccountPayment(clientSecret, data))), first());
}
confirmAlipayPayment(clientSecret, data, options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmAlipayPayment(clientSecret, data, options))), first());
}
confirmAuBecsDebitPayment(clientSecret, data) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmAuBecsDebitPayment(clientSecret, data))), first());
}
confirmBancontactPayment(clientSecret, data, options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmBancontactPayment(clientSecret, data, options))), first());
}
confirmBlikPayment(clientSecret, data, options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmBlikPayment(clientSecret, data, options))), first());
}
confirmBoletoPayment(clientSecret, data, options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmBoletoPayment(clientSecret, data, options))), first());
}
confirmCardPayment(clientSecret, data, options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmCardPayment(clientSecret, data, options))), first());
}
confirmCashappPayment(clientSecret, data, options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmCashappPayment(clientSecret, data, options))), first());
}
confirmCustomerBalancePayment(clientSecret, data, options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmCustomerBalancePayment(clientSecret, data, options))), first());
}
confirmEpsPayment(clientSecret, data, options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmEpsPayment(clientSecret, data, options))), first());
}
confirmFpxPayment(clientSecret, data, options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmFpxPayment(clientSecret, data, options))), first());
}
confirmGiropayPayment(clientSecret, data, options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmGiropayPayment(clientSecret, data, options))), first());
}
confirmGrabPayPayment(clientSecret, data, options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmGrabPayPayment(clientSecret, data, options))), first());
}
confirmIdealPayment(clientSecret, data, options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmIdealPayment(clientSecret, data, options))), first());
}
confirmKlarnaPayment(clientSecret, data, options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmKlarnaPayment(clientSecret, data, options))), first());
}
confirmKonbiniPayment(clientSecret, data, options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmKonbiniPayment(clientSecret, data, options))), first());
}
confirmMobilepayPayment(clientSecret, data, options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmMobilepayPayment(clientSecret, data, options))), first());
}
confirmOxxoPayment(clientSecret, data, options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmOxxoPayment(clientSecret, data, options))), first());
}
confirmP24Payment(clientSecret, data, options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmP24Payment(clientSecret, data, options))), first());
}
confirmPayNowPayment(clientSecret, data, options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmPayNowPayment(clientSecret, data, options))), first());
}
confirmPayPalPayment(clientSecret, data) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmPayPalPayment(clientSecret, data))), first());
}
confirmPixPayment(clientSecret, data, options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmPixPayment(clientSecret, data, options))), first());
}
confirmPromptPayPayment(clientSecret, data, options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmPromptPayPayment(clientSecret, data, options))), first());
}
confirmSepaDebitPayment(clientSecret, data) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmSepaDebitPayment(clientSecret, data))), first());
}
confirmSofortPayment(clientSecret, data, options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmSofortPayment(clientSecret, data, options))), first());
}
confirmWechatPayPayment(clientSecret, data, options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmWechatPayPayment(clientSecret, data, options))), first());
}
handleCardAction(clientSecret) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.handleCardAction(clientSecret))), first());
}
handleNextAction(options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.handleNextAction(options))), first());
}
verifyMicrodepositsForPayment(clientSecret, data) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.verifyMicrodepositsForPayment(clientSecret, data))), first());
}
createRadarSession() {
return this.stripe.pipe(switchMap((stripe) => from(stripe.createRadarSession())), first());
}
collectBankAccountForPayment(options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.collectBankAccountForPayment(options))), first());
}
createPaymentMethod(options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.createPaymentMethod(options))), first());
}
createConfirmationToken(options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.createConfirmationToken(options))), first());
}
retrievePaymentIntent(clientSecret) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.retrievePaymentIntent(clientSecret))), first());
}
confirmSetup(options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmSetup(options))), first());
}
confirmAcssDebitSetup(clientSecret, data, options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmAcssDebitSetup(clientSecret, data, options))), first());
}
confirmUsBankAccountSetup(clientSecret, data) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmUsBankAccountSetup(clientSecret, data))), first());
}
confirmAuBecsDebitSetup(clientSecret, data) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmAuBecsDebitSetup(clientSecret, data))), first());
}
confirmBacsDebitSetup(clientSecret, data) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmBacsDebitSetup(clientSecret, data))), first());
}
confirmBancontactSetup(clientSecret, data) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmBancontactSetup(clientSecret, data))), first());
}
confirmCardSetup(clientSecret, data, options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmCardSetup(clientSecret, data, options))), first());
}
confirmCashappSetup(clientSecret, data, options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmCashappSetup(clientSecret, data, options))), first());
}
confirmIdealSetup(clientSecret, data) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmIdealSetup(clientSecret, data))), first());
}
confirmPayPalSetup(clientSecret, data) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmPayPalSetup(clientSecret, data))), first());
}
confirmSepaDebitSetup(clientSecret, data) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmSepaDebitSetup(clientSecret, data))), first());
}
confirmSofortSetup(clientSecret, data, options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmSofortSetup(clientSecret, data, options))), first());
}
confirmAffirmPayment(clientSecret, data, options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmAffirmPayment(clientSecret, data, options))), first());
}
confirmAfterpayClearpayPayment(clientSecret, data, options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmAfterpayClearpayPayment(clientSecret, data, options))), first());
}
verifyMicrodepositsForSetup(clientSecret, data) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.verifyMicrodepositsForSetup(clientSecret, data))), first());
}
collectBankAccountForSetup(options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.collectBankAccountForSetup(options))), first());
}
retrieveSetupIntent(clientSecret) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.retrieveSetupIntent(clientSecret))), first());
}
processOrder(options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.processOrder(options))), first());
}
retrieveOrder(clientSecret) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.retrieveOrder(clientSecret))), first());
}
paymentRequest(options) {
const stripe = this.getInstance();
return stripe.paymentRequest(options);
}
createToken(tokenType, data) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.createToken(tokenType, data))), first());
}
createSource(a, b) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.createSource(a, b))), first());
}
retrieveSource(source) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.retrieveSource(source))), first());
}
verifyIdentity(clientSecret) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.verifyIdentity(clientSecret))), first());
}
collectFinancialConnectionsAccounts(options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.collectFinancialConnectionsAccounts(options))), first());
}
collectBankAccountToken(options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.collectBankAccountToken(options))), first());
}
createEphemeralKeyNonce(options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.createEphemeralKeyNonce(options))), first());
}
initCheckout(options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.initCheckout(options))), first());
}
initEmbeddedCheckout(options) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.initEmbeddedCheckout(options))), first());
}
/**
* @deprecated
*/
handleCardPayment(clientSecret, element, data) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.handleCardPayment(clientSecret, element, data))), first());
}
/**
* @deprecated
*/
confirmPaymentIntent(clientSecret, element, data) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmPaymentIntent(clientSecret, element, data))), first());
}
/**
* @deprecated
*/
handleCardSetup(clientSecret, element, data) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.handleCardSetup(clientSecret, element, data))), first());
}
/**
* @deprecated
*/
confirmSetupIntent(clientSecret, element, data) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.confirmSetupIntent(clientSecret, element, data))), first());
}
/**
* @deprecated
*/
handleFpxPayment(clientSecret, element, data) {
return this.stripe.pipe(switchMap((stripe) => from(stripe.handleFpxPayment(clientSecret, element, data))), first());
}
getNgxStripeAppInfo(version) {
return {
name: 'ngx-stripe',
url: 'https://ngx-stripe.dev',
partner_id: 'pp_partner_JR4l1rmvUoPP4V',
version
};
}
}
class WindowRef {
platformId;
constructor(platformId) {
this.platformId = platformId;
}
getNativeWindow() {
if (isPlatformBrowser(this.platformId)) {
return window;
}
return {};
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: WindowRef, deps: [{ token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: WindowRef });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: WindowRef, decorators: [{
type: Injectable
}], ctorParameters: () => [{ type: undefined, decorators: [{
type: Inject,
args: [PLATFORM_ID]
}] }] });
class DocumentRef {
platformId;
constructor(platformId) {
this.platformId = platformId;
}
getNativeDocument() {
if (isPlatformBrowser(this.platformId)) {
return document;
}
return {};
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: DocumentRef, deps: [{ token: PLATFORM_ID }], target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: DocumentRef });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: DocumentRef, decorators: [{
type: Injectable
}], ctorParameters: () => [{ type: undefined, decorators: [{
type: Inject,
args: [PLATFORM_ID]
}] }] });
class LazyStripeAPILoader {
platformId;
window;
document;
status = new BehaviorSubject({
error: false,
loaded: false,
loading: false
});
constructor(platformId, window, document) {
this.platformId = platformId;
this.window = window;
this.document = document;
}
asStream() {
this.load();
return this.status.asObservable();
}
isReady() {
return this.status.getValue().loaded;
}
load() {
if (isPlatformServer(this.platformId)) {
return;
}
const status = this.status.getValue();
if (this.window.getNativeWindow().hasOwnProperty('Stripe')) {
this.status.next({
error: false,
loaded: true,
loading: false
});
}
else if (!status.loaded && !status.loading) {
this.status.next({
...status,
loading: true
});
const script = this.document.getNativeDocument().createElement('script');
script.type = 'text/javascript';
script.async = true;
script.defer = true;
script.src = 'https://js.stripe.com/v3/';
script.onload = () => {
this.status.next({
error: false,
loaded: true,
loading: false
});
};
script.onerror = () => {
this.status.next({
error: true,
loaded: false,
loading: false
});
};
this.document.getNativeDocument().body.appendChild(script);
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: LazyStripeAPILoader, deps: [{ token: PLATFORM_ID }, { token: WindowRef }, { token: DocumentRef }], target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: LazyStripeAPILoader });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: LazyStripeAPILoader, decorators: [{
type: Injectable
}], ctorParameters: () => [{ type: undefined, decorators: [{
type: Inject,
args: [PLATFORM_ID]
}] }, { type: WindowRef }, { type: DocumentRef }] });
class StripeService {
version;
key;
options;
loader;
window;
stripe;
constructor(version, key, options, loader, window) {
this.version = version;
this.key = key;
this.options = options;
this.loader = loader;
this.window = window;
if (key) {
this.stripe = new StripeInstance(this.version, this.loader, this.window, key, options);
}
}
getStripeReference() {
return this.loader.asStream().pipe(filter((status) => status.loaded === true), map(() => this.window.getNativeWindow().Stripe));
}
getInstance() {
return this.stripe.getInstance();
}
setKey(key, options) {
return this.changeKey(key, options);
}
changeKey(key, options) {
this.stripe = new StripeInstance(this.version, this.loader, this.window, key, options);
return this.stripe;
}
elements(options) {
return this.stripe.elements(options);
}
redirectToCheckout(options) {
return this.stripe.redirectToCheckout(options);
}
confirmPayment(options) {
return this.stripe.confirmPayment(options);
}
confirmAcssDebitPayment(clientSecret, data, options) {
return this.stripe.confirmAcssDebitPayment(clientSecret, data, options);
}
confirmUsBankAccountPayment(clientSecret, data) {
return this.stripe.confirmUsBankAccountPayment(clientSecret, data);
}
confirmAlipayPayment(clientSecret, data, options) {
return this.stripe.confirmAlipayPayment(clientSecret, data, options);
}
confirmAuBecsDebitPayment(clientSecret, data) {
return this.stripe.confirmAuBecsDebitPayment(clientSecret, data);
}
confirmBancontactPayment(clientSecret, data, options) {
return this.stripe.confirmBancontactPayment(clientSecret, data, options);
}
confirmBlikPayment(clientSecret, data, options) {
return this.stripe.confirmBlikPayment(clientSecret, data, options);
}
confirmBoletoPayment(clientSecret, data, options) {
return this.stripe.confirmBoletoPayment(clientSecret, data, options);
}
confirmCardPayment(clientSecret, data, options) {
return this.stripe.confirmCardPayment(clientSecret, data, options);
}
confirmCashappPayment(clientSecret, data, options) {
return this.stripe.confirmCashappPayment(clientSecret, data, options);
}
confirmCustomerBalancePayment(clientSecret, data, options) {
return this.stripe.confirmCustomerBalancePayment(clientSecret, data, options);
}
confirmEpsPayment(clientSecret, data, options) {
return this.stripe.confirmEpsPayment(clientSecret, data, options);
}
confirmFpxPayment(clientSecret, data, options) {
return this.stripe.confirmFpxPayment(clientSecret, data, options);
}
confirmGiropayPayment(clientSecret, data, options) {
return this.stripe.confirmGiropayPayment(clientSecret, data, options);
}
confirmGrabPayPayment(clientSecret, data, options) {
return this.stripe.confirmGrabPayPayment(clientSecret, data, options);
}
confirmIdealPayment(clientSecret, data, options) {
return this.stripe.confirmIdealPayment(clientSecret, data, options);
}
confirmKlarnaPayment(clientSecret, data, options) {
return this.stripe.confirmKlarnaPayment(clientSecret, data, options);
}
confirmKonbiniPayment(clientSecret, data, options) {
return this.stripe.confirmKonbiniPayment(clientSecret, data, options);
}
confirmMobilepayPayment(clientSecret, data, options) {
return this.stripe.confirmMobilepayPayment(clientSecret, data, options);
}
confirmOxxoPayment(clientSecret, data, options) {
return this.stripe.confirmOxxoPayment(clientSecret, data, options);
}
confirmP24Payment(clientSecret, data, options) {
return this.stripe.confirmP24Payment(clientSecret, data, options);
}
confirmPayNowPayment(clientSecret, data, options) {
return this.stripe.confirmPayNowPayment(clientSecret, data, options);
}
confirmPayPalPayment(clientSecret, data) {
return this.stripe.confirmPayPalPayment(clientSecret, data);
}
confirmPixPayment(clientSecret, data, options) {
return this.stripe.confirmPixPayment(clientSecret, data, options);
}
confirmPromptPayPayment(clientSecret, data, options) {
return this.stripe.confirmPromptPayPayment(clientSecret, data, options);
}
confirmSepaDebitPayment(clientSecret, data) {
return this.stripe.confirmSepaDebitPayment(clientSecret, data);
}
confirmSofortPayment(clientSecret, data, options) {
return this.stripe.confirmSofortPayment(clientSecret, data, options);
}
confirmWechatPayPayment(clientSecret, data, options) {
return this.stripe.confirmWechatPayPayment(clientSecret, data, options);
}
handleCardAction(clientSecret) {
return this.stripe.handleCardAction(clientSecret);
}
handleNextAction(options) {
return this.stripe.handleNextAction(options);
}
verifyMicrodepositsForPayment(clientSecret, data) {
return this.stripe.verifyMicrodepositsForPayment(clientSecret, data);
}
createRadarSession() {
return this.stripe.createRadarSession();
}
collectBankAccountForPayment(options) {
return this.stripe.collectBankAccountForPayment(options);
}
createPaymentMethod(options) {
return this.stripe.createPaymentMethod(options);
}
createConfirmationToken(options) {
return this.stripe.createConfirmationToken(options);
}
retrievePaymentIntent(clientSecret) {
return this.stripe.retrievePaymentIntent(clientSecret);
}
confirmSetup(options) {
return this.stripe.confirmSetup(options);
}
confirmAcssDebitSetup(clientSecret, data, options) {
return this.stripe.confirmAcssDebitSetup(clientSecret, data, options);
}
confirmUsBankAccountSetup(clientSecret, data) {
return this.stripe.confirmUsBankAccountSetup(clientSecret, data);
}
confirmAuBecsDebitSetup(clientSecret, data) {
return this.stripe.confirmAuBecsDebitSetup(clientSecret, data);
}
confirmBacsDebitSetup(clientSecret, data) {
return this.stripe.confirmBacsDebitSetup(clientSecret, data);
}
confirmBancontactSetup(clientSecret, data) {
return this.stripe.confirmBancontactSetup(clientSecret, data);
}
confirmCardSetup(clientSecret, data, options) {
return this.stripe.confirmCardSetup(clientSecret, data, options);
}
confirmCashappSetup(clientSecret, data, options) {
return this.stripe.confirmCashappSetup(clientSecret, data, options);
}
confirmIdealSetup(clientSecret, data) {
return this.stripe.confirmIdealSetup(clientSecret, data);
}
confirmPayPalSetup(clientSecret, data) {
return this.stripe.confirmPayPalSetup(clientSecret, data);
}
confirmSepaDebitSetup(clientSecret, data) {
return this.stripe.confirmSepaDebitSetup(clientSecret, data);
}
confirmSofortSetup(clientSecret, data, options) {
return this.stripe.confirmSofortSetup(clientSecret, data, options);
}
confirmAffirmPayment(clientSecret, data, options) {
return this.stripe.confirmAffirmPayment(clientSecret, data, options);
}
confirmAfterpayClearpayPayment(clientSecret, data, options) {
return this.stripe.confirmAfterpayClearpayPayment(clientSecret, data, options);
}
verifyMicrodepositsForSetup(clientSecret, data) {
return this.stripe.verifyMicrodepositsForSetup(clientSecret, data);
}
collectBankAccountForSetup(options) {
return this.stripe.collectBankAccountForSetup(options);
}
retrieveSetupIntent(clientSecret) {
return this.stripe.retrieveSetupIntent(clientSecret);
}
processOrder(options) {
return this.stripe.processOrder(options);
}
retrieveOrder(clientSecret) {
return this.stripe.retrieveOrder(clientSecret);
}
paymentRequest(options) {
return this.stripe.paymentRequest(options);
}
createToken(tokenType, data) {
return this.stripe.createToken(tokenType, data);
}
createSource(a, b) {
return this.stripe.createSource(a, b);
}
retrieveSource(source) {
return this.stripe.retrieveSource(source);
}
verifyIdentity(clientSecret) {
return this.stripe.verifyIdentity(clientSecret);
}
collectFinancialConnectionsAccounts(options) {
return this.stripe.collectFinancialConnectionsAccounts(options);
}
collectBankAccountToken(options) {
return this.stripe.collectBankAccountToken(options);
}
createEphemeralKeyNonce(options) {
return this.stripe.createEphemeralKeyNonce(options);
}
initCheckout(options) {
return this.stripe.initCheckout(options);
}
initEmbeddedCheckout(options) {
return this.stripe.initEmbeddedCheckout(options);
}
/**
* @deprecated
*/
handleCardPayment(clientSecret, element, data) {
return this.stripe.handleCardPayment(clientSecret, element, data);
}
/**
* @deprecated
*/
confirmPaymentIntent(clientSecret, element, data) {
return this.stripe.confirmPaymentIntent(clientSecret, element, data);
}
/**
* @deprecated
*/
handleCardSetup(clientSecret, element, data) {
return this.stripe.handleCardSetup(clientSecret, element, data);
}
/**
* @deprecated
*/
confirmSetupIntent(clientSecret, element, data) {
return this.stripe.confirmSetupIntent(clientSecret, element, data);
}
/**
* @deprecated
*/
handleFpxPayment(clientSecret, element, data) {
return this.stripe.handleFpxPayment(clientSecret, element, data);
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: StripeService, deps: [{ token: NGX_STRIPE_VERSION }, { token: STRIPE_PUBLISHABLE_KEY }, { token: STRIPE_OPTIONS }, { token: LazyStripeAPILoader }, { token: WindowRef }], target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: StripeService });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: StripeService, decorators: [{
type: Injectable
}], ctorParameters: () => [{ type: undefined, decorators: [{
type: Inject,
args: [NGX_STRIPE_VERSION]
}] }, { type: undefined, decorators: [{
type: Inject,
args: [STRIPE_PUBLISHABLE_KEY]
}] }, { type: undefined, decorators: [{
type: Inject,
args: [STRIPE_OPTIONS]
}] }, { type: LazyStripeAPILoader }, { type: WindowRef }] });
class StripeElementsService {
stripeService;
constructor(stripeService) {
this.stripeService = stripeService;
}
elements(stripe, options = {}) {
if (stripe) {
if (Object.keys(options).length > 0) {
return stripe.elements(options);
}
return stripe.elements();
}
else {
if (Object.keys(options).length > 0) {
return this.stripeService.elements(options);
}
return this.stripeService.elements();
}
}
paymentRequest(stripe, options) {
return stripe ? stripe.paymentRequest(options) : this.stripeService.paymentRequest(options);
}
mergeOptions(options, containerClass) {
if (!containerClass || (options && options.classes)) {
return options || {};
}
if (!options || !options.classes) {
return {
...(options || {}),
classes: {
base: containerClass,
complete: `${containerClass}--complete`,
empty: `${containerClass}--empty`,
focus: `${containerClass}--focus`,
invalid: `${containerClass}--invalid`,
webkitAutoFill: `${containerClass}--webkit-autoFill`
}
};
}
return options || {};
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: StripeElementsService, deps: [{ token: StripeService }], target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: StripeElementsService });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: StripeElementsService, decorators: [{
type: Injectable
}], ctorParameters: () => [{ type: StripeService }] });
class StripeElementsDirective {
stripeElementsService;
elementsOptions;
stripe;
elements = new EventEmitter();
_elements;
state = 'notready';
constructor(stripeElementsService) {
this.stripeElementsService = stripeElementsService;
}
async ngOnChanges(changes) {
this.state = 'starting';
const elementsOptions = this.elementsOptions;
const stripe = this.stripe;
if (!stripe) {
this.state = 'notready';
return;
}
if (changes.elementsOptions) {
if (this._elements) {
const payload = Object.keys(elementsOptions).reduce((acc, key) => {
if (elementsOptions[key] !== changes.elementsOptions.previousValue[key] &&
!['fonts', 'loader', 'clientSecret'].includes(key)) {
acc[key] = elementsOptions[key];
}
return acc;
}, {});
this._elements.update(payload);
}
else {
this._elements = await this.stripeElementsService.elements(stripe, elementsOptions).toPromise();
this.elements.emit(this._elements);
this.state = 'ready';
}
}
}
async ngOnInit() {
if (this.state === 'notready') {
this.state = 'starting';
this._elements = await this.stripeElementsService.elements(this.stripe).toPromise();
this.elements.emit(this._elements);
this.state = 'ready';
}
}
fetchUpdates() {
if (!this._elements)
return null;
return from(this._elements.fetchUpdates());
}
update(options) {
if (!this._elements)
return null;
return this._elements.update(options);
}
submit() {
if (!this._elements)
return null;
return from(this._elements.submit());
}
getElement(elementType) {
if (!this._elements)
return null;
switch (elementType) {
case 'address':
return this._elements.getElement('address');
case 'paymentMethodMessaging':
return this._elements.getElement('paymentMethodMessaging');
case 'affirmMessage':
return this._elements.getElement('affirmMessage');
case 'afterpayClearpayMessage':
return this._elements.getElement('afterpayClearpayMessage');
case 'auBankAccount':
return this._elements.getElement('auBankAccount');
case 'card':
return this._elements.getElement('card');
case 'cardNumber':
return this._elements.getElement('cardNumber');
case 'cardExpiry':
return this._elements.getElement('cardExpiry');
case 'cardCvc':
return this._elements.getElement('cardCvc');
case 'fpxBank':
return this._elements.getElement('fpxBank');
case 'epsBank':
return this._elements.getElement('epsBank');
case 'p24Bank':
return this._elements.getElement('p24Bank');
case 'iban':
return this._elements.getElement('iban');
case 'idealBank':
return this._elements.getElement('idealBank');
case 'linkAuthentication':
return this._elements.getElement('linkAuthentication');
case 'expressCheckout':
return this._elements.getElement('expressCheckout');
case 'payment':
return this._elements.getElement('payment');
case 'paymentRequestButton':
return this._elements.getElement('paymentRequestButton');
case 'shippingAddress':
return this._elements.getElement('shippingAddress');
default:
return this._elements.getElement(elementType);
}
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: StripeElementsDirective, deps: [{ token: StripeElementsService }], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.1", type: StripeElementsDirective, isStandalone: true, selector: "ngx-stripe-elements,[ngxStripeElements]", inputs: { elementsOptions: "elementsOptions", stripe: "stripe" }, outputs: { elements: "elements" }, usesOnChanges: true, ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: StripeElementsDirective, decorators: [{
type: Directive,
args: [{
selector: 'ngx-stripe-elements,[ngxStripeElements]',
standalone: true
}]
}], ctorParameters: () => [{ type: StripeElementsService }], propDecorators: { elementsOptions: [{
type: Input
}], stripe: [{
type: Input
}], elements: [{
type: Output
}] } });
class StripeAddressComponent {
stripeElementsService;
elementsProvider;
loadingTemplate;
stripeElementRef;
element;
containerClass;
options;
elementsOptions;
stripe;
load = new EventEmitter();
blur = new EventEmitter();
change = new EventEmitter();
focus = new EventEmitter();
ready = new EventEmitter();
escape = new EventEmitter();
loaderror = new EventEmitter();
loaderstart = new EventEmitter();
elements;
state = 'notready';
elementsSubscription;
constructor(stripeElementsService, elementsProvider) {
this.stripeElementsService = stripeElementsService;
this.elementsProvider = elementsProvider;
}
async ngOnChanges(changes) {
this.state = 'starting';
let updateElements = false;
if (!this.elementsProvider && (changes.elementsOptions || changes.stripe || !this.elements)) {
this.elements = await this.stripeElementsService.elements(this.stripe, this.elementsOptions).toPromise();
updateElements = true;
}
const options = this.stripeElementsService.mergeOptions(this.options, this.containerClass);
if (changes.options || changes.containerClass || !this.element || updateElements) {
if (this.element && !updateElements) {
this.update(options);
}
else if (this.elements && updateElements) {
this.createElement(options);
}
}
this.state = 'ready';
}
async ngOnInit() {
const options = this.stripeElementsService.mergeOptions(this.options, this.containerClass);
if (this.elementsProvider) {
this.elementsSubscription = this.elementsProvider.elements.subscribe((elements) => {
this.elements = elements;
this.createElement(options);
this.state = 'ready';
});
}
else if (this.state === 'notready') {
this.state = 'starting';
this.elements = await this.stripeElementsService.elements(this.stripe).toPromise();
this.createElement(options);
this.state = 'ready';
}
}
ngOnDestroy() {
if (this.element) {
this.element.destroy();
}
if (this.elementsSubscription) {
this.elementsSubscription.unsubscribe();
}
}
update(options) {
return this.element.update(options);
}
getValue() {
const address = this.elements.getElement('address');
return address.getValue();
}
/**
* @deprecated
*/
getAddressElement() {
return this.element;
}
createElement(options) {
if (this.element) {
this.element.unmount();
}
this.element = this.elements.create('address', options);
this.element.on('change', (ev) => this.change.emit(ev));
this.element.on('blur', () => this.blur.emit());
this.element.on('focus', () => this.focus.emit());
this.element.on('ready', () => this.ready.emit());
this.element.on('escape', () => this.escape.emit());
this.element.on('loaderror', () => this.loaderror.emit());
this.element.on('loaderstart', () => this.loaderstart.emit());
this.element.mount(this.stripeElementRef.nativeElement);
this.load.emit(this.element);
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: StripeAddressComponent, deps: [{ token: StripeElementsService }, { token: StripeElementsDirective, optional: true }], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.1", type: StripeAddressComponent, isStandalone: true, selector: "ngx-stripe-address", inputs: { containerClass: "containerClass", options: "options", elementsOptions: "elementsOptions", stripe: "stripe" }, outputs: { load: "load", blur: "blur", change: "change", focus: "focus", ready: "ready", escape: "escape", loaderror: "loaderror", loaderstart: "loaderstart" }, queries: [{ propertyName: "loadingTemplate", first: true, predicate: NgxStripeElementLoadingTemplateDirective, descendants: true, read: TemplateRef }], viewQueries: [{ propertyName: "stripeElementRef", first: true, predicate: ["stripeElementRef"], descendants: true }], usesOnChanges: true, ngImport: i0, template: `
<div class="field" #stripeElementRef>
@if (state !== 'ready' && loadingTemplate) {
<ng-container [ngTemplateOutlet]="loadingTemplate" />
}
</div>
`, isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i3.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: StripeAddressComponent, decorators: [{
type: Component,
args: [{
selector: 'ngx-stripe-address',
standalone: true,
template: `
<div class="field" #stripeElementRef>
@if (state !== 'ready' && loadingTemplate) {
<ng-container [ngTemplateOutlet]="loadingTemplate" />
}
</div>
`,
imports: [CommonModule]
}]
}], ctorParameters: () => [{ type: StripeElementsService }, { type: StripeElementsDirective, decorators: [{
type: Optional
}] }], propDecorators: { loadingTemplate: [{
type: ContentChild,
args: [NgxStripeElementLoadingTemplateDirective, { read: TemplateRef }]
}], stripeElementRef: [{
type: ViewChild,
args: ['stripeElementRef']
}], containerClass: [{
type: Input
}], options: [{
type: Input
}], elementsOptions: [{
type: Input
}], stripe: [{
type: Input
}], load: [{
type: Output
}], blur: [{
type: Output
}], change: [{
type: Output
}], focus: [{
type: Output
}], ready: [{
type: Output
}], escape: [{
type: Output
}], loaderror: [{
type: Output
}], loaderstart: [{
type: Output
}] } });
class StripeAffirmMessageComponent {
stripeElementsService;
elementsProvider;
loadingTemplate;
stripeElementRef;
element;
containerClass;
options;
elementsOptions;
stripe;
load = new EventEmitter();
ready = new EventEmitter();
elements;
state = 'notready';
elementsSubscription;
constructor(stripeElementsService, elementsProvider) {
this.stripeElementsService = stripeElementsService;
this.elementsProvider = elementsProvider;
}
async ngOnChanges(changes) {
this.state = 'starting';
let updateElements = false;
if (!this.elementsProvider && (changes.elementsOptions || changes.stripe || !this.elements)) {
this.elements = await this.stripeElementsService.elements(this.stripe, this.elementsOptions).toPromise();
updateElements = true;
}
const options = this.stripeElementsService.mergeOptions(this.options, this.containerClass);
if (changes.options || changes.containerClass || !this.element || updateElements) {
if (this.element && !updateElements) {
this.update(options);
}
else if (this.elements && updateElements) {
this.createElement(options);
}
}
this.state = 'ready';
}
async ngOnInit() {
const options = this.stripeElementsService.mergeOptions(this.options, this.containerClass);
if (this.elementsProvider) {
this.elementsSubscription = this.elementsProvider.elements.subscribe((elements) => {
this.elements = elements;
this.createElement(options);
this.state = 'ready';
});
}
else if (this.state === 'notready') {
this.state = 'starting';
this.elements = await this.stripeElementsService.elements(this.stripe).toPromise();
this.createElement(options);
this.state = 'ready';
}
}
ngOnDestroy() {
if (this.element) {
this.element.destroy();
}
if (this.elementsSubscription) {
this.elementsSubscription.unsubscribe();
}
}
update(options) {
this.element.update(options);
}
/**
* @deprecated
*/
getAffirmMessage() {
return this.element;
}
createElement(options) {
if (this.element) {
this.element.unmount();
}
this.element = this.elements.create('affirmMessage', options);
this.element.on('ready', () => this.ready.emit());
this.element.mount(this.stripeElementRef.nativeElement);
this.load.emit(this.element);
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: StripeAffirmMessageComponent, deps: [{ token: StripeElementsService }, { token: StripeElementsDirective, optional: true }], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.1", type: StripeAffirmMessageComponent, isStandalone: true, selector: "ngx-stripe-affirm-message", inputs: { containerClass: "containerClass", options: "options", elementsOptions: "elementsOptions", stripe: "stripe" }, outputs: { load: "load", ready: "ready" }, queries: [{ propertyName: "loadingTemplate", first: true, predicate: NgxStripeElementLoadingTemplateDirective, descendants: true, read: TemplateRef }], viewQueries: [{ propertyName: "stripeElementRef", first: true, predicate: ["stripeElementRef"], descendants: true }], usesOnChanges: true, ngImport: i0, template: `
<div class="field" #stripeElementRef>
@if (state !== 'ready' && loadingTemplate) {
<ng-container [ngTemplateOutlet]="loadingTemplate" />
}
</div>
`, isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i3.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: StripeAffirmMessageComponent, decorators: [{
type: Component,
args: [{
selector: 'ngx-stripe-affirm-message',
standalone: true,
template: `
<div class="field" #stripeElementRef>
@if (state !== 'ready' && loadingTemplate) {
<ng-container [ngTemplateOutlet]="loadingTemplate" />
}
</div>
`,
imports: [CommonModule]
}]
}], ctorParameters: () => [{ type: StripeElementsService }, { type: StripeElementsDirective, decorators: [{
type: Optional
}] }], propDecorators: { loadingTemplate: [{
type: ContentChild,
args: [NgxStripeElementLoadingTemplateDirective, { read: TemplateRef }]
}], stripeElementRef: [{
type: ViewChild,
args: ['stripeElementRef']
}], containerClass: [{
type: Input
}], options: [{
type: Input
}], elementsOptions: [{
type: Input
}], stripe: [{
type: Input
}], load: [{
type: Output
}], ready: [{
type: Output
}] } });
class StripeAfterpayClearpayMe