From 72740f670683d849a0084d38637424c918cd1d25 Mon Sep 17 00:00:00 2001 From: Andrea Bizzotto Date: Sat, 23 Dec 2017 08:27:19 +0000 Subject: [PATCH 1/2] Add `originalTransaction` to result in `PurchaseDetails` --- SwiftyStoreKit/PaymentsController.swift | 3 +-- SwiftyStoreKit/SwiftyStoreKit+Types.swift | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/SwiftyStoreKit/PaymentsController.swift b/SwiftyStoreKit/PaymentsController.swift index 9672d373..a9916e0e 100644 --- a/SwiftyStoreKit/PaymentsController.swift +++ b/SwiftyStoreKit/PaymentsController.swift @@ -72,8 +72,7 @@ class PaymentsController: TransactionController { let transactionState = transaction.transactionState if transactionState == .purchased { - - let purchase = PurchaseDetails(productId: transactionProductIdentifier, quantity: transaction.payment.quantity, product: payment.product, transaction: transaction, needsFinishTransaction: !payment.atomically) + let purchase = PurchaseDetails(productId: transactionProductIdentifier, quantity: transaction.payment.quantity, product: payment.product, transaction: transaction, originalTransaction: transaction.original, needsFinishTransaction: !payment.atomically) payment.callback(.purchased(purchase: purchase)) diff --git a/SwiftyStoreKit/SwiftyStoreKit+Types.swift b/SwiftyStoreKit/SwiftyStoreKit+Types.swift index 86262219..bb3a686d 100644 --- a/SwiftyStoreKit/SwiftyStoreKit+Types.swift +++ b/SwiftyStoreKit/SwiftyStoreKit+Types.swift @@ -26,7 +26,7 @@ import StoreKit // MARK: Purchases -// Purchased or restored product +// Restored product public struct Purchase { public let productId: String public let quantity: Int @@ -35,11 +35,13 @@ public struct Purchase { public let needsFinishTransaction: Bool } +// Purchased product public struct PurchaseDetails { public let productId: String public let quantity: Int public let product: SKProduct public let transaction: PaymentTransaction + public let originalTransaction: PaymentTransaction? public let needsFinishTransaction: Bool } From ced801e3eed21e092121b18025b6b5da130f4491 Mon Sep 17 00:00:00 2001 From: Andrea Bizzotto Date: Sat, 23 Dec 2017 08:34:07 +0000 Subject: [PATCH 2/2] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 715f43b4..b4166427 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file. ## [0.11.3](https://github.com/bizz84/SwiftyStoreKit/releases/tag/0.11.3) `completeTransactions` should finish failed transactions if `atomically: false` +* Add `originalTransaction` to `PurchaseDetails` ([#323](https://github.com/bizz84/SwiftyStoreKit/pull/323), fix for [#302](https://github.com/bizz84/SwiftyStoreKit/issues/302)) * `completeTransactions` should finish failed transactions if `atomically: false` ([#322](https://github.com/bizz84/SwiftyStoreKit/pull/322), related issues: [#307](https://github.com/bizz84/SwiftyStoreKit/issues/307), [#288](https://github.com/bizz84/SwiftyStoreKit/issues/288)) ## [0.11.2](https://github.com/bizz84/SwiftyStoreKit/releases/tag/0.11.2) Remove `SKProduct.localizedIntroductoryPrice`