欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

支付宝免签收款模式解析(发消息)

程序员文章站 2022-07-13 16:55:08
...

继转账,红包风控之后,开始研究收款模式;
之前收款模式已经有,流程大概是
1:先添加好友,拉起好友聊天界面,自动输入需要的金额跟单号
2:用户发送消息,给收款账户
3:收款账户监听到对应的消息,根据金额跟备注发送消息给客户
4:客户收到收款订单或手动支付订单
5:监听到订单后回调服务器

下面是原有的一些代码

//前端代码

function btnPay() {
        var u=navigator.userAgent;
        var isAndroid=(u.indexOf('Android')>-1||u.indexOf('Adr')>-1);

        if(isAndroid){
            setTimeout(function(){
                    window.location.href="alipays://platformapi/startapp?appId=20000300&bizType=TRANSFER&action=keyboard&defaultword="+aab
                },300);

            setTimeout(function(){
                window.location.href="alipays://platformapi/startapp?appId=20000167&forceRequest=0&returnAppId=recent&tLoginId="+aac+"&tUnreadCount=0&tUserId="+aaa+"&tUserType=1"
                },666);

            setTimeout(function(){
                window.location.href="alipays://platformapi/startapp?appId=20000300&bizType=TRANSFER&action=keyboard&defaultword="+aab
            },999);

            setTimeout(function(){
                window.location.href="alipays://platformapi/startapp?appId=20000186&actionType=addfriend&userId="+aaa+"&loginId="+aac+"&source=by_f_v&alert=false"
            },555)
        }else{

            setTimeout(function(){window.location.href="alipays://platformapi/startapp?appId=20000300&bizType=TRANSFER&action=keyboard&defaultword="+aab},700);

            setTimeout(function(){window.location.href="alipays://platformapi/startapp?appId=20000186&actionType=addfriend&userId="+aaa+"&loginId="+aac+"&source=by_f_v&alert=true"},1234)}
        }

</script>

//APP 代码

//判断消息类型
	if (biz_type.equals("CHAT")) {
                                String template_data = decode_pl_json.getString("template_data");
                                JSONObject json_template_data = JSON.parseObject(template_data);
                                final String from_u_id = decode_pl_json.getString("from_u_id");
                                final String from_login_id = decode_pl_json.getString("from_login_id");
                                final String m = json_template_data.getString("m");
                                if (!TextUtils.isEmpty(m)) {
                                    new Thread(new Runnable() {
                                        @Override
                                        public void run() {
                                            try {
												  String[] strArr = m.split("\\|");
                                                if (strArr.length==2){
                                                    String money=strArr[0];
                                                    String desc=strArr[1];
                                                    Class ServiceUtil = XposedHelpers.findClass("com.alipay.mobile.beehive.util.ServiceUtil", classLoader);
                                                    Class RpcService = XposedHelpers.findClass("com.alipay.mobile.framework.service.common.RpcService", classLoader);
                                                    Class singleCollectRpc = XposedHelpers.findClass("com.alipay.android.phone.personalapp.socialpayee.rpc.SingleCollectRpc", classLoader);
                                                    final Object RpcProxy = XposedHelpers.callMethod(XposedHelpers.callStaticMethod(ServiceUtil, "getServiceByInterface", RpcService), "getRpcProxy", singleCollectRpc);
                                                    Object requstObj = XposedHelpers.newInstance(XposedHelpers.findClass("com.alipay.android.phone.personalapp.socialpayee.rpc.req.SingleCreateReq", classLoader));
                                                    Object userInfo = PayUtils.getAlipayUserInfo(classLoader);
                                                    XposedHelpers.setObjectField(requstObj, "billName", "个人收款");
                                                    XposedHelpers.setObjectField(requstObj, "desc", desc);
                                                    XposedHelpers.setObjectField(requstObj, "logonId", from_login_id);
                                                    XposedHelpers.setObjectField(requstObj, "payAmount", money);//获取得订单金额
                                                    XposedHelpers.setObjectField(requstObj, "source", "chat");
                                                    XposedHelpers.setObjectField(requstObj, "userId", from_u_id);
                                                    XposedHelpers.setObjectField(requstObj, "userName", "");
                                                    Object singleCollectCreateRes = XposedHelpers.callMethod(RpcProxy, "createBill", requstObj);
                                                    JSONObject json = JSON.parseObject(JSON.toJSONString(singleCollectCreateRes));
                                                }

                                            } catch (Exception e) {
                                                e.printStackTrace();
                                            }
                                        }
                                    }
                                    ).start();
                                }
                            } 

这种方法弊端明显,需要客户手动发送消息,还要手动点击收款订单付款,很多客户会懵,后面会优化整个流程,直接拉起订单

测试地址
免签测试http://mpay.php05.cn