Skip to content

Commit

Permalink
Merge pull request #270 from Pinelab-studio/fix/picqer-failing-webhook
Browse files Browse the repository at this point in the history
Fix/picqer failing webhook
  • Loading branch information
martijnvdbrug authored Oct 19, 2023
2 parents 7eb1857 + 271792c commit 0ca11cb
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
4 changes: 4 additions & 0 deletions packages/vendure-plugin-picqer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.0.11

- Don't throw insufficient stock errors on incoming webhooks, because it will eventually disable the entire webhook in Picqer

# 1.0.10

- Send streetline1 + streetline2 as address in Picqer
Expand Down
2 changes: 1 addition & 1 deletion packages/vendure-plugin-picqer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pinelab/vendure-plugin-picqer",
"version": "1.0.10",
"version": "1.0.11",
"description": "Vendure plugin syncing to orders and stock with Picqer",
"author": "Martijn van de Brug <[email protected]>",
"homepage": "https://pinelab-plugins.com/",
Expand Down
28 changes: 22 additions & 6 deletions packages/vendure-plugin-picqer/src/api/picqer.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,27 @@ export class PicqerController {
);
// Middleware isn't loaded when using the test server from @vendure/testing, so we use the normal body
const rawBody = (req as any).rawBody || JSON.stringify(body);
await this.picqerService.handleHook({
body,
channelToken,
rawBody,
signature,
});
try {
await this.picqerService.handleHook({
body,
channelToken,
rawBody,
signature,
});
} catch (e: any) {
Logger.error(
`Error handling incoming hook '${body.event}': ${e.message}`,
loggerCtx
);

// FIXME: For now, don't throw insufficient stock error, to prevent webhook disabling
if (
e.message ===
'INSUFFICIENT_STOCK_ON_HAND_ERROR: INSUFFICIENT_STOCK_ON_HAND_ERROR'
) {
return;
}
throw e;
}
}
}

0 comments on commit 0ca11cb

Please sign in to comment.