# Best practices for configuring the redirection URL

> Best practices for configuring and handling redirection URLs returned by the pay API across different client types.

After you call the [**pay**](pay) API, a different type of redirection URLs is returned in the API response depending on the payment method used to proceed with the payment process. This article provides you with best practices for using redirection URLs corresponding to different client types. For more details about redirection URLs returned for each payment method, see the [URLs returned for payment methods](urls).

# Redirection URL parameters

For different merchant client types (Web, WAP, App), different payment methods will return part or all of the following three types of redirection URLs in the response of the **pay** API to proceed with the payment process.

> **Notes**:
>
> -   When using the above links to initiate a payment, an exception may occur during the redirection if the buyer does not have the payment method app installed. Handle the exception properly if any.
> -   The URLs returned by some payment methods cannot be used multiple times. If the payment page failed to be invoked using the URL, we recommend that you use a new _paymentRequestId_ value to obtain the URL and reinvoke the payment page.
> -   In addition to the URL redirection method, the [**pay**](pay) API response may include the _orderCodeForm_ field for certain payment methods. This field value contains QR code or payment code information, which can be used to display the code on your website. This allows for a seamless payment process within your website. For more information on this solution, see the [Best practices for pre-front solution](pre-front_solution).

# Web

For payments on a computer website, _normalUrl_ is returned in the **pay** API response.

## Open the URL

After obtaining the _normalUrl_ value, you need to redirect the buyer to the payment page using the redirection URL. We recommend that you open the URL in a new tab to guide the buyer to complete the payment. The code for opening a new page is as follows:

```javascript
if (serverResponse.normalUrl != null) {
    window.open(serverResponse.normalUrl, '_blank');
}
```

## User experience

The payment page rendered using _normalUrl_ can be a QR code-scanning page or a login page. The following diagram shows the payment process in the two cases:

| **QR Code-scanning page** | ![image.png](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/1703501964166-3030185a-f3a2-4756-9242-eec39cfc3842.png) |
| --- | --- |
| **Login page** | ![image.png](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/1703501982572-ae440e0d-9688-41d2-816c-da6033b717f7.png) |

# WAP

For payments on a mobile website, the response of the **pay** API may contain one or more of the following URLs:

-   _normalUrl_
-   _applinkUrl_
-   _schemeUrl_

## Choose a URL

If the **pay** API response only contains one of the three URLs, use the received URL directly as the redirection link. If you receive multiple URLs, we recommend that you choose the URL based on the following instruction:

-   For iOS system: prioritize using _applinkUrl_, then _schemeUrl_, and finally _normalUrl_.
-   For Android system: prioritize using _schemeUrl_, then _applinkUrl_, and finally _normalUrl_.

## Open the URL

To open the URL using JavaScript's redirection method, use the following code:

```javascript
window.location.href = URL;
```

## User Experience

| **Type** | **Payment experience** |
| --- | --- |
| normalUrl | The buyer is redirected from your mobile website page to the payment method's mobile website page. The content displayed to the buyer on the payment method's mobile webiste page depends on the payment method and can be divided into the following two types: - Login page: The subsequent payment process is completed within the payment method's mobile website page. ![image.png](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/1703502077454-843a7c8b-4e51-470e-b596-99f6ccbc7133.png) - Guide the buyer to click a button to launch the payment method app. The subsequent payment process is completed within the payment method app. ![image.png](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/1703502095168-ae9564b1-f760-410d-b550-fbfc66a9d768.png) - Display a payment code. The buyer copies the code and pays in a payment method app. ![image.png](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/1703502120283-d7ca3f8a-c999-4bac-a0d8-84f3f22e0fd1.png) - Display a QR code. The buyer scans the code and pays in a payment method app. ![image.png](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/1703502134022-e7ff850f-bc81-4c76-a79a-5ea29ce38d95.png) |
| applinkUrl | The subsequent payment process is automatically determined based on whether the buyer has installed the payment method app: - If the buyer has installed the payment method's app: the app is opened, and the buyer completes the payment process within the app. ![image.png](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/1703502161213-5fe7a72b-21ef-4211-a637-c6b29d0c53c1.png) - If the buyer has not installed the payment method's app: the mobile website page is opened, and the buyer continues the payment process according to the instructions on the mobile website page. This process is opened and rendered in the default browser. ![image.png](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/1703502179805-a44f97e2-9640-4a23-8ee5-539742bd3a6c.png) |
| schemeUrl | The payment experience depends on whether the buyer has installed the payment method app: - If the buyer has installed the payment method's app: the app is opened, and the buyer completes the payment process within the app. ![image.png](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/1703502214418-5a3facd8-a387-4c25-97f3-a8633942fe02.png) - If the buyer has not installed the payment method app: the app cannot be launched using this URL, and the buyer may stay on the current page without being able to proceed with the payment process. ![image.png](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/1703502226044-d0839f87-64f3-48b4-b4c5-37d2c3ad2162.png) |

# APP

For payments on a mobile application, the response of the [**pay**](pay) API may contain one or more of the following URLs:

-   _normalUrl_
-   _applinkUrl_
-   _schemeUrl_

> **Note**: For payments on a mobile application, in addition to the URL parameters used for redirection mentioned above, the response of the **pay** API also contains the _appIdentifier_ parameter. This parameter is the package name of the corresponding payment method app and is used to determine whether the payment method app is installed for app payment. It can also be used to avoid disambiguation dialogs on Android.

## Choose a URL

If the [**pay**](pay) API response only contains one of the three URLs, use the received URL directly as the redirection link. If you receive multiple URLs, we recommend that you choose the URL based on the following instruction:

-   For iOS system: prioritize using _applinkUrl_, then _schemeUrl_, and finally _normalUrl_.
-   For Android system: prioritize using _schemeUrl_, then _applinkUrl_, and finally _normalUrl_.

## Open a URL

For Android and iOS, open the redirection URL using the following methods:

| **iOS** | **Android** |
| --- | --- |
| - Redirect outside of the application: Call the iOS method to open the redirection URL. - Redirect within the application: - - Use WKWebView - Use WKWebView and JSBridge - Use SafariViewController - Depending on whether the payment method app is installed, open the redirection URL either outside of the application or within the application. | - Redirect outside of the application: Call the Android method to open the redirection URL. - Redirect within the application: - - Use WKWebView - Use WKWebView and JavascriptInterface - Use Custom Tabs plug-in - Depending on whether the payment method app is installed, open the redirection URL either outside of the application or within the application. |

### Pros and cons of each redirection method

Each redirection method has its pros and cons. We recommend that you choose the most suitable redirection method based on the operation system and integration scenario.

| **Redirection method** | **Redirection method** | **Description** | **Pros** | **Cons** |
| --- | --- | --- | --- | --- |
| Redirect outside of the application: Call the Android/iOS method to open the redirection URL. | Redirect outside of the application: Call the Android/iOS method to open the redirection URL. | **Antom recommends this method.** | Low integration costs. One-time integration suits all payment methods. | The payment process is not fully kept on your clients. |
| Redirect within the application | - WKWebView - WebView | WKWebView/WebView is a built-in control that can embed a web browser in an application. You can use it to load website links. | You can customize a better payment experience for buyers. Furthermore, you can achieve a seamless payment experience by redirecting buyers within the application, which means buyers do not leave your application and complete the subsequent payment process within your application. | Requires more development and testing efforts. |
| Redirect within the application | - WKWebView+JSBridge - WebView+JavascriptInterface | An upgrade solution based on WKWebView/WebView. After using JSBridge/JavascriptInterface, you can directly call Android/iOS methods to open the redirection URL in WebView. | Performance, scalability, and security is improved compared to WKWebView/WebView. Provides a customized payment experience for buyers. | Requires more development and testing efforts. |
| Redirect within the application | - SafariViewController - Custom Tabs | Provided by iOS/Android to open the redirection URL within the application. Has more comprehensive capabilities compared to WebView. | Can be integrated with the system browser, and share capabilities such as cookies with the system browser. The integration is relatively simple. | Does not support customizing payment experience. |
| Depending on whether the payment method app is installed, open the redirection URL either outside of the application or within the application. | Depending on whether the payment method app is installed, open the redirection URL either outside of the application or within the application. | Depending on whether the payment method app is installed, provide different redirection methods. | Provides a buyer-friendly payment experience. | Requires more development and testing efforts. |

### Code sample (iOS)

#### Method 1: Call the iOS method to open the redirection URL

The following code sample shows how to redirect buyers from your application to a payment method application using an iOS method in the iOS system.

```javascript
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 10.0) {
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:Url] options:@{} completionHandler:nil];
}else{
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:Url]];
}
```

#### Method 2: Open the redirection URL within the application

To open the redirection URL in your application, use the following URL types:

