Skip to main content

Step 3: Use WebViewPaymentViewController Directly

If you need more control over presentation, use WebViewPaymentViewController directly instead of WePaySDK.openCheckoutUrl().


Presenting the View Controller​

import WePaySDK

let webVC = WebViewPaymentViewController(checkoutUrl: checkoutUrl)
let nav = UINavigationController(rootViewController: webVC)
nav.modalPresentationStyle = .fullScreen
present(nav, animated: true)

When to Use This Approach​

ScenarioRecommended Approach
Simple integration, default behaviorWePaySDK.openCheckoutUrl()
Custom navigation controller configurationWebViewPaymentViewController directly
Custom presentation style (e.g., sheet, formSheet)WebViewPaymentViewController directly
Need to set a delegate or observe dismissalWebViewPaymentViewController directly
Embedding in a container view controllerWebViewPaymentViewController directly

Handling Dismissal​

You can use presentationController(_:didDismiss:) or a custom delegate on the view controller to detect when the user dismisses the checkout:

import WePaySDK

class ViewController: UIViewController {

func openWePayCheckout(checkoutUrl: String) {
let webVC = WebViewPaymentViewController(checkoutUrl: checkoutUrl)
let nav = UINavigationController(rootViewController: webVC)
nav.modalPresentationStyle = .fullScreen
nav.presentationController?.delegate = self
present(nav, animated: true)
}
}

extension ViewController: UIAdaptivePresentationControllerDelegate {
func presentationControllerDidDismiss(_ presentationController: UIPresentationController) {
// Checkout was dismissed — refresh order status
}
}

Next Step​

Proceed to Configuration for required Info.plist settings.