use of com.alipay.api.AlipayClient in project synergic-developing by zeemood.
the class AlipayAssistant method preOrder4App.
/**
* 支付宝APP支付
*
* @param notifyUrl
* @param model
* @return
* @throws Exception
*/
public static String preOrder4App(String notifyUrl, AlipayTradeAppPayModel model) throws Exception {
AlipayClient alipayClient = new DefaultAlipayClient(// 支付地址
AlipayConfigurations.GATE_URL, // 应用id
AlipayConfigurations.getAppid(), // 私钥
AlipayConfigurations.getPrivateKey(), // 固定值json,参数类型,
AlipayConstants.FORMAT_JSON, // 编码方式
AlipayConstants.CHARSET_UTF8, // 公钥
AlipayConfigurations.getPublicKey(), AlipayConstants.SIGN_TYPE_RSA2);
// 实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay
AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
request.setBizModel(model);
if (notifyUrl == null || "".equals(notifyUrl)) {
throw new RuntimeException("异步通知回调地址不能为空");
}
// request.setNotifyUrl(AlipayConfigurations.getNotifyUrl(suffix));
request.setNotifyUrl(notifyUrl);
try {
// 这里和普通的接口调用不同,使用的是sdkExecute
AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request);
return response.getBody();
} catch (AlipayApiException e) {
e.printStackTrace();
throw e;
}
}
use of com.alipay.api.AlipayClient in project synergic-developing by zeemood.
the class AlipayAssistant method refund.
/**
* 退款接口
*
* @param model
* @return
* @throws Exception
*/
public static AlipayTradeRefundResponse refund(AlipayTradeRefundModel model) throws Exception {
AlipayClient alipayClient = new DefaultAlipayClient(// 支付地址
AlipayConfigurations.GATE_URL, // 应用id
AlipayConfigurations.getAppid(), // 私钥
AlipayConfigurations.getPrivateKey(), // 固定值json,参数类型,
AlipayConstants.FORMAT_JSON, // 编码方式
AlipayConstants.CHARSET_UTF8, // 公钥
AlipayConfigurations.getPublicKey(), AlipayConstants.SIGN_TYPE_RSA2);
AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();
request.setBizModel(model);
AlipayTradeRefundResponse response = alipayClient.execute(request);
if (!response.isSuccess()) {
throw new RuntimeException("调用失败");
}
return response;
}
use of com.alipay.api.AlipayClient in project synergic-developing by zeemood.
the class AlipayAssistant method preOrder4Web.
/**
* 网页支付
*
* @param model
* @param return_url
* @param notify_url
* @return
* @throws Exception
*/
public static String preOrder4Web(AlipayTradePagePayModel model, String return_url, String notify_url) throws Exception {
String html = "";
// 获得初始化的AlipayClient
AlipayClient alipayClient = new DefaultAlipayClient(AlipayConfigurations.GATE_URL, AlipayConfigurations.getAppid(), AlipayConfigurations.getPrivateKey(), AlipayConstants.FORMAT_JSON, AlipayConstants.CHARSET_UTF8, AlipayConfigurations.getPublicKey(), AlipayConstants.SIGN_TYPE_RSA2);
AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();
if (return_url != null && !"".equals(return_url)) {
request.setReturnUrl(return_url);
}
request.setNotifyUrl(notify_url);
request.setBizModel(model);
html = alipayClient.pageExecute(request).getBody();
return html;
}
use of com.alipay.api.AlipayClient in project synergic-developing by zeemood.
the class AlipayAssistant method preOrder4Wap.
/**
* 手机网页支付
*
* @param model
* @param return_url
* @param notify_url
* @return 返回的是一个网页
* @throws Exception
*/
public static String preOrder4Wap(AlipayTradeWapPayModel model, String return_url, String notify_url) throws Exception {
String html = "";
AlipayClient alipayClient = new DefaultAlipayClient(// 支付地址
AlipayConfigurations.GATE_URL, // 应用id
AlipayConfigurations.getAppid(), // 私钥
AlipayConfigurations.getPrivateKey(), // 固定值json,参数类型,
AlipayConstants.FORMAT_JSON, // 编码方式
AlipayConstants.CHARSET_UTF8, // 公钥
AlipayConfigurations.getPublicKey(), AlipayConstants.SIGN_TYPE_RSA2);
AlipayTradeWapPayRequest request = new AlipayTradeWapPayRequest();
if (return_url != null && !"".equals(return_url)) {
request.setReturnUrl(return_url);
}
request.setNotifyUrl(notify_url);
request.setBizModel(model);
AlipayTradeWapPayResponse response = alipayClient.pageExecute(request);
html = response.getBody();
return html;
}
use of com.alipay.api.AlipayClient in project synergic-developing by zeemood.
the class AlipayAssistant method orderStatusQuery.
/**
* 订单状态查询
*
* @param out_trade_no
* @return
* @throws Exception
*/
public static String orderStatusQuery(String out_trade_no) throws Exception {
AlipayClient alipayClient = new // 支付地址
DefaultAlipayClient(// 支付地址
AlipayConfigurations.GATE_URL, // 应用id
AlipayConfigurations.getAppid(), // 私钥
AlipayConfigurations.getPrivateKey(), // 固定值json,参数类型,
AlipayConstants.FORMAT_JSON, // 编码方式
AlipayConstants.CHARSET_UTF8, // 公钥
AlipayConfigurations.getPublicKey(), AlipayConstants.SIGN_TYPE_RSA2);
AlipayTradeQueryRequest request = new AlipayTradeQueryRequest();
AlipayTradeQueryModel model = new AlipayTradeQueryModel();
model.setOutTradeNo(out_trade_no);
AlipayTradeQueryResponse response = alipayClient.execute(request);
String tradeStatus = response.getTradeStatus();
return tradeStatus;
}
Aggregations