中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

如何利用java實現提現金額到支付寶賬戶的功能

發布時間:2020-12-11 09:42:13 來源:億速云 閱讀:629 作者:小新 欄目:編程語言

小編給大家分享一下如何利用java實現提現金額到支付寶賬戶的功能,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

實現步驟具體如下:

1、導入依賴

<dependency>
<groupId>com.alipay.sdk</groupId>
<artifactId>alipay-sdk-java</artifactId>
<version>4.9.5.ALL</version>
</dependency>

2、配置參數

如何利用java實現提現金額到支付寶賬戶的功能

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();
//設置網關地址https://openapi.alipay.com/gateway.do
certAlipayRequest.setServerUrl("https://openapi.alipay.com/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 = alipayClient.certificateExecute(request);
if (response.isSuccess()){
if("10000".equals(response.getCode())){
return Result.ok("轉賬成功");
} else {
return Result.fail(Integer.valueOf(response.getCode()),response.getSubMsg());
}
}else {
return Result.fail(Integer.valueOf(response.getCode()),response.getSubMsg());
}
}catch (Exception e){
e.printStackTrace();
return Result.error(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\":\"姓名\"" +
" }");

以上是“如何利用java實現提現金額到支付寶賬戶的功能”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

长沙县| 信宜市| 岱山县| 巴林右旗| 莱阳市| 遂平县| 南通市| 故城县| 新营市| 靖西县| 扬中市| 历史| 奉节县| 乌兰浩特市| 白水县| 嵊泗县| 安宁市| 柏乡县| 聊城市| 天峻县| 法库县| 松江区| 巢湖市| 大方县| 洱源县| 格尔木市| 万载县| 周宁县| 平度市| 南召县| 东海县| 二手房| 彝良县| 泸定县| 修水县| 兴城市| 安宁市| 桐庐县| 军事| 临澧县| 时尚|