Giter Site home page Giter Site logo

wechatpaylistener's Introduction

微信二维码支付监听器

由于私人无法向支付宝微信等申请支付API,让我们这些开发收费软件的个人开发者很难办,只能另寻门路。

一般我们通过在服务器挂软件,通过不停刷新支付宝帐单或者QQ机器人等方式实现自动售卖,但微信版的很少见到,于是我自己实现了一个。

分析

微信有手机版、电脑版、网页版,为了降低协议分析难度选择网页版入手。

通过微信收款的方式主要有三种,红包、转账和二维码转账,前两个需要添加好友,并且需要在手机端点击确认才能到账,电脑和网页版均无法确认收款,而二维码转账则不需要加好友,并且是直接到账的。

登录网页版微信,发现通过二维码转账后会收到服务通知,这边可获取的参数有收款金额、留言、到账时间,OK足够用了。

所以最终实现方法是,提前生成收款二维码(二维码是不会过期的),让用户扫描二维码,留言备注帐号并付款,我们在后台通过微信网页协议进行监听,收到款时,通过得到的备注信息和金额进行相应处理。

优点

绕过微信支付授权,实现用户微信支付后自动开通会员等功能。

缺点

需要用户用微信手动扫码和填写备注信息,而且用户付款时可能忘记或填错备注。

如果用户付款时服务器端微信掉线,再次上线后无法重新得到消息,会造成丢单。

目前我的解决办法是掉线后立即向我发邮件通知,并且留一个接口让软件和用户可以检测服务器微信是否在线,至于填错帐号或者丢单了只能人工处理。

还有网页协议不稳定,发生变动后可能需要更新。

说明

核心代码在WeChat.java,协议均通过对微信网页版抓包得到,把里面的checkPay方法里的openVip改成你的业务逻辑。

直接编译会提示找不到MtUtil类,这里面是我后台开通会员的业务代码,不公开,你们自己替换。

微信支付二维码在手机生成,可以预先设置金额。

运行本程序,扫描二维码登录,当该微信号通过二维码支付收到款时会立即得到消息。

其他

目前还没测试能保持在线多久,掉线后会发送通知邮件到我的邮箱,相关代码自行修改。

登录成功时会在运行目录创建一个Running文件,离线或退出后会自动删除,用途是我写了个jsp来访问判断微信是否在线。

如果登录成功后直接x掉控制台,Running文件不会自动删除,需要在控制台输入exit来手动退出。

我的微信公众号开通会员说明页面

wechatpaylistener's People

Contributors

l-jinbin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.