The SDK provides access to the Proton product catalog, subscriptions and Apple in-app purchase flows through StoreKit.
- iOS 17.0+ or macOS 14.0+
- Swift 6.2+
Add the Swift package dependency, replacing <version> with a published release
tag:
dependencies: [
.package(
url: "https://github.com/ProtonMail/payment-apple-sdk.git",
exact: "<version>"
)
],
targets: [
.target(
name: "YourApp",
dependencies: [
.product(name: "Payment", package: "payment-apple-sdk"),
.product(name: "PaymentUI", package: "payment-apple-sdk")
]
)
]Payment provides the SDK API. PaymentUI is optional and provides SwiftUI
components, including SubscriptionManagementView.
The SDK uses your application's HTTP client through HTTPCapability. Implement
its get(endpoint:) and post(endpoint:body:) methods. Return an HTTPResponse
with the status code and JSON body for HTTP responses, including error statuses;
throw only when no HTTP response was received.
Initialize the SDK once at app launch and retain the returned instance for the app's lifetime:
import Payment
let payments = Payments.initialize(httpCapability: httpCapability)Here, httpCapability is your implementation of HTTPCapability. Use
payments.products, payments.purchase and payments.subscriptions to access
the catalog, purchases and subscriptions.