Implementation Procedure

  1. The user initiates WeChat payment on the WeChat internal browser
  2. The web page program calls the OTT Pay API to make payment, and the OTT Pay server returns Payment Navigation Link
  3. The web page program uses navigate to Payment Navigation Link to call the WeChat wallet for payment
  4. After the user pays, regardless of success or failure, it will jump to the returnURL provided in the request parameter, and the URL returned by the navigation will have paymentId=xxxx (xxxx is the paymentId returned by OTT Pay)

Code Example

Get Payment Parameters:

Map<String, Object> data = new HashMap<>();
data.put("amount", "100");
data.put("callbackURL", "https://your.callback.url");
data.put("returnURL", "https://your.return.url");
data.put("remark", "this is remark");

Gson gson = new Gson();
RequestBody body = RequestBody.create(gson.toJson(data), MediaType.parse("application/json; charset=utf-8"));
String token = "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJBQjAwMDAwMDA0OTUiLCJhdWRpZW5jZSI6bnVsbCwicm9sZSI6bnVsbCwiY3JlYXRlZCI6MTY3ODQ3MTEwMjU5NiwidXNlcnR5cGUiOiJDVVNUT01FUiIsImV4cCI6MTY3ODQ3MjAwMiwidXNlcmlkIjo5NX0.UjhYQc5UCMiKiSiuClEMn1ugPcUYQWvD81qmN2awToWsJOInq-S6LFtaNaoZosRMm__UUT2UMjO2CCfTHrThJg";
Request request = new Request.Builder()
    .addHeader("Authorization", "Bearer " + token)

final OkHttpClient httpClient = new OkHttpClient();
try (Response response = httpClient.newCall(request).execute()) {
    if (!response.isSuccessful()) {
        throw new IOException("Unexpected code " + response);

    // Response
} catch (IOException e) {
    throw new RuntimeException(e);

The payInfo in the returned result is the payment navigation link, and the web page will navigate to this link for payment to complete