Gathering detailed insights and metrics for @alexandru-paun/ngx-stripe
Gathering detailed insights and metrics for @alexandru-paun/ngx-stripe
Gathering detailed insights and metrics for @alexandru-paun/ngx-stripe
Gathering detailed insights and metrics for @alexandru-paun/ngx-stripe
npm install @alexandru-paun/ngx-stripe
Typescript
Module System
Node Version
NPM Version
TypeScript (77.1%)
HTML (22.23%)
JavaScript (0.54%)
CSS (0.13%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
175 Commits
16 Branches
1 Contributors
Updated on Apr 26, 2023
Latest Version
1.0.0
Package Id
@alexandru-paun/ngx-stripe@1.0.0
Unpacked Size
213.33 kB
Size
50.85 kB
File Count
107
NPM Version
8.19.3
Node Version
16.19.0
Published on
Apr 26, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
21
23
An Angular 6+ wrapper for StripeJS elements
Ngx Stripe is a thin wrapper around Stripe Elements
. It allows adding Elements to any Angular app.
The StripeJS Reference
covers complete Elements customization details.
You can use Elements with any Stripe product to collect online payments. To find the right integration path for your business, explore Stripe Docs
.
ngx-stripe
on the new docs site 🤓After reviewing the state of the art for React and Vue counterparts, some major changes are going to be introduced to align this project with Stripe Elements
.
ngx-stripe
will no longer maintain its own interfaces. Instead, @stripe/stripe-js
has been added as peer dependency. This will make the library easier to maintain and avoid mistakes.Stripe Service
has been updated with all the missing APIs from StripeJSElement Components
like IBAN, Ideal, FPX, ... have been addedRequest Payment Button
now has full supportContainer Style
functionality supportMigration
guide has been added with details of what have changedInstallation
section to see how to install an older version.In order to ease the transition, we are naming the old version of the library legacy
and we have created some npm tags
to make it easy to install older versions.
Active Versions
To install the last active version:
1$ npm install ngx-stripe @stripe/stripe-js
To install an specific version for an older Angular major, use the lts npm tags or check the table below to pick the right version, for example, for v8:
1$ npm install ngx-stripe@v8-lts @stripe/stripe-js
Legacy Versions
To install some of the older versions of the library use the legacy npm tags or check the table below to pick the right version, for example, for v7:
1$ npm install ngx-stripe@v7-legacy
Choose the version corresponding to your Angular version:
Angular | ngx-stripe (legacy) | ngx-stripe |
---|---|---|
11 | Not Available | 11.x+ |
10 | Not Available | 10.x+ |
9 | v9-legacy / 9.0.x+ | v9-lts / 9.1.x+ |
8 | v8-legacy / 7.4.4+ | v8-lts / 8.1.x+ |
7 | v7-legacy / 7.x+ | v7-lts / 7.5.x+ |
6 | v6-legacy / 0.6.x | v6-lts / 6.1.x+ |
5 | 0.5.x or less | Not Available |
4 | 0.4.x or less | Not Available |
Most of the documentation has been moved to a new docs site. Only a very basic example has been left here:
Import the NgxStripeModule
into your application
The module takes the same parameters as the global Stripe object. The APIKey
and the optional options to use Stripe connect
1import { BrowserModule } from '@angular/platform-browser'; 2import { NgModule } from '@angular/core'; 3 4import { AppComponent } from './app.component'; 5 6// Import the library 7import { NgxStripeModule } from 'ngx-stripe'; 8 9@NgModule({ 10 declarations: [AppComponent], 11 imports: [ 12 BrowserModule, 13 ReactiveFormsModule, 14 NgxStripeModule.forRoot('***your-stripe-publishable-key***'), 15 LibraryModule 16 ], 17 providers: [], 18 bootstrap: [AppComponent] 19}) 20export class AppModule {}
Once the module has been imported, you can collect credit card details using the ngx-stripe-card component.
Then you can use the Stripe Service, which is basically an Obseravble wrapper around the stripejs object, to use that information. In this example we use it to create a token, but it can be use to confirm a Payment Intent, Setup Intent, etc...
Please check the docs site to see a complete set of Stripe Element Components available and the full API of the Stripe Service.
// stripe.html
1<form novalidate (ngSubmit)="createToken()" [formGroup]="stripeTest"> 2 <input type="text" formControlName="name" placeholder="Jane Doe"> 3 <ngx-stripe-card 4 [options]="cardOptions" 5 [elementsOptions]="elementsOptions" 6 ></ngx-stripe-card> 7 <button type="submit"> 8 CREATE TOKEN 9 </button> 10</form>
1import { Component, OnInit, ViewChild } from '@angular/core'; 2import { FormGroup, FormBuilder, Validators } from '@angular/forms'; 3 4import { StripeService, StripeCardComponent } from 'ngx-stripe'; 5import { 6 StripeCardElementOptions, 7 StripeElementsOptions 8} from '@stripe/stripe-js'; 9 10@Component({ 11 selector: 'app-create-token', 12 templateUrl: 'stripe.html' 13}) 14export class StripeCreateTokenComponent implements OnInit { 15 @ViewChild(StripeCardComponent) card: StripeCardComponent; 16 17 cardOptions: StripeCardElementOptions = { 18 style: { 19 base: { 20 iconColor: '#666EE8', 21 color: '#31325F', 22 fontWeight: '300', 23 fontFamily: '"Helvetica Neue", Helvetica, sans-serif', 24 fontSize: '18px', 25 '::placeholder': { 26 color: '#CFD7E0' 27 } 28 } 29 } 30 }; 31 32 elementsOptions: StripeElementsOptions = { 33 locale: 'es' 34 }; 35 36 stripeTest: FormGroup; 37 38 constructor(private fb: FormBuilder, private stripeService: StripeService) {} 39 40 ngOnInit(): void { 41 this.stripeTest = this.fb.group({ 42 name: ['', [Validators.required]] 43 }); 44 } 45 46 createToken(): void { 47 const name = this.stripeTest.get('name').value; 48 this.stripeService 49 .createToken(this.card.element, { name }) 50 .subscribe((result) => { 51 if (result.token) { 52 // Use the token 53 console.log(result.token.id); 54 } else if (result.error) { 55 // Error creating the token 56 console.log(result.error.message); 57 } 58 }); 59 } 60}
MIT © Ricardo Sánchez Gregorio
No vulnerabilities found.
No security vulnerabilities found.