{"id":21878076,"url":"https://github.com/midtrans/midtrans-sample-snapwebview","last_synced_at":"2026-05-17T08:37:32.850Z","repository":{"id":47065896,"uuid":"406185196","full_name":"Midtrans/Midtrans-Sample-SnapWebView","owner":"Midtrans","description":null,"archived":false,"fork":false,"pushed_at":"2021-09-15T03:04:08.000Z","size":163,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-26T18:17:28.164Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Midtrans.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-14T01:36:35.000Z","updated_at":"2023-12-06T12:33:12.000Z","dependencies_parsed_at":"2022-09-04T22:22:27.197Z","dependency_job_id":null,"html_url":"https://github.com/Midtrans/Midtrans-Sample-SnapWebView","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Midtrans%2FMidtrans-Sample-SnapWebView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Midtrans%2FMidtrans-Sample-SnapWebView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Midtrans%2FMidtrans-Sample-SnapWebView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Midtrans%2FMidtrans-Sample-SnapWebView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Midtrans","download_url":"https://codeload.github.com/Midtrans/Midtrans-Sample-SnapWebView/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244885532,"owners_count":20526293,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-28T08:11:37.052Z","updated_at":"2026-05-17T08:37:27.820Z","avatar_url":"https://github.com/Midtrans.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"#Midtrans Sample SNAP in Android \u0026 iOS WebView/WKWebView\n\nif your mobile app is using WebView to display Snap, this is sample project that you can use to try open Snap using webview. \nYou can try the demo apps from our [simulator](https://sample-demo-dot-midtrans-support-tools.et.r.appspot.com/snap-webview)\n\nYou need to make sure the app follows the points given below.\n- Enable JavaScript capability for the WebView.\n- Allow WebView to open bank web domain. For Android,the app is available in Java.\n[Android Sample Code](https://github.com/Midtrans/Midtrans-Sample-SnapWebView/blob/main/Android/MidtransSnapWebView/app/src/main/java/com/midtrans/snapwebview/MyWebView.java#L40-L86)\n```java\n    @SuppressLint(\"SetJavaScriptEnabled\")\n    private void openUrlFromWebView(String url) {\n        WebView webView = findViewById(R.id.myWebView);\n        webView.setWebViewClient(new WebViewClient() {\n            final ProgressDialog pd = new ProgressDialog(MyWebView.this);\n            @Override\n            public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {\n                String requestUrl = request.getUrl().toString();\n                if (requestUrl.contains(\"gojek://\")\n                        || requestUrl.contains(\"shopeeid://\")\n                        || requestUrl.contains(\"//wsa.wallet.airpay.co.id/\")\n\n                        // This is handle for sandbox Simulator\n                        || requestUrl.contains(\"/gopay/partner/\")\n                        || requestUrl.contains(\"/shopeepay/\")) {\n\n                    final Intent intent = new Intent(Intent.ACTION_VIEW, request.getUrl());\n                    startActivity(intent);\n                    // `true` means for the specified url, will be handled by OS by starting Intent\n                    return true;\n                } else {\n                    // `false` means any other url will be loaded normally by the WebView\n                    return false;\n                }\n            }\n```\n\n- For iOS, the app is available in Swift [iOS Sample Code](https://github.com/Midtrans/Midtrans-Sample-SnapWebView/blob/main/iOS/midtrans-snap-WebView-sample/MyWebViewController.swift#L38-L54)\n```swift\n    // WKWebView Configuration\n    func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -\u003e Void) {\n        let url = navigationAction.request.url\n        \n        // detect these specified deeplinks and e_money simulator to be handled by OS\n        if url!.absoluteString.hasPrefix(\"https://simulator.sandbox.midtrans.com/gopay/partner/\")\n            || url!.absoluteString.hasPrefix(\"https://simulator.sandbox.midtrans.com/shopeepay/\")\n            || url!.absoluteString.hasPrefix(\"shopeeid://\")\n            || url!.absoluteString.hasPrefix(\"gojek://\")\n            || url!.absoluteString.hasPrefix(\"//wsa.wallet.airpay.co.id/\") {\n            decisionHandler(.cancel)\n            UIApplication.shared.open(url!)\n            \n        // any other url will be loaded normally by the WebView\n        } else {\n            decisionHandler(.allow)\n        }\n    }\n```\n\nA lot of payment methods within Snap, redirect the customer to the bank's website. Your mobile developer needs to ensure that the app allows WebView to open the bank's website domains. All domains needs to be whitelisted, as the customers can use any issuing bank credit card with any website domain.\nFor testing or on Sandbox environment, allow WebView to open Midtrans simulator domain: https://simulator.midtrans.com. Those configs may found on app config/manifest. Or specific code when calling WebView.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmidtrans%2Fmidtrans-sample-snapwebview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmidtrans%2Fmidtrans-sample-snapwebview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmidtrans%2Fmidtrans-sample-snapwebview/lists"}