1711680493 / spay Goto Github PK
View Code? Open in Web Editor NEW个人也可实现在线支付
License: MIT License
个人也可实现在线支付
License: MIT License
作者你好,请教一下我这回调错误是咋回事呢
package com.lys.spay.service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class PayService {
@GetMapping("/payment_config")
public Object getPaymentConfig() {
return new Object() {
public String code = "10000";
public Object msg = new Object() {
public Object paystr = new Object() {
public Object 微信 = new Object() {
public boolean isUp = true;
public String[] packName = {"com.tencent.mm"};
public Object[] list = {
new Object() {
public boolean isTitle = false;
public String start = "微信支付收款";
public String end = "元";
},
new Object() {
public boolean isTitle = false;
public String start = "收款";
public String end = "元";
}
};
};
};
public String purl = "http://8.134.189.49:8080/payment_callback";
};
};
}
@PostMapping("/payment_callback")
public Object processPaymentCallback(@RequestBody CallbackRequest request) {
String priKey = "lys"; // 请替换为实际的私钥
// 验证priKey和time
long currentTime = System.currentTimeMillis() / 1000; // 当前时间戳(秒)
if (!priKey.equals(request.getPriKey()) || currentTime - request.getTime() > 150) {
return new Response("20001", "权限验证失败");
}
// 根据amount和type确认订单,完成支付逻辑
// 这里可以添加具体的订单处理逻辑
// 响应结果
return new Response("10000", "支付回调成功");
}
static class CallbackRequest {
private int amount;
private String type;
private String priKey;
private long time;
// 省略getter和setter方法
public int getAmount() {
return amount;
}
public void setAmount(int amount) {
this.amount = amount;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getPriKey() {
return priKey;
}
public void setPriKey(String priKey) {
this.priKey = priKey;
}
public long getTime() {
return time;
}
public void setTime(long time) {
this.time = time;
}
}
static class Response {
private String code;
private String msg;
public Response(String code, String msg) {
this.code = code;
this.msg = msg;
}
// 省略getter和setter方法
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
}
}
这个回调接口的接收参数的类型是用@requestbody吗
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.