TON Connect manifest
Before installing and setting up the TON Pay SDK, the application must provide a TON Connect manifest, which is a JSON file that defines application metadata. Wallets use the TON Connect manifest to discover the application.First payment
Add TON Connect provider
TON Pay UI uses TON Connect UI for wallet communication.The application must be wrapped with
TonConnectUIProvider and configured with an absolute URL to the TON Connect manifest. Add TonConnectUIProvider at the root of the application.Add a payment button
Add a
TonPayButton and provide a handler. The handler uses useTonPay to connect a wallet if needed, send a transaction through TON Connect, and return tracking data for the next step.TonPayButtonwraps wallet connect and disconnect UX and invokes the provided handler.useTonPayaccepts an async message factory that receivessenderAddrand returns{ message }along with any tracking fields to propagate.- Return
referencefromcreateTonPayTransferso it can be used later withgetTonPayTransferByReference.
{ message } is a TON Connect transaction message. useTonPay forwards it to the wallet through TON Connect and initiates the transaction send; direct calls to the wallet SDK are not required.In the examples below, replace <WALLET_ADDRESS> with the recipient wallet address, <TONPAY_API_KEY> with an optional dashboard API key, and <ORDER_REFERENCE> with an order label or ID.Minimal server-side flow example
Minimal server-side flow example
Handle loading state and results
Wallet approval does not mean the payment is finalized yet. After The status lookup guide describes the response fields and lookup methods used in this step.
pay(createMessage) resolves, use the reference returned by createTonPayTransfer to query TON Pay until the transfer leaves the pending state.The example below uses React. The same flow applies in other clients: keep the reference, poll status, and update the UI when the transfer leaves pending.Use the SDK flow below:- Return
referencefrom thecreateMessagefunction together withmessage. - Call
pay(createMessage)and, once it resolves, read the propagatedreferencefrom its return value. - Call
getTonPayTransferByReference(reference, options)with the samechainand optionalapiKeyused during transfer creation. - While the SDK returns
status: "pending", keep the UI in a loading or “confirming payment” state. - When the status becomes
success, show the confirmation UI and persist any result fields the application needs, such astxHashortraceId. - When the status becomes
error, show the failure state and captureerrorCodeorerrorMessagefor diagnostics.
reference after pay(createMessage) resolves and returns it. This is enough to resume status checks after a reload during polling, but it does not cover the period while the wallet approval screen is open. To avoid that gap, create the transfer on the server and persist the reference before opening the wallet.Result handling example
Full example
This minimal example scaffolds a React app, installs TON Pay dependencies, and renders a working button wired to TON Connect. Replace the manifest URL andrecipientAddr with the necessary values.