From d0d0cb5bcf9346ebde967548ca33018bd73a8298 Mon Sep 17 00:00:00 2001 From: Tarun Kumar Date: Wed, 29 Apr 2020 00:16:29 -0400 Subject: [PATCH 1/2] Removing verification field in create card and make payment --- components/CreateCardForm.vue | 1 - lib/cardTestData.ts | 21 ++++------ lib/cardsApi.ts | 1 - lib/marketplaceApi.ts | 11 +++-- lib/paymentsApi.ts | 11 +++-- pages/debug/cards/create.vue | 45 +++++---------------- pages/debug/marketplace/payments/create.vue | 38 ++++------------- pages/debug/payments/create.vue | 38 ++++------------- pages/flow/charge/existing-card/index.vue | 3 +- pages/flow/charge/index.vue | 2 - 10 files changed, 50 insertions(+), 121 deletions(-) diff --git a/components/CreateCardForm.vue b/components/CreateCardForm.vue index 53dd7944..89b9fcc1 100644 --- a/components/CreateCardForm.vue +++ b/components/CreateCardForm.vue @@ -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, diff --git a/lib/cardTestData.ts b/lib/cardTestData.ts index 2ae620c4..57822c8b 100644 --- a/lib/cardTestData.ts +++ b/lib/cardTestData.ts @@ -16,8 +16,7 @@ export const exampleCards = [ city: 'Test City', postalCode: '11111', phoneNumber: '+12025550180', - email: 'customer-0001@circle.com', - verification: 'cvv' + email: 'customer-0001@circle.com' } }, { @@ -37,8 +36,7 @@ export const exampleCards = [ city: 'Test City', postalCode: '11111', phoneNumber: '+12025550180', - email: 'customer-0002@circle.com', - verification: 'cvv' + email: 'customer-0002@circle.com' } }, { @@ -58,8 +56,7 @@ export const exampleCards = [ city: 'Test City', postalCode: '11111', phoneNumber: '+12025550180', - email: 'customer-0003@circle.com', - verification: 'cvv' + email: 'customer-0003@circle.com' } }, { @@ -79,8 +76,7 @@ export const exampleCards = [ city: 'Test City', postalCode: '11111', phoneNumber: '+12025550180', - email: 'customer-0004@circle.com', - verification: 'cvv' + email: 'customer-0004@circle.com' } }, { @@ -100,8 +96,7 @@ export const exampleCards = [ city: 'Test City', postalCode: '11111', phoneNumber: '+12025550180', - email: 'customer-0005@circle.com', - verification: 'cvv' + email: 'customer-0005@circle.com' } }, { @@ -121,8 +116,7 @@ export const exampleCards = [ city: 'Test City', postalCode: '11111', phoneNumber: '+12025550180', - email: 'customer-0006@circle.com', - verification: 'cvv' + email: 'customer-0006@circle.com' } }, { @@ -142,8 +136,7 @@ export const exampleCards = [ city: 'Test City', postalCode: '11111', phoneNumber: '+12025550180', - email: 'customer-0007@circle.com', - verification: 'cvv' + email: 'customer-0007@circle.com' } } ] diff --git a/lib/cardsApi.ts b/lib/cardsApi.ts index 52f592a8..98cfde9c 100644 --- a/lib/cardsApi.ts +++ b/lib/cardsApi.ts @@ -42,7 +42,6 @@ export interface CreateCardPayload { } expMonth: number expYear: number - verification: string metadata: MetaData } diff --git a/lib/marketplaceApi.ts b/lib/marketplaceApi.ts index 545c550e..ea4a3205 100644 --- a/lib/marketplaceApi.ts +++ b/lib/marketplaceApi.ts @@ -23,13 +23,12 @@ export interface CreateMarketplacePaymentPayload { amount: string currency: string } - verification: string source: { id: string type: string } - keyId: string - encryptedData: string + keyId?: string + encryptedData?: string metadata: MetaData marketplaceInfo: MarketplaceInfo } @@ -92,6 +91,12 @@ function createPayment(payload: CreateMarketplacePaymentPayload) { if (payload.metadata) { payload.metadata.phoneNumber = nullIfEmpty(payload.metadata.phoneNumber) } + if (payload.keyId) { + payload.keyId = nullIfEmpty(payload.keyId) + } + if (payload.encryptedData) { + payload.encryptedData = nullIfEmpty(payload.encryptedData) + } return instance.post(url, payload) } diff --git a/lib/paymentsApi.ts b/lib/paymentsApi.ts index 8866cceb..07455585 100644 --- a/lib/paymentsApi.ts +++ b/lib/paymentsApi.ts @@ -16,13 +16,12 @@ export interface CreatePaymentPayload { amount: string currency: string } - verification: string source: { id: string type: string } - keyId: string - encryptedData: string + keyId?: string + encryptedData?: string metadata: MetaData } @@ -101,6 +100,12 @@ function createPayment(payload: CreatePaymentPayload) { if (payload.metadata) { payload.metadata.phoneNumber = nullIfEmpty(payload.metadata.phoneNumber) } + if (payload.keyId) { + payload.keyId = nullIfEmpty(payload.keyId) + } + if (payload.encryptedData) { + payload.encryptedData = nullIfEmpty(payload.encryptedData) + } return instance.post(url, payload) } diff --git a/pages/debug/cards/create.vue b/pages/debug/cards/create.vue index d228d020..1b956e80 100644 --- a/pages/debug/cards/create.vue +++ b/pages/debug/cards/create.vue @@ -41,17 +41,7 @@ - - - + @@ -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', @@ -176,35 +164,24 @@ 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: { + const cardDetails: { number: string cvv?: string } = { - number: cardNumber.trim().replace(/\D/g, '') - } - - if (verification === 'cvv') { - cardDetails = { - ...cardDetails, - cvv - } + number: cardNumber.trim().replace(/\D/g, ''), + cvv } const payload: CreateCardPayload = { idempotencyKey: uuidv4(), expMonth: parseInt(expiry.month), expYear: 2000 + parseInt(expiry.year), - verification, keyId: '', encryptedData: '', billingDetails, @@ -217,14 +194,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) { diff --git a/pages/debug/marketplace/payments/create.vue b/pages/debug/marketplace/payments/create.vue index 70131eec..c8e5d6fd 100644 --- a/pages/debug/marketplace/payments/create.vue +++ b/pages/debug/marketplace/payments/create.vue @@ -15,13 +15,7 @@ - - - +