Skip to content

SetuHQ/cou-wl-ios

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Setu COU WL iOS App

A complete iOS WebView application with integrated payment gateway for Setu's COU WL (Customer Onboard Utility - White Label) solution.

Features

  • 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+

App Structure

Main Components

  • SetuCOUWLApp.swift - Main app entry point
  • ContentView.swift - Root view managing navigation between screens
  • URLInputView.swift - URL input screen (equivalent to Android MainActivity)
  • WebView.swift - WebView container with navigation controls
  • PaymentView.swift - Native payment interface (equivalent to Android PaymentScreen)
  • JSInterface.swift - JavaScript bridge for Setu integration
  • PaymentModel.swift - Data models and validation logic

Assets

  • test.html - Basic WebView functionality test
  • payment_test.html - Payment integration test page
  • Assets.xcassets - App icons and colors
  • Info.plist - App configuration and permissions

How to Build

  1. Open SetuCOUWL.xcodeproj in Xcode 15+
  2. Select your target device or simulator
  3. Build and run the app (⌘+R)

Requirements

  • iOS 15.0+ (Compatible with NavigationView)
  • Xcode 14.0+
  • Swift 5.0+

Payment Integration

The app includes full integration with Setu's payment gateway:

JavaScript Interface

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();

Payment Flow

  1. WebView calls initiatePayment() with payment details JSON
  2. App shows native payment screen with UPI/Card options
  3. User completes or cancels payment
  4. App returns to WebView with payment results in URL parameters

Payment Parameters

{
    "orderId": "ORDER123",
    "amount": "100.00",
    "postPaymentUrl": "https://example.com/callback",
    "customerMobileNumber": "9876543210",
    "customerId": "CUST123",  // optional
    "allowedPaymentModes": "UPI,DEBIT_CARD"  // optional
}

Callback Results

Success:

?paymentStatus=SUCCESS&transactionId=TXN_123&paymentMode=UPI&paymentDateTime=2024-01-01%2012:00:00

Failure/Cancel:

?paymentStatus=FAILURE

Usage

  1. Launch the Setu COU WL app
  2. Enter URL or use test URLs:
    • test.html - Basic WebView test
    • payment_test.html - Payment integration test
  3. Tap "Open Website" to load in WebView
  4. Test payments using the payment integration test page
  5. Navigate using back button or home button in WebView

Testing Payment Integration

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

Key Differences from Android Version

Architecture

  • SwiftUI instead of XML layouts
  • Swift instead of Java/Kotlin
  • iOS-native navigation and UI components

JavaScript Interface

  • Uses WKScriptMessageHandler instead of @JavascriptInterface
  • Provides both iOS and Android objects for compatibility
  • Automatic injection of JavaScript interface

Payment UI

  • Native SwiftUI payment forms
  • iOS-style navigation and alerts
  • SwiftUI state management

WebView Implementation

  • WKWebView with enhanced JavaScript injection
  • Automatic interface availability after page load
  • iOS-specific security and configuration

Network Security

The app allows arbitrary loads for development and testing. For production:

  1. Remove NSAllowsArbitraryLoads from Info.plist
  2. Add specific domain exceptions in NSAppTransportSecurity
  3. Ensure all URLs use HTTPS

File Structure

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

Compatibility

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published