Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
componentDidMount() {
const { cardNumber } = this.state;
const cardType = payment.fns.cardType(cardNumber);
this.setState({
cardImage: CARD_IMAGES[cardType] || placeholder
});
}
isCardNumberValid() {
return payment.fns.validateCardNumber(this.state.cardNumber)
}
isExpiryValid() {
isValid: (otherValues, card) => {
return Payment.fns.validateCardNumber(card)
}
}}
Component
} = React;
import Payment from 'payment';
import FlipCard from 'react-native-flip-card';
import {
View,
TouchableOpacity,
Text,
StyleSheet,
Platform,
Image
} from 'react-native';
const images = require('./card-images');
const validate = Payment.fns;
class CreditCard extends Component {
constructor(props) {
super(props);
this.state = {
type: {
name:"unknown",
length: 16
}
}
}
getValue(name) {
return this[name]();
}
componentWillReceiveProps(nextProps) {
this.updateType(nextProps);
{};
const cardTypeLengths = cardTypeInfo.lengths || [16];
this.setState({
cardImage: CARD_IMAGES[cardType] || placeholder,
cardNumber
});
payment.formatCardNumber(document.getElementById('card-number'));
this.setFieldValid();
if (cardTypeLengths) {
const lastCardTypeLength = cardTypeLengths[cardTypeLengths.length - 1];
for (let length of cardTypeLengths) {
if (
length === cardNumberLength &&
payment.fns.validateCardNumber(cardNumber)
) {
document.getElementById('card-expiry').focus();
break;
}
if (cardNumberLength === lastCardTypeLength) {
this.setFieldInvalid('Card number is invalid');
}
}
}
const { cardNumberInputProps } = this.props;
if (cardNumberInputProps.onChange) {
cardNumberInputProps.onChange(e);
}
}
this.setState({ cardNumber: this.cardNumberField.value }, () => {
const cardType = payment.fns.cardType(this.state.cardNumber);
const images = this.images;
this.setState({
cardImage: images[cardType] || images.placeholder
});
});
};