From a6b0f06f884b16cf0085d36511ac60210caa8bf9 Mon Sep 17 00:00:00 2001 From: Pasha Date: Wed, 23 Jul 2025 16:19:30 +0300 Subject: [PATCH] upd proto and added rpc client for cart --- internal/client/callback.go | 40 +++++ internal/proto/payment_callback/service.pb.go | 161 +++++++++--------- .../proto/payment_callback/service_grpc.pb.go | 62 +++++-- proto/callback/service.proto | 3 +- 4 files changed, 170 insertions(+), 96 deletions(-) diff --git a/internal/client/callback.go b/internal/client/callback.go index fdf8394..1105327 100644 --- a/internal/client/callback.go +++ b/internal/client/callback.go @@ -107,3 +107,43 @@ func (c *CallbackClient) SendOnFailure(ctx context.Context, host string, event * return nil } + +func (c *CallbackClient) SendOnCartPurchase(ctx context.Context, host string, event *models.Event) errors.Error { + connection, err := grpc.Dial(host, grpc.WithTransportCredentials(insecure.NewCredentials())) + if err != nil { + c.logger.Error("failed to connect on of ", zap.Error(err), zap.String("host", host)) + return errors.NewWithError(fmt.Errorf("failed connect to callback service: %w", err), errors.ErrInternalError) + } + defer func() { + if closeErr := connection.Close(); closeErr != nil { + c.logger.Error("failed to close connection on of ", zap.Error(closeErr)) + } + }() + + client := payment_callback.NewPaymentCallbackServiceClient(connection) + + if _, err := client.OnCartPurchase(ctx, &payment_callback.Event{ + Key: event.Key, + Message: event.Message, + Payment: &payment_callback.Payment{ + ID: event.Payment.ID, + UserID: event.Payment.UserID, + PaymentID: event.Payment.PaymentID, + IdempotencePaymentID: event.Payment.IdempotencePaymentID, + Amount: event.Payment.Amount, + Currency: event.Payment.Currency, + Type: string(event.Payment.Type), + Status: string(event.Payment.Status), + Completed: event.Payment.Completed, + }, + }); err != nil { + c.logger.Error("failed to send cart purchase callback on of ", + zap.Error(err), + zap.String("host", host), + zap.Any("event", event), + ) + return errors.NewWithError(fmt.Errorf("failed to cart purchase callback: %w", err), errors.ErrInternalError) + } + + return nil +} diff --git a/internal/proto/payment_callback/service.pb.go b/internal/proto/payment_callback/service.pb.go index 8f02a6f..0bac741 100644 --- a/internal/proto/payment_callback/service.pb.go +++ b/internal/proto/payment_callback/service.pb.go @@ -1,8 +1,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.33.0 -// protoc (unknown) -// source: callback/service.proto +// protoc-gen-go v1.25.0-devel +// protoc v3.14.0 +// source: service.proto package payment_callback @@ -10,7 +10,6 @@ import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" emptypb "google.golang.org/protobuf/types/known/emptypb" - _ "google.golang.org/protobuf/types/known/timestamppb" reflect "reflect" sync "sync" ) @@ -35,7 +34,7 @@ type Event struct { func (x *Event) Reset() { *x = Event{} if protoimpl.UnsafeEnabled { - mi := &file_callback_service_proto_msgTypes[0] + mi := &file_service_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -48,7 +47,7 @@ func (x *Event) String() string { func (*Event) ProtoMessage() {} func (x *Event) ProtoReflect() protoreflect.Message { - mi := &file_callback_service_proto_msgTypes[0] + mi := &file_service_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -61,7 +60,7 @@ func (x *Event) ProtoReflect() protoreflect.Message { // Deprecated: Use Event.ProtoReflect.Descriptor instead. func (*Event) Descriptor() ([]byte, []int) { - return file_callback_service_proto_rawDescGZIP(), []int{0} + return file_service_proto_rawDescGZIP(), []int{0} } func (x *Event) GetKey() string { @@ -104,7 +103,7 @@ type Payment struct { func (x *Payment) Reset() { *x = Payment{} if protoimpl.UnsafeEnabled { - mi := &file_callback_service_proto_msgTypes[1] + mi := &file_service_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -117,7 +116,7 @@ func (x *Payment) String() string { func (*Payment) ProtoMessage() {} func (x *Payment) ProtoReflect() protoreflect.Message { - mi := &file_callback_service_proto_msgTypes[1] + mi := &file_service_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -130,7 +129,7 @@ func (x *Payment) ProtoReflect() protoreflect.Message { // Deprecated: Use Payment.ProtoReflect.Descriptor instead. func (*Payment) Descriptor() ([]byte, []int) { - return file_callback_service_proto_rawDescGZIP(), []int{1} + return file_service_proto_rawDescGZIP(), []int{1} } func (x *Payment) GetID() string { @@ -196,90 +195,94 @@ func (x *Payment) GetCompleted() bool { return false } -var File_callback_service_proto protoreflect.FileDescriptor +var File_service_proto protoreflect.FileDescriptor -var file_callback_service_proto_rawDesc = []byte{ - 0x0a, 0x16, 0x63, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x10, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, - 0x74, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, - 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, - 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, - 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x68, 0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, - 0x74, 0x12, 0x10, 0x0a, 0x03, 0x4b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, - 0x4b, 0x65, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x33, 0x0a, - 0x07, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, - 0x2e, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, - 0x6b, 0x2e, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x07, 0x50, 0x61, 0x79, 0x6d, 0x65, - 0x6e, 0x74, 0x22, 0x81, 0x02, 0x0a, 0x07, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x0e, - 0x0a, 0x02, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x49, 0x44, 0x12, 0x16, - 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x44, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, - 0x55, 0x73, 0x65, 0x72, 0x49, 0x44, 0x12, 0x1c, 0x0a, 0x09, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, - 0x74, 0x49, 0x44, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x50, 0x61, 0x79, 0x6d, 0x65, - 0x6e, 0x74, 0x49, 0x44, 0x12, 0x32, 0x0a, 0x14, 0x49, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, - 0x6e, 0x63, 0x65, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x44, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x14, 0x49, 0x64, 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x65, 0x50, - 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x44, 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, - 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, - 0x12, 0x1a, 0x0a, 0x08, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x08, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x12, 0x0a, 0x04, - 0x54, 0x79, 0x70, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x54, 0x79, 0x70, 0x65, - 0x12, 0x16, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x43, 0x6f, 0x6d, 0x70, - 0x6c, 0x65, 0x74, 0x65, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x43, 0x6f, 0x6d, - 0x70, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x32, 0x98, 0x01, 0x0a, 0x16, 0x50, 0x61, 0x79, 0x6d, 0x65, - 0x6e, 0x74, 0x43, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x12, 0x3e, 0x0a, 0x09, 0x4f, 0x6e, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x17, - 0x2e, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, - 0x6b, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, - 0x00, 0x12, 0x3e, 0x0a, 0x09, 0x4f, 0x6e, 0x46, 0x61, 0x69, 0x6c, 0x75, 0x72, 0x65, 0x12, 0x17, - 0x2e, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, - 0x6b, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, - 0x00, 0x42, 0x14, 0x5a, 0x12, 0x2e, 0x2f, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x63, - 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +var file_service_proto_rawDesc = []byte{ + 0x0a, 0x0d, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, + 0x10, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, + 0x6b, 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x68, + 0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x4b, 0x65, 0x79, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x4b, 0x65, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x4d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x12, 0x33, 0x0a, 0x07, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x63, + 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x2e, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x52, + 0x07, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x81, 0x02, 0x0a, 0x07, 0x50, 0x61, 0x79, + 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x02, 0x49, 0x44, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x44, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x44, 0x12, 0x1c, 0x0a, 0x09, + 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x44, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x09, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x44, 0x12, 0x32, 0x0a, 0x14, 0x49, 0x64, + 0x65, 0x6d, 0x70, 0x6f, 0x74, 0x65, 0x6e, 0x63, 0x65, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, + 0x49, 0x44, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x14, 0x49, 0x64, 0x65, 0x6d, 0x70, 0x6f, + 0x74, 0x65, 0x6e, 0x63, 0x65, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x44, 0x12, 0x16, + 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, + 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, + 0x63, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, + 0x63, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x54, 0x79, 0x70, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x04, 0x54, 0x79, 0x70, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1c, + 0x0a, 0x09, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x09, 0x43, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x32, 0xdd, 0x01, 0x0a, + 0x16, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x43, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x3e, 0x0a, 0x09, 0x4f, 0x6e, 0x53, 0x75, 0x63, + 0x63, 0x65, 0x73, 0x73, 0x12, 0x17, 0x2e, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x63, + 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x1a, 0x16, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x09, 0x4f, 0x6e, 0x46, 0x61, 0x69, + 0x6c, 0x75, 0x72, 0x65, 0x12, 0x17, 0x2e, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x63, + 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x1a, 0x16, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x12, 0x43, 0x0a, 0x0e, 0x4f, 0x6e, 0x43, 0x61, 0x72, + 0x74, 0x50, 0x75, 0x72, 0x63, 0x68, 0x61, 0x73, 0x65, 0x12, 0x17, 0x2e, 0x70, 0x61, 0x79, 0x6d, + 0x65, 0x6e, 0x74, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x2e, 0x45, 0x76, 0x65, + 0x6e, 0x74, 0x1a, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x22, 0x00, 0x42, 0x14, 0x5a, 0x12, + 0x2e, 0x2f, 0x70, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x62, 0x61, + 0x63, 0x6b, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - file_callback_service_proto_rawDescOnce sync.Once - file_callback_service_proto_rawDescData = file_callback_service_proto_rawDesc + file_service_proto_rawDescOnce sync.Once + file_service_proto_rawDescData = file_service_proto_rawDesc ) -func file_callback_service_proto_rawDescGZIP() []byte { - file_callback_service_proto_rawDescOnce.Do(func() { - file_callback_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_callback_service_proto_rawDescData) +func file_service_proto_rawDescGZIP() []byte { + file_service_proto_rawDescOnce.Do(func() { + file_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_service_proto_rawDescData) }) - return file_callback_service_proto_rawDescData + return file_service_proto_rawDescData } -var file_callback_service_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_callback_service_proto_goTypes = []interface{}{ +var file_service_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_service_proto_goTypes = []interface{}{ (*Event)(nil), // 0: payment_callback.Event (*Payment)(nil), // 1: payment_callback.Payment (*emptypb.Empty)(nil), // 2: google.protobuf.Empty } -var file_callback_service_proto_depIdxs = []int32{ +var file_service_proto_depIdxs = []int32{ 1, // 0: payment_callback.Event.Payment:type_name -> payment_callback.Payment 0, // 1: payment_callback.PaymentCallbackService.OnSuccess:input_type -> payment_callback.Event 0, // 2: payment_callback.PaymentCallbackService.OnFailure:input_type -> payment_callback.Event - 2, // 3: payment_callback.PaymentCallbackService.OnSuccess:output_type -> google.protobuf.Empty - 2, // 4: payment_callback.PaymentCallbackService.OnFailure:output_type -> google.protobuf.Empty - 3, // [3:5] is the sub-list for method output_type - 1, // [1:3] is the sub-list for method input_type + 0, // 3: payment_callback.PaymentCallbackService.OnCartPurchase:input_type -> payment_callback.Event + 2, // 4: payment_callback.PaymentCallbackService.OnSuccess:output_type -> google.protobuf.Empty + 2, // 5: payment_callback.PaymentCallbackService.OnFailure:output_type -> google.protobuf.Empty + 2, // 6: payment_callback.PaymentCallbackService.OnCartPurchase:output_type -> google.protobuf.Empty + 4, // [4:7] is the sub-list for method output_type + 1, // [1:4] is the sub-list for method input_type 1, // [1:1] is the sub-list for extension type_name 1, // [1:1] is the sub-list for extension extendee 0, // [0:1] is the sub-list for field type_name } -func init() { file_callback_service_proto_init() } -func file_callback_service_proto_init() { - if File_callback_service_proto != nil { +func init() { file_service_proto_init() } +func file_service_proto_init() { + if File_service_proto != nil { return } if !protoimpl.UnsafeEnabled { - file_callback_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Event); i { case 0: return &v.state @@ -291,7 +294,7 @@ func file_callback_service_proto_init() { return nil } } - file_callback_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*Payment); i { case 0: return &v.state @@ -308,18 +311,18 @@ func file_callback_service_proto_init() { out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_callback_service_proto_rawDesc, + RawDescriptor: file_service_proto_rawDesc, NumEnums: 0, NumMessages: 2, NumExtensions: 0, NumServices: 1, }, - GoTypes: file_callback_service_proto_goTypes, - DependencyIndexes: file_callback_service_proto_depIdxs, - MessageInfos: file_callback_service_proto_msgTypes, + GoTypes: file_service_proto_goTypes, + DependencyIndexes: file_service_proto_depIdxs, + MessageInfos: file_service_proto_msgTypes, }.Build() - File_callback_service_proto = out.File - file_callback_service_proto_rawDesc = nil - file_callback_service_proto_goTypes = nil - file_callback_service_proto_depIdxs = nil + File_service_proto = out.File + file_service_proto_rawDesc = nil + file_service_proto_goTypes = nil + file_service_proto_depIdxs = nil } diff --git a/internal/proto/payment_callback/service_grpc.pb.go b/internal/proto/payment_callback/service_grpc.pb.go index c4291fd..891b558 100644 --- a/internal/proto/payment_callback/service_grpc.pb.go +++ b/internal/proto/payment_callback/service_grpc.pb.go @@ -1,8 +1,4 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.3.0 -// - protoc (unknown) -// source: callback/service.proto package payment_callback @@ -19,17 +15,13 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 -const ( - PaymentCallbackService_OnSuccess_FullMethodName = "/payment_callback.PaymentCallbackService/OnSuccess" - PaymentCallbackService_OnFailure_FullMethodName = "/payment_callback.PaymentCallbackService/OnFailure" -) - // PaymentCallbackServiceClient is the client API for PaymentCallbackService service. // // 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 PaymentCallbackServiceClient interface { OnSuccess(ctx context.Context, in *Event, opts ...grpc.CallOption) (*emptypb.Empty, error) OnFailure(ctx context.Context, in *Event, opts ...grpc.CallOption) (*emptypb.Empty, error) + OnCartPurchase(ctx context.Context, in *Event, opts ...grpc.CallOption) (*emptypb.Empty, error) } type paymentCallbackServiceClient struct { @@ -42,7 +34,7 @@ func NewPaymentCallbackServiceClient(cc grpc.ClientConnInterface) PaymentCallbac func (c *paymentCallbackServiceClient) OnSuccess(ctx context.Context, in *Event, opts ...grpc.CallOption) (*emptypb.Empty, error) { out := new(emptypb.Empty) - err := c.cc.Invoke(ctx, PaymentCallbackService_OnSuccess_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, "/payment_callback.PaymentCallbackService/OnSuccess", in, out, opts...) if err != nil { return nil, err } @@ -51,7 +43,16 @@ func (c *paymentCallbackServiceClient) OnSuccess(ctx context.Context, in *Event, func (c *paymentCallbackServiceClient) OnFailure(ctx context.Context, in *Event, opts ...grpc.CallOption) (*emptypb.Empty, error) { out := new(emptypb.Empty) - err := c.cc.Invoke(ctx, PaymentCallbackService_OnFailure_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, "/payment_callback.PaymentCallbackService/OnFailure", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *paymentCallbackServiceClient) OnCartPurchase(ctx context.Context, in *Event, opts ...grpc.CallOption) (*emptypb.Empty, error) { + out := new(emptypb.Empty) + err := c.cc.Invoke(ctx, "/payment_callback.PaymentCallbackService/OnCartPurchase", in, out, opts...) if err != nil { return nil, err } @@ -59,14 +60,16 @@ func (c *paymentCallbackServiceClient) OnFailure(ctx context.Context, in *Event, } // PaymentCallbackServiceServer is the server API for PaymentCallbackService service. -// All implementations should embed UnimplementedPaymentCallbackServiceServer +// All implementations must embed UnimplementedPaymentCallbackServiceServer // for forward compatibility type PaymentCallbackServiceServer interface { OnSuccess(context.Context, *Event) (*emptypb.Empty, error) OnFailure(context.Context, *Event) (*emptypb.Empty, error) + OnCartPurchase(context.Context, *Event) (*emptypb.Empty, error) + mustEmbedUnimplementedPaymentCallbackServiceServer() } -// UnimplementedPaymentCallbackServiceServer should be embedded to have forward compatible implementations. +// UnimplementedPaymentCallbackServiceServer must be embedded to have forward compatible implementations. type UnimplementedPaymentCallbackServiceServer struct { } @@ -76,6 +79,11 @@ func (UnimplementedPaymentCallbackServiceServer) OnSuccess(context.Context, *Eve func (UnimplementedPaymentCallbackServiceServer) OnFailure(context.Context, *Event) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method OnFailure not implemented") } +func (UnimplementedPaymentCallbackServiceServer) OnCartPurchase(context.Context, *Event) (*emptypb.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method OnCartPurchase not implemented") +} +func (UnimplementedPaymentCallbackServiceServer) mustEmbedUnimplementedPaymentCallbackServiceServer() { +} // UnsafePaymentCallbackServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to PaymentCallbackServiceServer will @@ -98,7 +106,7 @@ func _PaymentCallbackService_OnSuccess_Handler(srv interface{}, ctx context.Cont } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: PaymentCallbackService_OnSuccess_FullMethodName, + FullMethod: "/payment_callback.PaymentCallbackService/OnSuccess", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(PaymentCallbackServiceServer).OnSuccess(ctx, req.(*Event)) @@ -116,7 +124,7 @@ func _PaymentCallbackService_OnFailure_Handler(srv interface{}, ctx context.Cont } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: PaymentCallbackService_OnFailure_FullMethodName, + FullMethod: "/payment_callback.PaymentCallbackService/OnFailure", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(PaymentCallbackServiceServer).OnFailure(ctx, req.(*Event)) @@ -124,6 +132,24 @@ func _PaymentCallbackService_OnFailure_Handler(srv interface{}, ctx context.Cont return interceptor(ctx, in, info, handler) } +func _PaymentCallbackService_OnCartPurchase_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(Event) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PaymentCallbackServiceServer).OnCartPurchase(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/payment_callback.PaymentCallbackService/OnCartPurchase", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PaymentCallbackServiceServer).OnCartPurchase(ctx, req.(*Event)) + } + return interceptor(ctx, in, info, handler) +} + // PaymentCallbackService_ServiceDesc is the grpc.ServiceDesc for PaymentCallbackService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -139,7 +165,11 @@ var PaymentCallbackService_ServiceDesc = grpc.ServiceDesc{ MethodName: "OnFailure", Handler: _PaymentCallbackService_OnFailure_Handler, }, + { + MethodName: "OnCartPurchase", + Handler: _PaymentCallbackService_OnCartPurchase_Handler, + }, }, Streams: []grpc.StreamDesc{}, - Metadata: "callback/service.proto", + Metadata: "service.proto", } diff --git a/proto/callback/service.proto b/proto/callback/service.proto index d9eea36..f85995e 100644 --- a/proto/callback/service.proto +++ b/proto/callback/service.proto @@ -3,13 +3,14 @@ syntax = "proto3"; package payment_callback; import "google/protobuf/empty.proto"; -import "google/protobuf/timestamp.proto"; +//import "google/protobuf/timestamp.proto"; option go_package = "./payment_callback"; service PaymentCallbackService { rpc OnSuccess(Event) returns (google.protobuf.Empty) {} rpc OnFailure(Event) returns (google.protobuf.Empty) {} + rpc OnCartPurchase(Event) returns (google.protobuf.Empty) {} } message Event {