← Guides

Guide

Selling from your own app

Use 402.shop to accept payments while you manage products, orders and fulfilment in your own app.

Accept payments with 402.shop while managing products, orders and fulfilment in your own app. One-time purchases require no 402.shop account and are linked to the wallet used to pay.

Set up once. Sign in as a seller (see Authentication), choose a seller username with PUT /api/me/username, then create a product and publish a price for each product you sell. Price names must produce distinct checkout slugs across your products. Read checkoutPath from the price list for the generated link. Leave files and content empty if you handle delivery yourself. Buyers will see a payment confirmation on 402.shop. To send buyers back to your site, register its origins with PUT /api/me/return-origins.

Your order ID. Include an order ID in each checkout link: order, 1–128 characters of A-Z a-z 0-9 _ . : -. Make it unguessable (a random suffix is enough), because it appears in the buyer's link. Each order supports one purchase or subscription; a wallet can pay for multiple orders.

Take the payment. Send the buyer to the hosted page:

/{username}/{slug}?order=<id>&return_url=<url>

After payment, buyers see a confirmation and are redirected to return_url after two seconds, provided its origin is registered. Your order ID is added to the return URL if it is not already included. If the payment response was lost, buyers can recover their purchase at /{username}/{slug}/recover?order=<your id>.

You can also accept one-time payments directly from your own page, without a session or redirect (CORS is open): POST /api/prices/{priceId}/purchase?order=<your id> returns HTTP 402 with a payment challenge. The buyer's wallet signs it, then repeats the POST with Payment-Authorization. The response is 200 when paid, 202 while payment is being confirmed (resend the same credential), or 409 if another wallet paid for the order. Subscriptions are bought on the hosted page for now.

Fulfil the order. A redirect to return_url does not prove payment, because buyers can edit the URL. Check the order status:

GET /api/orders/<your id>?priceId=<the price you sent them to>
→ open | processing | paid (buyer, paidAt, paymentReference, amountAtomic)
→ 409 when the order was paid at another of your prices

Always pass priceId to verify that the buyer paid the correct price for the order. Poll this endpoint until the status is paid before fulfilling the order; no payment notification is sent to your app. For subscriptions, provide access while access is true and cancel with DELETE /api/orders/<your id>/subscription when a customer cancels in your app. GET /api/sales lists payments with their order IDs for reconciliation.

Full endpoint and field details are in the API reference.