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\":\"姓名\"" + " }");