-   normalUrl
-   applinkUrl

> **Note**: Some payment methods do not support payment on a mobile website. Opening _normalUrl_ triggers invoking the corresponding payment method app via a redirection, while WKWebView intercepts the redirection. You need to use the `decidePolicyForNavigationAction` method of WKWebView and call the iOS method to open the redirection URL to achieve the redirection from your WKWebView to the payment method app.

##### Use WKWebView

The following code sample shows how to use WKWebView to load the payment method page within the iOS application:

```javascript
// Initialize webview configuration
WKWebViewConfiguration *configuration = [[WKWebViewConfiguration alloc]init];
// Initialize webView
WKWebView *webView = [[WKWebView alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height) configuration:configuration];
webView.navigationDelegate = self;
//Load the payment method URL
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:Url]]];
[self.view addSubview:self.webView];
```

The following code sample shows how to use the `decidePolicyForNavigationAction` method of WKWebView to achieve the redirection from your WKWebView to a payment method app:

```javascript
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler{
    // WKWebView intercepts the redirection by default. Enable the redirection in the following ways.
    // Operations such as opening Safari
    NSURL *url = navigationAction.request.URL;
    NSString *absoluteString = url.absoluteString;
    NSString *scheme = url.baseURL.scheme;

    DLog(@"navigationAction.request.URL.absoluteString=====> %@", absoluteString);
    if ([absoluteString isEqualToString:@"about:blank"]) {
        decisionHandler(WKNavigationActionPolicyCancel);
    }
    if (!([absoluteString containsString:@"https://"] || [absoluteString containsString:@"http://"])) {
        if ([absoluteString containsString:@"://"]) {
            NSString *urlHeader =  [absoluteString componentsSeparatedByString:@"://"][0];
            [MBProgressHUD showAutoMessage:[NSString stringWithFormat:@"Scheme\n%@://",urlHeader] toView:self.view];
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                [self openAppWithUrlStr:navigationAction.request.URL];
                decisionHandler(WKNavigationActionPolicyAllow);
            });
        }
    } else {
        decisionHandler(WKNavigationActionPolicyAllow);
    }
}
```

##### Use WKWebView and JSBridge

Using WKWebView and JSBridge optimizes the buyer's payment experience, while requiring strong development capabilities. Combining the use of JSBridge with opening URLs through WKWebView is beneficial for the project's maintenance and scalability, as well as improving performance and security. Using JSBridge can facilitate interaction between web pages and native applications, allowing WAP pages to directly call native methods of the app. The following code example demonstrates how to use JSBridge in WKWebView.

```javascript
[self.wkWebView evaluateJavaScript:bridge completionHandler:nil];
```

##### Use SFSafariViewController

SFSafariViewController supports opening and rendering _normalUrl_, _applinkUrl_, and _schemeUrl_. Compared to WebView, it has more comprehensive capabilities and a simpler integration. For how to use SFSafariViewController to open the redirection URL, see the [SFSafariViewController](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller) user guide. The following code sample demonstrates how to use SFSafariViewController.

```javascript
SFSafariViewController *safariVC = [[SFSafariViewController alloc] initWithURL:Url entersReaderIfAvailable:NO];
safariVC.delegate = self;
[self.navigationController presentViewController:safariVC animated:YES completion:nil];
```

#### Method 3: Handle the redirection according to whether the payment method app is installed

You must first determine whether the buyer has installed the payment method app, and then handle the opening method of the redirection URL accordingly. Perform the following steps:

1.  Add _LSApplicationQueriesSchemes_ to the configuration in _info.plist_. Note that there is a limit on the number of schemes in _info.plist_.
2.  Use the `canOpenURL` method to determine whether the payment method app is installed. See the following code:

```javascript
NSString *walletSchemeUrl = @"gcash://";

if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:walletSchemeUrl]]){
    // The payment method app is installed. Open the app directly.
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:Url] options:@{} completionHandler:nil];

    return YES;
} else {
    // The payment method app is not installed. We recommend that you load the mobile website in WebView.
    SFSafariViewController *safariVC = [[SFSafariViewController alloc] initWithURL:Url entersReaderIfAvailable:NO];
    safariVC.delegate = self;
    [self.navigationController presentViewController:safariVC animated:YES completion:nil];

    return NO;
}
```

### Code sample (Android)

#### Method 1: Call an Android method to open the redirection URL

The following code sample demonstrates how to open the redirection URL using an Android method to achieve the redirection from your application to a payment method application.

