Making a Purchase
Start a purchase by adding a payment to the queue, process the resulting transaction, and finish it.
Start the purchase
@MainActor func add(
_ payment: OnsidePayment,
completion: ((Result<Void, OnsidePaymentQueueAddProductError>) -> Void)?
)func buy(_ product: OnsideProduct) {
let payment = OnsidePayment(product: product)
Onside.defaultPaymentQueue().add(payment) { result in
if case .failure(let error) = result {
// Pre-flight failure, e.g. the user dismissed the login screen.
print("Couldn't start the purchase: \(error)") // .loginDiscarded
}
}
}Associating a purchase with your account system
Process the transaction
Next
Last updated
Was this helpful?