接入支付宝 联调修改

This commit is contained in:
2024-02-15 14:03:44 +08:00
parent 318d0a1441
commit 87580cfece
3 changed files with 10 additions and 7 deletions

View File

@@ -35,12 +35,14 @@ public class AliPayController {
@ApiOperation("统一收单下单并支付页面接口的调用")
@PostMapping("/trade/page/pay/{productId}")
public Response<String> tradePagePay(@PathVariable Long productId){
public Response<String> tradePagePay(@PathVariable Long productId,@RequestParam String returnUrl){
System.out.println(productId + " " + returnUrl);
log.info("统一收单下单并支付页面接口的调用");
//支付宝开放平台接受 request 请求对象后
// 会为开发者生成一个html 形式的 form表单包含自动提交的脚本
String formStr = aliPayService.tradeCreate(productId);
String formStr = aliPayService.tradeCreate(productId, returnUrl);
//我们将form表单字符串返回给前端程序之后前端将会调用自动提交脚本进行表单的提交
//此时表单会自动提交到action属性所指向的支付宝开放平台中从而为用户展示一个支付页面
return Response.success(formStr);

View File

@@ -3,7 +3,7 @@ package com.ai.da.service;
import java.util.Map;
public interface AliPayService {
String tradeCreate(Long productId);
String tradeCreate(Long productId,String returnUrl);
void processOrder(Map<String, String> params);

View File

@@ -50,7 +50,7 @@ public class AliPayServiceImpl implements AliPayService {
@Transactional(rollbackFor = Exception.class)
@Override
public String tradeCreate(Long productId) {
public String tradeCreate(Long productId, String returnUrl) {
try {
//生成订单
@@ -60,10 +60,11 @@ public class AliPayServiceImpl implements AliPayService {
//调用支付宝接口
AlipayTradePagePayRequest request = new AlipayTradePagePayRequest();
//配置需要的公共请求参数
//支付完成后,支付宝向谷粒学院发起异步通知的地址
//支付完成后,支付宝发起异步通知的地址
request.setNotifyUrl(config.getProperty("alipay.notify-url"));
//支付完成后,我们想让页面跳转回谷粒学院的页面配置returnUrl
request.setReturnUrl(config.getProperty("alipay.return-url"));
//支付完成后,我们想让页面跳转回aida的页面配置returnUrl
// request.setReturnUrl(config.getProperty("alipay.return-url"));
request.setReturnUrl(returnUrl);
//组装当前业务方法的请求参数
JSONObject bizContent = new JSONObject();