Ngx Stripe
  • Introduction
  • Getting Started
    • Installation
    • Setup Application
  • Core Concepts
    • Checkout
    • Payment Element
    • Element Components
    • Identity
    • Payment Request Button
    • Service
    • Styling
    • Service Factory
    • Reference & Instance
    • Manually Mount your Element
  • Support
  • FAQS
  • Examples
  • Migration
Powered by GitBook
On this page

Was this helpful?

  1. Core Concepts

Reference & Instance

For situations where the module has any mistakes or missing methods (I'm aware it has) you can now access both your elements instance and a reference to Stripe:

import { Component, OnInit } from '@angular/core';

import { StripeService } from 'ngx-stripe';

@Component({
  selector: 'app-stripe-test',
  templateUrl: 'stripe.html'
})
export class StripeTestComponent implements OnInit {

  constructor(
    private fb: FormBuilder,
    private stripeSerivce: StripeService
  ) {}

  ngOnInit() {
    // this is equivalent to window.Stipe, but it make sure the module is loaded
    const Stripe$: Observable<any> = this.stripeService.getStripeReference();

    // this is a reference to the stripe elements object
    const stripe = this.stripeService.getInstance();
  }
}
PreviousService FactoryNextManually Mount your Element

Last updated 4 years ago

Was this helpful?