Skip to content
This repository has been archived by the owner on Dec 24, 2019. It is now read-only.

Add payment page #3

Open
timarney opened this issue Sep 4, 2019 · 2 comments
Open

Add payment page #3

timarney opened this issue Sep 4, 2019 · 2 comments

Comments

@timarney
Copy link
Member

timarney commented Sep 4, 2019

Collect fake Credit card data (Radio Visa/MC number, exp date, CCV)

@timarney
Copy link
Member Author

timarney commented Sep 4, 2019

Use this for your schema.js file

const isCreditCard = require("validator/lib/isCreditCard").default;

const Schema = {
  card_type: {
    isIn: {
      errorMessage: "errors.card_type.valid",
      options: [["Visa", "MasterCard"]]
    }
  },
  card_number: {
    custom: {
      options: (value, { req }) => {
        return isCreditCard(value);
      },
      errorMessage: "errors.card_number.valid"
    }
  },
  ccv: {
    isLength: {
      errorMessage: "errors.ccv.length",
      options: { min: 3, max: 3 }
    }
  },
  expiry: {
    isLength: {
      errorMessage: "errors.expiry.length",
      options: { min: 5, max: 5 }
    }
  }
};

module.exports = {
  Schema
};

In the view file for the Credit Card radio buttons use the pug mixin

extends /base
include /_includes/radios

//... more code

+radioButtons('card_type', {1:'Visa',2:'MasterCard'}, data.card_type, 'Name of card', errors)

@timarney
Copy link
Member Author

timarney commented Sep 4, 2019

Test card #'s
MasterCard => 5555555555554444
MasterCard =>5105105105105100
Visa => 4111111111111111

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant