支付宝支付 第六集:生成支付二维码
一、资源
-
支付宝沙箱显示APP-ID错误:我的原因是支付宝网关地址写错了
-
支付宝沙箱报错invalid-signature,我的原因是应用公钥操作错误了(两个错误我都占上了,靠!!!)
支付宝沙箱报错: invalid-signature 错误原因: 验签出错,建议检查签名字符串或签名私钥与应用公钥是否匹配,网关生成的验签字符串为:xxx
二、目录结构
三、代码
-
AlipayController.java
@Controller public class AlipayController { private final AlipayService alipayService; public AlipayController(AlipayService alipayService) { this.alipayService = alipayService; } @GetMapping("/alipay/pay") @ResponseBody public byte[] alipay(PayVo payVo){ payVo.setUserId("1"); return alipayService.alipay(payVo); } }
-
修改index.html
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>支付</title> </head> <body> <h1>支付宝二维码支付</h1> <img src="/alipay/pay" alt=""> </body> </html>