银行支付接口开发之子账户


前言

银行支付接口开发之子账户(因为涉及银行保密,所以以下字段都是小编编的!!实际开发以银行支付文件为准)

一、添加依赖

1.直接把银行依赖部署到项目的公共库(GitLab)中

如果没有直接把银行依赖导入项目中即可
在这里插入图片描述

二、配置文件

按银行支付接口的标准配置即可
在这里插入图片描述

三、画简易流程图

这里以添加子账户(个人、个体户及企业)的部分信息为例

在这里插入图片描述

四、前端页面(vue-elementui):

这里以开户为例

 <!--查询子账户信息-->
 <el-button type="primary" size="mini" icon="el-icon-search" @click="handleQuery">查询</el-button>
                <el-table stripe style="width:100%;" ref="table" :data="tableData">
                    <el-table-column fixed prop="id" label="" type="selection"></el-table-column>

                    <el-table-column prop="AcctNo" label="子账户编号" width="200"></el-table-column>

                    <el-table-column prop="Name" label="子账户名称" width="100"></el-table-column>
                    <el-table-column prop="Mobile" label="银行卡手机号码" width="180"></el-table-column>
                    <el-table-column fixed="right" label="操作" width="400">
                    	<!--开户-->
                        <template slot-scope="scope">
                            <el-popconfirm
                                    title="确定前请检查开户信息"
                                    confirm-button-text='确定'
                                    cancel-button-type=""
                                    cancel-button-text='取消'
                                    @confirm="openAcct(scope.row)">
                                <el-button size="mini" type="text" icon="el-icon-arrow-right" slot="reference">开户</el-button>
                            </el-popconfirm>
                        </template>
                    </el-table-column>
                </el-table>

..................
			<!--js中method开户方法-->
            openAcct(row){
                // 实名开户
                console.log(row)
                this.doPostData(this.openAcctUrl+row.id+".do",{}, (rep) => {
                    if(rep.success){
                        this.$message.success("开户成功");
                    }
                })
            },

四、后端:

1.上传银行工具类

把银行支付要用的工具类直接copy即可
在这里插入图片描述

2.控制器方法
    /**
     * @Description 子账户开户控制器方法
     **/
    @ResponseBody
    @RequestMapping(value = "openAcct/{id}", method = RequestMethod.POST)
    public Result openAcct(@PathVariable("id")String id){
        try{
            Acct param = AcctService.selectById(id);
            Map<String, Object> repParam = AcctRegister.open(param);
            if(repParam.get("ReturnCode").equals("0000")){
                param.setAcctNo(repParam.get("AcctNo").toString());
                param.setTotalAcctNo(repParam.get("TotalAcctNo").toString());
                AcctService.updateById(param);
            }else {
                return Results.error(repParam.get("ReturnMsg").toString());
            }
            return Results.opOk();
        }catch (Exception e){
            logger.error("银行开户失败!params:"+id,e);
            return Results.error(e.getMessage());
        }
    }

3.开户实现方法

    // 配置文件路径
    public static Properties properties;
    protected static final String configPath = "profiles/properties";


	// 初始化配置文件及方法
    {
        Pay.init();
    }

    public static void init(){
        try {
            if(properties == null) {
                properties = FileUtil.getProperties(configPath);
                ApiClient.init(properties);
            }
        } catch (Exception var3) {
            throw new RunTimeException(ExceptionEnum.CONFIG_PATH_ERROR, new Object[]{configPath});
        }
    }


  	/**
     * @Description 开户方法
     **/
    public static Map<String,Object> open(Acct param) throws Exception {
        Map<String, String> reqParam = new HashMap<>();
        reqParam.put("Time", DataUtil.orderTimeNow());
        reqParam.put("Code", properties.getProperty("platformCode"));
        reqParam.put("Name", param.getName());
        reqParam.put("TotalAcctNo", properties.getProperty("Account"));
        String result = ApiClient.post("/OpenAcctId", reqParam, null);
        Map<String,Object> repParam = new HashMap<>();
        JSONObject object = JSONObject.parseObject(result);
        if(object.getJSONObject("SuccessData")!=null){
            repParam = object.getJSONObject("SuccessData");
            repParam.put("TotalAcctNo",properties.getProperty("Account"));
        }else {
            repParam = object.getJSONObject("ErrorData");
        }
        return repParam;
    }

总结:

其他子账户签约、查看等接口开发类似,主要是读懂银行支付文件,掌握流程,结合公司需要开发相应的接口就可以了

随心所往,看见未来。Follow your heart,see light!

欢迎点赞、关注、留言,一起学习、交流!

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值