PaymentQueueSpy.swift 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // PaymentQueueSpy.swift
  3. // SwiftyStoreKit
  4. //
  5. // Created by Andrea Bizzotto on 17/01/2017.
  6. // Copyright © 2017 musevisions. All rights reserved.
  7. //
  8. import SwiftyStoreKit
  9. import StoreKit
  10. class PaymentQueueSpy: PaymentQueue {
  11. weak var observer: SKPaymentTransactionObserver?
  12. var payments: [SKPayment] = []
  13. var restoreCompletedTransactionCalledCount = 0
  14. var finishTransactionCalledCount = 0
  15. func add(_ observer: SKPaymentTransactionObserver) {
  16. self.observer = observer
  17. }
  18. func remove(_ observer: SKPaymentTransactionObserver) {
  19. if self.observer === observer {
  20. self.observer = nil
  21. }
  22. }
  23. func add(_ payment: SKPayment) {
  24. payments.append(payment)
  25. }
  26. func restoreCompletedTransactions(withApplicationUsername username: String?) {
  27. restoreCompletedTransactionCalledCount += 1
  28. }
  29. func finishTransaction(_ transaction: SKPaymentTransaction) {
  30. finishTransactionCalledCount += 1
  31. }
  32. func start(_ downloads: [SKDownload]) {
  33. }
  34. func pause(_ downloads: [SKDownload]) {
  35. }
  36. func resume(_ downloads: [SKDownload]) {
  37. }
  38. func cancel(_ downloads: [SKDownload]) {
  39. }
  40. }