Skip to content

Instantly share code, notes, and snippets.

@ren6
Created June 18, 2019 09:53
Show Gist options
  • Save ren6/643c22c62f0fd1b2a9e2dd39834e1af8 to your computer and use it in GitHub Desktop.
Save ren6/643c22c62f0fd1b2a9e2dd39834e1af8 to your computer and use it in GitHub Desktop.
func purchaseProduct(product : SKProduct, success: @escaping SuccessBlock, failure: @escaping FailureBlock){
guard SKPaymentQueue.canMakePayments() else {
return
}
guard SKPaymentQueue.default().transactions.last?.transactionState != .purchasing else {
return
}
self.successBlock = success
self.failureBlock = failure
let payment = SKPayment(product: product)
SKPaymentQueue.default().add(payment)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment