-
Connected: {walletInfo.walletName}
-
Address: {walletInfo.address}
-
- );
-}
-```
-
-## Server-side message building
-
-For production applications, build transaction messages on the server to centralize tracking and validation.
-
-### Backend endpoint
-
-```typescript expandable
-import { createTonPayTransfer } from "@ton-pay/api";
-import { validateWalletAddress } from "./utils/validation";
-
-app.post("/api/create-transaction", async (req, res) => {
- const { orderId, senderAddr } = req.body;
-
- try {
- // Validate inputs
- if (!validateWalletAddress(senderAddr)) {
- return res.status(400).json({ error: "Invalid wallet address" });
- }
-
- // Fetch order details from database
- const order = await db.orders.findById(orderId);
- if (!order) {
- return res.status(404).json({ error: "Order not found" });
- }
-
- if (order.status !== "pending") {
- return res.status(400).json({ error: "Order already processed" });
- }
-
- // Create transaction message
- const { message, reference, bodyBase64Hash } = await createTonPayTransfer(
- {
- amount: order.amount,
- asset: order.currency || "TON",
- recipientAddr: "