I’m using the plugin NativeScript Stripe(https://github.com/triniwiz/nativescript-stripe) with Angular. When i get the data dynamically from the frontend, the card number and the cvv are fine, but the expiring month and year are failing the card validation process. When I replace the dynamic month and year data with hardcoded values everything works great. Here is my code:
import { Component, OnInit, ViewChild, ElementRef } from
"@angular/core";
import { Router } from '@angular/router';
import {Page} from "ui/page";
import {View} from "ui/core/view";
import { CreditCardView, Card, Stripe } from 'nativescript-stripe';
import { EventData } from 'data/observable';
@Component({
selector: "Payment",
moduleId: module.id,
templateUrl: "./payment.component.html"
})
export class PaymentComponent implements OnInit {
@ViewChild("card") card: ElementRef;
constructor(page: Page) {}
ngOnInit(): void {
// Init your component properties here.
}
submit(args: EventData): void {
let cardView = <CreditCardView>this.card.nativeElement;
let card = <Card>cardView.card.card;
const stripe = new Stripe('...');
stripe.createToken(card,(error,token)=>{
if (!error) {
console.log(token.getId());
console.log(token.getCard());
} else {
console.log(error);
}
});
}
HTML:
<CreditCardView #card></CreditCardView>
<Button text="Button" (tap)="submit($event)"></Button>
When I try to print the card properties, I get the right card number and cvv, but both card.expireMonth and card.expireYear are giving me a 10 digits number, not a 2 digits one. I’m not sure if i did something wrong, or this is a bug. I’ve tested only on Android.
Best regards,
Vlad