| | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import io.swagger.annotations.Api; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.ui.Model; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.IOException; |
| | |
| | | import java.security.NoSuchAlgorithmException; |
| | | |
| | | @Slf4j |
| | | @RestController |
| | | @Controller |
| | | //@RestController |
| | | @Api(value = "FiuuReturnController", tags = "FIUU支付-ReturnURL") |
| | | @RequestMapping(value = "/api/fuPayReturn") |
| | | public class FiuuReturnController { |
| | | |
| | | @PostMapping("/payment/callback") |
| | | public String handlePaymentCallback( |
| | | @RequestParam("amount") String amount, |
| | | @RequestParam("orderid") String orderId, |
| | | @RequestParam("tranID") String tranId, |
| | | @RequestParam("status") String status, |
| | | @RequestParam("domain") String domain, |
| | | @RequestParam("currency") String currency, |
| | | @RequestParam("paydate") String payDate, |
| | | @RequestParam("skey") String skey, |
| | | Model model) { |
| | | |
| | | // // 验证skey以确保数据完整性 |
| | | // if (!validateSkey(tranId, orderId, status, domain, amount, currency, payDate, skey)) { |
| | | // return "error"; // 如果验证失败,跳转到错误页面 |
| | | // } |
| | | |
| | | // 将支付结果信息传递给支付成功页面 |
| | | model.addAttribute("amount", amount); |
| | | model.addAttribute("orderId", orderId); |
| | | model.addAttribute("tranId", tranId); |
| | | model.addAttribute("status", status); |
| | | model.addAttribute("currency", currency); |
| | | model.addAttribute("payDate", payDate); |
| | | |
| | | // 跳转到支付成功页面 |
| | | return "payment-success"; |
| | | } |
| | | |
| | | private boolean validateSkey(String tranId, String orderId, String status, String domain, |
| | | String amount, String currency, String payDate, String skey) { |
| | | // 这里实现skey的验证逻辑 |
| | | // 根据支付网关提供的skey生成规则,生成skey并与传入的skey进行比较 |
| | | // 如果一致,返回true,否则返回false |
| | | return true; // 这里假设验证通过 |
| | | } |
| | | |
| | | private static final String SECRET_KEY = "59c709fc18978a6a83b87f05d37cecbf"; |
| | | @Resource |
| | | private MallOrderInfoMapper mallOrderInfoMapper; |