HANGER CREDITS — IMPLEMENTATION AND SETUP
Updated 19 October 2026

PUBLIC PAGE
https://hanger-try-on-backend.muxidada.chatgpt.site/credits
Owner settings: https://hanger-try-on-backend.muxidada.chatgpt.site/admin

PACKS (USD, before applicable checkout taxes)
100 credits = $10
500 credits = $47
1,000 credits = $90
One credit = one successfully generated image. One-time packs; no automatic renewal or expiry.

CURRENT SCOPE
This preview funds one shared merchant balance on the existing Hanger backend. Shoppers need no login, payment details or API keys. It is not yet a multi-merchant Shopify billing platform. Android clients using this backend also use the shared balance when credit billing is enabled. Free testing stays active by default, so the existing APK remains usable while payments are being set up. Legacy browser extensions that call fal directly do not use this hosted ledger.

TO CONNECT LEMON SQUEEZY
1. Create a Lemon Squeezy store and complete its required activation/identity steps yourself. Hanger cannot accept live payments until the store is activated.
2. Create three one-time USD product variants, priced at $10, $47 and $90. Use quantity 1 and no subscriptions or discounts. Keep the store currency USD for the current order validation.
3. In Lemon Squeezy, create a webhook pointing to:
   https://hanger-try-on-backend.muxidada.chatgpt.site/api/billing/webhook
   Subscribe to order_created and order_refunded. Choose a signing secret of 6–40 characters.
4. Sign in as the Hanger owner at /admin. Save the store ID, three variant IDs, API key and matching signing secret under Credits & checkout. Secrets are encrypted and never returned to the browser.
5. Leave Test checkout only checked. Complete a Lemon Squeezy test checkout and verify test credits appear. Test credits cannot fund live fal generation.
6. Configure live credentials/IDs when appropriate, uncheck Test checkout only, and confirm store activation and prices. Make a live purchase only when you intentionally want to pay for a pack.
7. Once there is a positive live merchant balance, Enable credit billing. All hosted generation requests then reserve one credit. Switch back to free testing from the same settings if desired.

Optional hosting environment overrides (all sensitive fields should be private):
LEMONSQUEEZY_API_KEY
LEMONSQUEEZY_WEBHOOK_SECRET
LEMONSQUEEZY_STORE_ID
LEMONSQUEEZY_VARIANT_100
LEMONSQUEEZY_VARIANT_500
LEMONSQUEEZY_VARIANT_1000
LEMONSQUEEZY_TEST_MODE=true (literal false for live checkout)
When the API-key environment variable is set, update all billing settings through the environment rather than the encrypted form. Deploy after changing hosted environment values.

ACCOUNTING
Only signed, validated paid-order webhooks add credits. A checkout return does not. Orders are matched to server-created purchase intents and validated against store, variant, mode, currency and exact pack price. Duplicate and reordered notifications do not mint extra credits. Partial refunds revoke a proportional number of credits, rounded up; full refunds revoke the whole pack. A refund can leave the merchant balance negative if credits were already spent.
Generation reservations and job insertion occur in one database transaction. Repeating the same request ID cannot charge twice. Confirmed failures/cancellations return the reserved credit exactly once. Unknown submission outcomes and temporary result-fetch errors retain the reservation for reconciliation; there is no automatic paid resubmission. Owner settings show recent live credit activity.

SHOPIFY DISTRIBUTION
Shopify App Store apps must use Shopify App Pricing or the Shopify Billing API unless Shopify explicitly grants an exception. Use Lemon Squeezy for direct Hanger sales, not as a substitute for mandatory Shopify merchant app billing. A registered Shopify app, development store, tenant isolation and Shopify billing integration are still needed before public Shopify distribution.
https://shopify.dev/docs/apps/launch/shopify-app-store/app-store-requirements

COMPETITOR SNAPSHOT — PUBLIC PRICES CHECKED 19 OCTOBER 2026
Hanger: $10/100, $47/500, $90/1,000 = $0.10, $0.094, $0.09 per completed image; one-time packs.
TryItOn (Chrome/Edge extension): Plus $5/month for 50 try-ons, Pro $16/month for 250, both displayed as billed annually = $0.10 or $0.064 per included try-on if fully used. Subscription allowances reset; this is not equivalent to a one-time pack.
https://tryiton.now/pricing
WearTryOn (related web product, not verified as a browser extension): one-time top-ups $6/~30 try-ons, $18/~100, $45/~300 = roughly $0.20, $0.18, $0.15 per try-on. Its internal credits do not equal Hanger credits.
https://weartryon.com/pricing
TRYON (merchant storefront competitor): $0.10/generated fitting image, optional $500/month analytics subscription.
https://tryon.technology/pricing
Hanger is competitive on pay-as-you-go pricing; it is not the cheapest across every annual subscription or feature set.

GPT IMAGE 2 PROVIDER SNAPSHOT
fal: measured $0.057 for one 1024x1536 medium-quality edit with two references, request 01a152f1-8812-7cb3-9e10-afc01d3c96f6, 25.36 seconds. This is the only provider tested with the actual references.
https://fal.ai/models/openai/gpt-image-2/edit
Kie.ai: advertises $0.03 at 1K, $0.05 at 2K, $0.08 at 4K, with image-to-image and up to 16 input images. Requires its own key/balance.
https://kie.ai/gpt-image-2
API Stock: advertises GPT Image 2 generation/editing at $0.013 (1k), $0.021 (2k), $0.032 (4k); references supported. Requires its own key/balance.
https://api-stock.com/model/gpt-image-2
Provider resolution names and quality controls differ. These are advertised candidate prices, not verified like-for-like results. No alternative provider was connected, paid, or given reference photos. Compare identity fidelity, garment details, exact dimensions, latency, failure costs and privacy terms before changing production. Hanger remains on fal.

UNIT ECONOMICS AT THE MEASURED FAL COST
Lemon Squeezy base fee is 5% + $0.50 per transaction; some payments incur extra fees.
$10 pack: $5.70 AI + $1.00 base fee = $3.30 before hosting and other costs.
$47 pack: $28.50 AI + $2.85 base fee = $15.65 before hosting and other costs.
$90 pack: $57.00 AI + $5.00 base fee = $28.00 before hosting and other costs.
https://www.lemonsqueezy.com/pricing
Costs increase with reference usage and generation settings; one sample is not a guaranteed future price.

VALIDATION
Automated backend tests use migrated SQLite and simulated provider responses. Cover: owner-only settings, encryption, CSRF, exact packs, signed/forged/mismatched webhooks, duplicate and out-of-order paid/refund events, test/live isolation, 105 simultaneous requests against 100 credits, duplicate-generation protection, definitive-failure refunds, uncertain holds and transient-result errors. No real checkout was possible because there is no Lemon Squeezy store yet.
