# 4.2.4 Example

```jsx
// parse the orderNo from url
App({
  paymentData:{
    orderNo:null
  },
  onShow: function (options) {
    // 解析 scheme URL 中的参数 ： {orderNo: "202508251000251204"}
    console.log('启动参数:', options.query);
    if (options && options.query) {
        Object.assign(this.paymentData, options.query);
    }
  }
})

// awake the wechat cashier to pay
const cashier = function (param) {
    wx.requestPayment({
        "timeStamp": param.timeStamp,
        "nonceStr": param.nonceStr,
        "package": param.package,
        "signType": param.signType,
        "paySign": param.paySign,
        "success": function (res) {
            //路由到成功页面
        },
        "fail": function (res) {
            //路由到失败页面
        },
        "complete": function (res) {}
    })
}

// Obtain payment info 
const payment = function(orderNo){
    wx.login({
        success: res => {
            debugger
            wx.request({
                url: 'http://192.168.0.20:8181/api/open/converge/pay/v2/getMiniPayment',
                method: 'POST',
                data: {
                    code: res.code,
                    newpayOrderNo: orderNo,
                    timestamp: Date.now()
                },
                header: {
                    'content-type': 'application/json;charset=UTF-8'
                },
                success(res) {
                    console.log(res.data);
                    if(res.data.code !== '0'){
                        wx.showToast({
                            title: res.data.message,
                            icon: 'none', 
                            duration: 3000
                          });
                        return;  
                    }
                    cashier(res.data.data.resMap)
                },
                fail(err) {
                    console.error('请求失败:', err);
                }
            });
        }
    });
}

Page({
    data: {
        message: '',
    },
    onReady() {
        // step 1: parse orderNo from url
        const app = getApp();
        const orderNo = app.paymentData.orderNo;
        console.log(orderNo);
        if(orderNo){
            // step2: payment
            // step2.1: wx.login to get the code
            // step2.2: obtain payment info
            // step2.3: awake cashier to pay
            payment(orderNo);
        }
    },
})
```
