Server Communication

All app-server protocols: handshake sync, in-app purchases, and event logging

Endpoints

EndpointPurposeAuth
/functions/v1/handshakeContent sync, user data, manifestJWT Bearer
/functions/v1/validate_purchaseCourse & subscription IAP validationJWT Bearer
/functions/v1/validate_purchase_ai_creditsAI credits IAP validationJWT Bearer
/functions/v1/app_logsEvent loggingJWT Bearer

All endpoints authenticate via JWT. User ID is extracted from the token — never sent in the payload.

Handshake Sync Flow

Flutter App
Build payload
JWT + checksums
Handshake
Edge Function
manifest
Sync Orchestrator
ADD / UPDATE / DELETE
files
Cloudflare R2
CDN delivery
1
Speed test — 3 tests via Cloudflare CDN, min 1.5 Mbps avg
2
Handshake — send analytics + device_id + pending purchases
3
Manifest — server returns json_manifest, ai_usage, subscription
4
Progressive sync — ADD new courses (with user confirm), UPDATE changed, DELETE removed

In-App Purchase Flows

Course Purchase
Consumable
Subscription-gated, uses download slots (2 for premium)
Subscription
Non-consumable
Monthly premium access
AI Credits
Consumable
Adds credits to user bank
1
Store purchase — Google Play / App Store native dialog
2
Get receipt — Android: purchase_token | iOS: receipt_data via method channel
3
Server validate/validate_purchase verifies with Google/Apple API
4
AcknowledgecompletePurchase() ONLY after server confirms
Deferred Acknowledgment

Purchases are NOT acknowledged until the server validates the receipt. If validation fails, the purchase stays unacknowledged and Google/Apple auto-refunds after 3 days.

Product IDs

ProductAndroidiOS
Course (e.g. H01ENB)h01enbme.hypnoelp.app.h01enb
Subscriptionhypnoelp_subscriptionsme.hypnoelp.app.subscription_1month
AI Credits (4K)ai_credits_4000me.hypnoelp.app.ai_credits_4000
AI Credits (10K)ai_credits_10000me.hypnoelp.app.ai_credits_10000
Custom Audiox99enbme.hypnoelp.app.x99enb

Platform Support

FeatureAndroidiOS
Course PurchaseGoogle Play BillingStoreKit
SubscriptionMulti-planMonthly only
AI CreditsConsumableConsumable
Upgrade/DowngradeWith prorationN/A (single plan)
Free TrialPricing phasesApp Store managed
Receipt SourceserverVerificationDataMethod channel (app_receipt)

Event Logging

Logs sent to /functions/v1/app_logs with user_id, log_type, message, origin, and timestamp.

sync_module
Speed tests, sync status, download failures
billing
Purchase initiated, validated, failed
authentication
Login/logout events
audio_playback
Audio player events
ai_chat
AI chatbot usage
user_report
User-reported issues

Checksum Requirements

RequirementValue
JSON formatting4-space indentation
Line endingsCRLF (\r\n)
Field orderLinkedHashMap (preserves server order)
Hash algorithmMD5 of raw file bytes
Detailed docs: Handshake & Sync | Course Purchase | Subscriptions | AI Credits | Event Logging
Back to Hypnoelp App