```javascript
try {
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(Url));
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    // use the startActivity function to redirect to the wallet app
    startActivity(intent);
} catch (Exception e) {
    e.printStackTrace();
}
```

Using this method may result in the appearance of a disambiguation dialog box.

**What is a disambiguation dialog box**

Android App Link requests authentication from Google servers when installing the app. If authentication fails, the Android App Link will become invalid, and a disambiguation dialog box will appear when the buyer tries to open the app through such a link. The buyer needs to manually select how to open the link.

| This image shows an example of a disambiguation dialog box that appears when a buyer clicks on an Android App Link. The user needs to manually select how to open the link: using Google Maps or Google Browser. | ![image.png](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/1703502410174-7056c9d2-403f-4627-97f6-3ee618407375.png) |
| --- | --- |

**Prevent the appearance of a disambiguation dialog box**

When a disambiguation dialog box appears, the buyer needs to manually select the way to open the application, which affects the payment success rate. Therefore, you need to prevent the appearance of a disambiguation dialog box by taking the following action as needed:

-   If the buyer has installed the payment method app, specify the package name of the payment method and open the URL of the payment method.
-   If the buyer has not installed the payment method app, use the sample code below to open the URL.


```javascript
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(applinkUrl));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//Specify the package name of the payment method
intent.setPackage(walletPackageName);
PackageManager packageManager = MainActivity.this.getPackageManager();
//Check whether there is an app that supports opening this link.
List<ResolveInfo> activities = packageManager.queryIntentActivities(intent, 0);
if (activities.size() <= 0) {
   //The payment method app is not installed. Initialize the Intent object. This link will be opened by the default Android method.
   intent = new Intent(Intent.ACTION_VIEW, Uri.parse(applinkUrl));
   intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
     startActivity(intent);
} else {
  //The payment method app is installed. Specify the package name of the payment method and open the payment method URL. The disambiguation dialog box will not appear.
     startActivity(intent);
}
```

> Note: The _packageName_ values of some payment methods are shown as follows:
>
> -   AlipayHK: hk.alipay.wallet
> -   GCash: com.globe.gcash.android
> -   TrueMoney: th.co.truemoney.wallet
> -   KakaoPay: com.kakao.talk
> -   Touch 'n Go: my.com.tngdigital.ewallet
> -   Dana: id.dana

#### Method 2: Open the redirection URL within the application

To open the redirection URL in your application, use WebView to load _normalUrl_ or _applinkUrl_ as a mobile website:

-   _normalUrl_
-   _applinkUrl_

> **Note**: Some payment methods do not support payment on a mobile website. Opening _normalUrl_ triggers invoking the corresponding payment method app via a redirection, while WKWebView intercepts the redirection. You need to use the `shouldOverrideUrlLoading` method of WKWebView and call the Android method to open the redirection URL to achieve the redirection from your WKWebView to the payment method app.

##### Use WebView

The following code sample demonstrates how to load the payment method page in WebView.

```javascript
WebView webView = findViewById(R.id.webview);
//Set webview
webView.setWebViewClient(new WebViewClient() {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
        view.loadUrl(request.getUrl().toString());
        return super.shouldOverrideUrlLoading(view, request);
    }});

WebSettings webSettings = webView.getSettings();
//Enable javascript
webSettings.setJavaScriptEnabled(true);
//Enable scaling
webSettings.setSupportZoom(true);
//Enable scaling controls (buttons)
webSettings.setBuiltInZoomControls(true);
//Webview has two cache modes. Cache is not used here.
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
//Allow JavaScript to open a new tab (false by default)
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
//Allow JavaScript to load local storage
webSettings.setDomStorageEnabled(true);
//WAP cache size (settings are not needed)
//webSettings.setAppCacheMaxSize(1024 * 1024 * 8);
//WAP cache path
String absolutePath = getApplicationContext().getCacheDir().getAbsolutePath();
//WAP cache size
webSettings.setAppCachePath(absolutePath);
//Set whether to allow WebView to access files (true by default)
webSettings.setAllowFileAccess(true);
//Allow WAP cache to be saved
webSettings.setAppCacheEnabled(true);
//In preview mode, if the page width exceeds the WebView display, scale down the page to fit WebView (false by default)
webSettings.setLoadWithOverviewMode(true);
//Support the viewport HTML meta tag
webSettings.setUseWideViewPort(true);
//Load the payment method URL
webView.loadUrl(Url);
```

