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

Fallback to SK1 Transaction #173

Merged
merged 6 commits into from
Sep 15, 2023
Merged

Conversation

yusuftor
Copy link
Collaborator

@yusuftor yusuftor commented Sep 7, 2023

Changes in this pull request

  • Fixes issue where the retrieved StoreTransaction associated with the purchased product may be nil. This stores every purchased transaction by product ID if the transaction date of the purchased transaction is > the last stored transaction. Then, when getting the latest transaction it defaults to SK2 and checks it has a transaction date within the last hour. If that fails, then it gets the lastInternalTransaction, i.e. the transaction that caused the internal purchase controller to mark the transaction as purchased. Otherwise, we fallback to getting the last transaction whose date is within the last hour. If that fails, we wait 500ms before trying again and finally returning nil.
  • When completing a purchase, we check whether the productId of the purchase is the one being purchased. We also check that the transactionDate of the purchase is within the last hour to stop old purchases from completing the purchase.

Checklist

  • All unit and UI tests pass. Demo project builds and runs.
  • I added tests, an experiment, or detailed why my change isn't tested.
  • I added an entry to the CHANGELOG.md for any breaking changes, enhancements, or bug fixes.
  • I have run swiftlint in the main directory and fixed any issues.
  • I have updated the SDK documentation as well as the online docs.
  • I have reviewed the contributing guide

@yusuftor yusuftor changed the title feature/fallback-to-sk1-product Fallback to SK1 Transaction Sep 7, 2023
- Stores every purchased transaction by product if the transaction date of the purchased transaction is greater than the last stored transaction. Then when getting the latest transaction it defaults to SK2 and checks it has a transaction date within the last hour. If that fails, then it gets the lastInternalTransaction, i.e. the transaction that caused the internal purchase controller to mark the transaction as purchased. Otherwise, we fallback to getting the last transaction whose date is within the last hour. If that fails, we wait 500ms before trying again and finally returning nil.
- When completing a purchase, a check is added that the productId of the purchase is the one being purchased. Also checks that the date of the purchase is within the last hour to stop old purchases from completing the purchase.
- Fixes tests and swiftlint
Fixes issue where transactions other than purchased wouldn't call the completion block.
@yusuftor yusuftor merged commit 9cf4d2e into develop Sep 15, 2023
2 checks passed
@yusuftor yusuftor deleted the feature/fallback-to-sk1-product branch September 15, 2023 04:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant