-
Notifications
You must be signed in to change notification settings - Fork 40
feat(ton-pay): webhooks #1772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(ton-pay): webhooks #1772
Conversation
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the thorough TON Pay docs update; I’ve suggested several targeted edits in ecosystem/ton-pay/webhooks.mdx—please apply the inline suggestions to align the content with the shared style and code guidelines.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
/review |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for expanding the TON Pay webhook docs. I’ve left several suggestions in ecosystem/ton-pay/webhooks.mdx to align phrasing, link text, and callout usage with the style guide, so please apply the inline suggestions.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
/review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the detailed TON Pay webhook docs update. I’ve left several suggestions in ecosystem/ton-pay/webhooks.mdx: please apply the inline suggestions.
| const order = await db.getOrderByReference(webhookData.data.reference); | ||
| if (!order) { | ||
| console.error("Order not found:", webhookData.data.reference); | ||
| return res.status(200).json({ received: true }); // Acknowledge to prevent retry | ||
| } | ||
| ``` | ||
|
|
||
| 1. Verify the amount matches the expected payment amount. | ||
|
|
||
| ```ts | ||
| if (parseFloat(webhookData.data.amount) !== order.expectedAmount) { | ||
| console.error("Amount mismatch:", { | ||
| expected: order.expectedAmount, | ||
| received: webhookData.data.amount, | ||
| }); | ||
| return res.status(200).json({ received: true }); // Acknowledge to prevent retry | ||
| } | ||
| ``` | ||
|
|
||
| 1. Verify the payment currency or token. | ||
|
|
||
| ```ts | ||
| if (webhookData.data.asset !== order.expectedAsset) { | ||
| console.error("Asset mismatch:", { | ||
| expected: order.expectedAsset, | ||
| received: webhookData.data.asset, | ||
| }); | ||
| return res.status(200).json({ received: true }); // Acknowledge to prevent retry | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[HIGH] Trailing explanatory comments on code lines in TypeScript examples
Several validation snippets in this section use trailing inline comments on the same line as executable code, for example return res.status(200).json({ received: true }); // Acknowledge to prevent retry on lines 358, 370, 382, and similar patterns further down the file. The style guide requires explanatory comments in examples to appear on their own line immediately above the code, and forbids trailing end-of-line comments for general-purpose languages. Keeping these inline comments makes the examples visually noisy and inconsistent with the commenting standard across the docs.
Please leave a reaction 👍/👎 to this suggestion to improve future reviews for everyone!
| ### Complete validation example | ||
|
|
||
| ```ts expandable | ||
| import { verifySignature, type WebhookPayload } from "@ton-pay/api"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[HIGH] Partial TypeScript snippets missing “Not runnable” label
The “Complete validation example” TypeScript block starting at line 403 relies on undefined symbols such as app, db, and processOrderCompletion, making it a partial excerpt rather than a standalone runnable program. The extended style guide requires all partial snippets to be explicitly labeled “Not runnable” above the fenced block so readers do not assume they can execute them unchanged (contribute/style-guide-extended.mdx §“Partial snippets”). Other examples on this page (for example, earlier Express and validation snippets that also reference db and helper functions) show similar partial patterns and should follow the same labeling convention.
Please leave a reaction 👍/👎 to this suggestion to improve future reviews for everyone!
| app.post('/webhook', async (req, res) => { | ||
| // Validate signature first | ||
| if (!verifyWebhookSignature(...)) { | ||
| return res.status(401).json({ error: 'Invalid signature' }); | ||
| } | ||
|
|
||
| // Quick validations | ||
| if (!isValidWebhook(req.body)) { | ||
| return res.status(400).json({ error: 'Invalid webhook data' }); | ||
| } | ||
|
|
||
| // Acknowledge after validation | ||
| res.status(200).json({ received: true }); | ||
|
|
||
| // Process in background | ||
| processWebhookAsync(req.body).catch(console.error); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[HIGH] Literal ellipsis ... used as placeholder in code example
The best-practices example around lines 539–555 includes if (!verifyWebhookSignature(...)) {, using a literal ... as a stand-in for arguments. This makes the code invalid TypeScript/JavaScript and directly violates the rule that examples must be copy-pasteable and must not use literal ellipses that change syntax. Readers copying this snippet will encounter a syntax error or need to guess the missing arguments, which undermines trust in the documentation.
Please leave a reaction 👍/👎 to this suggestion to improve future reviews for everyone!
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Closes #1750