The previous article said that the directory was where I first touched money, but the directory itself did not charge anyone.
So I kept wondering whether I could make something that could actually take a payment.
Later, I took on a job to build a music-generation site.
There were already generation APIs on the market, charging by use. But for an ordinary person to try one, they had to register, add a card, read English documentation, and then figure out how to pay.
My idea was to wrap those steps up. A user registers, buys credits, clicks Generate, and gets a song. All the annoying parts in the middle become my problem.
The frontend took only two days.
I used Clerk for login and Tailwind for the interface. The theme, dark mode, and Chinese-English switch were all ready-made. For someone who had written plenty of pages, this part was not difficult.
The backend took two weeks.
What held me up was not code. It was money.
The whole chain looked like this: the user registers and the information goes into the database; a top-up sends them to a payment page; after payment, the platform calls a webhook; the backend verifies the order and adds credits; the frontend refreshes and shows the new balance.
It sounds like four steps, but every step has traps.
The biggest trap was the callback.
During local development, the payment platform needed to reach my machine. I started with ngrok, but the address changed every time I restarted it, so I had to update it in the dashboard over and over.
In one day, I spent more time filling in the address than writing code.
Eventually I switched to a fixed port and a stable local address. Things finally got quiet.
Once the callback worked, there was an even more annoying problem: duplicate callbacks.
The platform might send several notifications for the same order. Without deduplication, one payment could add credits three times.
The documentation did not say much about this. You only think of it after running the whole thing for real.
The code was done, but deployment was another round of trouble.
I first deployed to Cloudflare and ran into a pile of configuration issues. Then I moved to Vercel, which listed the incompatible parts directly so I could fix them one by one.
The database was still Supabase, essentially Postgres. I had written the connection string incorrectly at first and spent a long time chasing that mistake.
After more than a month, the site finally ran for real.
The site is still there.
Whether anyone actually paid is another question. At least the chain worked: from placing an order to receiving credits to generating a song, I ran the whole path end to end.
The lesson had little to do with writing code.
If a tool is only for me, it can break and I can start over. If it takes someone else’s money, one broken link means their payment is wasted. And it is someone else’s money.
Since then, I have added one question to the way I look at my projects:
If this takes money, would I trust a stranger to use it?
The next article returns to something completely different.
It does not sell, it is not for other people, and it only runs on my own computer. Yet it became the one I kept the longest.