Skip to content

Commit 1e459c6

Browse files
OttiaOttia
authored andcommitted
Fixing Lint and Formatting Issues
1 parent 9535f86 commit 1e459c6

16 files changed

+50
-55
lines changed

src/models/request/add-card-form.model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IsNotEmpty, IsNumber, IsOptional, IsString } from 'class-validator'
1+
import { IsNotEmpty, IsOptional, IsString } from 'class-validator'
22

33
/**
44
* Class AddCardFormRequest

src/models/request/request-model/item.model.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { IsNotEmpty, IsNumber, IsOptional, IsString, Length, Max, Min } from 'class-validator'
22
import 'reflect-metadata'
33

4-
5-
64
/**
75
* Class Item
86
*
@@ -104,5 +102,4 @@ export class Item {
104102
@IsOptional()
105103
@Length(0, 50)
106104
public merchant?: string
107-
108105
}

src/paytrail-client.ts

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { responseMessage, responseStatus } from './constants/message-response.constant'
1+
import { responseStatus } from './constants/message-response.constant'
22
import { API_ENDPOINT, METHOD } from './constants/variable.constant'
33
import { IPaytrail } from './interfaces/IPayTrail.interface'
44
import {
@@ -350,32 +350,26 @@ export class PaytrailClient extends Paytrail implements IPaytrail {
350350
} as any
351351
}
352352

353-
try {
354-
const payload = {
355-
checkoutRedirectSuccessUrl: addCardFormRequest.checkoutRedirectSuccessUrl,
356-
checkoutRedirectCancelUrl: addCardFormRequest.checkoutRedirectCancelUrl,
357-
language: addCardFormRequest.language
358-
}
359-
const headers = this.getHeaders(METHOD.POST, null, null, payload)
360-
361-
// Signature override for add-card-form: Sign Method + Path + Body
362-
// Headers are NOT included in this signature calculation
363-
364-
const signature = Signature.calculateCustomHmac(
365-
this.secretKey as string,
366-
'POST',
367-
'/tokenization/addcard-form',
368-
convertObjectKeys(payload)
369-
)
370-
headers['signature'] = signature
353+
const payload = {
354+
checkoutRedirectSuccessUrl: addCardFormRequest.checkoutRedirectSuccessUrl,
355+
checkoutRedirectCancelUrl: addCardFormRequest.checkoutRedirectCancelUrl,
356+
language: addCardFormRequest.language
357+
}
358+
const headers = this.getHeaders(METHOD.POST, null, null, payload)
371359

372-
const data = await api.tokenPayments.createAddCardFormRequest(payload, headers)
360+
// Signature override for add-card-form: Sign Method + Path + Body
361+
// Headers are NOT included in this signature calculation
373362

374-
return data as any
363+
const signature = Signature.calculateCustomHmac(
364+
this.secretKey as string,
365+
'POST',
366+
'/tokenization/addcard-form',
367+
convertObjectKeys(payload)
368+
)
369+
headers['signature'] = signature
375370

376-
return data as any
377-
} catch (error) {
378-
throw error
379-
}
371+
const data = await api.tokenPayments.createAddCardFormRequest(payload, headers)
372+
373+
return data as any
380374
}
381375
}

src/utils/axios.util.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import axios, { AxiosResponse } from 'axios'
22
import { API_ENDPOINT } from '../constants/variable.constant'
33
import {
4-
AddCardFormRequest,
54
AddCardFormResponse,
65
CreateCitPaymentParams,
76
CreateCitPaymentRequest,

src/utils/handle-request.util.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ export const handleRequest = async <T>(promise: Promise<T>): Promise<readonly [a
22
return promise
33
.then((data): readonly [any, T] => [undefined, data] as const)
44
.catch((err): readonly [any, T] => [err, undefined] as const)
5-
65
}

src/validators/unit-price.validator.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { ValidationArguments, ValidatorConstraint, ValidatorConstraintInterface, registerDecorator, ValidationOptions } from 'class-validator'
1+
import {
2+
ValidationArguments,
3+
ValidatorConstraint,
4+
ValidatorConstraintInterface,
5+
registerDecorator,
6+
ValidationOptions
7+
} from 'class-validator'
28

39
/**
410
* Validator constraint for validating unitPrice based on context
@@ -48,9 +54,9 @@ export class IsValidUnitPriceConstraint implements ValidatorConstraintInterface
4854
defaultMessage(args: ValidationArguments): string {
4955
const object = args.object as any
5056
const unitPrice = args.value as number
51-
57+
5258
const isShopInShopItem = object.merchant && object.stamp && object.reference
53-
59+
5460
if (isShopInShopItem && unitPrice < 0) {
5561
return 'Shop-in-Shop items cannot have negative unitPrice'
5662
}
@@ -78,4 +84,4 @@ export function IsValidUnitPrice(validationOptions?: ValidationOptions) {
7884
validator: IsValidUnitPriceConstraint
7985
})
8086
}
81-
}
87+
}

tests/create-cit-payment-authorization-hold.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('create-cit-payment-authorization-hold', () => {
1616
standardData.amount = 1590
1717
standardData.currency = 'EUR'
1818
standardData.language = 'FI'
19-
19+
2020
const item = new Item()
2121
item.unitPrice = 1590
2222
item.units = 1
@@ -44,7 +44,7 @@ describe('create-cit-payment-authorization-hold', () => {
4444
nonStandardData.amount = -1590
4545
nonStandardData.currency = 'EUR'
4646
nonStandardData.language = 'FI'
47-
47+
4848
const nonStandardItem = new Item()
4949
nonStandardItem.unitPrice = 1590
5050
nonStandardItem.units = 1

tests/create-cit-payment-charge.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('create-cit-payment-charge', () => {
1616
standardData.amount = 1590
1717
standardData.currency = 'EUR'
1818
standardData.language = 'FI'
19-
19+
2020
const item = new Item()
2121
item.unitPrice = 1590
2222
item.units = 1
@@ -44,7 +44,7 @@ describe('create-cit-payment-charge', () => {
4444
nonStandardData.amount = -1590
4545
nonStandardData.currency = 'EUR'
4646
nonStandardData.language = 'FI'
47-
47+
4848
const nonStandardItem = new Item()
4949
nonStandardItem.unitPrice = 1590
5050
nonStandardItem.units = 1

tests/create-cit-payment-commit.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('create-cit-payment-commit', () => {
1717
standardData.amount = 1590
1818
standardData.currency = 'EUR'
1919
standardData.language = 'FI'
20-
20+
2121
const item = new Item()
2222
item.unitPrice = 1590
2323
item.units = 1
@@ -46,7 +46,7 @@ describe('create-cit-payment-commit', () => {
4646
nonStandardData.amount = -1590
4747
nonStandardData.currency = 'EUR'
4848
nonStandardData.language = 'FI'
49-
49+
5050
const nonStandardItem = new Item()
5151
nonStandardItem.unitPrice = 1590
5252
nonStandardItem.units = 1

tests/create-mit-payment-authorization-hold.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('create-mit-payment-authorization-hold', () => {
1616
standardData.amount = 1590
1717
standardData.currency = 'EUR'
1818
standardData.language = 'FI'
19-
19+
2020
const item = new Item()
2121
item.unitPrice = 1590
2222
item.units = 1
@@ -44,7 +44,7 @@ describe('create-mit-payment-authorization-hold', () => {
4444
nonStandardData.amount = -1590
4545
nonStandardData.currency = 'EUR'
4646
nonStandardData.language = 'FI'
47-
47+
4848
const nonStandardItem = new Item()
4949
nonStandardItem.unitPrice = 1590
5050
nonStandardItem.units = 1

0 commit comments

Comments
 (0)