Apphud uses a single upload mechanism via submitReceipt to synchronize purchase data with the backend. This process handles both StoreKit 1 and StoreKit 2 transactions.
Key Submission Details
- Endpoint:
POST /v1/subscriptions - Data Sent: Includes
device_id, user_id, environment, bundle_id, receipt_data (base64), transaction_id, and jws (for StoreKit 2). - Product Info: For real purchases, the payload includes
product_bundle_id, paywall_id, placement_id, variation_identifier, experiment_id, screen_id, and rule_id. - Concurrency: The SDK uses a single-flight slot
submittingTransaction to prevent redundant uploads. Non-owning callers (like restoration or eligibility checks) join the in-flight request. Owning callers (ownsTransaction: true) that differ from the in-flight transaction will receive an immediate error to prevent finishing a transaction on a foreign result. - Retry Logic: If an upload fails, the SDK uses
scheduleSubmitReceiptRetry with an increasing delay. It also sets a requiresReceiptSubmissionKey in UserDefaults to ensure the receipt is re-submitted during the next registration attempt.
// Note: This is an internal method used by the SDK to sync transactions
submitReceipt(productInfo:apphudProduct:transactionIdentifier:transactionProductIdentifier:transactionState:receipt_string:transactionJws:notifyDelegate:eligibilityCheck:ownsTransaction:fromScreen:callback:) async