feat: payment refund

This commit is contained in:
zzw
2026-10-07 09:28:12 +08:00
parent a39ab003f4
commit a4c04b9c83
17 changed files with 258 additions and 116 deletions
Binary file not shown.
+5 -4
View File
@@ -26,16 +26,16 @@ service Payment {
};
}
rpc Refund(RefundReq) returns (Response) {
rpc Notify(NotifyReq) returns (Response) {
option (google.api.http) = {
post: "/api/v3/payment/refund"
post: "/api/v3/payment/notify"
body: "*"
};
}
rpc Notify(NotifyReq) returns (Response) {
rpc Refund(RefundReq) returns (Response) {
option (google.api.http) = {
post: "/api/v3/payment/notify"
post: "/admin/v3/payment/refund"
body: "*"
};
}
@@ -51,6 +51,7 @@ message PayReq {
string order_sn = 1;
string client = 2;
string channel = 3;
string openid = 4;
}
message QueryReq {
+14 -5
View File
@@ -88,6 +88,7 @@ type PayReq struct {
OrderSn string `protobuf:"bytes,1,opt,name=order_sn,json=orderSn,proto3" json:"order_sn,omitempty"`
Client string `protobuf:"bytes,2,opt,name=client,proto3" json:"client,omitempty"`
Channel string `protobuf:"bytes,3,opt,name=channel,proto3" json:"channel,omitempty"`
Openid string `protobuf:"bytes,4,opt,name=openid,proto3" json:"openid,omitempty"` // 小程序微信支付必传,当前微信会话的openid
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -143,6 +144,13 @@ func (x *PayReq) GetChannel() string {
return ""
}
func (x *PayReq) GetOpenid() string {
if x != nil {
return x.Openid
}
return ""
}
type QueryReq struct {
state protoimpl.MessageState `protogen:"open.v1"`
OrderSn string `protobuf:"bytes,1,opt,name=order_sn,json=orderSn,proto3" json:"order_sn,omitempty"`
@@ -383,11 +391,12 @@ const file_payment_payment_proto_rawDesc = "" +
"\bResponse\x12\x12\n" +
"\x04code\x18\x01 \x01(\x05R\x04code\x12\x10\n" +
"\x03msg\x18\x02 \x01(\tR\x03msg\x12\x12\n" +
"\x04data\x18\x03 \x01(\tR\x04data\"U\n" +
"\x04data\x18\x03 \x01(\tR\x04data\"m\n" +
"\x06PayReq\x12\x19\n" +
"\border_sn\x18\x01 \x01(\tR\aorderSn\x12\x16\n" +
"\x06client\x18\x02 \x01(\tR\x06client\x12\x18\n" +
"\achannel\x18\x03 \x01(\tR\achannel\"?\n" +
"\achannel\x18\x03 \x01(\tR\achannel\x12\x16\n" +
"\x06openid\x18\x04 \x01(\tR\x06openid\"?\n" +
"\bQueryReq\x12\x19\n" +
"\border_sn\x18\x01 \x01(\tR\aorderSn\x12\x18\n" +
"\achannel\x18\x02 \x01(\tR\achannel\"?\n" +
@@ -405,13 +414,13 @@ const file_payment_payment_proto_rawDesc = "" +
"\x04body\x18\x03 \x01(\fR\x04body\x1a:\n" +
"\fHeadersEntry\x12\x10\n" +
"\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" +
"\x05value\x18\x02 \x01(\tR\x05value:\x028\x012\xa8\x03\n" +
"\x05value\x18\x02 \x01(\tR\x05value:\x028\x012\x9e\x03\n" +
"\aPayment\x12I\n" +
"\x03Pay\x12\x0f.payment.PayReq\x1a\x11.payment.Response\"\x1e\x82\xd3\xe4\x93\x02\x18:\x01*\"\x13/api/v3/payment/pay\x12O\n" +
"\x05Query\x12\x11.payment.QueryReq\x1a\x11.payment.Response\" \x82\xd3\xe4\x93\x02\x1a:\x01*\"\x15/api/v3/payment/query\x12O\n" +
"\x05Close\x12\x11.payment.CloseReq\x1a\x11.payment.Response\" \x82\xd3\xe4\x93\x02\x1a:\x01*\"\x15/api/v3/payment/close\x12R\n" +
"\x06Refund\x12\x12.payment.RefundReq\x1a\x11.payment.Response\"!\x82\xd3\xe4\x93\x02\x1b:\x01*\"\x16/api/v3/payment/refund\x12\\\n" +
"\x06Notify\x12\x12.payment.NotifyReq\x1a\x11.payment.Response\"+\x82\xd3\xe4\x93\x02%:\x01*\" /api/v3/payment/notify/{channel}B\x1bZ\x19lone-services/rpc/paymentb\x06proto3"
"\x06Refund\x12\x12.payment.RefundReq\x1a\x11.payment.Response\"!\x82\xd3\xe4\x93\x02\x1b:\x01*\"\x16/api/v3/payment/refund\x12R\n" +
"\x06Notify\x12\x12.payment.NotifyReq\x1a\x11.payment.Response\"!\x82\xd3\xe4\x93\x02\x1b:\x01*\"\x16/api/v3/payment/notifyB\x1bZ\x19lone-services/rpc/paymentb\x06proto3"
var (
file_payment_payment_proto_rawDescOnce sync.Once
-10
View File
@@ -30,15 +30,10 @@ const (
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type PaymentClient interface {
// 发起支付
Pay(ctx context.Context, in *PayReq, opts ...grpc.CallOption) (*Response, error)
// 查询支付状态
Query(ctx context.Context, in *QueryReq, opts ...grpc.CallOption) (*Response, error)
// 关闭支付
Close(ctx context.Context, in *CloseReq, opts ...grpc.CallOption) (*Response, error)
// 退款
Refund(ctx context.Context, in *RefundReq, opts ...grpc.CallOption) (*Response, error)
// 支付回调(由 BFF/网关转发原始 body + headers)
Notify(ctx context.Context, in *NotifyReq, opts ...grpc.CallOption) (*Response, error)
}
@@ -104,15 +99,10 @@ func (c *paymentClient) Notify(ctx context.Context, in *NotifyReq, opts ...grpc.
// All implementations must embed UnimplementedPaymentServer
// for forward compatibility.
type PaymentServer interface {
// 发起支付
Pay(context.Context, *PayReq) (*Response, error)
// 查询支付状态
Query(context.Context, *QueryReq) (*Response, error)
// 关闭支付
Close(context.Context, *CloseReq) (*Response, error)
// 退款
Refund(context.Context, *RefundReq) (*Response, error)
// 支付回调(由 BFF/网关转发原始 body + headers)
Notify(context.Context, *NotifyReq) (*Response, error)
mustEmbedUnimplementedPaymentServer()
}