npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-credit-card-v2

v1.1.3

Published

React native credit card input component

Downloads

90

Readme

React Native Credit Card 💳

A better credit card form for React Native

React native port of the display of Card by @jessepollak

rn-credit-card rn-ios

Demo

https://exp.host/@sonnylazuardi/react-native-credit-card-demos

Background

This is a react native port of Card. There is a react port of Card, but it still renders on browser DOM (which is not as good as native view), so this library will take advantage of both.

Goals

  • Look like Card.
  • Provide a react interface for displaying credit card information.

Design Resources

I got the design resources from the Ramakrishna V's dribbble

design

Usage

  • npm install --save react-native-credit-card-v2
  • In your react native script add these lines
import CheckerCC from 'card-validator';
import React, {useMemo} from 'react';
import CreditCard from 'react-native-credit-card-v2';

export const Assets = {
  card: {
    amex: require('../assets/cards/amex.png'),
    diners: require('../assets/cards/diners.png'),
    discover: require('../assets/cards/discover.png'),
    jcb: require('../assets/cards/jcb.png'),
    maestro: require('../assets/cards/maestro.png'),
    mastercard: require('../assets/cards/mastercard.png'),
    visa: require('../assets/cards/visa.png'),
    unionpay: require('../assets/cards/unionpay.png'),
  },
};

type CardType = keyof typeof Assets['card'];

type CardDetailType = {
  cvv?: number | string;
  cardNumber?: number | string;
  expiryMonth?: number | string;
  expiryYear?: number | string;
  expiry?: string;
  holderName?: string;
};

type ExampleProps = {
  cardDetail?: CardDetailType;
};

const Example = (props: ExampleProps) => {
  const {cardDetail} = props;

  const cardType: CardType = useMemo(() => {
    if (cardDetail?.cardNumber) {
      const numberValidation = CheckerCC.number(cardDetail?.cardNumber);
      return numberValidation.card?.type;
    }

    return '' as any;
  }, [cardDetail]);

  return (
   
      <CreditCard
        imageFront={Assets.images.card1}
        imageBack={Assets.images.card1}
        shiny={false}
        bar={false}
        width={width(90)}
        height={height(32)}
        bgColor={DEFAULT_IMAGE_BG_COLOR}
        mainContainerStyle={{
          borderRadius: 10,
        }}
        frontImageStyle={{
          borderRadius: 10,
        }}
        frontImageBgStyle={{
          borderRadius: 10,
        }}
        backImageStyle={{
          borderRadius: 10,
        }}
        backImageBgStyle={{
          borderRadius: 10,
        }}
        name={cardDetail?.holderName}
        number={cardDetail?.cardNumber}
        type={cardType}
        expiry={cardDetail?.expiry}
        showExpiryAfterLabel={false}
        cardTypeImages={Assets.card}
      />
    
  );
};

export default Example;

import CreditCard from 'react-native-credit-card-v2';


<CreditCard
    type={this.state.type}
    imageFront={require('./images/card-front.png')}
    imageBack={require('./images/card-back.png')}
    shiny={false}
    bar={false}
    focused={this.state.focused}
    number={this.state.number}
    name={this.state.name}
    expiry={this.state.expiry}
    cvc={this.state.cvc}/>

Available props

  • cvc: number(max 4 characters, will cut the rest)(The "/" will be automatically added)
  • name: string (max 2 lines)
  • number: credit card number(max 16 characters, will cut the rest)
  • expiry: number(max 4 characters, will cut the rest)
  • imageFront: image(image file for the card front card background -- with require)
  • imageBack: image(image file for the card back card background -- with require)
  • shiny: boolean(show sticker)
  • bar: boolean(show bar on the back)
  • focused: one of the above fields
    • type
    • name
    • number
    • expiry
    • cvc (Upon focusing cvc, the form will be rotated until this is changed.)
    • null
  • type: Available in case you need to explicitly specify the card type. In most cases this will be inferred for you as the user fills the form, so you won't need to use it. One of the following:
    • dankort
    • discover
    • mastercard
    • visa
    • amex -fullNameText: Change the default text for FULL NAME -showExpiryBeforeLabel: boolean(show the MONTH/YEAR text) -showExpiryAfterLabel: boolean(show the VALID THRU text) -expiryBeforeText: Change the default text for MONTH/YEAR -expiryAfterText: Change the default text for VALID THRU -cardTypeImages: Change card type images -mainContainerStyle: Main Container Style -frontImageStyle: Front Image Style -frontImageBgStyle: Front Image Bg Style (Used ImageBackground) -backImageStyle: Front Image Style -backImageBgStyle: Front Image Bg Style (Used ImageBackground)

Todo

  • Automated test
  • More credit card type variations

Examples

todo.

Most of the credit goes to @jessepollak and @JohnyDays for creating and mantaining Card and React Credit Card, I just ported it over to React Native.