Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove verification field in create card #40

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion components/CreateCardForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ export default class CreateCardFormClass extends Vue {
idempotencyKey: uuidv4(),
expMonth: parseInt(expiry.month),
expYear: 2000 + parseInt(expiry.year),
verification: 'cvv',
keyId: '',
encryptedData: '',
billingDetails,
Expand Down
1 change: 0 additions & 1 deletion lib/cardsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export interface CreateCardPayload {
}
expMonth: number
expYear: number
verification: string
metadata: MetaData
}

Expand Down
41 changes: 10 additions & 31 deletions pages/debug/cards/create.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,7 @@
<v-form>
<v-text-field v-model="formData.cardNumber" label="Card Number" />

<v-select
v-model="formData.verification"
:items="verificationMethods"
label="Verification Method"
/>

<v-text-field
v-if="showCVVField"
v-model="formData.cvv"
label="CVV"
/>
<v-text-field v-model="formData.cvv" label="CVV" />

<v-text-field v-model="formData.expiry.month" label="Expiry Month" />

Expand Down Expand Up @@ -147,11 +137,9 @@ export default class CreateCardClass extends Vue {
line2: '',
city: '',
postalCode: '',
verification: 'cvv',
phoneNumber: '',
email: ''
}
verificationMethods = ['none', 'cvv', 'avs']
rules = {
isNumber: (v: string) =>
v === '' || !isNaN(parseInt(v)) || 'Please enter valid number',
Expand All @@ -176,15 +164,11 @@ export default class CreateCardClass extends Vue {
this.formData = exampleCards[index].formData
}

get showCVVField() {
return this.formData.verification === 'cvv'
}

async makeApiCall() {
this.loading = true

const { email, phoneNumber, cardNumber, cvv, ...data } = this.formData
const { expiry, verification, ...billingDetails } = data
const { expiry, ...billingDetails } = data

let cardDetails: {
number: string
Expand All @@ -193,18 +177,15 @@ export default class CreateCardClass extends Vue {
number: cardNumber.trim().replace(/\D/g, '')
}

if (verification === 'cvv') {
cardDetails = {
...cardDetails,
cvv
}
cardDetails = {
...cardDetails,
cvv
}

const payload: CreateCardPayload = {
idempotencyKey: uuidv4(),
expMonth: parseInt(expiry.month),
expYear: 2000 + parseInt(expiry.year),
verification,
keyId: '',
encryptedData: '',
billingDetails,
Expand All @@ -217,14 +198,12 @@ export default class CreateCardClass extends Vue {
}

try {
if (verification === 'cvv' || verification === 'avs') {
const publicKey = await this.$cardsApi.getPCIPublicKey()
const encryptedData = await openPGP.encrypt(cardDetails, publicKey)
const { encryptedMessage, keyId } = encryptedData
const publicKey = await this.$cardsApi.getPCIPublicKey()
const encryptedData = await openPGP.encrypt(cardDetails, publicKey)
const { encryptedMessage, keyId } = encryptedData

payload.keyId = keyId
payload.encryptedData = encryptedMessage
}
payload.keyId = keyId
payload.encryptedData = encryptedMessage

await this.$cardsApi.createCard(payload)
} catch (error) {
Expand Down
1 change: 0 additions & 1 deletion pages/flow/charge/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,6 @@ export default class ChargeFlowClass extends Vue {
idempotencyKey: uuidv4(),
expMonth: parseInt(this.formData.cardData.expiry.month),
expYear: 2000 + parseInt(this.formData.cardData.expiry.year),
verification: 'none',
keyId: '',
encryptedData: '',
billingDetails: {
Expand Down