Skip to content

Commit

Permalink
fix(pagaleve): Properly matching transaction by ID on Pagaleve webhooks
Browse files Browse the repository at this point in the history
  • Loading branch information
leomp12 committed Jan 14, 2025
1 parent fb4db5e commit fcc719c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/apps/pagaleve/src/pagaleve-webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ export const pagaleve = {
try {
const { data: order } = await api.get(orderEndpoint);
if (order?.transactions) {
const transactionIndex = order.transactions.findIndex(({ app }) => {
return app?.intermediator?.code === 'pagaleve';
const transactionIndex = order.transactions.findIndex(({ intermediator }) => {
return intermediator?.transaction_id === id;
});
const transactionId = order.transactions[transactionIndex]?._id;
if (!transactionId) {
Expand Down
5 changes: 1 addition & 4 deletions packages/apps/paghiper/src/functions-lib/handle-webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default async (req: Request, res: Response) => {
let transactionId: string | undefined;
if (transactions) {
transactions.forEach((transaction) => {
const { app, intermediator } = transaction;
const { intermediator } = transaction;
if (intermediator && intermediator.transaction_id === String(transactionCode)) {
if (transaction.status) {
if (
Expand All @@ -104,9 +104,6 @@ export default async (req: Request, res: Response) => {
return;
}
}
if (app && app.intermediator && app.intermediator.code !== 'paghiper') {
return;
}
transactionId = transaction._id;
}
});
Expand Down

0 comments on commit fcc719c

Please sign in to comment.