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-billing-card

v1.0.0

Published

Input, display and manage Credit card information

Downloads

31

Readme

React Billing Card

React Billing Card is a lighweight and cusomizable React Component for handling credit card input and billing information in your web applications. This component simplifies the process of collecting and validating payment-related data from users, making it easier to integrate [ayment processing into your react application.

Installation

npm

npm install react-billing-card

yarn

yarn add react-billing-card

Usage

import React, { useState } from "react";
import CreditCard from "react-billing-card";

function MyBillingForm() {
  const [creditCard, setCreditCard] = useState({
    name: "John Doe",
    number: "4111 1111 1111 1111",
    expiry: "12/25",
    cvc: "123",
    focus: "",
  });

  function handleInputChange(k, v) {
    setCreditCard({
      ...creditCard,
      [k]: v,
    });
  }

  const style = {
    front: {},
    back: {},
    common: {
      backgroundColor: "rgba(80, 80, 0, .99)",
      backgroundImage:
        "linear-gradient(30deg, rgba(161, 98, 7, .99), rgba(161, 98, 7, .55), rgba(161, 98, 7, .99))",
    },
    text_styles: {
      color: "rgba(19, 6, 6, 0.685)",
      textShadow:
        "-0.04em -0.04em 0.04em rgba(192, 192, 192, .8), 0.04em 0.04em 0.04em rgba(0, 0, 0, 0.8)",
      fontWeight: "bold",
    },
  };

  return (
    <div>
      <CreditCard
        className="shadow-lg shadow-black text-gray-600 caret-slate-300 bg-gradient-to-tr from-lime-700 via-yellow-500 to-yellow-700"
        display="both"
        config={config}
        style={style}
        value={creditCard}
        onChange={handleInputChange}
      />
    </div>
  );
}

Props

CreditCard accepts the following props:

  • display - (string, optional) A string indicating which phases to display:

    • both Diplay both phases(Front and Back)
    • front-only Display only the front phase
    • back-only Display only the back phase
  • value - (Object, required) a state managed object representing the fields of a credit card:

    name: 'John Doe',
    number: '4111 1111 1111 1111',
    expiry: '12/25',
    cvc: '123',
    focus: ''
- **name** - The name of the CardHolder
- **number** - Sixteen digit code
- **expiry** - The expiry date of the card
- **cvc** - Card verification code
  • onChange - (function, required) - Callback function to be called when an input value changes. The function is called with two arguments: the first is the key or name of the input field, the second is the value of the input field. Use these arguments to set state accordingly.

License

This package is open-source and available under the ISC License. Feel free to use and contribute to this project on GitHub: React Billing Card on GitHub.

Issues and Contributions

If you encounter any issues or have suggestions for improvements, please open an issue on GitHub. Pull requests are also welcome!

Credits

React Billing Card is developed and maintained by Erick Obuya. It relies on various open-source packages, including React and PropTypes.

Thank you for using React Billing Card! We hope it simplifies the integration of billing information into your React applications.