A complete iOS WebView application with integrated payment gateway for Setu's COU WL (Customer Onboard Utility - White Label) solution.
- URL Input Screen: Clean interface to enter website URLs with validation
- WebView Integration: Full-featured WebView with JavaScript bridge for payments
- Payment Gateway: Native iOS payment screen with UPI and Card options
- JavaScript Interface: Seamless communication between WebView and native code
- Test Pages: Built-in HTML pages for testing WebView and payment integration
- Modern SwiftUI: Built entirely with SwiftUI for iOS 15+
SetuCOUWLApp.swift- Main app entry pointContentView.swift- Root view managing navigation between screensURLInputView.swift- URL input screen (equivalent to Android MainActivity)WebView.swift- WebView container with navigation controlsPaymentView.swift- Native payment interface (equivalent to Android PaymentScreen)JSInterface.swift- JavaScript bridge for Setu integrationPaymentModel.swift- Data models and validation logic
test.html- Basic WebView functionality testpayment_test.html- Payment integration test pageAssets.xcassets- App icons and colorsInfo.plist- App configuration and permissions
- Open
SetuCOUWL.xcodeprojin Xcode 15+ - Select your target device or simulator
- Build and run the app (⌘+R)
- iOS 15.0+ (Compatible with NavigationView)
- Xcode 14.0+
- Swift 5.0+
The app includes full integration with Setu's payment gateway:
The app provides both iOS and Android objects for compatibility:
// Initiate payment
iOS.initiatePayment(paymentDetailsJson);
// or for Android compatibility
Android.initiatePayment(paymentDetailsJson);
// Unload/go back to home
iOS.unload();
// or
Android.unload();- WebView calls
initiatePayment()with payment details JSON - App shows native payment screen with UPI/Card options
- User completes or cancels payment
- App returns to WebView with payment results in URL parameters
{
"orderId": "ORDER123",
"amount": "100.00",
"postPaymentUrl": "https://example.com/callback",
"customerMobileNumber": "9876543210",
"customerId": "CUST123", // optional
"allowedPaymentModes": "UPI,DEBIT_CARD" // optional
}Success:
?paymentStatus=SUCCESS&transactionId=TXN_123&paymentMode=UPI&paymentDateTime=2024-01-01%2012:00:00
Failure/Cancel:
?paymentStatus=FAILURE
- Launch the Setu COU WL app
- Enter URL or use test URLs:
test.html- Basic WebView testpayment_test.html- Payment integration test
- Tap "Open Website" to load in WebView
- Test payments using the payment integration test page
- Navigate using back button or home button in WebView
Use the built-in test page: payment_test.html
- ✅ Interface Detection: Verifies iOS/Android interface availability
- 🔧 Payment Configuration: Customize order details and payment modes
- 💰 Payment Testing: Test complete payment flow
- 📋 Result Verification: View callback results after payment
- SwiftUI instead of XML layouts
- Swift instead of Java/Kotlin
- iOS-native navigation and UI components
- Uses
WKScriptMessageHandlerinstead of@JavascriptInterface - Provides both
iOSandAndroidobjects for compatibility - Automatic injection of JavaScript interface
- Native SwiftUI payment forms
- iOS-style navigation and alerts
- SwiftUI state management
WKWebViewwith enhanced JavaScript injection- Automatic interface availability after page load
- iOS-specific security and configuration
The app allows arbitrary loads for development and testing. For production:
- Remove
NSAllowsArbitraryLoadsfrom Info.plist - Add specific domain exceptions in
NSAppTransportSecurity - Ensure all URLs use HTTPS
SetuCOUWL/
├── SetuCOUWL.xcodeproj/ # Xcode project file
└── SetuCOUWL/ # Source code
├── SetuCOUWLApp.swift # App entry point
├── ContentView.swift # Root navigation
├── URLInputView.swift # URL input screen
├── WebView.swift # WebView container
├── PaymentView.swift # Payment interface
├── JSInterface.swift # JavaScript bridge
├── PaymentModel.swift # Data models
├── test.html # WebView test page
├── payment_test.html # Payment test page
├── Info.plist # App configuration
├── Assets.xcassets/ # App assets
└── Preview Content/ # SwiftUI previews
This iOS app provides full feature parity with the Android version:
| Feature | Android | iOS |
|---|---|---|
| URL Input | ✅ MainActivity | ✅ URLInputView |
| WebView | ✅ WebViewActivity | ✅ WebView |
| Payment Screen | ✅ PaymentScreen | ✅ PaymentView |
| JS Interface | ✅ WebAppInterface | ✅ JSInterface |
| Test Pages | ✅ Assets | ✅ Bundle Resources |
| Payment Integration | ✅ Full Support | ✅ Full Support |
Built for Setu COU WL - Customer Onboard Utility White Label Solution