Skip to content

Add a hosted payment link to Next.js and grant an access pass

The buyer pays with a wallet on a 0to1pay checkout page. Your app receives a webhook and grants access. The beta uses test tokens only and collects no real funds.

Select Create a test project on the home page and sign in. Name your project, then open API keys, issue a test key and store it on your server. Copy the merchant ID and project ID from Project settings → Project details. Run the next two setup steps on your server with this project’s test key.

Register a receiving address on the payment network

Call createChainConnection for the network you want to accept. Use its connection_id and your project details to prepare a proof for the receiving address. On Ethereum or Base Sepolia, sign recipientProofMessage with the wallet that owns the address. On TRON Nile, use tronRecipientProofMessage and signMessageV2. Submit the address and signature with registerChainRecipients. Each new order needs one unused address. Signing requires no transfer or gas.

Register a fulfillment webhook

Register a public HTTPS webhook URL on your own service with createWebhookEndpoint and select the fulfillment.requested event. Save signing_secret.key_id and signing_secret.secret_base64url from the one-time response on your receiving server. Use them to verify the raw request body and headers. The hosted-link example below includes the receiving route and fulfillment worker. Set the link ID and product code on the worker after creating the link.

Return to Payment links in the same project and select Refresh under Payment setup. Check the available receiving address and registered webhook. Enter a product name, product code and price, choose the network and webhook, then select Create payment link. For a Base Sepolia pass, try a price of 0.01 and a product code of course_pass. You can copy the link immediately. The buyer needs test tokens and gas when they pay.

Add the link to your Next.js buy button

Choose Copy link, set PAYMENT_LINK_URL to the public URL and use this Server Component on your product page. Keep your merchant API key and webhook signing key on the server.

export default function BuyCoursePass() {
  const href = process.env.PAYMENT_LINK_URL;
  if (!href) throw new Error('PAYMENT_LINK_URL');
  return <a href={href}>Buy a test course pass</a>;
}

Pay with a wallet and recover the same order

Use test USDC and test ETH for gas on Ethereum Sepolia or Base Sepolia. On TRON Nile, use test USDT and test TRX for fees. Save the recovery ID and approve the order in the wallet. Send once, then sign the transaction proof. If you already sent the tokens, reopen the same link with your recovery ID and original wallet, then submit the existing transaction hash.

Grant one pass per order

Verify the webhook signature against the raw request body and headers, then save the event before acknowledging it. Your worker checks that the grant_access command matches your project, link and product code (action_ref). Use grant_key to deduplicate, save the pass and result in one database transaction, then report the result after commit.

Check access for a signed-in member

Have the signed-in member sign a one-time message with the paying wallet. Verify the signature on your server to link that wallet to the account. When they open protected content, check on your server for an active pass whose target_ref matches the wallet verified for that member.