Set WebViewClient for WebView, use the `WebViewClient.shouldOverrideUrlLoading` method to intercept the URL, and call the corresponding Android method. See the following code sample:

```javascript
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
    if (request.getUrl().toString().startsWith("http")) {
        view.loadUrl(request.getUrl().toString());
        return super.shouldOverrideUrlLoading(view, request);
    } else {
        view.onPause();
        view.stopLoading();
        try {
          Intent intent = Intent.parseUri(uri, Intent.URI_INTENT_SCHEME);
          intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          view.getContext().startActivity(intent);
        } catch (URISyntaxException e) {
          //Alert that this scheme is not supported
        }
        return false;
    }
}
```

> **Note**: If your application has an allowlist of applications that can be redirected to, configure the allowlist properly, consider compatibility issues with older versions, and reduce the number of application releases.

##### Use WebView and JavascriptInterface

Using this method will optimize the buyer's payment experience, while requiring strong development capabilities. We recommend that you use JavascriptInterface in WevView. Using JavascriptInterface can help facilitate bidirectional communication between the Android application and WebView, allowing a mobile webpage to directly call native methods of the app, making your application more flexible and powerful, and beneficial for the subsequent maintenance and improvement of the project. The following code sample demonstrates how to use JavascriptInterface in WebView.

1.  Declare JavascriptInterface in WebView

```javascript
@JavascriptInterface
    public void openActivity(String url) {
        //Add the code if needed
        try {
        Intent intent = Intent.parseUri(uri, Intent.URI_INTENT_SCHEME);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
    } catch (Exception e) {
        Toast.makeText(context, "App not installed", Toast.LENGTH_SHORT).show();
    }
}
```

2.  Add JavascripInterface to WebView

```javascript
mWebView.addJavascriptInterface(this, "bridge");
```

3.  Open the redirection URL using the following code

```javascript
window.bridge.openActivity("Url");
```

##### Use Custom Tabs

Custom Tabs supports opening and rendering _normalUrl_, _applinkUrl_, and _schemeUrl_. Compared to WebView, it has more comprehensive capabilities and a simpler integration. The following code sample demonstrates how to use Custom Tabs.

1.  Add Custom Tabs in the _build.gradle_ file.

```javascript
dependencies {
    ...
    implementation "androidx.browser:browser:1.4.0"
}
```

2.  Use Custom Tabs to open a Chrome tab in your application.

```javascript
// Use CustomTabsIntent.Builder to configure CustomTabsIntent.
// Use CustomTabsIntent.Builder.build() to create CustomTabsIntent
// Use CustomTabsIntent.launchUrl() to launch the URL

CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(this, Uri.parse(url));
```

