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

ET-2557: delete adyen payment provider #349

Merged
merged 3 commits into from
Dec 22, 2023
Merged
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [20.0.0](https://github.com/karhoo/web-lib-demand/compare/v19.1.1...v20.0.0) (2023-12-22)

**Note:** Version bump only for package web-lib-demand





## [19.1.1](https://github.com/karhoo/web-lib-demand/compare/v19.1.0...v19.1.1) (2023-05-12)

**Note:** Version bump only for package web-lib-demand
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
},
"npmClient": "yarn",
"useWorkspaces": true,
"version": "19.1.1"
"version": "20.0.0"
}
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
},
"homepage": "https://github.com/karhoo/web-lib-demand#readme",
"devDependencies": {
"@adyen/adyen-web": "5.38.0",
"@microsoft/api-extractor": "^7.19.2",
"@types/braintree-web": "^3.75.0",
"@types/date-and-time": "^0.13.0",
Expand Down
8 changes: 8 additions & 0 deletions packages/create-demand-bloc-module/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [20.0.0](https://github.com/karhoo/web-lib-demand/compare/v19.1.1...v20.0.0) (2023-12-22)

**Note:** Version bump only for package @karhoo/create-demand-bloc-module





## [19.1.1](https://github.com/karhoo/web-lib-demand/compare/v19.1.0...v19.1.1) (2023-05-12)

**Note:** Version bump only for package @karhoo/create-demand-bloc-module
Expand Down
2 changes: 1 addition & 1 deletion packages/create-demand-bloc-module/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@karhoo/create-demand-bloc-module",
"description": "🔥 Node.js CLI tool to generate Karhoo Demand Bussness Logic Component",
"version": "19.1.1",
"version": "20.0.0",
"homepage": "https://github.com/karhoo/web-lib-demand#readme",
"bin": "src/create-demand-bloc-module.js",
"license": "BSD-2-Clause",
Expand Down
8 changes: 8 additions & 0 deletions packages/demand-api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [20.0.0](https://github.com/karhoo/web-lib-demand/compare/v19.1.1...v20.0.0) (2023-12-22)

**Note:** Version bump only for package @karhoo/demand-api





## [19.1.1](https://github.com/karhoo/web-lib-demand/compare/v19.1.0...v19.1.1) (2023-05-12)

**Note:** Version bump only for package @karhoo/demand-api
Expand Down
5 changes: 1 addition & 4 deletions packages/demand-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@karhoo/demand-api",
"version": "19.1.1",
"version": "20.0.0",
"description": "The Demand API provides the ability to contact Karhoo's public API and allows you to send and receive network calls and responses.",
"homepage": "https://github.com/karhoo/web-lib-demand/tree/master/packages/demand-api#readme",
"license": "BSD-2-Clause",
Expand Down Expand Up @@ -36,8 +36,5 @@
"date-and-time": "^2.0.1",
"lodash": "^4.17.21",
"uuid": "^8.3.2"
},
"peerDependencies": {
"@adyen/adyen-web": "4.9.0"
}
}
115 changes: 0 additions & 115 deletions packages/demand-api/src/payment/PaymentService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,119 +125,4 @@ describe('PaymentService', () => {
expect(http.get).toHaveBeenCalledWith('v3/payments/providers')
})
})

describe('getOriginKey', () => {
it('should call get of http', () => {
new PaymentService(http).getAdyenClientKey()

expect(http.get).toHaveBeenCalledTimes(1)
expect(http.get).toHaveBeenCalledWith('v3/payments/adyen/client-key')
})
})

describe('getPaymentMethods', () => {
it('should call post of http', () => {
const params = {
merchantAccount: 'testAccount',
countryCode: 'UK',
amount: {
currency: 'GBR',
value: 35,
},
}

new PaymentService(http).getAdyenPaymentMethods(params)

expect(http.post).toHaveBeenCalledTimes(1)
expect(http.post).toHaveBeenCalledWith('v3/payments/adyen/payments-methods', params)
})
})

describe('getPaymentMethods v68', () => {
it('should call post of http', () => {
const params = {
merchantAccount: 'testAccount',
countryCode: 'UK',
amount: {
currency: 'GBR',
value: 35,
},
}

const service = new PaymentService(http)
service.getAdyenPaymentMethods(params, 'v68')

expect(http.post).toHaveBeenCalledTimes(1)
expect(http.post).toHaveBeenCalledWith('v3/payments/adyen/v68/payments-methods', params)
})
})

describe('createPaymentAuth', () => {
it('should call post of http', () => {
const params = {
supply_partner_id: 'fleetId',
payments_payload: {
amount: {
currency: 'GBR',
value: 35,
},
merchantAccount: 'testAccount',
reference: 'reference',
returnUrl: 'https://your-company.com/checkout?shopperOrder=12xy',
paymentMethod: {
type: 'test',
number: '1234',
expiryMonth: '11',
expiryYear: '2022',
holderName: 'Name',
cvc: '123',
},
},
}

new PaymentService(http).createAdyenPaymentAuth(params)

expect(http.post).toHaveBeenCalledTimes(1)
expect(http.post).toHaveBeenCalledWith('v3/payments/adyen/payments', params)
})
})

describe('getPaymentDetails', () => {
it('should call post of http', () => {
const params = {
trip_id: 'trip_id',
payments_payload: {
paymentData: 'paymentData',
details: {
MD: 'MD',
PaRes: 'PaRes',
},
},
}

new PaymentService(http).getAdyenPaymentDetails(params)

expect(http.post).toHaveBeenCalledTimes(1)
expect(http.post).toHaveBeenCalledWith('v3/payments/adyen/payments-details', params)
})
})

