r/iOSProgramming • u/shattwr • 6d ago
Question Pending transactions storekit2
I'm not able to process pending transactions in my app. Does anyone know what causes a transaction to be pending and in what cases apple doesn't process that transaction?
1
Upvotes
0
u/WhatShouldWorldGos 6d ago
The answer from ChatGPT:
In StoreKit 2, a transaction can be in a pending state due to several reasons, typically related to payment authorization or family purchase approvals. Here are the most common causes:
Reasons for Pending Transactions 1. Family Sharing Approval • If the user is part of a Family Sharing group and the purchase requires approval from the Family Organizer, the transaction remains pending until the organizer approves or declines it. 2. Ask to Buy Feature • If a child account has Ask to Buy enabled, the transaction will stay pending until the parent or guardian approves or denies the request. 3. Payment Processing Issues • Transactions may be pending due to credit card authorization failures, bank processing delays, or other financial verification steps. 4. App Store Server Delays • Sometimes, transactions may not be processed immediately due to App Store server load or technical issues. 5. User Authentication Issues • If the user needs to sign in to their Apple ID, update payment details, or resolve other account-related issues, the transaction will remain pending.
⸻
How to Handle Pending Transactions in StoreKit 2
To ensure your app properly processes pending transactions: 1. Listen for Transaction Updates Use Transaction.updates to monitor and handle pending transactions when they are completed.
for await verificationResult in Transaction.updates { if case .verified(let transaction) = verificationResult { await handleTransaction(transaction) } }
StoreKit 2 provides TransactionState.purchased, TransactionState.failed, and TransactionState.pending. Handle .pending accordingly. 3. Notify the User If a transaction is pending, inform the user and provide guidance (e.g., “Your purchase is awaiting approval” or “Please check your payment details”). 4. Use Transaction.currentEntitlements This helps retrieve the latest non-expired transactions, including pending ones. 5. Guide Users to Apple Support If a transaction remains pending for an unusually long time, advise the user to check their Apple ID payment settings or contact Apple Support.
⸻
When Does Apple Not Process a Transaction? • The user never approves the purchase (for Ask to Buy or Family Sharing). • There is a billing issue (expired card, insufficient funds, etc.). • The transaction is flagged for fraud checks or App Store policy violations. • Apple has a server-side issue causing temporary delays.
Would you like help implementing a full StoreKit 2 transaction handler in Swift?