For more information about how to use CustomTabs to open the URL, see the [Custom Tabs user guide](https://developer.chrome.com/docs/android/custom-tabs/).

#### Method 3: Handle the redirection according to whether the payment method app is installed

You must first determine whether the buyer has installed the payment method app, and then handle the opening method of the redirection URL accordingly. Perform the following steps:

1.  To comply with Android system's privacy and security policies, the <queries> tag needs to be added in _AndroidManifest.xml_ to ensure that the redirection URL can invoke the corresponding payment method app. The package name of the payment method app needs to be configured in the <queries> tag. You can obtain the corresponding value from the _appIdentifier_ parameter in the **pay** response returned by APO or by contacting Antom Technical Support.

```javascript
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:tools="http://schemas.android.com/tools"
          package="com.llw.scandemo">

  ...
  <queries>
    <package android:name="th.co.truemoney.wallet" />
    <package android:name="com.eg.android.AlipayGphone" />
    <package android:name="my.com.tngdigital.ewallet" />
    ...
  </queries>
  ...

</manifest>
```

2.  Determine whether the payment method app is installed and invoke the payment page:

```javascript
String Url = "applinkUrl/schemeUrl";
try {
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(Url));
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setPackage("my.com.tngdigital.ewallet");
    // Determine whether the payment method app is installed
    PackageManager packageManager = MainActivity.this.getPackageManager();
    List<ResolveInfo> activities = packageManager.queryIntentActivities(intent, 0);

    if (activities.size() <= 0) {
        // The payment method app is not installed. We recommend that you open the mobile website URL in WebView.

        intent = new Intent(MainActivity.this, WebviewActivity.class);
        intent.setData(Uri.parse(Url));
        startActivity(intent);
    } else {

        // The payment method app is installed. Open the payment method app directly.
        startActivity(intent);
    }
} catch (Exception e) {
    // Handle exceptions
    e.printStackTrace();
}
```

## User experience

The payment processes corresponding to different opening methods of the redirection URL are as follows:

| **Redirection method** | **Payment process** |
| --- | --- |
| Redirect outside of the application: Call the Android/iOS method to open the redirection URL. | Redirect outside of the application. The payment process depends on whether the buyer has installed the payment method app: - **Installed**: Redirect from your app to the payment method app. After the buyer selects the payment method, the payment method app is directly launched for payment through the schemeUrl or _applinkUrl_ returned by Antom, and the buyer completes the payment on the payment method app. ![image.png](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/1703502607078-9c4b67bf-d336-47cc-a3af-9587bc3c9baf.png) - **Not installed**: Redirect from the your app to the default browser. - - **Payment in a default browser:** After the buyer selects the payment method, they are redirected from your app to the payment method page in the default browser via _normalUrl_ or _applinkUrl_ returned by Antom, and the buyer completes the payment on this page. ![image.png](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/1703502624053-2fd50515-80dc-49c1-8ac4-e831ac963d22.png) - - **Payment in a payment method app:** After the buyer selects the payment method, they are redirected from your app to the payment method page in the default browser via _normalUrl_ or _applinkUrl_ returned by Antom, the payment method page will launch the payment method app, and the buyer completes the payment on the payment method app. ![image.png](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/1703502641010-e3af8a18-71da-43ce-8961-bb94a41a3879.png) |
| Redirect within the application | There are two types of payment experiences: redirection from your app and redirection within your app. - **Payment method app payment (redirection from your app):** After the buyer selects the payment method, they are redirected from your app to the payment method page in WebView via _normalUrl_ or _applinkUrl_ returned by Antom, the payment method page will launch the payment method app, and the buyer completes the payment on the payment method app. ![image.png](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/1703502708034-e840e772-cd2a-4344-93ff-abbf8e710628.png) - **WebView payment (redirection within your app):** After the buyer selects the payment method, they are redirected from your app to the payment method page in WebView via _normalUrl_ or _applinkUrl_ returned by Antom, and the buyer completes the payment on this page. ![image.png](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/1703502720296-5d630454-5bba-469d-8027-e332c5ffde7c.png) |
| Redirect within the application | There are two types of payment experiences: redirection from your app and redirection within your app. - **Payment method app payment (redirection from your app):** After the buyer selects the payment method, they are redirected from your app to the payment method page in WebView via _normalUrl_ or _applinkUrl_ returned by Antom, the payment method page will launch the payment method app, and the buyer completes the payment on the payment method app. ![image.png](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/1703502708034-e840e772-cd2a-4344-93ff-abbf8e710628.png) - **WebView payment (redirection within your app):** After the buyer selects the payment method, they are redirected from your app to the payment method page in WebView via _normalUrl_ or _applinkUrl_ returned by Antom, and the buyer completes the payment on this page. ![image.png](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/1703502720296-5d630454-5bba-469d-8027-e332c5ffde7c.png) |
| Redirect within the application | There are two types of payment experiences: redirection from your app and redirection within your app. - **Payment method app payment (redirection from your app):** After the buyer selects the payment method, they are redirected from your app to the payment method page in WebView via _normalUrl_ or _applinkUrl_ returned by Antom, the payment method page will launch the payment method app, and the buyer completes the payment on the payment method app. ![image.png](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/1703502708034-e840e772-cd2a-4344-93ff-abbf8e710628.png) - **WebView payment (redirection within your app):** After the buyer selects the payment method, they are redirected from your app to the payment method page in WebView via _normalUrl_ or _applinkUrl_ returned by Antom, and the buyer completes the payment on this page. ![image.png](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/1703502720296-5d630454-5bba-469d-8027-e332c5ffde7c.png) |

### Best practice

We recommend that you fix the configuration for opening the redirection URL based on different payment methods, or route based on the payment method, device environment, and URL type. The following figure shows an example of fixed configuration based on different payment methods:

![image.png](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/1703502733231-1e2e1d01-0e58-49ee-9bb3-92536d609392.png)

For each payment method, we recommend that you determine the method of opening the redirection URL according to the following logic:

![image.png](https://idocs-assets.marmot-cloud.com/storage/idocs87c36dc8dac653c1/1703502746046-34a676c2-4e23-4979-9424-e1b4e26e6aa2.png)