iOS: Don't resolve request ID 0 from the payment queue

updatedTransactions posted success/failure unconditionally, but StoreKit also
delivers transactions we didn't initiate - unfinished ones at startup, for
instance - when no request is pending. Request IDs start at 10, so that just
produced "Unexpected request ID 0" errors. Guard it like the restore-finished
handler already does.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JZk5y4Fzw811WJoNWZb8Sc
This commit is contained in:
Henrik RydgårdandClaude Opus 5 committed 2026-08-06 20:56:37 +02:00
1 parent 6548a4f5cf
commit 56affb3cb9
1 file changed
+9 -4
+9 -4
View File
@@ -134,15 +134,20 @@
// Perform the unlock (updaing the variable and switching the icon).
[self unlockGold];
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
g_requestManager.PostSystemSuccess(_pendingRequestID, "", 0);
_pendingRequestID = 0;
// The queue also delivers transactions we didn't ask for, like unfinished ones at startup.
if (_pendingRequestID != 0) {
g_requestManager.PostSystemSuccess(_pendingRequestID, "", 0);
_pendingRequestID = 0;
}
break;
case SKPaymentTransactionStateFailed:
NSLog(@"[IAPManager] Purchase failed (requestID: %d): %@", _pendingRequestID, transaction.error.localizedDescription);
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
// Optionally post failure callback here
g_requestManager.PostSystemFailure(_pendingRequestID);
_pendingRequestID = 0;
if (_pendingRequestID != 0) {
g_requestManager.PostSystemFailure(_pendingRequestID);
_pendingRequestID = 0;
}
break;
default:
break;