<dependency> <groupId>net.guerlab</groupId> <artifactId>sdk-alipay-starter</artifactId> <version>1.0.3</version> </dependency>
sdk: alipay: dev: true/false #默认false,为true表示使用沙箱环境 sign-type: RSA2 #签名算法 app-id: #应用ID private-key: #应用私钥 alipay-public-key: #支付宝公钥
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import com.alibaba.fastjson.JSONObject;
import com.alipay.api.AlipayClient;
import com.alipay.api.request.AlipayTradeAppPayRequest;
import com.alipay.api.request.AlipayTradePagePayRequest;
import com.alipay.api.request.AlipayTradeWapPayRequest;
import net.guerlab.sdk.alipay.controller.AlipayAbstractController;
@RequestMapping("/pay/alipay")
public class AlipayController extends AlipayAbstractController {
@Autowired
private AlipayClient client;//支付宝请求sdk客户端
/**
* 支付请求
*/
@GetMapping("/app/{orderId}")
public String app(
@PathVariable Long orderId,
HttpServletResponse httpResponse) {
JSONObject data = new JSONObject();
data.put("out_trade_no", "201701010000001234"); //商户订单号
data.put("product_code", "QUICK_MSECURITY_PAY"); //产品码, APP支付 QUICK_MSECURITY_PAY, PC支付 FAST_INSTANT_TRADE_PAY, 移动H5支付 QUICK_WAP_PAY
data.put("total_amount", "0.01"); //订单金额
data.put("subject", "测试订单"); //订单标题
//APP支付
AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
//PC支付
//AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();
//移动H5支付
//AlipayTradeWapPayRequest request = new AlipayTradeWapPayRequest();
request.setNotifyUrl("http://demo/pay/alipay/notify/1"); //异步通知地址
request.setBizContent(data.toJSONString()); //业务参数
return client.sdkExecute(request).getBody();
}
@PostMapping("/notify/{orderId}")
public String notify(
@PathVariable Long orderId,
HttpServletRequest request) {
if (!notify0(request.getParameterMap())) {
//这里处理验签失败
}
request.getParameter("trade_no");//获取请求参数中的商户订单号
return "success";
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有