describe('getPaymentDetails using new api version', () => {
it('should call post of http', () => {
const params = {
trip_id: 'trip_id',
payments_payload: {
details: {
redirectResult: '',
},
},
}

const service = new PaymentService(http)
service.getAdyenPaymentDetails(params, 'v68')

expect(http.post).toHaveBeenCalledTimes(1)
expect(http.post).toHaveBeenCalledWith('v3/payments/adyen/v68/payments-details', params)
})
})
})
37 changes: 0 additions & 37 deletions packages/demand-api/src/payment/PaymentService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@ import {
AddPaymentCardParams,
Payment,
PaymentProvidersResponse,
ClientKeyResponse,
PaymentMethodsParams,
PaymentAuthParams,
PaymentAuthResponse,
PaymentDetailsParams,
PaymentMethodsResponse,
PaymentDetailsResponse,
ProviderVersion,
} from './types'

export class PaymentService implements Payment {
Expand All @@ -28,10 +20,6 @@ export class PaymentService implements Payment {
this.http = http
}

private getApiVersionPath(version: ProviderVersion) {
return version ? `${version}/` : ''
}

/** @deprecated use createBraintreeClientToken instead */

createClientToken(params: CreateTokenParams) {
Expand Down Expand Up @@ -87,29 +75,4 @@ export class PaymentService implements Payment {
getPaymentProvider() {
return this.http.get<PaymentProvidersResponse>(`${this.apiV3}/${this.url}/providers`)
}

getAdyenClientKey() {
return this.http.get<ClientKeyResponse>(`${this.apiV3}/${this.url}/adyen/client-key`)
}

getAdyenPaymentMethods(params: PaymentMethodsParams, version?: ProviderVersion) {
return this.http.post<PaymentMethodsResponse>(
`${this.apiV3}/${this.url}/adyen/${this.getApiVersionPath(version)}payments-methods`,
params
)
}

createAdyenPaymentAuth(params: PaymentAuthParams, version?: ProviderVersion) {
return this.http.post<PaymentAuthResponse>(
`${this.apiV3}/${this.url}/adyen/${this.getApiVersionPath(version)}payments`,
params
)
}

getAdyenPaymentDetails(params: PaymentDetailsParams, version?: ProviderVersion) {
return this.http.post<PaymentDetailsResponse>(
`${this.apiV3}/${this.url}/adyen/${this.getApiVersionPath(version)}payments-details`,
params
)
}
}
77 changes: 0 additions & 77 deletions packages/demand-api/src/payment/testMocks.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import { PaymentMethodsResponse, PaymentDetailsResponse } from './types'
import { HttpResponse, HttpResponseOk, HttpResponseError, ApiError } from '../http/types'
import { errorCodes } from '../responseCodes'

import {
CreateTokenResponse,
ClientNonceResponse,
PaymentProvidersResponse,
ClientKeyResponse,
PaymentAuthResponse,
ProviderId,
LoyaltyProgram,
} from './types'
import { PaymentAction } from '@adyen/adyen-web/dist/types/types'

const clientNonceResponse = {
card_type: 'cardType',
Expand Down Expand Up @@ -124,76 +120,3 @@ export const getMockedPaymentProviderWithoutLoyaltyResponse =
})

export const getPaymentProviderMock = getMock(getMockedPaymentProviderResponse)

export const getMockedAdyenClientKeyResponse = (): HttpResponseOk<ClientKeyResponse> => ({
ok: true,
status: 200,
headers: jsonResponseHeaders,
body: {
clientKey: 'origin-key',
environment: 'test',
},
})

export const getAdyenClientKeyMock = getMock(getMockedAdyenClientKeyResponse)
export const getMockedErrorAdyenClientKeyResponse = getErrorResponse('No client key received')

export const getMockedAdyenPaymentMethodsResponse = (): HttpResponseOk<PaymentMethodsResponse> => ({
ok: true,
status: 200,
headers: jsonResponseHeaders,
body: {
paymentMethods: [],
},
})

export const getAdyenPaymentMethodsMock = getMock(getMockedAdyenPaymentMethodsResponse)
export const getMockedErrorAdyenPaymentMethodsResponse = getErrorResponse('No payment methods received')

export const getMockedPaymentAuthResponse = (): HttpResponseOk<PaymentAuthResponse> => ({
ok: true,
status: 200,
headers: jsonResponseHeaders,
body: {
trip_id: 'trip_id',
payload: {
action: {
paymentData: 'paymentData',
type: 'redirect',
} as PaymentAction,
},
},
})

export const getCreateAdyenPaymentAuthMock = getMock(getMockedPaymentAuthResponse)
export const getMockedErrorAdyenPaymentAuthResponse = getErrorResponse('Failed to create a payment')

export const getMockedAdyenPaymentDetailsResponse = (): HttpResponseOk<PaymentDetailsResponse> => ({
ok: true,
status: 200,
headers: jsonResponseHeaders,
body: {
additionalData: { cardSummary: '0000' },
merchantReference: 'merchantReference',
pspReference: 'pspReference',
resultCode: 'Authorised',
},
})

export const getAdyenPaymentDetailsMock = getMock(getMockedAdyenPaymentDetailsResponse)
export const getMockedErrorAdyenPaymentDetailsResponse = getErrorResponse('Failed to create a payment')

export const getMockedAdyenPaymentDetailsRefusedResponse = (): HttpResponseOk<PaymentDetailsResponse> => ({
ok: true,
status: 200,
headers: jsonResponseHeaders,
body: {
additionalData: { cardSummary: '0000' },
merchantReference: 'merchantReference',
pspReference: 'pspReference',
resultCode: 'Refused',
refusalReasonCode: 'CVC Declined',
},
})

export const getAdyenPaymentDetailsRefusedMock = getMock(getMockedAdyenPaymentDetailsRefusedResponse)
Loading
Loading