Repository navigation
Server-verified consumables: buy with an account token, finish after the server accepts - #11
Merged
Merged
Conversation
…the server accepts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Apps whose server credits purchases to an account (coins, tokens, credits) could not use the kit safely:
appAccountToken. A purchase could not carry one, so the server had no signed proof of which account a purchase belongs to.Transaction.updatesdelivery. A finished consumable is never redelivered. If the request to the server was then lost, the customer had paid and nothing would ever credit them.What changes (additive, minor version)
FinishPolicy-.automatic(default, unchanged behaviour) or.manual. Set viaconfigure(identifiers:finishing:), which defaults to.automatic, so existing call sites compile and behave as before.purchase(productID:appAccountToken:)and the visionOSpurchase(productID:appAccountToken:confirmIn:). The token is signed into the transaction.finish(_:).Transaction.unfinishedby id.unfinishedTransactions()- drain at launch and after sign-in.transactionUpdates- every verified update: Ask to Buy approvals, pending payments, launch replays. One fresh stream per access, likepurchasedProducts.StoreTransaction.jwsRepresentation- the App Store's signed form for the server to verify. The public initializer gains it as a trailing defaulted parameter.ServerVerifiedPurchasesProtocol- the new surface as its own protocol. Adding requirements toPurchasesProtocolwould have broken every existing conformer, including test stand-ins.PurchasesManagerconforms to both.Under
.manualthe purchase path and the update listener both leave transactions unfinished. Under.automaticboth finish exactly as before.Verified
swift test: 34 tests pass, 4 new ones on the protocol surface and the signed form.xcodebuild buildfor iOS, Mac Catalyst, watchOS, tvOS and visionOS: all succeed.xcodebuild docbuild: no warnings. Links to the oldconfigure(identifiers:)are updated.Not covered by automated tests: the StoreKit-backed finish path itself.
SKTestSessionreportsinvalidAppoutside an app host, the same limitation the existing suite has.