|
@@ -41,16 +41,16 @@ public class SwiftyStoreKit {
|
|
|
|
|
|
// MARK: Internal methods
|
|
// MARK: Internal methods
|
|
|
|
|
|
- func retrieveProductsInfo(_ productIds: Set<String>, completion: @escaping (RetrieveResults) -> ()) {
|
|
|
|
|
|
+ func retrieveProductsInfo(_ productIds: Set<String>, completion: @escaping (RetrieveResults) -> Void) {
|
|
return productsInfoController.retrieveProductsInfo(productIds, completion: completion)
|
|
return productsInfoController.retrieveProductsInfo(productIds, completion: completion)
|
|
}
|
|
}
|
|
|
|
|
|
- func purchaseProduct(_ productId: String, atomically: Bool = true, applicationUsername: String = "", completion: @escaping ( PurchaseResult) -> ()) {
|
|
|
|
|
|
+ func purchaseProduct(_ productId: String, atomically: Bool = true, applicationUsername: String = "", completion: @escaping ( PurchaseResult) -> Void) {
|
|
|
|
|
|
if let product = productsInfoController.products[productId] {
|
|
if let product = productsInfoController.products[productId] {
|
|
purchase(product: product, atomically: atomically, applicationUsername: applicationUsername, completion: completion)
|
|
purchase(product: product, atomically: atomically, applicationUsername: applicationUsername, completion: completion)
|
|
} else {
|
|
} else {
|
|
- retrieveProductsInfo(Set([productId])) { result -> () in
|
|
|
|
|
|
+ retrieveProductsInfo(Set([productId])) { result -> Void in
|
|
if let product = result.retrievedProducts.first {
|
|
if let product = result.retrievedProducts.first {
|
|
self.purchase(product: product, atomically: atomically, applicationUsername: applicationUsername, completion: completion)
|
|
self.purchase(product: product, atomically: atomically, applicationUsername: applicationUsername, completion: completion)
|
|
} else if let error = result.error {
|
|
} else if let error = result.error {
|
|
@@ -64,7 +64,7 @@ public class SwiftyStoreKit {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- func restorePurchases(atomically: Bool = true, applicationUsername: String = "", completion: @escaping (RestoreResults) -> ()) {
|
|
|
|
|
|
+ func restorePurchases(atomically: Bool = true, applicationUsername: String = "", completion: @escaping (RestoreResults) -> Void) {
|
|
|
|
|
|
paymentQueueController.restorePurchases(RestorePurchases(atomically: atomically, applicationUsername: applicationUsername) { results in
|
|
paymentQueueController.restorePurchases(RestorePurchases(atomically: atomically, applicationUsername: applicationUsername) { results in
|
|
|
|
|
|
@@ -73,7 +73,7 @@ public class SwiftyStoreKit {
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
- func completeTransactions(atomically: Bool = true, completion: @escaping ([Product]) -> ()) {
|
|
|
|
|
|
+ func completeTransactions(atomically: Bool = true, completion: @escaping ([Product]) -> Void) {
|
|
|
|
|
|
paymentQueueController.completeTransactions(CompleteTransactions(atomically: atomically, callback: completion))
|
|
paymentQueueController.completeTransactions(CompleteTransactions(atomically: atomically, callback: completion))
|
|
}
|
|
}
|
|
@@ -83,7 +83,7 @@ public class SwiftyStoreKit {
|
|
paymentQueueController.finishTransaction(transaction)
|
|
paymentQueueController.finishTransaction(transaction)
|
|
}
|
|
}
|
|
|
|
|
|
- func refreshReceipt(_ receiptProperties: [String : Any]? = nil, completion: @escaping (RefreshReceiptResult) -> ()) {
|
|
|
|
|
|
+ func refreshReceipt(_ receiptProperties: [String : Any]? = nil, completion: @escaping (RefreshReceiptResult) -> Void) {
|
|
receiptRefreshRequest = InAppReceiptRefreshRequest.refresh(receiptProperties) { result in
|
|
receiptRefreshRequest = InAppReceiptRefreshRequest.refresh(receiptProperties) { result in
|
|
|
|
|
|
self.receiptRefreshRequest = nil
|
|
self.receiptRefreshRequest = nil
|
|
@@ -102,7 +102,7 @@ public class SwiftyStoreKit {
|
|
}
|
|
}
|
|
|
|
|
|
// MARK: private methods
|
|
// MARK: private methods
|
|
- private func purchase(product: SKProduct, atomically: Bool, applicationUsername: String = "", completion: @escaping (PurchaseResult) -> ()) {
|
|
|
|
|
|
+ private func purchase(product: SKProduct, atomically: Bool, applicationUsername: String = "", completion: @escaping (PurchaseResult) -> Void) {
|
|
guard SwiftyStoreKit.canMakePayments else {
|
|
guard SwiftyStoreKit.canMakePayments else {
|
|
let error = NSError(domain: SKErrorDomain, code: SKError.paymentNotAllowed.rawValue, userInfo: nil)
|
|
let error = NSError(domain: SKErrorDomain, code: SKError.paymentNotAllowed.rawValue, userInfo: nil)
|
|
completion(.error(error: SKError(_nsError: error)))
|
|
completion(.error(error: SKError(_nsError: error)))
|
|
@@ -159,7 +159,7 @@ extension SwiftyStoreKit {
|
|
return SKPaymentQueue.canMakePayments()
|
|
return SKPaymentQueue.canMakePayments()
|
|
}
|
|
}
|
|
|
|
|
|
- public class func retrieveProductsInfo(_ productIds: Set<String>, completion: @escaping (RetrieveResults) -> ()) {
|
|
|
|
|
|
+ public class func retrieveProductsInfo(_ productIds: Set<String>, completion: @escaping (RetrieveResults) -> Void) {
|
|
|
|
|
|
return sharedInstance.retrieveProductsInfo(productIds, completion: completion)
|
|
return sharedInstance.retrieveProductsInfo(productIds, completion: completion)
|
|
}
|
|
}
|
|
@@ -171,29 +171,28 @@ extension SwiftyStoreKit {
|
|
* - Parameter applicationUsername: an opaque identifier for the user’s account on your system
|
|
* - Parameter applicationUsername: an opaque identifier for the user’s account on your system
|
|
* - Parameter completion: handler for result
|
|
* - Parameter completion: handler for result
|
|
*/
|
|
*/
|
|
- public class func purchaseProduct(_ productId: String, atomically: Bool = true, applicationUsername: String = "", completion: @escaping ( PurchaseResult) -> ()) {
|
|
|
|
|
|
+ public class func purchaseProduct(_ productId: String, atomically: Bool = true, applicationUsername: String = "", completion: @escaping ( PurchaseResult) -> Void) {
|
|
|
|
|
|
sharedInstance.purchaseProduct(productId, atomically: atomically, applicationUsername: applicationUsername, completion: completion)
|
|
sharedInstance.purchaseProduct(productId, atomically: atomically, applicationUsername: applicationUsername, completion: completion)
|
|
}
|
|
}
|
|
|
|
|
|
- public class func restorePurchases(atomically: Bool = true, applicationUsername: String = "", completion: @escaping (RestoreResults) -> ()) {
|
|
|
|
|
|
+ public class func restorePurchases(atomically: Bool = true, applicationUsername: String = "", completion: @escaping (RestoreResults) -> Void) {
|
|
|
|
|
|
sharedInstance.restorePurchases(atomically: atomically, applicationUsername: applicationUsername, completion: completion)
|
|
sharedInstance.restorePurchases(atomically: atomically, applicationUsername: applicationUsername, completion: completion)
|
|
}
|
|
}
|
|
|
|
|
|
- public class func completeTransactions(atomically: Bool = true, completion: @escaping ([Product]) -> ()) {
|
|
|
|
|
|
+ public class func completeTransactions(atomically: Bool = true, completion: @escaping ([Product]) -> Void) {
|
|
|
|
|
|
sharedInstance.completeTransactions(atomically: atomically, completion: completion)
|
|
sharedInstance.completeTransactions(atomically: atomically, completion: completion)
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
public class func finishTransaction(_ transaction: PaymentTransaction) {
|
|
public class func finishTransaction(_ transaction: PaymentTransaction) {
|
|
|
|
|
|
sharedInstance.finishTransaction(transaction)
|
|
sharedInstance.finishTransaction(transaction)
|
|
}
|
|
}
|
|
|
|
|
|
// After verifying receive and have `ReceiptError.NoReceiptData`, refresh receipt using this method
|
|
// After verifying receive and have `ReceiptError.NoReceiptData`, refresh receipt using this method
|
|
- public class func refreshReceipt(_ receiptProperties: [String : Any]? = nil, completion: @escaping (RefreshReceiptResult) -> ()) {
|
|
|
|
|
|
+ public class func refreshReceipt(_ receiptProperties: [String : Any]? = nil, completion: @escaping (RefreshReceiptResult) -> Void) {
|
|
|
|
|
|
sharedInstance.refreshReceipt(receiptProperties, completion: completion)
|
|
sharedInstance.refreshReceipt(receiptProperties, completion: completion)
|
|
}
|
|
}
|
|
@@ -219,7 +218,7 @@ extension SwiftyStoreKit {
|
|
public class func verifyReceipt(
|
|
public class func verifyReceipt(
|
|
using validator: ReceiptValidator,
|
|
using validator: ReceiptValidator,
|
|
password: String? = nil,
|
|
password: String? = nil,
|
|
- completion:@escaping (VerifyReceiptResult) -> ()) {
|
|
|
|
|
|
+ completion:@escaping (VerifyReceiptResult) -> Void) {
|
|
|
|
|
|
InAppReceipt.verify(using: validator, password: password) { result in
|
|
InAppReceipt.verify(using: validator, password: password) { result in
|
|
|
|
|