Swift
Lightweight Fiuu Mobile XDK for native Swift iOS applications.
Repository: Mobile-XDK-Fiuu_Swift
Current native SDK: FiuuXDKSwift 1.1.1 (releases)
Requirements
| Requirement | Version |
|---|---|
| iOS | 16.0+ |
| Swift | 5.0+ |
| Xcode | 14+ |
Installation
CocoaPods — add to your Podfile:
pod 'FiuuXDKSwift', :git => 'https://github.com/FiuuPayment/Mobile-XDK-Fiuu_Swift.git'
Or:
pod 'FiuuXDKSwift'
Swift Package Manager — add the repository URL in Xcode dependencies.
Basic Integration
let paymentDetails: [String: Any] = [
"mp_username": "",
"mp_password": "",
"mp_merchant_ID": "",
"mp_app_name": "",
"mp_verification_key": "",
"mp_order_ID": "order123",
"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": "bill email",
"mp_bill_mobile": "0123456789",
"mp_express_mode": false,
"mp_closebutton_display": true,
]
let vc = FiuuXDKController(with: paymentDetails)
let navController = UINavigationController(rootViewController: vc)
navController.modalPresentationStyle = .fullScreen
vc.startXDK { [weak self] result in
navController.dismiss(animated: true)
switch result {
case .success(let data):
print("RESULTS: \(data)")
case .failure:
print("ERROR!")
}
}
self.present(navController, animated: true)
Delegate Pattern
let vc = FiuuXDKController(with: paymentDetails)
vc.delegate = self
vc.startXDK()
extension ViewController: FiuuXDKControllerDelegate {
func didReceiveResults(_ results: Result<String, any Error>) {
navController?.dismiss(animated: true)
switch results {
case .success(let value):
resultLabel.text = "Success: \(value)"
case .failure(let error):
resultLabel.text = "\(error)"
}
}
func didFinishDeepLink() {
// Only for TNG eWallet — close manually
vc.closePayment()
}
}
SwiftUI Integration
Create a UIViewControllerRepresentable 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) {}
}
Use in SwiftUI:
.fullScreenCover(isPresented: $showVC) {
FiuuXDKWrapper { results in
showVC = false
switch results {
case .success(let data):
labelText = "RESULTS: \(data)"
case .failure:
labelText = "ERROR!"
}
}
}
Apple Pay
let paymentDetails: [String: Any] = [
"mp_channel": "ApplePay",
"mp_express_mode": true,
"mp_allowed_channels": ["ApplePay"],
"mp_ap_merchant_ID": "merchant.com.yourcompany.applepay",
// ... other mandatory parameters
]
See Apple Pay Configuration for full setup.
Environment Configuration
paymentDetails["mp_core_env"] = "4" // Sandbox
See Core Integration for all environment values.
Related Guides
- SwiftUI — Same
FiuuXDKSwiftSDK viaUIViewControllerRepresentable - Apple Pay Setup
- Deeplink Setup