mas/MasKit/AppStore/SSPurchase.swift

33 lines
1.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
2016-09-17 12:58:38 +00:00
typealias SSPurchaseCompletion = (_ purchase: SSPurchase?, _ completed: Bool, _ error: Error?, _ response: SSPurchaseResponse?) -> ()
2015-08-24 18:45:54 +00:00
extension SSPurchase {
convenience init(adamId: UInt64, account: ISStoreAccount) {
self.init()
2016-09-15 00:40:55 +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
let downloadMetadata = SSDownloadMetadata()
downloadMetadata.kind = "software"
downloadMetadata.itemIdentifier = adamId
self.downloadMetadata = downloadMetadata
}
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
}
}