mas/MasKit/AppStore/SSPurchase.swift

35 lines
1 KiB
Swift
Raw Normal View History

2015-08-24 18:45:54 +00:00
//
// SSPurchase.swift
// mas-cli
//
// Created by Andrew Naylor on 25/08/2015.
// Copyright (c) 2015 Andrew Naylor. All rights reserved.
//
2018-10-14 19:41:19 +00:00
import CommerceKit
import StoreFoundation
2019-01-12 01:06:02 +00:00
typealias SSPurchaseCompletion =
(_ purchase: SSPurchase?, _ completed: Bool, _ error: Error?, _ response: SSPurchaseResponse?) -> Void
2015-08-24 18:45:54 +00:00
extension SSPurchase {
convenience init(adamId: UInt64, account: ISStoreAccount) {
self.init()
2019-01-12 01:06:02 +00:00
self.buyParameters =
"productType=C&price=0&salableAdamId=\(adamId)&pricingParameters=STDRDL&pg=default&appExtVrsId=0"
2015-08-24 18:45:54 +00:00
self.itemIdentifier = adamId
self.accountIdentifier = account.dsID
self.appleID = account.identifier
2019-01-12 01:06:02 +00:00
2015-08-24 18:45:54 +00:00
let downloadMetadata = SSDownloadMetadata()
downloadMetadata.kind = "software"
downloadMetadata.itemIdentifier = adamId
2019-01-12 01:06:02 +00:00
2015-08-24 18:45:54 +00:00
self.downloadMetadata = downloadMetadata
}
2019-01-12 01:06:02 +00:00
2016-09-17 12:58:38 +00:00
func perform(_ completion: @escaping SSPurchaseCompletion) {
CKPurchaseController.shared().perform(self, withOptions: 0, completionHandler: completion)
2015-08-24 18:45:54 +00:00
}
}