public String aliPay() {
AlipayClient alipayClient = new DefaultAlipayClient(AppAliPayConfigs.getGateWay(), //https://openapi.alipay.com/gateway.do
AppAliPayConfigs.getAppID(), //商户id
AppAliPayConfigs.getPrivateKey(), //私钥
AppAliPayConfigs.FORMAT, //返回格式“json”
AppAliPayConfigs.CHARSET, //编码“UTF-8”
AppAliPayConfigs.getAliPublicKey(),//公钥
AppAliPayConfigs.SIGNTYPE);//“RSA2”
AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
model.setBody("XXX商铺");
model.setSubject("xxx商铺"订单号为+Order.getOrderCode())); // "xxx商铺订单:" + Order.getOrderCode()
model.setOutTradeNo(订单号); // Order.getOrderCode()
model.setTimeoutExpress("30m"); //超时30分钟,自动取消
model.setTotalAmount(amount); //Order.getPrice()
model.setProductCode("QUICK_MSECURITY_PAY");
request.setBizModel(model);
request.setNotifyUrl((String)body.get("notify_url")); //回调接口对应的方法地址
String orderStr = "";
try {
AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request);
orderStr = response.getBody();
} catch (AlipayApiException e) {
e.printStackTrace();
}
return orderStr;
}
调用jar,导包就不详细叙述了。具体参考https://docs.open.alipay.com/api
APP端付款-->支付宝
最新推荐文章于 2021-04-15 09:53:46 发布