stripe angular
npm install stripe-angular --save
stripe angular
npm install stripe-angular --save
stripe angular
import { Component } from "@angular/core"
import { Token, StripeSource } from "stripe-angular"
const template=
`
<div *ngIf="invalidError" style="color:red">
{{ invalidError.message }}
</div>
<stripe-card
#stripeCard
(catch) = "onStripeError($event)"
[(complete)] = "cardDetailsFilledOut"
[(invalid)] = "invalidError"
(cardMounted) = "cardReady = 1"
(tokenChange) = "setStripeToken($event)"
(sourceChange) = "setStripeSource($event)"
></stripe-card>
<button type="button" (click)="stripeCard.createToken(extraData)">createToken</button>
`
@Component({
selector: "app-sub-page",
template: template
}) export class AppComponent{
cardReady = false;
extraData = {
"name": null,
"address_city": null,
"address_line1": null,
"address_line2": null,
"address_state": null,
"address_zip": null
};
onStripeInvalid( error: Error ){
console.log('Validation Error', error)
}
setStripeToken( token: Token ){
console.log('Stripe token', token)
}
setStripeSource( source: StripeSource ){
console.log('Stripe source', source)
}
onStripeError( error: Error ){
console.error('Stripe error', error)
}
}
stripe angular
<stripe-bank #stripeBank
(catch) = "$event"
[(token)] = "token"
[(invalid)] = "invalidError"
></stripe-card>
<button type="button" (click)="stripeBank.createToken({...bank_account...})">createToken</button>
stripe angular
import { NgModule } from "@angular/core";
import { StripeModule } from "stripe-angular"
@NgModule({
imports: [ StripeModule.forRoot("...YOUR-STRIPE-KEY-HERE...") ]
}) export class AppModule {}
stripe angular
<stripe-card #stripeCard
(catch) = "$event"
[(token)] = "token"
[(invalid)] = "invalidError"
(cardMounted) = "cardReady = 1"
></stripe-card>
<button type="button" (click)="stripeCard.createToken(extraData)">createToken</button>
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us