Displaying the payment page in a web view

Once the request is processed, the payment gateway returns the payment URL to the mobile application.

The application initializes a webview and displays a payment page.

Exerpt of code sample for Android (Kotlin)
val webView = WebView(this)
				
// Url loading
webView.loadUrl(url)
	
// Enable javascript
webView.settings.javaScriptEnabled = true
	
// To allow debug WebView from Chrome Dev Tools
WebView.setWebContentsDebuggingEnabled(false)
	
// Define new web view client by overriding shouldOverrideUrlLoading method in order to check urls
webView.webViewClient = object: WebViewClient() {
	override fun onPageFinished(view: WebView, url: String) {
		progressBar.visibility = View.GONE
		super.onPageFinished(view, url)
	}
	
	@Suppress("OverridingDeprecatedMember")
	override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
		return checkUrl(webView, url)
	}
	
	@TargetApi(Build.VERSION_CODES.LOLLIPOP)
	override fun shouldOverrideUrlLoading(view: WebView, webResourceRequest: WebResourceRequest): Boolean {
		return checkUrl(webView, webResourceRequest.url.toString())
	}
}
webView.canGoForward()			

Exerpt of code sample for iOS (Swift)
/// Call server to get payment url, supply a block completion (callback)
///
/// - Returns: status boolean, payment url
func getPaymentContext(completion: @escaping (Bool, String, NSError?) -> ()){
	// Build request
	let urlRequest = buildRequest()
	// Call server to obtain a payment Url
	// Completion is a callback, giving call status, and payment url if success
	if let request = urlRequest{
		let task = URLSession.shared.dataTask(with: request) { (data: Data?, response: URLResponse?, error: Error?) in
			if error != nil{
				completion(false, "", NSError.init(domain:PayZenPayment.ERROR_DOMAIN, code: PayZenPayment.ERROR_NO_CONNECTION.errorCode, userInfo: [NSLocalizedFailureReasonErrorKey: PayZenPayment.ERROR_NO_CONNECTION.errorMsg]))
			}
			if let httpResponse = response as? HTTPURLResponse {
				let json = try? JSONSerialization.jsonObject(with: data!, options: .mutableContainers) as? NSDictionary
				var redirectionUrl = ""
				var errorMsg = ""
				if let jsonResponse = json {
					redirectionUrl = (jsonResponse!["redirectionUrl"] as? String)!
					errorMsg = (jsonResponse!["errorMessage"] as? String)!
				}
				switch(httpResponse.statusCode){
					case 200:
						completion(true, redirectionUrl, nil)
					case 400, 500:
						completion(false, "", NSError.init(domain:PayZenPayment.ERROR_DOMAIN, code: PayZenPayment.ERROR_SERVER.errorCode, userInfo: [NSLocalizedFailureReasonErrorKey: PayZenPayment.ERROR_SERVER.errorMsg + errorMsg]) )
					default:
						completion(false, "", NSError.init(domain:PayZenPayment.ERROR_DOMAIN, code: PayZenPayment.ERROR_UNKNOW.errorCode, userInfo: [NSLocalizedFailureReasonErrorKey: PayZenPayment.ERROR_UNKNOW.errorMsg]))
				}
			}
			else{
				completion(false, "", NSError.init(domain:PayZenPayment.ERROR_DOMAIN, code: PayZenPayment.ERROR_TIMEOUT.errorCode, userInfo: [NSLocalizedFailureReasonErrorKey: PayZenPayment.ERROR_TIMEOUT.errorMsg]))
			}
	}
	task.resume()
	} else{
		completion(false, "", NSError.init(domain:PayZenPayment.ERROR_DOMAIN, code: PayZenPayment.ERROR_UNKNOW.errorCode, userInfo: [NSLocalizedFailureReasonErrorKey: PayZenPayment.ERROR_UNKNOW.errorMsg]))
	}
}