public static void main(String[] args) {
? ? ? ? CertAlipayRequest certAlipayRequest = new CertAlipayRequest();? ?
? ? ? ? certAlipayRequest.setServerUrl("https://openapi.alipay.com/gateway.do");? ?
? ? ? ? certAlipayRequest.setAppId("setAppId");
? ? ? ? certAlipayRequest.setPrivateKey("setPrivateKey");
? ? ? ? certAlipayRequest.setCertPath(AlipayTurnConfig.certPathGgf);
? ? ? ? certAlipayRequest.setAlipayPublicCertPath(AlipayTurnConfig.alipayPublickCertPathGgf);
? ? ? ? certAlipayRequest.setRootCertPath(AlipayTurnConfig.rootCertPathGgf);
? ? ? ? certAlipayRequest.setSignType("RSA2");
? ? ? ? certAlipayRequest.setFormat("json");
? ? ? ? certAlipayRequest.setCharset("UTF-8");
? ? ? ? AlipayClient alipayClient = null;
? ? ? ? try {
? ? ? ? ? ? alipayClient = new DefaultAlipayClient(certAlipayRequest);
? ? ? ? *//** 實例化具體API對應的request類,類名稱和接口名稱對應,當前調用接口名稱:alipay.fund.trans.common.query(轉賬業(yè)務單據查詢接口) **//*
? ? ? ? AlipayFundTransCommonQueryRequest request = new AlipayFundTransCommonQueryRequest();
? ? ? ? *//** 設置業(yè)務參數,具體接口參數傳值以文檔說明為準:https://opendocs.alipay.com/apis/api_28/alipay.fund.trans.common.query/? **//*
? ? ? ? AlipayFundTransCommonQueryModel model = new AlipayFundTransCommonQueryModel();
? ? ? ? *//** 固定值:TRANS_ACCOUNT_NO_PWD:單筆無密轉賬到支付寶賬戶? **//*
? ? ? ? model.setProductCode("TRANS_ACCOUNT_NO_PWD");
? ? ? ? *//** 描述特定的業(yè)務場景,如果傳遞了out_biz_no則該字段為必傳,固定值:DIRECT_TRANSFER:B2C 現金紅包、單筆無密轉賬 **//*
? ? ? ? model.setBizScene("DIRECT_TRANSFER");
? ? ? ? *//** 商戶轉賬唯一訂單號,單筆轉賬接口的入參? **//*
? ? ? ? model.setOutBizNo("TXPO202101010849274"); // 支付寶轉賬成功,系統作廢的!
? ? ? ? //model.setOutBizNo("TXPO202101010849271");// 不存在的
? ? ? ? //model.setOutBizNo("TXVK202101111337477");// 轉賬失敗的
? ? ? ? request.setBizModel(model);
? ? ? ? AlipayFundTransCommonQueryResponse response = null;
? ? ? ? ? ? response = alipayClient.certificateExecute(request);
? ? ? ? ? ? if(response.isSuccess()){
? ? ? ? ? ? System.out.println("調用成功");
? ? ? ? ? ? //System.out.println(request.getBizContent());
? ? ? ? ? ? System.out.println(request.getBizModel());
? ? ? ? ? ? System.out.println(response.getParams());
? ? ? ? ? ? System.out.println(response.getBody());
? ? ? ? ? ? System.out.println(response.getOrderId());
? ? ? ? ? ? System.out.println(response.getTransAmount());
? ? ? ? } else {
? ? ? ? System.out.println("調用失敗");
? ? ? ? System.out.println(request.getBizModel().toString());
? ? ? ? System.out.println(response.getParams());
? ? ? ? ? ? System.out.println(response.getBody());
? ? ? ? ? ? System.out.println(response.getOrderId());
? ? ? ? ? ? System.out.println(response.getSubCode());
? ? ? ? ? ? System.out.println(response.getSubMsg());
? ? ? ? }
? ? ? ? } catch (AlipayApiException e) {
? ? ? ? ? ? e.printStackTrace();
? ? ? ? }
}