-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lint fixes and code refactoring changes
- Loading branch information
1 parent
7727e2b
commit 2b3b9ee
Showing
18 changed files
with
84 additions
and
157 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,28 @@ | ||
import { v4 as uuid } from 'uuid'; | ||
import {CreatePaymentRequest, MockPaymentProviderResponse} from '../services/types/payment.type'; | ||
import {PaymentOutcome} from "../dtos/payment.dto"; | ||
import { CreatePaymentRequest, MockPaymentProviderResponse } from '../services/types/payment.type'; | ||
import { PaymentOutcome } from '../dtos/payment.dto'; | ||
|
||
// TODO: Make it class , add interface and provide implementation | ||
export const paymentProviderApi = (): any => { | ||
|
||
const allowedCreditCards = ['4111111111111111', '5555555555554444', '341925950237632']; | ||
/** | ||
* @param request | ||
* @returns | ||
*/ | ||
const processPayment = async (request: CreatePaymentRequest): Promise<MockPaymentProviderResponse> => { | ||
const paymentMethod = request.data.paymentMethod; | ||
const isAuthorized = isCreditCardAllowed(paymentMethod.cardNumber); | ||
|
||
return { | ||
resultCode: isAuthorized ? PaymentOutcome.AUTHORIZED: PaymentOutcome.REJECTED, | ||
pspReference: uuid(), | ||
paymentMethodType: paymentMethod.type, | ||
} | ||
}; | ||
|
||
const isCreditCardAllowed = (cardNumber: string) => allowedCreditCards.includes(cardNumber); | ||
const allowedCreditCards = ['4111111111111111', '5555555555554444', '341925950237632']; | ||
/** | ||
* @param request | ||
* @returns | ||
*/ | ||
const processPayment = async (request: CreatePaymentRequest): Promise<MockPaymentProviderResponse> => { | ||
const paymentMethod = request.data.paymentMethod; | ||
const isAuthorized = isCreditCardAllowed(paymentMethod.cardNumber); | ||
|
||
return { | ||
processPayment | ||
resultCode: isAuthorized ? PaymentOutcome.AUTHORIZED : PaymentOutcome.REJECTED, | ||
pspReference: uuid(), | ||
paymentMethodType: paymentMethod.type, | ||
}; | ||
}; | ||
|
||
const isCreditCardAllowed = (cardNumber: string) => allowedCreditCards.includes(cardNumber); | ||
|
||
return { | ||
processPayment, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
|
||
async function postDeploy(properties) { | ||
|
||
async function postDeploy(properties: any) { | ||
// TODO: Implement postDeploy scripts if any | ||
} | ||
|
||
async function run() { | ||
async function runPostDeployScripts() { | ||
try { | ||
const properties = new Map(Object.entries(process.env)); | ||
await postDeploy(properties); | ||
} catch (error) { | ||
process.stderr.write(`Post-deploy failed: ${error.message}\n`); | ||
if (error instanceof Error) { | ||
process.stderr.write(`Post-deploy failed: ${error.message}\n`); | ||
} | ||
process.exitCode = 1; | ||
} | ||
} | ||
|
||
run(); | ||
runPostDeployScripts(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
import * as dotenv from 'dotenv'; | ||
dotenv.config(); | ||
|
||
import { setupFastify } from "./server"; | ||
import { setupFastify } from './server'; | ||
|
||
(async () => { | ||
const server = await setupFastify(); | ||
const server = await setupFastify(); | ||
|
||
const HOST = '0.0.0.0'; | ||
try { | ||
await server.listen({ | ||
port: 8080, | ||
host: HOST, | ||
}); | ||
} catch (err) { | ||
server.log.error(err); | ||
process.exit(1); | ||
} | ||
})(); | ||
const HOST = '0.0.0.0'; | ||
try { | ||
await server.listen({ | ||
port: 8080, | ||
host: HOST, | ||
}); | ||
} catch (err) { | ||
server.log.error(err); | ||
process.exit(1); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.