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

Nest SKProduct and Purchase fields inside PurchaseDetails type #206

Merged
merged 4 commits into from
May 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SwiftyStoreKit/PaymentQueueController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protocol TransactionController {
}

public enum TransactionResult {
case purchased(purchase: Purchase)
case purchased(purchase: PurchaseDetails)
case restored(purchase: Purchase)
case failed(error: SKError)
}
Expand Down
6 changes: 3 additions & 3 deletions SwiftyStoreKit/PaymentsController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ class PaymentsController: TransactionController {
let transactionState = transaction.transactionState

if transactionState == .purchased {

let purchase = Purchase(productId: transactionProductIdentifier, quantity: transaction.payment.quantity, transaction: transaction, originalTransaction: transaction.original, needsFinishTransaction: !payment.atomically)

let purchase = PurchaseDetails(productId: transactionProductIdentifier, quantity: transaction.payment.quantity, product: payment.product, transaction: transaction, needsFinishTransaction: !payment.atomically)
payment.callback(.purchased(purchase: purchase))

if payment.atomically {
Expand Down
10 changes: 9 additions & 1 deletion SwiftyStoreKit/SwiftyStoreKit+Types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ public struct Purchase {
public let needsFinishTransaction: Bool
}

public struct PurchaseDetails {
public let productId: String
public let quantity: Int
public let product: SKProduct
public let transaction: PaymentTransaction
public let needsFinishTransaction: Bool
}

//Conform to this protocol to provide custom receipt validator
public protocol ReceiptValidator {
func validate(receipt: String, password autoRenewPassword: String?, completion: @escaping (VerifyReceiptResult) -> Void)
Expand All @@ -58,7 +66,7 @@ public struct RetrieveResults {

// Purchase result
public enum PurchaseResult {
case success(purchase: Purchase)
case success(purchase: PurchaseDetails)
case error(error: SKError)
}

Expand Down