richnologies / ngx-stripe

Angular 6+ wrapper for StripeJS
MIT License
217 stars 77 forks source link

Create Card token from StripeCardGroupDirective #251

Closed matheo closed 5 months ago

matheo commented 5 months ago

Is your feature request related to a problem? Please describe. I'm capturing the data of the credit card with the StripeCardGroupDirective, and while trying to createToken I see that the service only receives StripeCardElement | StripeCardNumberElement.

Describe the solution you'd like I would like to know if it's possible to setup a StripeCardElement from StripeCardGroupDirective so we can create the token from separated components and not only from a StripeCardComponent.

Describe alternatives you've considered I might need to migrate to StripeCardComponent because I cannot replicate the security offered by the Stripe Elements.

Also it's difficult to evaluate the status of the Stripe Elements inside my ReactiveForm and the only way possible seems to access the nativeElement CSS class, an Angula's API like valid(), touched(), etc. would be good.

Thanks in advance for the advise!

matheo commented 5 months ago

Ok, I found this talking about this non-intuitive stuff: https://stackoverflow.com/questions/58783206/pass-cvc-to-stripe-createpaymentmethod-js

and I see that createPaymentMethod works with the single CardNumber element, so I think createToken does the same. Nice magic, thanks for the great stuff!