How to accept your first payment in a Lovable app
Suppose you’ve built an invoice app in Lovable. Anyone with an account can create invoices for free. For $19, they can unlock PDF export with a single payment. A buyer who pays while editing an invoice should come back to that same invoice, ready to download it.
Choose how to take the payment
| If you want to… | Start with… |
|---|---|
| Set up payment and test it inside Lovable | Lovable’s built-in payments. On Pro or higher, Lovable sets up Stripe or Paddle and provides separate test and live environments. |
| Keep control of your existing Stripe account, or use Lovable's Free plan | Connect your own Stripe account. This path needs a backend. |
| Run checkout and sales follow-up in Spiffy | A hosted Spiffy checkout. Link to it from Lovable and use a manual check or your own backend integration to unlock PDF export. |
You’ll need sign-in and a database so the buyer can download another invoice next week. For built-in payments, ask Lovable to charge $19 once and save PDF export access on the buyer’s account. Choose Stripe or Paddle when prompted and check the price in Payments. Use Preview for testing, then complete the provider verification and go-live checklist in Payments before taking orders.
For the Spiffy route below, you’ll need a paid Spiffy plan and a connected payment gateway. You can grant the upgrade by hand from your app’s admin tools, or connect a backend that receives payment notifications.
Create the $19 checkout in Spiffy
- Connect your payment gateway in Spiffy. In Products, create a Single Price product called Invoice PDF Export with a price of $19 USD. For the offer description, try "Download PDFs of your invoices with a one-time purchase."
- In Checkouts, create a Standard checkout and select that product. Preview the checkout as a buyer. Once the name, amount and currency look right, publish it and copy its hosted URL.
- Pick how you’ll grant access. For manual fulfillment, add an Unlock PDF export · $19 once button for signed-in buyers and point it to the checkout. Ask them to pay with their verified app email. Save the invoice they’re editing and create a signed-in return page that takes them back to it. If you’re granting access by hand, skip to connecting the return page. For automatic fulfillment, continue below.
Connect Lovable to Spiffy for automatic fulfillment
In Spiffy, create a private key under Account Settings → API → Credentials. Save it as SPIFFY_API_KEY in your backend’s secrets. Ask Spiffy support to enable a webhook secret for your account and save it as SPIFFY_WEBHOOK_SECRET. On Lovable’s built-in backend, open More → Settings → Secrets. If you connected Supabase, use Edge Function Secrets in its dashboard. Keep both values out of project chat.
Your app also needs the ID of the $19 price. Ask Lovable to run this one-time product lookup from the backend:
Use the stored
SPIFFY_API_KEYas the bearer token for requests tohttps://api.spiffy.co. CallGET /v2/products?search=Invoice%20PDF%20Exportand find Invoice PDF Export by its exact name in the results. Use its product ID inGET /v2/products/{id}?include=options. Find the one-time USD price for 1900 cents underdata.options[].prices[]and return that price’sid. If you can’t identify one exact match, stop and show me what you found.
Save the confirmed price ID as SPIFFY_PRICE_ID in the backend settings. Replace [SPIFFY_CHECKOUT_URL] with the hosted checkout link, then paste this prompt into Lovable.
Add an “Unlock PDF export · $19 once” button for signed-in buyers. Ask them to pay with their verified app email. Save their current invoice ID before opening [SPIFFY_CHECKOUT_URL]. Create a signed-in /billing/return page that shows “Checking payment” until this account has PDF export access, then links back to that invoice.
Create a separate server endpoint for Spiffy’s Product Purchased webhook. Verify its bearer token with SPIFFY_WEBHOOK_SECRET. Use SPIFFY_API_KEY to look up the order and confirm a successful payment for the item with SPIFFY_PRICE_ID. Match the order email to one verified app account and grant export once per order. Check the buyer’s identity, invoice ownership and export access on every download. Give me the return page and webhook paths and tell me where to find their full HTTPS addresses after deployment.
Connect the return page and grant access
Publish the signed-in return page. In Spiffy’s Custom Thank You Page setting, paste the page’s full HTTPS address and turn off Send Order Details Through URL. Buyers should see the invoice they left or a message that their purchase is being checked.
If you grant access by hand, open the order in Spiffy and find the successful payment for Invoice PDF Export. Match the checkout email to the buyer’s verified app email. Enable export for that account in your admin tools and record the Spiffy order ID. If the addresses differ, resolve the purchase with the buyer first. You can skip to the buyer tests below.
If you use a Supabase Edge Function, configure just the webhook function for external requests (verify_jwt = false). Spiffy calls it without a buyer session, so the function itself must reject requests with a missing or incorrect Spiffy bearer token. Keep the return page and PDF download behind app sign-in.
Deploy the webhook endpoint with the backend settings above. In the product’s Product Purchased automation, add Custom Webhooks → Send Webhook and paste the endpoint’s full HTTPS address. This is the server address Spiffy calls even if the buyer closes the tab. Log only the event name and order ID.
After authenticating the webhook, use its order_id to fetch GET /v2/orders/{id} with include=items,payments,customer and your private Spiffy API key. Find the order item matching the notification’s order_item_id. Check that it has the PDF upgrade’s price ID and that a payment for that item succeeded. Then match the order’s customer email to one verified account in your app.
Save the purchase under the app’s internal user ID. Make the Spiffy order ID unique in your database so a second notification for the same order can’t grant access twice. Set aside mismatched orders for manual review.
The thank-you page reads the signed-in buyer’s saved permission. Opening or refreshing that page can’t unlock export. Each time the server generates a PDF, check that the buyer owns the invoice and has export access. Decide what happens when you issue a full refund, and make the corresponding access change in your app.
Test the full buyer flow
- Start in a separate test environment with an unpaid account. Click the button and check that it opens the right checkout. Visit the return page before paying and try to download the PDF. It should still be locked. For an automatic setup, use Send Test with a test receiver to check delivery and the bearer secret. The sample can omit the event name. Use a representative paid order to test the actual unlock.
- With test data, process the same paid order twice using your chosen fulfillment method. The matching buyer should get export access once and be able to reopen the invoice and download it. Try an unpaid order and a different signed-in account too. Neither should unlock the download.
- For Lovable's built-in payments, open project Preview and confirm you're in test mode. Sign in, select the upgrade, and enter a test card for your payment provider. Check that the test purchase appears under Payments and the buyer can download a PDF.
- For Spiffy, run the access checks with simulated orders in your test app. If your gateway is Stripe, use its sandbox for card tests. When your first customer buys the upgrade, check the paid order in Spiffy and confirm that the matching account can download its invoice.
If the buyer has a paid order and export is still locked, check the email match, product match, and the webhook delivery or manual grant before asking them to do anything else.