-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cc5c72a
commit 628f63c
Showing
68 changed files
with
2,459 additions
and
2 deletions.
There are no files selected for viewing
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/node_modules | ||
.env | ||
/dist |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Server configuration | ||
NODE_ENV=development | ||
SERVER_HOST=0.0.0.0 | ||
SERVER_PORT=8080 | ||
|
||
# Adyen credentials | ||
ADYEN_ENVIRONMENT=TEST | ||
ADYEN_API_KEY=[Adyen-api-key] | ||
ADYEN_LIVE_URL_PREFIX= | ||
ADYEN_NOTIFICATION_HMAC_KEY=[Adyen-hmac-key] | ||
ADYEN_MERCHANT_ACCOUNT=[Adyen-merchant-account] | ||
ADYEN_RETURN_URL=[Adyen-return-url-connector] | ||
|
||
#Adyen config options | ||
SUPPORTED_UI_ELEMENTS=[dropin,components] | ||
ENABLE_STORE_DETAILS=[true/false] | ||
|
||
# CoCo credentials | ||
CTP_AUTH_URL=https://auth.[region].commercetools.com | ||
CTP_API_URL=https://api.[region].commercetools.com | ||
CTP_CLIENT_ID=[CoCo-client-id] | ||
CTP_CLIENT_SECRET=[CoCo-client-secret] | ||
CTP_PROJECT_KEY=[CoCo-project-key] | ||
CTP_SESSION_URL=[CoCo-session-url] | ||
|
||
# Merchant website | ||
SELLER_RETURN_URL=[Merchant-website-return-url] | ||
SELLER_SEND_NOTIFICATION_ENABLED=[true/false] | ||
SELLER_NOTIFICATION_URL=[Merchant-website-return-url] |
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"root": true, | ||
"env": { | ||
"node": true, | ||
"jest": true | ||
}, | ||
"parser": "@typescript-eslint/parser", | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:import/typescript", | ||
"prettier", | ||
"plugin:prettier/recommended" | ||
], | ||
"plugins": ["@typescript-eslint", "import", "jest", "prettier", "unused-imports"], | ||
"rules": { | ||
"no-redeclare": ["warn"], | ||
"no-console": ["error"], | ||
"no-unused-vars": "off", | ||
"no-irregular-whitespace": "warn", | ||
"no-duplicate-imports": "off", | ||
"unused-imports/no-unused-imports": "error", | ||
"unused-imports/no-unused-vars": [ | ||
"warn", | ||
{ | ||
"vars": "all", | ||
"varsIgnorePattern": "^_", | ||
"args": "after-used", | ||
"argsIgnorePattern": "^_" | ||
} | ||
], | ||
"@typescript-eslint/no-unused-vars": ["warn"], | ||
"import/no-duplicates": "error", | ||
"@typescript-eslint/no-explicit-any": "off", | ||
"@typescript-eslint/no-var-requires": "off" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
dist | ||
coverage | ||
node_modules | ||
pnpm-lock.yaml |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = { | ||
arrowParens: 'always', | ||
bracketSameLine: true, | ||
bracketSpacing: true, | ||
printWidth: 120, | ||
singleQuote: true, | ||
tabWidth: 2, | ||
trailingComma: 'all', | ||
useTabs: false, | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
FROM node:18 | ||
|
||
COPY . /app | ||
WORKDIR /app | ||
RUN npm ci | ||
RUN npm run build | ||
|
||
ENTRYPOINT [ "npm", "run", "start" ] |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Adyen advanced flow | ||
|
||
[Official documentation](https://docs.adyen.com/online-payments/build-your-integration/additional-use-cases/advanced-flow-integration/?platform=Web&integration=Drop-in&version=5.51.0){:target="_blank"} | ||
|
||
|
||
## Get payment methods | ||
|
||
|
||
## Make a payment | ||
|
||
|
||
## Submit additional payment details | ||
|
||
|
||
## Get the payment outcome |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} */ | ||
|
||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { Client, CheckoutAPI } from '@adyen/api-library'; | ||
import { config } from '../../config/config'; | ||
|
||
export const AdyenAPI = (): CheckoutAPI => { | ||
const apiClient = new Client({ | ||
apiKey: config.adyenApiKey, | ||
environment: config.adyenEnvironment.toUpperCase() as Environment, | ||
...(config.adyenLiveUrlPrefix && { | ||
liveEndpointUrlPrefix: config.adyenLiveUrlPrefix, | ||
}), | ||
}); | ||
|
||
return new CheckoutAPI(apiClient); | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const convertStringCommaSeparatedValuesToArray = (supportedUIElements?: string): string[] => { | ||
if (supportedUIElements) { | ||
return supportedUIElements.split(','); | ||
} | ||
return []; | ||
}; | ||
|
||
export const config = { | ||
// Required by Payment SDK | ||
projectKey: process.env.CTP_PROJECT_KEY || 'test', | ||
clientId: process.env.CTP_CLIENT_ID || 'clientId', | ||
clientSecret: process.env.CTP_CLIENT_SECRET || 'clientSecret', | ||
authUrl: process.env.CTP_AUTH_URL || 'http://auth.test.com', | ||
apiUrl: process.env.CTP_API_URL || 'http://api.test.com', | ||
sessionUrl: process.env.CTP_SESSION_URL || 'http://session.test.com', | ||
|
||
// Required by logger | ||
loggerLevel: process.env.LOGGER_LEVEL || 'info', | ||
|
||
// Required to setup fastify server | ||
serverPort: process.env.SERVER_PORT ? parseInt(process.env.SERVER_PORT) : 8080, | ||
serverHost: process.env.SERVER_HOST || '0.0.0.0', | ||
|
||
// Adyen specific configuration | ||
adyenEnvironment: process.env.ADYEN_ENVIRONMENT || '', | ||
adyenClientKey: process.env.ADYEN_CLIENT_KEY || '', | ||
adyenApiKey: process.env.ADYEN_API_KEY || '', | ||
adyenHMACKey: process.env.ADYEN_NOTIFICATION_HMAC_KEY || '', | ||
adyenLiveUrlPrefix: process.env.ADYEN_LIVE_URL_PREFIX || '', | ||
adyenMerchantAccount: process.env.ADYEN_MERCHANT_ACCOUNT || '', | ||
adyenReturnUrl: process.env.ADYEN_RETURN_URL || '', | ||
|
||
// TODO review these configurations | ||
supportedUIElements: convertStringCommaSeparatedValuesToArray(process.env.SUPPORTED_UI_ELEMENTS), | ||
enableStoreDetails: process.env.ENABLE_STORE_DETAILS === 'true' ? true : false, | ||
sellerReturnUrl: process.env.SELLER_RETURN_URL || '', | ||
sellerNotificationUrl: process.env.SELLER_NOTIFICATION_URL || '', | ||
sellerSendNotiticationEnabled: process.env.SELLER_SEND_NOTIFICATION_ENABLED === 'true' ? true : false, | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { Notification } from '@adyen/api-library/lib/src/typings/notification/notification'; | ||
|
||
export type PaymentNotificationData = Notification; |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Static, Type } from '@sinclair/typebox'; | ||
|
||
export const SupportedPaymentMethodDTO = Type.Object({ | ||
type: Type.String(), | ||
}); | ||
|
||
export const SupportedPaymentMethodsSchema = Type.Object({ | ||
dropin: Type.Optional(Type.Array(SupportedPaymentMethodDTO)), | ||
components: Type.Optional(Type.Array(SupportedPaymentMethodDTO)), | ||
hostedPage: Type.Optional(Type.Array(SupportedPaymentMethodDTO)), | ||
}); | ||
|
||
export type SupportedPaymentMethodsDTO = Static<typeof SupportedPaymentMethodsSchema>; |
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 |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { Static, Type } from '@sinclair/typebox'; | ||
import { CreateCheckoutSessionRequest } from '@adyen/api-library/lib/src/typings/checkout/createCheckoutSessionRequest'; | ||
import { CreateCheckoutSessionResponse } from '@adyen/api-library/lib/src/typings/checkout/createCheckoutSessionResponse'; | ||
import { PaymentDetailsRequest } from '@adyen/api-library/lib/src/typings/checkout/paymentDetailsRequest'; | ||
import { PaymentDetailsResponse } from '@adyen/api-library/lib/src/typings/checkout/paymentDetailsResponse'; | ||
import { PaymentMethodsRequest } from '@adyen/api-library/lib/src/typings/checkout/paymentMethodsRequest'; | ||
import { PaymentMethodsResponse } from '@adyen/api-library/lib/src/typings/checkout/paymentMethodsResponse'; | ||
import { PaymentRequest } from '@adyen/api-library/lib/src/typings/checkout/paymentRequest'; | ||
import { PaymentResponse } from '@adyen/api-library/lib/src/typings/checkout/paymentResponse'; | ||
|
||
export type GetPaymentMethodsData = Omit<PaymentMethodsRequest, 'amount' | 'merchantAccount' | 'countryCode'>; | ||
export type PaymentMethodsData = PaymentMethodsResponse; | ||
|
||
export type CreateSessionData = Omit< | ||
CreateCheckoutSessionRequest, | ||
| 'amount' | ||
| 'merchantAccount' | ||
| 'countryCode' | ||
| 'returnUrl' | ||
| 'reference' | ||
| 'storePaymentMethod' | ||
| 'shopperReference' | ||
| 'recurringProcessingModel' | ||
| 'storePaymentMethodMode' | ||
>; | ||
|
||
export type SessionData = { | ||
sessionData: CreateCheckoutSessionResponse; | ||
paymentReference: string; | ||
}; | ||
|
||
export type CreatePaymentData = Omit< | ||
PaymentRequest, | ||
| 'amount' | ||
| 'additionalAmount' | ||
| 'merchantAccount' | ||
| 'countryCode' | ||
| 'returnUrl' | ||
| 'lineItems' | ||
| 'reference' | ||
| 'shopperReference' | ||
| 'recurringProcessingModel' | ||
> & { | ||
paymentReference?: string; | ||
}; | ||
export type PaymentData = Pick< | ||
PaymentResponse, | ||
'action' | 'resultCode' | 'threeDS2ResponseData' | 'threeDS2Result' | 'threeDSPaymentData' | ||
> & { | ||
paymentReference: string; | ||
}; | ||
|
||
export type PaymentConfirmationData = Pick< | ||
PaymentDetailsResponse, | ||
'resultCode' | 'threeDS2ResponseData' | 'threeDS2Result' | 'threeDSPaymentData' | ||
> & { | ||
paymentReference: string; | ||
}; | ||
|
||
export type ConfirmPaymentData = PaymentDetailsRequest & { | ||
paymentReference: string; | ||
}; | ||
|
||
export const CapturePaymentRequestSchema = Type.Object({ | ||
amount: Type.Object({ | ||
centAmount: Type.Number(), | ||
currencyCode: Type.String(), | ||
}), | ||
}); | ||
|
||
export const RefundPaymentRequestSchema = Type.Object({ | ||
amount: Type.Object({ | ||
centAmount: Type.Number(), | ||
currencyCode: Type.String(), | ||
}), | ||
}); | ||
|
||
export enum PaymentModificationStatus { | ||
RECEIVED = 'received', | ||
} | ||
const PaymentModificationSchema = Type.Enum(PaymentModificationStatus); | ||
|
||
export const PaymentModificationResponseSchema = Type.Object({ | ||
status: PaymentModificationSchema, | ||
}); | ||
|
||
export type DeleteStoredPaymentMethodData = { | ||
customerId: string; | ||
}; | ||
|
||
export type CapturePaymentRequestDTO = Static<typeof CapturePaymentRequestSchema>; | ||
export type RefundPaymentRequestDTO = Static<typeof RefundPaymentRequestSchema>; | ||
export type PaymentModificationResponseDTO = Static<typeof PaymentModificationResponseSchema>; |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import '@fastify/request-context'; | ||
import { ContextData, SessionContextData } from './libs/fastify/context/context'; | ||
|
||
declare module '@fastify/request-context' { | ||
interface RequestContextData { | ||
request: ContextData; | ||
session?: SessionContextData; | ||
} | ||
} | ||
|
||
declare module 'fastify' { | ||
interface FastifyInstance { | ||
vite: any; | ||
} | ||
|
||
export interface FastifyRequest { | ||
correlationId?: string; | ||
} | ||
} |
Oops, something went wrong.