Skip to content

Commit

Permalink
feat(payments): added support to retrieve the future order number fro…
Browse files Browse the repository at this point in the history
…m the session (#435)

* feat(payments): added a method to retrieve the future order number from the session so it could be sent to the payment providers if needed

* feat(payments): modified transactions API to receive the future order number
  • Loading branch information
dasanorct authored Nov 7, 2024
1 parent 9f3677c commit 666f5da
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 42 deletions.
76 changes: 35 additions & 41 deletions processor/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion processor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"license": "ISC",
"dependencies": {
"@commercetools-backend/loggers": "22.33.0",
"@commercetools/connect-payments-sdk": "0.10.0",
"@commercetools/connect-payments-sdk": "0.11.0",
"@fastify/autoload": "6.0.1",
"@fastify/cors": "10.0.1",
"@fastify/formbody": "8.0.1",
Expand Down
1 change: 1 addition & 0 deletions processor/src/dtos/operations/transaction.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const TransactionDraft = Type.Object({
currencyCode: Type.String(),
}),
),
futureOrderNumber: Type.Optional(Type.String()),
});

const TransactionStatePending = Type.Literal('Pending', {
Expand Down
5 changes: 5 additions & 0 deletions processor/src/libs/fastify/context/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ export const getMerchantReturnUrlFromContext = (): string | undefined => {
return authentication?.getPrincipal().merchantReturnUrl;
};

export const getFutureOrderNumberFromContext = (): string | undefined => {
const authentication = getRequestContext().authentication as SessionAuthentication;
return authentication?.getPrincipal().futureOrderNumber;
};

export const requestContextPlugin = fp(async (fastify: FastifyInstance) => {
// Enhance the request object with a correlationId property
fastify.decorateRequest('correlationId', '');
Expand Down

0 comments on commit 666f5da

Please sign in to comment.