28.1 · Products, prices, the purchase call, verification and the update stream
The first sale is easy to demo and easy to get wrong: a missing product list, a price formatted by hand, a result that is not unwrapped, a delivery that happens twice.
Mental model. Treat every purchase as an event you may see more than once, from more than one place: ask the store for products, start the purchase, verify the signed result, deliver idempotently, then finish.
Products and the purchase call
What you can sell, how to show it, and what the purchase call can return or throw.
- Which product types does StoreKit 2 sell, why can Product.products(for:) come back empty, and why must prices come from the store?
A Product has a type (.consumable, .nonConsumable, .autoRenewable, .nonRenewable), and the type decides who remembers the purchase. A consumable is gone from… - What can product.purchase() return or throw, and how should each outcome behave in the UI?
purchase(options:) returns a Product.PurchaseResult with three cases and can also throw. .success(VerificationResult<Transaction>) means the payment went…
Verification and delivery
What a verified result proves, and how to deliver once even if it arrives twice.
- What does a .verified StoreKit result prove, what does it not prove, and when would you read unsafePayloadValue?
Every Transaction, RenewalInfo and AppTransaction arrives wrapped in a VerificationResult: .verified(value) or .unverified(value, error). .verified means… - Why start a Transaction.updates listener at launch, and what do finish() and idempotent delivery guarantee?
A purchase can complete when your purchase call is not running: a renewal at 3 a.m., an Ask to Buy approval, a refund, a purchase made on the iPad, a…
More in Purchases & subscriptions
- 28.2 · Subscription groups, renewal states, grace period, billing retry and offers
- 28.3 · What the user owns: entitlements, restore, family sharing, refunds and revocation
- 28.4 · JWS, certificate chains, notifications, the Server API and why receipts gave way to transactions
- 28.5 · Paywall design, price display and testing with StoreKit configuration, sandbox and TestFlight
- 28.6 · App Review rules, external purchases and designing a billing platform
- 28.7 · Building the integration: the store object, the catalogue, the SwiftUI views, status, account tokens and tests