axiom-codex/skills/axiom-implement-iap/SKILL.md
Use when the user wants to add in-app purchases, implement StoreKit 2, or set up subscriptions.
npx skillsauth add charleswiltgen/axiom axiom-implement-iapInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
You are an expert at implementing production-ready in-app purchases using StoreKit 2.
Implement complete IAP following testing-first workflow:
Ask the user:
com.company.app.product_nameCRITICAL: Create .storekit file BEFORE any Swift code!
Create StoreManager.swift with these essential components:
@MainActor
final class StoreManager: ObservableObject {
@Published private(set) var products: [Product] = []
@Published private(set) var purchasedProductIDs: Set<String> = []
private var transactionListener: Task<Void, Never>?
init(productIDs: [String]) {
// Start transaction listener IMMEDIATELY
transactionListener = listenForTransactions()
Task { await loadProducts(); await updatePurchasedProducts() }
}
// CRITICAL: Transaction listener handles ALL purchase sources
func listenForTransactions() -> Task<Void, Never> {
Task.detached { [weak self] in
for await result in Transaction.updates {
await self?.handleTransaction(result)
}
}
}
private func handleTransaction(_ result: VerificationResult<Transaction>) async {
guard let transaction = try? result.payloadValue else { return }
if transaction.revocationDate != nil {
// Handle refund
await transaction.finish()
return
}
await grantEntitlement(for: transaction)
await transaction.finish() // CRITICAL: Always finish
await updatePurchasedProducts()
}
func purchase(_ product: Product, confirmIn scene: UIWindowScene) async throws -> Bool {
let result = try await product.purchase(confirmIn: scene)
switch result {
case .success(let verification):
guard let tx = try? verification.payloadValue else { return false }
await grantEntitlement(for: tx)
await tx.finish()
return true
case .userCancelled, .pending: return false
@unknown default: return false
}
}
func restorePurchases() async {
try? await AppStore.sync()
await updatePurchasedProducts()
}
}
Key Requirements:
Custom View or StoreKit Views (iOS 17+):
// Custom
Button(product.displayPrice) {
Task { _ = try await store.purchase(product, confirmIn: scene) }
}
// StoreKit Views (simpler)
StoreKit.StoreView(ids: productIDs)
SubscriptionStoreView(groupID: "pro_tier")
Check subscription status via:
let statuses = try? await Product.SubscriptionInfo.status(for: groupID)
// Handle: .subscribed, .expired, .inGracePeriod, .inBillingRetryPeriod
App Store Requirement: Non-consumables/subscriptions MUST have restore:
Button("Restore Purchases") {
Task { await store.restorePurchases() }
}
Products.storekit - Configuration fileStoreManager.swift - Centralized IAP managerFor detailed patterns: axiom-integration (skills/in-app-purchases.md)
For API reference: axiom-integration (skills/storekit-ref.md)
For auditing: iap-auditor agent
development
Use when building ANY watchOS app — app structure, independent apps, Watch Connectivity, Smart Stack widgets, complications, controls, RelevanceKit, background tasks, ClockKit migration.
development
Use when working with HealthKit, WorkoutKit, health data, workouts, or fitness features on iOS or watchOS. Covers permissions, queries, background delivery, custom workouts, multidevice coordination.
development
Use when building, fixing, or improving ANY SwiftUI UI — views, navigation, layout, animations, performance, architecture, gestures, debugging, iOS 26 features.
content-media
Use when working with camera, photos, audio, haptics, ShazamKit, or Now Playing. Covers AVCaptureSession, PHPicker, PhotosPicker, AVFoundation, Core Haptics, audio recognition, MediaPlayer, CarPlay, MusicKit.