SwiftUI
Use the public FiuuXDKSwift SDK from Mobile-XDK-Fiuu_Swift inside a SwiftUI app via UIViewControllerRepresentable.
Repository: Mobile-XDK-Fiuu_Swift
Current native SDK: FiuuXDKSwift 1.1.1
Public SDK
There is no separate public SwiftUI repository. The Swift SDK includes a SwiftUI wrapper example. Do not link to unpublished or private GitHub repos.
Requirements
| Requirement | Version |
|---|---|
| iOS | 16.0+ |
| Swift | 5.0+ |
| Xcode | 14+ |
Installation
Add to your Podfile:
pod 'FiuuXDKSwift', :git => 'https://github.com/FiuuPayment/Mobile-XDK-Fiuu_Swift.git'
Or add the repository URL with Swift Package Manager in Xcode.
Then add these keys to Info.plist:
- App Transport Security Settings → Allow Arbitrary Loads →
YES - NSPhotoLibraryUsageDescription →
Payment images - NSPhotoLibraryAddUsageDescription →
Payment images
SwiftUI wrapper
struct FiuuXDKWrapper: UIViewControllerRepresentable {
typealias CompletionHandler = (Result<String, Error>) -> Void
var onResults: CompletionHandler
func makeUIViewController(context: Context) -> UINavigationController {
let formatter = DateFormatter()
formatter.dateFormat = "yyyyMMddkkmmss"
let orderId = formatter.string(from: Date())
let paymentDetails: [String: Any] = [
"mp_username": "",
"mp_password": "",
"mp_merchant_ID": "",
"mp_app_name": "",
"mp_verification_key": "",
"mp_order_ID": orderId,
"mp_currency": "MYR",
"mp_country": "MY",
"mp_amount": "1.01",
"mp_channel": "multi",
"mp_bill_description": "bill description",
"mp_bill_name": "bill name",
"mp_bill_email": "email@domain.com",
"mp_bill_mobile": "0123456789",
]
let vc = FiuuXDKController(with: paymentDetails)
vc.startXDK(completion: onResults,
onFinishDeepLink: { vc.closePayment() })
return UINavigationController(rootViewController: vc)
}
func updateUIViewController(_ uiViewController: UINavigationController, context: Context) {}
}
Present it with .fullScreenCover:
struct ContentView: View {
@State private var labelText = "Waiting for RESULTS..."
@State private var showVC = false
var body: some View {
VStack {
Text(labelText)
Button("START") { showVC = true }
}
.fullScreenCover(isPresented: $showVC) {
FiuuXDKWrapper { results in
showVC = false
switch results {
case .success(let data):
labelText = "RESULTS: \(data)"
case .failure:
labelText = "ERROR!"
}
}
}
}
}
onFinishDeepLink is required for Touch 'n Go eWallet so the host can close the XDK after redirection.
Apple Pay
Pass the same Apple Pay parameters as the Swift SDK:
"mp_channel": "ApplePay"
"mp_express_mode": true
"mp_allowed_channels": ["ApplePay"]
"mp_ap_merchant_ID": "merchant.com.yourcompany.applepay"
Payment Parameters
See Payment Parameters for the full list of mp_* parameters.
Related Guides
- Swift — UIKit
FiuuXDKControllerintegration - Apple Pay Setup
- Deeplink Setup
- Response Handling