Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PurchaseOrchestrator: fix incorrect InitiationSource for SK1 queue transactions #2430

Merged

Conversation

NachoSoto
Copy link
Contributor

@NachoSoto NachoSoto commented Apr 21, 2023

All StoreKit 1 transactions were being sent with InitiationSource.purchased.
#1957 introduced this, but it was only set correctly for SK2.

The consequence of this is that users might see "invalid receipt" errors when posting receipts due to updated transactions from the queue, which can only happen for InitiationSource.purchased.

@NachoSoto NachoSoto added the pr:fix A bug fix label Apr 21, 2023
@NachoSoto NachoSoto requested a review from a team April 21, 2023 19:03
@NachoSoto NachoSoto force-pushed the nacho/sdk-2867-ios-code-to-send-headers-in-post-receipt branch from a8dfbdd to fc064d5 Compare April 21, 2023 21:36
@NachoSoto NachoSoto marked this pull request as ready for review April 21, 2023 21:37
Copy link
Contributor

@tonidero tonidero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@NachoSoto
Copy link
Contributor Author

@aboedo does this look good to you?

Sources/Purchasing/Purchases/PurchasesOrchestrator.swift Outdated Show resolved Hide resolved
Comment on lines +812 to +817
private func initiationSource(
for productIdentifier: String,
restored: Bool
) -> ProductRequestData.InitiationSource {
// Having a purchase completed callback implies that the transation comes from an explicit call
// to `purchase()` instead of a StoreKit transaction notification.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this works.

I got quite confused at first, since that restore isn't coming from us, and we do offer the ability to attach a completion block to restores when they get initiated through our SDK.

But restores that are coming from us won't actually go through this flow in the first place since they don't issue transactions in the queue. Instead, for our restores we just refresh the receipt and send it.

Maybe we can document that behavior more in detail?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@NachoSoto NachoSoto enabled auto-merge (squash) April 25, 2023 16:23
@NachoSoto NachoSoto merged commit 13245f4 into main Apr 25, 2023
@NachoSoto NachoSoto deleted the nacho/sdk-2867-ios-code-to-send-headers-in-post-receipt branch April 25, 2023 16:39
NachoSoto added a commit that referenced this pull request Apr 26, 2023
…e transactions (#2430)

All StoreKit 1 transactions were being sent with
`InitiationSource.purchased`.
#1957 introduced this, but it was only set correctly for SK2.

The consequence of this is that users might see "invalid receipt" errors
when posting receipts due to updated transactions from the queue, which
can only happen for `InitiationSource.purchased`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:fix A bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants