很简单。只需三个参数实现 单笔转账到支付宝账户
1、获取开放平台创建的APPID,同时必须添加 单笔转账到支付宝账户 这个功能
开放平台:https://open.alipay.com/platform/home.htm
2、登录支付宝商家中心平台:https://b.alipay.com/index.htm
创建应用。到产品中心开通 转账功能
(1)下载支付宝密匙生成工具:https://docs.open.alipay.com/291/105971
生成私钥与公钥
(2)配置公钥
注:一定要使用 开放平台密钥里面的支付宝公钥
3、获取APPID与私钥和公钥。即可实现转账(提现)
Servlet下创建三个String
提现代码:
下载支付宝SDK:https://search.maven.org/search?q=g:com.alipay.sdk%20AND%20a:alipay-sdk-java&core=gav
复制jar包到WEB-INF文件夹下lib文件夹下
注:只需修改payee_account、payee_real_name,收款人账号和真实收款人姓名即可。out_biz_no是随机数,可用时间戳
AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",App_ID,private_key,"json","GBK",public_key,"RSA2");
AlipayFundTransToaccountTransferRequest request2 = new AlipayFundTransToaccountTransferRequest();
request2.setBizContent("{" +
" \"out_biz_no\":\"3142321423432\"," +
" \"payee_type\":\"ALIPAY_LOGONID\"," +
" \"payee_account\":\"1598888499\"," +
" \"amount\":\"0.2\"," +
" \"payer_show_name\":\"天鑫计费退款\"," +
" \"payee_real_name\":\"李888\"," +
" \"remark\":\"转账备注\"," +
" }");
AlipayFundTransToaccountTransferResponse response2;
try {
response2 = alipayClient.execute(request2);
endString = response2.getCode();
if (endString.equals("10000")) {
System.out.println("---------------调用成功");
endString = "成功";
} else {
System.out.println("--------------调用失败");
endString = "失败";
}
} catch (AlipayApiException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
在线回复bug:qq1085220040