Small learning program - payment and transfer from the camera to scan two-dimensional code

Reception process is
1, to a backstage pass code (will pass) and parameters needed to return to my background background parameters
2, after the success I pull it to pay these parameters and then returns the listener in a letter passed to the micro-end results

// user clicks the button I want to pay 
wx.login ({ 
      Success: function (RES) {
         IF (res.code) {
           // initiate network requests 
          wx.request ({ 
            url: Here is the background interface // you need to a background pass code 
            Method: 'the GET' , 
            Data: { 
              code: res.code   // request after a successful return wx.login code 
            }, 
            success: function (R & lt) {   // the background after the return parameters for timeStamp, nonceStr, package, paySign, appid. (some will return other parameters, these parameters must be returned to the left) 
              var _res = r.data.data   //    too long to r the following data to the variable _res
              wx.requestPayment ({     // invoking pay                
                'timeStamp': _r.timeStamp,   // required number of seconds a time stamp from January 1, 1970 00:00:00 So far, that the current               
                'nonceStr': _r. nonceStr,   // required random string of 32 characters or less. 
                'Package': _r.package,   // prepay_id parameter values required single unified interface to return 
                'signType': 'the MD5',   // required signature algorithm, temporary support MD5 
                'paySign': _r.paySign, // required signature 
                'success': function (RES) { // interface call success callback function 
                  console.log (RES); 
                },
                'fail': function (RES) { // interface call failed callback function 
                  the console.log ( 'Fail:' + the JSON.stringify (RES)); 
                } 
              }) 
            }, 
            Fail: function (ERR) { 
              the console.log (ERR) 
            } 
          } ) 
        } the else { 
          the console.log ( 'Get user login state fails!' + res.errMsg) 
        } 
      } 
    })
A  scan code
 2  // allow scan code from the camera and photo albums 
. 3  wx.scanCode ({
 . 4    Success (RES) {
 . 5      the console.log (RES)
 . 6    }
 . 7  })
 . 8  // only allow scan code from the camera 
. 9  wx.scanCode ({
 10    onlyFromCamera: to true ,
 . 11    Success (RES) {
 12 is      the console.log (RES)
 13 is    }
 14 })

// reprint

Guess you like

Origin www.cnblogs.com/Alitar/p/11418624.html
Recommended