小編給大家分享一下如何利用java實(shí)現(xiàn)提現(xiàn)金額到支付寶賬戶(hù)的功能,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
創(chuàng)新互聯(lián)是一家專(zhuān)注于成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站制作與策劃設(shè)計(jì),勐海網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)做網(wǎng)站,專(zhuān)注于網(wǎng)站建設(shè)10多年,網(wǎng)設(shè)計(jì)領(lǐng)域的專(zhuān)業(yè)建站公司;建站業(yè)務(wù)涵蓋:勐海等地區(qū)。勐海做網(wǎng)站價(jià)格咨詢(xún):028-86922220實(shí)現(xiàn)步驟具體如下:
1、導(dǎo)入依賴(lài)
<dependency> <groupId>com.alipay.sdk</groupId> <artifactId>alipay-sdk-java</artifactId> <version>4.9.5.ALL</version> </dependency>
2、配置參數(shù)
3、實(shí)現(xiàn)方法
@ApiOperation(value = "企業(yè)轉(zhuǎn)賬到支付寶", httpMethod = "POST", produces = "application/json;charset=UTF-8") @ApiImplicitParams(value = {@ApiImplicitParam(value = "*用戶(hù)token", name = "token",defaultValue ="", dataType = "String",paramType="header"), @ApiImplicitParam(value = "支付寶會(huì)員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 = "支付寶會(huì)員id不能為空")String aliuserId){ try { String out_biz_no = "R-" + System.currentTimeMillis() + ((long) ((Math.random() * 9 + 1) * 100000000L) + "").substring(0, 8); //構(gòu)造client CertAlipayRequest certAlipayRequest = new CertAlipayRequest(); //設(shè)置網(wǎng)關(guān)地址https://openapi.alipay.com/gateway.do certAlipayRequest.setServerUrl("https://openapi.alipay.com/gateway.do"); //設(shè)置應(yīng)用AppId certAlipayRequest.setAppId(appid); //設(shè)置應(yīng)用私鑰 certAlipayRequest.setPrivateKey(zzpri); certAlipayRequest.setFormat("json"); //設(shè)置字符集 certAlipayRequest.setCharset("UTF-8"); //設(shè)置簽名類(lèi)型 certAlipayRequest.setSignType("RSA2"); //設(shè)置應(yīng)用公鑰證書(shū)路徑 certAlipayRequest.setCertPath(appcertpath); //設(shè)置支付寶公鑰證書(shū)路徑 certAlipayRequest.setAlipayPublicCertPath(alicertpath); //設(shè)置支付寶根證書(shū)路徑 certAlipayRequest.setRootCertPath(rootcertpath); //構(gòu)造Client AlipayClient alipayClient = null; try { alipayClient = new DefaultAlipayClient(certAlipayRequest); } catch (AlipayApiException e) { e.printStackTrace(); } //實(shí)例化接口 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\":\"轉(zhuǎn)賬\"," + "\"payee_info\":{" + "\"identity\":\""+aliuserId+"\"," + "\"identity_type\":\"ALIPAY_USER_ID\"," + " }," + "\"remark\":\"單筆轉(zhuǎn)賬\"" + " }"); AlipayFundTransUniTransferResponse response=null; response = alipayClient.certificateExecute(request); if (response.isSuccess()){ if("10000".equals(response.getCode())){ return Result.ok("轉(zhuǎn)賬成功"); } 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,"支付寶轉(zhuǎn)賬失?。?quot;); } }
注意:該功能實(shí)現(xiàn)需要先實(shí)現(xiàn)支付寶授權(quán)功能獲取支付寶會(huì)員id,支付寶會(huì)員id是由2088開(kāi)頭的,如果是用客戶(hù)手機(jī)號(hào)進(jìn)行提現(xiàn),就會(huì)還需要輸入客戶(hù)真實(shí)姓名。
用客戶(hù)手機(jī)號(hào)提現(xiàn)只是部分參數(shù)不同,代碼如下:
request.setBizContent("{" + "\"out_biz_no\":\""+out_biz_no+"\"," + "\"trans_amount\":\""+money+"\"," + "\"product_code\":\"TRANS_ACCOUNT_NO_PWD\"," + "\"biz_scene\":\"DIRECT_TRANSFER\"," + "\"order_title\":\"轉(zhuǎn)賬\"," + "\"payee_info\":{" + "\"identity\":\""+aliuserId+"\"," + "\"identity_type\":\"ALIPAY_USER_ID\"," + "\"name\":\"ALIPAY_USER_ID\"" + " }," + "\"remark\":\"姓名\"" + " }");
以上是“如何利用java實(shí)現(xiàn)提現(xiàn)金額到支付寶賬戶(hù)的功能”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
標(biāo)題名稱(chēng):如何利用java實(shí)現(xiàn)提現(xiàn)金額到支付寶賬戶(hù)的功能-創(chuàng)新互聯(lián)
網(wǎng)站鏈接:http://muchs.cn/article16/dhgidg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App設(shè)計(jì)、動(dòng)態(tài)網(wǎng)站、網(wǎng)站建設(shè)、手機(jī)網(wǎng)站建設(shè)、用戶(hù)體驗(yàn)、網(wǎng)站設(shè)計(jì)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容