Gathering detailed insights and metrics for @nomadreservations/ngx-stripe
Gathering detailed insights and metrics for @nomadreservations/ngx-stripe
Gathering detailed insights and metrics for @nomadreservations/ngx-stripe
Gathering detailed insights and metrics for @nomadreservations/ngx-stripe
npm install @nomadreservations/ngx-stripe
Typescript
Module System
Node Version
NPM Version
74.2
Supply Chain
91.3
Quality
81.3
Maintenance
50
Vulnerability
98.6
License
TypeScript (86.78%)
HTML (5.4%)
JavaScript (4.57%)
CSS (2.25%)
Shell (0.99%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
41 Stars
76 Commits
30 Forks
2 Watchers
26 Branches
7 Contributors
Updated on Oct 23, 2023
Latest Version
1.2.3
Package Id
@nomadreservations/ngx-stripe@1.2.3
Unpacked Size
1.09 MB
Size
251.25 kB
File Count
129
NPM Version
6.4.1
Node Version
10.16.3
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
1
2
43
Table of Contents
@angular wrapper for StripeJS based on module by Ricardo Sánchez Gregorio at https://github.com/richnologies/ngx-stripe
Note: This version is designed to work with angular v8+ only
To install this library, run:
1$ npm install @nomadreservations/ngx-stripe --save 2or 3$ yarn add @nomadreservations/ngx-stripe
Import the NgxStripeModule
into the 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 your library 7import { NgxStripeModule } from '@nomadreservations/ngx-stripe'; 8 9@NgModule({ 10 declarations: [ 11 AppComponent 12 ], 13 imports: [ 14 BrowserModule, 15 NgxStripeModule.forRoot('***your-stripe-publishable key***'), 16 LibraryModule 17 ], 18 providers: [], 19 bootstrap: [AppComponent] 20}) 21export class AppModule { }
Note: If you leave the publishable key blank you must set on using StripeSerive.changeKey prior to creating token's or sources
As an alternative to the previous example, you could use the StripeCardComponent.
It will make a little bit easier to mount the card.
To fetch the Stripe Element, you could you use either the (change) output, or, by using a ViewChild, the public method getCard()
//stripe.compnent.html
1<ngx-stripe-card [options]="cardOptions" [elementsOptions]="elementsOptions" (change)="cardUpdated($event)" (error)="error = $event"></ngx-stripe-card> 2<div class="error"> 3 {{error?.message}} 4</div> 5<button (click)="getCardToken()" [disabled]="!complete">Get Card Token</button>
//stripe.component.ts
1import { Component, OnInit, ViewChild, ElementRef } from '@angular/core'; 2import { FormGroup, FormBuilder, Validators } from "@angular/forms"; 3 4import { StripeService, StripeCardComponent, ElementOptions, ElementsOptions } from "@nomadreservations/ngx-stripe"; 5 6 7@Component({ 8 selector: 'app-stripe-test', 9 templateUrl: 'stripe.component.html' 10}) 11export class StripeTestComponent implements OnInit { 12 stripeKey = ''; 13 error: any; 14 complete = false; 15 element: StripeElement; 16 cardOptions: ElementOptions = { 17 style: { 18 base: { 19 iconColor: '#276fd3', 20 color: '#31325F', 21 lineHeight: '40px', 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: ElementsOptions = { 33 locale: 'en' 34 }; 35 36 constructor( 37 private _stripe: StripeService 38 ) {} 39 40 cardUpdated(result) { 41 this.element = result.element; 42 this.complete = result.card.complete; 43 this.error = undefined; 44 } 45 46 keyUpdated() { 47 this._stripe.changeKey(this.stripeKey); 48 } 49 50 getCardToken() { 51 this._stripe.createToken(this.element, { 52 name: 'tested_ca', 53 address_line1: '123 A Place', 54 address_line2: 'Suite 100', 55 address_city: 'Irving', 56 address_state: 'BC', 57 address_zip: 'VOE 1H0', 58 address_country: 'CA' 59 }).subscribe(result => { 60 // Pass token to service for purchase. 61 console.log(result); 62 }); 63 } 64}
A payment request button (e.g. apple pay, google chrome payment, etc.) can be enabled with the ngx-payment-request
component. All of the options Request Payment Api options are exposed via the three options sections in the component.
// request-button.component.html
1<div class="container"> 2 <mat-card> 3 Pay: <mat-slider min="1" max="100" step="10" thumbLabel [value]="pay" (valueChange)="updatePay($event)"></mat-slider> 4 <ngx-payment-request 5 [options]="requestOptions" 6 [elementsOptions]="elementsOptions" 7 [styles]="styles" 8 (shippingAddressChange)="updateShippingAddress($event)" 9 (shippingOptionChange)="updateShippingOption($event)" 10 (change)="requestUpdated($event)"> 11 </ngx-payment-request> 12 13 </mat-card>
// request-button.compnent.ts
1@Component({ 2 selector: 'app-test', 3 templateUrl: 'request-button.component.html' 4}) 5export class RequestButtonComponent implements OnInit { 6 @Input set stripeKey(key) { 7 this._stripe.changeKey(key); 8 } 9 10 public requestOptions: RequestElementOptions = { 11 country: 'US', 12 currency: 'usd', 13 requestPayerName: true, 14 requestPayerEmail: true, 15 requestPayerPhone: true, 16 requestShipping: true, 17 total: { 18 amount: 10000, 19 label: 'Donate to the things' 20 } 21 }; 22 23 public styles: PaymentRequestButtonStyle = { 24 type: 'donate', 25 theme: 'light', 26 height: '64px' 27 }; 28 29 public elementsOptions: ElementsOptions = { 30 locale: 'en' 31 }; 32 33 public pay = 100; 34 35 constructor(private _stripe: StripeService) { } 36 37 public updatePay(amount: number) { 38 this.pay = amount; 39 this.requestOptions = { 40 ...this.requestOptions, 41 total: { 42 ...this.requestOptions.total, 43 amount: amount * 100 44 } 45 }; 46 } 47 48 public async requestUpdated(result) { 49 const response = await fetch('/charges', { 50 method: 'POST', 51 body: JSON.stringify({token: result.token.id}), 52 headers: {'content-type': 'application/json'}, 53 }); 54 55 if (response.ok) { 56 result.complete('success'); 57 } else { 58 result.complete('fail'); 59 } 60 } 61 62 public updateShippingAddress(result) { 63 result.updateWith({ 64 status: 'success', 65 shippingOptions: [ 66 { 67 id: 'free-shipping', 68 label: 'Free shipping', 69 detail: 'Arrives in 5 to 7 days', 70 amount: 0 71 }, 72 { 73 id: 'express', 74 label: 'Express shipping', 75 detail: 'Arrives in 1 to 2 days', 76 amount: 1000 77 } 78 ] 79 }); 80 } 81 82 public updateShippingOption(result) { 83 result.updateWith({ 84 status: 'success' 85 }); 86 } 87} 88
Given the way an AOT angular build processes provided values if you need to provide a stripe key at runtime you'll want to forgo the forRoot initialization and instead add a factory and provider
1
2 export function NgxStripeFactory(): string {
3 return dynamicLocation.stripePkKey;
4 }
5
6 @NgModule({
7 ...
8 imports: []
9 ...
10 NgxStripeModule.forRoot('whatever key you think should be default'),
11 ...
12 ]
13 providers: [
14 {
15 provide: STRIPE_PUBLISHABLE_KEY,
16 useFactory: NgxStripeFactory
17 }
18 ]
19 })
You can use the payment intents api with this service just like with stripe.js the following are exposed via the StripeService
1 handleCardSetup(clientSecret: string, el: Element, cardSetupOptions?: SetupIntentData): Promise<SetupIntentResult>;
2 handleCardAction(clientSecret: string);
3 handleCardPayment(clientSecret: string, el: Element, data: CardPaymentData);
4 confirmPaymentIntent(clientSecret: string, el: Element, data: ConfirmIntentData);
5 retrievePaymentIntent(clientSecret: string);
6 confirmSetupIntent(clientSecret: string, el: Element, data: ConfirmSetupIntentData);
7 retrieveSetupIntent(clientSecret: string);
3D Secure payments are enabled by following a 3D Secure Flow using the payment intents api's. You will need to setup a proper next action in the payment intent based off of the 3D Secure response from the customers bank/institution.
Example: //stripe.compnent.html
1<ngx-stripe-card [options]="cardOptions" [elementsOptions]="elementsOptions" (change)="cardUpdated($event)" (error)="error = $event"></ngx-stripe-card> 2<div class="error"> 3 {{error?.message}} 4</div> 5<button (click)="payNow()" [disabled]="!complete">Pay</button>
//stripe.component.ts
1import { Component, OnInit, ViewChild, ElementRef } from '@angular/core'; 2import { FormGroup, FormBuilder, Validators } from "@angular/forms"; 3 4import { StripeService, StripeCardComponent, ElementOptions, ElementsOptions } from "@nomadreservations/ngx-stripe"; 5 6 7@Component({ 8 selector: 'app-stripe-test', 9 templateUrl: 'stripe.component.html' 10}) 11export class StripeTestComponent implements OnInit { 12 stripeKey = ''; 13 error: any; 14 complete = false; 15 element: StripeElement; 16 cardOptions: ElementOptions = { 17 style: { 18 base: { 19 iconColor: '#276fd3', 20 color: '#31325F', 21 lineHeight: '40px', 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: ElementsOptions = { 33 locale: 'en' 34 }; 35 36 constructor( 37 private _stripe: StripeService 38 ) {} 39 40 cardUpdated(result) { 41 this.element = result.element; 42 this.complete = result.card.complete; 43 if(this.complete) { 44 this._stripe. 45 } 46 this.error = undefined; 47 } 48 49 keyUpdated() { 50 this._stripe.changeKey(this.stripeKey); 51 } 52 53 async payNow() { 54 const response = await fetch('/paymentIntent', { 55 method: 'POST', 56 body: JSON.stringify({amount: 10000, currency: 'usd'}), 57 headers: {'content-type': 'application/json'}, 58 }); 59 60 const body = await response.json(); 61 this._stripe.handleCardPayment(body.client_secret, this.element, { payment_method_data: { 62 billing_details: {name: 'Bob Smith'} 63 }}).subscribe(result => { 64 if(result.error) { 65 console.error('got stripe error', result.error); 66 } else { 67 console.log('payment succeeded'); 68 } 69 }); 70 } 71}
Please note you can also manually handle this flow using the paymentIntent methods however that is not the default path and you will have to implement it yourself (see more here)
The following command runs unit & integration tests that are in the tests
folder, and unit tests that are in src
folder:
1yarn test
The following command:
1yarn build
dist
folder with all the files of distributionTo test the npm package locally, use the following command:
1yarn publish:dev
You can then run the following to install it in an app to test it:
1yalc link @nomadreservations/ngx-stripe
1yarn release:patch 2or 3yarn release:minor 4or 5yarn release:major
To generate the documentation, this starter uses compodoc:
1yarn compodoc 2yarn compodoc:serve
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 2/22 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
162 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More