UNPKG

@secrethub/ngx-stripe

Version:

The core package for ngx-stripe, for using stripe.js in your application

106 lines (105 loc) 4.76 kB
import { StripeConfigOptions } from 'stripejs'; import { StripeElement, ElementFactory, ElementCreatorOptions } from 'stripejs/element'; import { StripePaymentOptions, StripePaymentRequest } from 'stripejs/payment'; import { BankTokenData, IBANTokenData, PiiTokenData, Token, TokenData } from 'stripejs/token'; import { Source, SourceData } from 'stripejs/source'; import { StripeLoader } from './stripe-loader.service'; export declare class StripeService { private loader; /** * A BehaviorSubject containing the StripeJS object * * Since the script is loaded Async we need an options for all our functions * to wait for stripe to have been loaded */ private stripe$; /** * Lazy load the StripeJS javascript file on first usage of the service * @param loader - The loader that should be used for loading StripeJS */ constructor(loader: StripeLoader); /** * Creates a new stripe instance with the given key * @param key - The public key that should be used to communicate with Stripe * @param options - Any options to configure StripeJS */ changeKey(key: string, options?: StripeConfigOptions): void; /** * Configures the `Elements` object from StripeJS with the given options * @see https://stripe.com/docs/stripe-js/elements/quickstart#create-form * @param [options] - Any configuration options for the Elements object * @param [isIETFLocaleTag] - Whether or not the options `locale` is formatted as a IETFLocaleTag. * If true the locale will be formatted by this function * * @return Observable that resolves in an StripeJS ElementsCreator */ getElementFactory(options?: ElementCreatorOptions, isIETFLocaleTag?: boolean): Promise<ElementFactory>; /** * Create a payment request * NOTE: This is NOT supported for Firefox * @see https://stripe.com/docs/payment-request-api * * @param options - Payment information that should be used by Stripe * * @return the created request */ makePaymentRequest(options: StripePaymentOptions): Promise<StripePaymentRequest>; /** * Creates a token from the given element * * @param element - The element from which the data needs to be extracted * @param [data] - an object containing additional payment information you might have collected * * @return A promise that resolves in a token or a rejection if the creation of the token failed */ createTokenFromElement(element: StripeElement, data?: TokenData | IBANTokenData): Promise<Token>; /** * Creates a token from a bank account * * @param data - The data from the bank account that should be used for the token * * @return A promise that resolves in a token or a rejection if the creation of the token failed */ createTokenFromBankAccount(data: BankTokenData): Promise<Token>; /** * Creates a token from the personal information of a customer * * @param data - The personal information that should be used for the creation of the token * * @return A promise that resolves in a token or a rejection if the creation of the token failed */ createTokenFromPii(data: PiiTokenData): Promise<Token>; /** * Creates a source object from the given element and data * * @param element - The element from which the data needs to be extracted * @param data - An object containing the type of Source you want to create and any additional payment source information * * @return A promise that resolves in a source object or a rejection if the creation of the source failed */ createSourceFromElement(element: StripeElement, data: SourceData): Promise<Source>; /** * Creates a source object from only data * * @param data - The data that should be used for the creation of the source object * * @return A promise that resolves in a source object or a rejection if the creation of the source failed */ createSourceFromData(data: SourceData): Promise<Source>; /** * Fetches an existing source based on the given parameters * * @param id - The unique identifier of the source * @param client_secret - A secret available to the web client that created the Source * * @return A promise that resolves in a source object or a rejection if the creation of the source failed */ getSource(id: string, client_secret: string): Promise<Source>; /** * Fetches the StripeJS instance * NOTE: Use the instance for token generation * * @return The StripeJS instance when it is available (since StripeJS is loaded Async) */ private getStripe; }