Socket
Socket
Sign inDemoInstall

@fireflysemantics/angular-stripe-service

Package Overview
Dependencies
1
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @fireflysemantics/angular-stripe-service

Stripe service used to integrate Stripe Elements with Angular.


Version published
Weekly downloads
463
decreased by-2.94%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Angular Stripe Service

Stripe service used to integrate Stripe Elements with Angular.

Documentation

Integrating Stripe Elements with Angular

Stackblitz

Stackblitz Demo

Usage

  constructor(
    private cd: ChangeDetectorRef,
    private stripeService:AngularStripeService) {}

  ngAfterViewInit() {
    this.stripeService.setPublishableKey('pk_test_2syov9fTMRwOxYG97AAXbOgt008X6NL46o').then(
      stripe=> {
        this.stripe = stripe;
    const elements = stripe.elements();    
    this.card = elements.create('card');
    this.card.mount(this.cardInfo.nativeElement);
    this.card.addEventListener('change', this.cardHandler);
    });
}

Why?

The @fireflysemantics/angular-stripe-service service injects the Stripe scripts for us and waits for it to load before attempting to initialize elements.

The reason this is important is that if our component containing the Stripe form is loaded before Stripe has a chance to initialize elements then the form will not paint correctly.

In other words the Stripe API download and subsequent elements construction is racing the construction of the credit card form component.

If the form component wins that race, the component does not get constructed right, because elements is not yet available.

Firefly Semantics Slice State Manager

Want simple and lightweight reactive state management for Angular supporting all types, business entities, and object in general then Checkout Firefly Semantics Slice.

Keywords

FAQs

Last updated on 07 Nov 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc