Before reading this document, ensure you have completed the Integration Guide and are familiar with the APIs for creating a checkout.
The iOS SDK provided by PayKKa allows you to easily embed our Web Checkout via a WebView. By simply providing a sessionId to the SDK, you can open the checkout page within your app, accept payments, and customize payment callbacks. The latest SDK download link is available in the iOS SDK Release History.
After downloading the SDK, you will receive a .zip file with the following directory structure:
.
├── PayKKaCheckoutApp-iOS
│ ├── OcCheckoutDemo
│ │ ├── OcCheckoutDemo
│ │ └── OcCheckoutDemo.xcodeproj
│ ├── PayKKaCheckoutApp-iOS.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ ├── xcshareddata
│ │ └── xcuserdata
│ └── SwiftCheckoutDemo
│ ├── SwiftCheckoutDemo
│ ├── SwiftCheckoutDemo.xcodeproj
│ ├── SwiftCheckoutDemoTests
│ └── SwiftCheckoutDemoUITests
└── sdk
└── PayKKaCheckoutPayments.xcframework
├── Info.plist
├── ios-arm64
└── ios-arm64_x86_64-simulatorThe PayKKaCheckoutApp-iOS folder contains two Xcode projects for sample apps written in Objective-C and Swift, allowing developers to understand how to use the PayKKa SDK APIs through sample code.
The PayKKaCheckoutPayments.xcframework in the sdk folder at the root directory after extraction is the core PayKKa SDK.
To integrate the PayKKa SDK, simply follow these steps in Xcode: Project Navigator <Your Project> → TARGETS <Your Target> → Build Phases → Link Binary With Libraries → click the + icon → select Add Files... → choose <sdk/PayKKaCheckoutPayments.xcframework>.
Note: Under TARGETS <Your Target> → General → Frameworks, Libraries, and Embedded Content, ensure PayKKaCheckoutPayments.xcframework is set to Embed & Sign, as shown below:

Once the SDK is integrated, you can begin using the PayKKa Checkout in your app. Key code snippets are provided below; for full code and examples, refer to the source code of the PayKKaCheckoutApp-iOS Xcode projects included with the SDK.
import SwiftUI
/// Import the SDK
import PayKKaCheckoutPayments
struct ConfirmOrder: View {
@EnvironmentObject var router: NavigationRouter
/// Define a state variable to control the visibility of the WebViewSheet
@State private var showWebView = false
/// PayKKa Checkout sessionId, typically returned by the backend API, used to construct and display the checkout
private let sessionId: String
let price: Double = 1118.83;
var body: some View {
ScrollView {
...
}
/// Register the paykkaPaymentWKWebViewSheet component here to customize payment callbacks
.paykkaPaymentWKWebViewSheet(isPresented: $showWebView, sessionId: sessionId, onPaymentResultCallback: { paymentResult in
print("---->", paymentResult.toString())
switch paymentResult.status {
// Checkout payment successful
case .success:
router.redirect(to: .payment_complete(extraData: ["paymentResult": paymentResult]))
// Checkout session expired
case .expired:
router.redirect(to: .payment_complete(extraData: ["paymentResult": paymentResult]))
print("onExpired: \(paymentResult.toString())")
default:
print("Unhandled payment status: \(paymentResult.status)")
}
})
.navigationTitle("Confirm Order")
.navigationBarTitleDisplayMode(.inline)
HStack {
Button {
/// Tap button to show WebViewSheet
showWebView = true
} label: {
...
}
}
...
}
init(showWebView: Bool = false, sessionId: String) {
/// Initialize the PayKKa SDK environment configuration here...
PayKKa.use(.sandbox)
self.showWebView = showWebView
self.sessionId = sessionId
}
}
...You can use test cards in the PayKKa SANDBOX environment for testing. Switch to the PROD environment when building the release version of your app.
/// SANDBOX (default)
PayKKa.use(.sandbox)
/// Switch to European production environment
PayKKa.use(.prod_EU)
/// Switch to Hong Kong production environment
PayKKa.use(.prod_HK)You need to log in to App Store Connect, create a sandbox account using an email address, then log in with this sandbox account on your iOS device. Link a sandbox test card for Apple Pay to conduct payment testing. The complete configuration guide can be found in Apple's official documentation: Apple Pay Sandbox Testing.
More documentation on the checkout can be found here: Payment Method - Apple Pay