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
[x] All unit and UI tests pass. Demo project builds and runs.
[ ] I added tests, an experiment, or detailed why my change isn't tested.
[x] I added an entry to the CHANGELOG.md for any breaking changes, enhancements, or bug fixes.
[x] I have run swiftlint in the main directory and fixed any issues.
[ ] I have updated the SDK documentation as well as the online docs.
Changes in this pull request
StoreTransaction
associated with the purchased product may benil
. 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 thelastInternalTransaction
, 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.transactionDate
of the purchase is within the last hour to stop old purchases from completing the purchase.Checklist
CHANGELOG.md
for any breaking changes, enhancements, or bug fixes.swiftlint
in the main directory and fixed any issues.