How to send red envelopes with WeChat applet

Source: Internet
Author: User
Tags openid
In the current version of the applet does not support the function of sending red envelopes, developers are grinning, the heart of MOM sell batch! here, provide a solution that has been practiced.

Detailed analysis, is the following several steps

1, the first is in the small program inside the collar red envelope entrance
2, click to jump WebView, with the current small program token to webview authentication, WebView SRC point to a service number with the ability to obtain the OpenID page, according to the additional token to determine whether the user can receive red envelopes, At this time the user has two OpenID, one is relative to the small program OpenID, one is relative to the service number used to send red envelopes OpenID, such as the following pseudo-code

Pseudo code    weixinApi.angerPay.sendRedPacket ({      total_num:1,      mch_billno: ' 1000000 ',      send_name: ' Test title ',      re_openid: ' Xaxadsadas ',//acquired OpenID      total_amount:100,      wishing: ' Congratulations on fortune, Prosperity ',      act_name: ' Sweep code collar red Envelopes ',      Remark: ' Memo info ',      client_ip: ' 127.0.0.1 ',      scene_id: ' Product_2 '      }, (err, result) = {      Console.log (err, result)  });

3. Return to Collection results

Precautions

1, jump to the WebView src to add to the applet business domain name
2, the link must be the HTTPS protocol

The future of the interface

In the near future, will open a red envelope interface, is wx.sendbizredpacket, usage examples.

 Wx.sendbizredpacket ({timestamp:e.timestamp, noncestr:e.noncestr, Package:e.package, Signtype:e.signtype, Paysign:e.paysign, Success:function (res) {Console.log ( ' Red envelope success ') let url = config.        Http_prize_url + '/v1/sign_tmp/sendsuccess.do '; Let data = {minipid:that.data.minipid, date:that.data.date} console.log (' The number of interface request parameters after the red packet succeeded According to: ' + json.stringify (data) ') util.request (URL, ' post ', data, ' Loading Date ', function (res) {Console.log (' Red envelope after success The interface returns the result: ' + json.stringify (res.data)}) ' Wx.relaunch ({url: ') '. /my_prize/my_prize_2?reward= ' + Res.data.body.reward,})}, Fail:function (res) {Console.log (' red envelope Fail ')}, Complete:function (res) {Console.log (' Red envelope complete ')//Wx.showmodal ({//title : ' Red envelope complete ',//content: ' Red envelope complete ',//}}}) 
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.