vuetify-credit-card
Advanced tools
Comparing version 1.0.0-beta.1 to 1.0.0-beta.2
{ | ||
"name": "vuetify-credit-card", | ||
"version": "1.0.0-beta.1", | ||
"version": "1.0.0-beta.2", | ||
"description": "Vue.js wrapper for credit card https://github.com/jessepollak/card with vuetify example and pugjs and stylus.", | ||
@@ -5,0 +5,0 @@ "author": "Ilio Adriano de Oliveira Junior <ilioadriano@live.com>", |
import Payment from 'payment/lib' | ||
import DefaultOptionsHelper from './DefaultOptionsHelper' | ||
const options = { | ||
formatting: false, | ||
monthYear: 'month/year', | ||
validDate: 'valid\nthru', | ||
cardTypes: [ | ||
'amex', | ||
'dankort', | ||
'dinersclub', | ||
'discover', | ||
'jcb', | ||
'laser', | ||
'maestro', | ||
'mastercard', | ||
'unionpay', | ||
'visa', | ||
'visaelectron', | ||
'elo' | ||
], | ||
inputTypes: [ | ||
'number', | ||
'name', | ||
'expiry', | ||
'cvc' | ||
], | ||
placeholders: { | ||
number: '•••• •••• •••• ••••', | ||
cvc: '•••', | ||
expiry: '••/••', | ||
name: 'Full Name' | ||
} | ||
} | ||
class CardService { | ||
constructor () { | ||
this.options = DefaultOptionsHelper.options | ||
this.emptyCreditCardData = DefaultOptionsHelper.emptyCreditCardData | ||
const defaultClassDisplay = { | ||
'jp-card-focused': false, | ||
'jp-card-valid': false, | ||
'jp-card-invalid': false | ||
} | ||
this.rules = { | ||
number: val => Payment.fns.validateCardNumber(val), | ||
name: val => !!val, | ||
cvc: (val, cardType) => Payment.fns.validateCardCVC(val, cardType), | ||
expiry: val => { | ||
const valueObject = Payment | ||
.fns | ||
.cardExpiryVal(val) | ||
const clone = (value) => { | ||
return {...value} | ||
} | ||
return Payment.fns.validateCardExpiry(valueObject.month, valueObject.year) | ||
}, | ||
validate: (type, value, cardType) => { | ||
const rule = this.rules[type] | ||
return rule(value, cardType) | ||
} | ||
} | ||
const classDisplay = { | ||
number: clone(defaultClassDisplay), | ||
name: clone(defaultClassDisplay), | ||
expiry: clone(defaultClassDisplay), | ||
cvc: clone(defaultClassDisplay), | ||
this.classDisplay = { | ||
number: this.clone(DefaultOptionsHelper.classDisplay), | ||
name: this.clone(DefaultOptionsHelper.classDisplay), | ||
expiry: this.clone(DefaultOptionsHelper.classDisplay), | ||
cvc: this.clone(DefaultOptionsHelper.classDisplay), | ||
setClass: (type, className, value) => { | ||
const classDisplayType = classDisplay[type] | ||
classDisplayType[className] = value | ||
setClass: (type, className, value) => { | ||
const classDisplayType = this.classDisplay[type] | ||
classDisplayType[className] = value | ||
} | ||
} | ||
} | ||
} | ||
options | ||
.inputTypes | ||
.forEach(type => { | ||
classDisplay[type] = { | ||
'jp-card-focused': false, | ||
'jp-card-valid': false, | ||
'jp-card-invalid': false | ||
} | ||
}) | ||
const rules = { | ||
number: val => Payment.fns.validateCardNumber(val), | ||
name: val => !!val, | ||
cvc: (val, cardType) => Payment.fns.validateCardCVC(val, cardType), | ||
expiry: val => { | ||
const valueObject = Payment | ||
.fns | ||
.cardExpiryVal(val) | ||
return Payment.fns.validateCardExpiry(valueObject.month, valueObject.year) | ||
}, | ||
validate: (type, value, cardType) => { | ||
const rule = rules[type] | ||
return rule(value, cardType) | ||
clone (objectSource) { | ||
return Object.assign({}, objectSource) | ||
} | ||
} | ||
export default { | ||
options, | ||
rules, | ||
classDisplay | ||
} | ||
export default new CardService() |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
862995
54
806
1