Link/iOS
iOS SDK
CoverPaySDK presents CoverPay's checkout in a sheet. Your server creates the link token; the app opens Link with it and sends the public token back to your server.
Install
Swift Package Manager: add the CoverPay iOS SDK package and the CoverPaySDK product to your app target (iOS 14+).
UIKit
import CoverPaySDK
CoverPayLink.open(linkToken: linkToken, from: self) { result in
switch result {
case .success(let payment):
// payment.publicToken → your server → POST /v1/link/public_token/exchange
// nil only if the provider approved but CoverPay hadn't confirmed yet: rely on your webhook.
api.completeOrder(publicToken: payment.publicToken, orderId: orderId)
case .failure(.userCancelled):
break
case .failure(let error):
showError(error.localizedDescription)
}
}SwiftUI
@State private var showCheckout = false
@State private var linkToken = ""
Button("Pay later") {
Task {
linkToken = try await api.createLinkToken(productId: product.id)
showCheckout = true
}
}
.coverPayLink(isPresented: $showCheckout, linkToken: linkToken) { result in
// same result as UIKit
}Result
| Field | Description |
|---|---|
publicToken | Exchange it on your server. Single business, 30 minutes, safe to exchange again. |
provider | klarna, affirm, afterpay, zip or coverpay. |
sessionId | CoverPay payment id. |
status | succeeded, requires_capture or processing. |
Behaviour
The completion runs exactly once. Swiping the sheet down counts as a cancel. The token's environment must match
CoverPayLink.setup(...) if you call it. open(params:) (amount from the app) is deprecated and sandbox-only.