|
@@ -46,11 +46,11 @@ public class SwiftyStoreKit {
|
|
return productsInfoController.retrieveProductsInfo(productIds, completion: completion)
|
|
return productsInfoController.retrieveProductsInfo(productIds, completion: completion)
|
|
}
|
|
}
|
|
|
|
|
|
- fileprivate func purchaseProduct(_ productId: String, quantity: Int = 1, atomically: Bool = true, applicationUsername: String = "", completion: @escaping ( PurchaseResult) -> Void) {
|
|
|
|
|
|
+ fileprivate func purchaseProduct(_ productId: String, quantity: Int = 1, atomically: Bool = true, applicationUsername: String = "", simulatesAskToBuyInSandbox: Bool = false, completion: @escaping ( PurchaseResult) -> Void) {
|
|
|
|
|
|
retrieveProductsInfo(Set([productId])) { result -> Void in
|
|
retrieveProductsInfo(Set([productId])) { result -> Void in
|
|
if let product = result.retrievedProducts.first {
|
|
if let product = result.retrievedProducts.first {
|
|
- self.purchase(product: product, quantity: quantity, atomically: atomically, applicationUsername: applicationUsername, completion: completion)
|
|
|
|
|
|
+ self.purchase(product: product, quantity: quantity, atomically: atomically, applicationUsername: applicationUsername, simulatesAskToBuyInSandbox: simulatesAskToBuyInSandbox, completion: completion)
|
|
} else if let error = result.error {
|
|
} else if let error = result.error {
|
|
completion(.error(error: SKError(_nsError: error as NSError)))
|
|
completion(.error(error: SKError(_nsError: error as NSError)))
|
|
} else if let invalidProductId = result.invalidProductIDs.first {
|
|
} else if let invalidProductId = result.invalidProductIDs.first {
|
|
@@ -61,14 +61,14 @@ public class SwiftyStoreKit {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- fileprivate func purchase(product: SKProduct, quantity: Int, atomically: Bool, applicationUsername: String = "", completion: @escaping (PurchaseResult) -> Void) {
|
|
|
|
|
|
+ fileprivate func purchase(product: SKProduct, quantity: Int, atomically: Bool, applicationUsername: String = "", simulatesAskToBuyInSandbox: Bool = false, 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)))
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
- paymentQueueController.startPayment(Payment(product: product, quantity: quantity, atomically: atomically, applicationUsername: applicationUsername) { result in
|
|
|
|
|
|
+ paymentQueueController.startPayment(Payment(product: product, quantity: quantity, atomically: atomically, applicationUsername: applicationUsername, simulatesAskToBuyInSandbox: simulatesAskToBuyInSandbox) { result in
|
|
|
|
|
|
completion(self.processPurchaseResult(result))
|
|
completion(self.processPurchaseResult(result))
|
|
})
|
|
})
|
|
@@ -159,9 +159,9 @@ 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, quantity: Int = 1, atomically: Bool = true, applicationUsername: String = "", completion: @escaping (PurchaseResult) -> Void) {
|
|
|
|
|
|
+ public class func purchaseProduct(_ productId: String, quantity: Int = 1, atomically: Bool = true, applicationUsername: String = "", simulatesAskToBuyInSandbox: Bool = false, completion: @escaping (PurchaseResult) -> Void) {
|
|
|
|
|
|
- sharedInstance.purchaseProduct(productId, quantity: quantity, atomically: atomically, applicationUsername: applicationUsername, completion: completion)
|
|
|
|
|
|
+ sharedInstance.purchaseProduct(productId, quantity: quantity, atomically: atomically, applicationUsername: applicationUsername, simulatesAskToBuyInSandbox: simulatesAskToBuyInSandbox, completion: completion)
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -172,9 +172,9 @@ 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(_ product: SKProduct, quantity: Int = 1, atomically: Bool = true, applicationUsername: String = "", completion: @escaping ( PurchaseResult) -> Void) {
|
|
|
|
|
|
+ public class func purchaseProduct(_ product: SKProduct, quantity: Int = 1, atomically: Bool = true, applicationUsername: String = "", simulatesAskToBuyInSandbox: Bool = false, completion: @escaping ( PurchaseResult) -> Void) {
|
|
|
|
|
|
- sharedInstance.purchase(product: product, quantity: quantity, atomically: atomically, applicationUsername: applicationUsername, completion: completion)
|
|
|
|
|
|
+ sharedInstance.purchase(product: product, quantity: quantity, atomically: atomically, applicationUsername: applicationUsername, simulatesAskToBuyInSandbox: simulatesAskToBuyInSandbox, completion: completion)
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|