Location>code7788 >text

WeChat mini program/H5 to adjust the confirmation and collection interface

Popularity:784 ℃/2025-04-18 10:03:04
## 🧾 WeChat mini program/H5 to adjust the confirmation and collection interface (with code + platform compatibility processing)

> Scenario: After the user clicks the "Cash Collection" button, the system will call up the WeChat collection component, and the user will complete the transfer or collection process after confirmation. This capability is widely used in business scenarios such as cash marketing, second-hand transactions, commission remuneration, and corporate compensation.

## [See the official document for details](/doc/v3/merchant/4012711988)

## 💡 Background

The WeChat official updated the **requestMerchantTransfer** interface in the first two months, allowing the **WeChat mini program** and **H5 page** to adjust an interface for users to confirm payment, and users can complete the transfer after completing the confirmation.

This API can be used to implement:

- Merchants ask users to confirm when making payments to users (the platform sends them on their behalf)
- User confirms receipt to another user (point-to-point receipt)
- Wallet withdrawal application (display transfer details first → User consent → Initiate payment)
  ...

---

## ⚙️Precautions for use

### ✅ Application requirements:

- ** Merchants transfer to change** Product permissions that require the WeChat payment merchant platform;
- Bind to a mini program or official account;
- `mchId` (merchant number), `appId` (the appid of the current applet/public account), `package` (order details package).

---

## 🔄 Call method:

| Platform      | Call Method Description                                          |
| --------- | ------------------------------------- |
| Mini Program  | Native API `` |
| H5 in WeChat | Called through `()` |

[APP also see the official documentation, including Android and iOS, no detailed description here](/doc/v3/merchant/4012719576)

---

## 🔧 Core code implementation

The following uses uniapp as a compatible mini program + the complete call method of WeChat H5 on both ends (you can use it after copying):

```js
getMoney(item) {
  const that = this;
// The judgment platform can also be used (// #ifdef MP-WEIXIN  // #endif)
  if ( === 'wx') {
// ✅ Mini-program call method
    ({
mchId: , // Merchant number, generated and issued by WeChat Pay
appId: , // The AppID bound by the merchant (corpid number corpid is this AppID), generated by WeChat, can be viewed in the background of the official account
package: item.package_info, // The corresponding package_info in the response parameter of the initiating transfer interface (returned only when the transfer document status is WAIT_USER_CONFIRM: is confirmed by the user), which is used to invoke the user to confirm the receipt page.
      success(res) {
('User confirms that the payment is successful', res);
        ({
title: 'The collection was successful',
          icon: 'success'
        });
(false, 1); // Refresh data
      },
      fail(res) {
('User failed to confirm the payment', res);
        ({
title: 'Cash failed',
          icon: 'error'
        });
      },
      complete(res) {
('Request completed', res);
      }
    });
} else if ( === 'h5') {   // It can also be used (// #ifdef H5   // #endif)
// ✅ H5 calling method (make sure it is in the WeChat environment)
    (function() {
      ({
        jsApiList: ['requestMerchantTransfer'],
        success: function(res) {
          if (['requestMerchantTransfer']) {
// The H5 end is called through WeixinJSBridge
            ('requestMerchantTransfer', {
              mchId: ,
              appId: ,
              package: item.package_info,
            }, function(res) {
              if (res.err_msg === 'requestMerchantTransfer:ok') {
                ({
title: 'The collection was successful',
                  icon: 'success'
                });
(); // Refresh data
              } else {
('User cancellation or payment failed', res);
              }
            });
          } else {
alert('Your WeChat version is too low, please update to the latest version.');
          }
        }
      });
    });
  }
}
```

---

## 🔍 Interpretation (key points description)

| Parameters/Logics                                                                                                          |
| ---------------------------- | ------------------------------------------------ |
| `mchId`                                                                                                                             |
| `appId`                                                                                                                       |
| `package`                                 |
| `` | The mini program has built-in API, initiating a transfer confirmation process               |
| `()`  | JS bridge call on the H5 side of WeChat, used to evoke payment, collection and other interfaces |
| `checkJsApi()`                     | Check whether the current WeChat version supports the JS API                |
| `err_msg: ok`                             |

---

## ⚠️ FAQ & Tips for Trapping

- **Please make sure that the AppID has configured transfer permissions** in the mini program, otherwise "no permission" will be reported;
- **H5 calls must be made in `()`, and the premise is that the JS-SDK signature is injected first**;
- **WeChat version below 7.0.20 may not support this capability**;
- **Please do not test the H5 side in non-WeChat browsers, WeixinJSBridge cannot inject **;
- **package parameters must be obtained from the backend, and be sure to pay attention to encryption and signature verification**;

---

📚 Reference link:
[WeChat open document: requestMerchantTransfer](/doc/v3/merchant/4012716430)