GithubHelp home page GithubHelp logo

apooo91 / ccc.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from br0keh/ccc.js

0.0 0.0 0.0 125 KB

:credit_card::fire::heavy_check_mark: Credit Card Check in JS

License: MIT License

JavaScript 99.71% HTML 0.17% CSS 0.12%

ccc.js's Introduction

๐Ÿ’ณ ccc.js โœ”๏ธ


Credit Card Check in JS

only for studies


Usage example

const ccc = require("ccc.js");

ccc.config({
  // payment gateway url
  url: "http://localhost:3333/pay",
  method: "post",
  // replace credit card values to <CARD>, <MONTH>, <YEAR>, <CVV>
  data: `{"card": "<CARD>","month": "<MONTH>","year": "<YEAR>","cvv": "<CVV>"}`,
  headers: { "Content-Type": "application/json" },
  // keywords to search in gateway response
  keywords: {
    declined: "Declined",
    approved: "Approved"
  }
});

const CardNumber = "4444444444444444";
const CardMonth = "01";
const CardYear = "2020";
const CardCVV = "000";

async function example() {
  const Check = await ccc.check(CardNumber, CardMonth, CardYear, CardCVV);

  if (Check.error) {
    return console.log(Check.error);
  }

  if (Check.approved) {
    // approved
  }

  if (Check.declined) {
    // declined
  }
}

example();

Credit Card Check API

ccc.config(Object config)

Example config

{
  // It is like axios config

  // `url` is the server URL that will be used for the request
  url: 'https://some-domain.com/api/',

  // CCC.JS: String to search in response body
  keywords: {
    declined: "Payment declined",
    approved: "Thank you! Payment success."
  }

  // `method` is the request method to be used when making the request
  method: 'post', // default is 'get'

  // `headers` are custom headers to be sent
  headers: {'X-Requested-With': 'XMLHttpRequest'},

  // syntax alternative to send data into the body
  // method post
  // only the value is sent, not the key
  // CCC.JS: replace CREDIT CARD values to <CARD>, <MONTH>, <YEAR>, <CVV>
  data: 'card_credit_number=<CVV>&card_cvv=<CVV>&card_year=<YEAR>',

  // `timeout` specifies the number of milliseconds before the request times out.
  // If the request takes longer than `timeout`, the request will be aborted.
  timeout: 1000, // default is `0` (no timeout)

  // `withCredentials` indicates whether or not cross-site Access-Control requests
  // should be made using credentials
  withCredentials: false, // default
}
ccc.check(cardNumber, cardMonth, cardYear, cardCVV)

Returns

{
  error: String;
}
// or
{
  declined: true;
}
// or
{
  approved: true;
}

Example: https://github.com/br0keh/cc-checker

ccc.js's People

Contributors

br0keh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.