java提现功能开发_利⽤java实现提现⾦额到⽀付宝账户的功能
实现步骤具体如下:
(学习视频分享:java教学视频)
1、导⼊依赖
com.alipay.sdk
alipay-sdk-java
4.9.
5.ALL
2、配置参数
3、实现⽅法@ApiOperation(value = "企业转账到⽀付宝", httpMethod = "POST", produces = "application/json;charset=UTF-8")
@ApiImplicitParams(value = {@ApiImplicitParam(value = "*⽤户token", name = "token",defaultValue ="", dataType = "String",paramType="header"),
@ApiImplicitParam(value = "⽀付宝会员id", name = "aliuserId",defaultValue ="", dataType = "int",paramType="query",example = "0"),
@ApiImplicitParam(value = "⾦额", name = "money",defaultValue ="", dataType = "String",paramType="query")
})
@PostMapping("/alipay/transfer")
public Result getMoney(HttpServletRequest servletRequest,BigDecimal money,@NotNull(message = "⽀付宝会员id不能为空")String aliuserId){
try {
String out_biz_no = "R-" + System.currentTimeMillis() + ((long) ((Math.random() * 9 + 1) * 100000000L) + "").substring(0, 8);
//构造client
CertAlipayRequest certAlipayRequest = new CertAlipayRequest();
certAlipayRequest.setServerUrl("openapi.alipay/gateway.do");
/
/设置应⽤AppId
certAlipayRequest.setAppId(appid);
//设置应⽤私钥
certAlipayRequest.setPrivateKey(zzpri);
certAlipayRequest.setFormat("json");
//设置字符集
certAlipayRequest.setCharset("UTF-8");
英语考试有哪些//设置签名类型
certAlipayRequest.setSignType("RSA2");
//设置应⽤公钥证书路径打新冠疫苗前后要注意什么
certAlipayRequest.setCertPath(appcertpath);
/
/设置⽀付宝公钥证书路径吴亦凡招供范冰冰
certAlipayRequest.setAlipayPublicCertPath(alicertpath);
皂液//设置⽀付宝根证书路径
certAlipayRequest.setRootCertPath(rootcertpath);
//构造Client
AlipayClient alipayClient = null;
try {
alipayClient = new DefaultAlipayClient(certAlipayRequest);
} catch (AlipayApiException e) {
e.printStackTrace();
}
/
/实例化接⼝
AlipayFundTransUniTransferRequest request=new AlipayFundTransUniTransferRequest(); request.setBizContent("{" +
"\"out_biz_no\":\""+out_biz_no+"\"," +
"\"trans_amount\":\""+money+"\"," +
"\"product_code\":\"TRANS_ACCOUNT_NO_PWD\"," +
"\"biz_scene\":\"DIRECT_TRANSFER\"," +
"\"order_title\":\"转账\"," +
"\"payee_info\":{" +
"\"identity\":\""+aliuserId+"\"," +
"\"identity_type\":\"ALIPAY_USER_ID\"," +
" }," +
"\"remark\":\"单笔转账\"" +
" }");
AlipayFundTransUniTransferResponse response=null;
response = ificateExecute(request);
if (response.isSuccess()){
if("10000".Code())){
return Result.ok("转账成功");
} else {
return Result.fail(Integer.Code()),SubMsg());
}
}else {
return Result.fail(Integer.Code()),SubMsg());
}
}catch (Exception e){
e.printStackTrace();
(901,"⽀付宝转账失败!");
}
}
注意:该功能实现需要先实现⽀付宝授权功能获取⽀付宝会员id,⽀付宝会员id是由2088开头的,如果是⽤客户⼿机号进⾏提现,就会还需要输⼊客户真实姓名。
⽤客户⼿机号提现只是部分参数不同,代码如下:request.setBizContent("{" +
"\"out_biz_no\":\""+out_biz_no+"\"," +
"\"trans_amount\":\""+money+"\"," +
"\"product_code\":\"TRANS_ACCOUNT_NO_PWD\"," +
"\"biz_scene\":\"DIRECT_TRANSFER\"," +
"\"order_title\":\"转账\"," +
"\"payee_info\":{" +
"\"identity\":\""+aliuserId+"\"," +
"\"identity_type\":\"ALIPAY_USER_ID\"," +
"\"name\":\"ALIPAY_USER_ID\"" +
" }," +
临沂旅游景点"\"remark\":\"姓名\"" + " }");喜剧之王 李荣浩
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论