From 05089cab41b16f2a0e49c8f1a19539e90fc0abaf Mon Sep 17 00:00:00 2001 From: pasha1coil Date: Sat, 14 Jun 2025 04:33:27 +0300 Subject: [PATCH 01/20] update proto --- internal/proto/treasurer/payment.model.pb.go | 408 ------------ internal/proto/treasurer/service.pb.go | 626 +++++++++++++++---- internal/proto/treasurer/service_grpc.pb.go | 82 ++- proto/treasurer/payment.model.proto | 10 +- proto/treasurer/service.proto | 7 +- 5 files changed, 586 insertions(+), 547 deletions(-) delete mode 100644 internal/proto/treasurer/payment.model.pb.go diff --git a/internal/proto/treasurer/payment.model.pb.go b/internal/proto/treasurer/payment.model.pb.go deleted file mode 100644 index 266a504..0000000 --- a/internal/proto/treasurer/payment.model.pb.go +++ /dev/null @@ -1,408 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.33.0 -// protoc (unknown) -// source: treasurer/payment.model.proto - -package treasurer - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type MainPaymentSettings struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Currency string `protobuf:"bytes,1,opt,name=Currency,proto3" json:"Currency,omitempty"` - Amount int64 `protobuf:"varint,2,opt,name=Amount,proto3" json:"Amount,omitempty"` - CallbackHostGRPC []string `protobuf:"bytes,3,rep,name=CallbackHostGRPC,proto3" json:"CallbackHostGRPC,omitempty"` - ReturnURL string `protobuf:"bytes,4,opt,name=ReturnURL,proto3" json:"ReturnURL,omitempty"` - UserID string `protobuf:"bytes,5,opt,name=UserID,proto3" json:"UserID,omitempty"` - ClientIP string `protobuf:"bytes,6,opt,name=ClientIP,proto3" json:"ClientIP,omitempty"` - Customer *Customer `protobuf:"bytes,7,opt,name=Customer,proto3" json:"Customer,omitempty"` - Items []*Item `protobuf:"bytes,8,rep,name=Items,proto3" json:"Items,omitempty"` -} - -func (x *MainPaymentSettings) Reset() { - *x = MainPaymentSettings{} - if protoimpl.UnsafeEnabled { - mi := &file_treasurer_payment_model_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *MainPaymentSettings) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*MainPaymentSettings) ProtoMessage() {} - -func (x *MainPaymentSettings) ProtoReflect() protoreflect.Message { - mi := &file_treasurer_payment_model_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use MainPaymentSettings.ProtoReflect.Descriptor instead. -func (*MainPaymentSettings) Descriptor() ([]byte, []int) { - return file_treasurer_payment_model_proto_rawDescGZIP(), []int{0} -} - -func (x *MainPaymentSettings) GetCurrency() string { - if x != nil { - return x.Currency - } - return "" -} - -func (x *MainPaymentSettings) GetAmount() int64 { - if x != nil { - return x.Amount - } - return 0 -} - -func (x *MainPaymentSettings) GetCallbackHostGRPC() []string { - if x != nil { - return x.CallbackHostGRPC - } - return nil -} - -func (x *MainPaymentSettings) GetReturnURL() string { - if x != nil { - return x.ReturnURL - } - return "" -} - -func (x *MainPaymentSettings) GetUserID() string { - if x != nil { - return x.UserID - } - return "" -} - -func (x *MainPaymentSettings) GetClientIP() string { - if x != nil { - return x.ClientIP - } - return "" -} - -func (x *MainPaymentSettings) GetCustomer() *Customer { - if x != nil { - return x.Customer - } - return nil -} - -func (x *MainPaymentSettings) GetItems() []*Item { - if x != nil { - return x.Items - } - return nil -} - -type Customer struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - FullName string `protobuf:"bytes,1,opt,name=FullName,proto3" json:"FullName,omitempty"` - INN string `protobuf:"bytes,2,opt,name=INN,proto3" json:"INN,omitempty"` - Email string `protobuf:"bytes,3,opt,name=Email,proto3" json:"Email,omitempty"` - Phone string `protobuf:"bytes,4,opt,name=Phone,proto3" json:"Phone,omitempty"` -} - -func (x *Customer) Reset() { - *x = Customer{} - if protoimpl.UnsafeEnabled { - mi := &file_treasurer_payment_model_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Customer) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Customer) ProtoMessage() {} - -func (x *Customer) ProtoReflect() protoreflect.Message { - mi := &file_treasurer_payment_model_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Customer.ProtoReflect.Descriptor instead. -func (*Customer) Descriptor() ([]byte, []int) { - return file_treasurer_payment_model_proto_rawDescGZIP(), []int{1} -} - -func (x *Customer) GetFullName() string { - if x != nil { - return x.FullName - } - return "" -} - -func (x *Customer) GetINN() string { - if x != nil { - return x.INN - } - return "" -} - -func (x *Customer) GetEmail() string { - if x != nil { - return x.Email - } - return "" -} - -func (x *Customer) GetPhone() string { - if x != nil { - return x.Phone - } - return "" -} - -type Item struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Description string `protobuf:"bytes,1,opt,name=Description,proto3" json:"Description,omitempty"` - Measure string `protobuf:"bytes,2,opt,name=Measure,proto3" json:"Measure,omitempty"` - Quantity string `protobuf:"bytes,3,opt,name=Quantity,proto3" json:"Quantity,omitempty"` - Money string `protobuf:"bytes,4,opt,name=Money,proto3" json:"Money,omitempty"` - Currency string `protobuf:"bytes,5,opt,name=Currency,proto3" json:"Currency,omitempty"` -} - -func (x *Item) Reset() { - *x = Item{} - if protoimpl.UnsafeEnabled { - mi := &file_treasurer_payment_model_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Item) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Item) ProtoMessage() {} - -func (x *Item) ProtoReflect() protoreflect.Message { - mi := &file_treasurer_payment_model_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Item.ProtoReflect.Descriptor instead. -func (*Item) Descriptor() ([]byte, []int) { - return file_treasurer_payment_model_proto_rawDescGZIP(), []int{2} -} - -func (x *Item) GetDescription() string { - if x != nil { - return x.Description - } - return "" -} - -func (x *Item) GetMeasure() string { - if x != nil { - return x.Measure - } - return "" -} - -func (x *Item) GetQuantity() string { - if x != nil { - return x.Quantity - } - return "" -} - -func (x *Item) GetMoney() string { - if x != nil { - return x.Money - } - return "" -} - -func (x *Item) GetCurrency() string { - if x != nil { - return x.Currency - } - return "" -} - -var File_treasurer_payment_model_proto protoreflect.FileDescriptor - -var file_treasurer_payment_model_proto_rawDesc = []byte{ - 0x0a, 0x1d, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2f, 0x70, 0x61, 0x79, 0x6d, - 0x65, 0x6e, 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, - 0x09, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x22, 0x9f, 0x02, 0x0a, 0x13, 0x4d, - 0x61, 0x69, 0x6e, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, - 0x67, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x16, - 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, - 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2a, 0x0a, 0x10, 0x43, 0x61, 0x6c, 0x6c, 0x62, 0x61, - 0x63, 0x6b, 0x48, 0x6f, 0x73, 0x74, 0x47, 0x52, 0x50, 0x43, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, - 0x52, 0x10, 0x43, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x48, 0x6f, 0x73, 0x74, 0x47, 0x52, - 0x50, 0x43, 0x12, 0x1c, 0x0a, 0x09, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x55, 0x52, 0x4c, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x55, 0x52, 0x4c, - 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x44, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x44, 0x12, 0x1a, 0x0a, 0x08, 0x43, 0x6c, 0x69, 0x65, - 0x6e, 0x74, 0x49, 0x50, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x43, 0x6c, 0x69, 0x65, - 0x6e, 0x74, 0x49, 0x50, 0x12, 0x2f, 0x0a, 0x08, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, - 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, - 0x65, 0x72, 0x2e, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x52, 0x08, 0x43, 0x75, 0x73, - 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x12, 0x25, 0x0a, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x08, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, - 0x2e, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x22, 0x64, 0x0a, 0x08, - 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x46, 0x75, 0x6c, 0x6c, - 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x46, 0x75, 0x6c, 0x6c, - 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x49, 0x4e, 0x4e, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x03, 0x49, 0x4e, 0x4e, 0x12, 0x14, 0x0a, 0x05, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x14, 0x0a, 0x05, - 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x50, 0x68, 0x6f, - 0x6e, 0x65, 0x22, 0x90, 0x01, 0x0a, 0x04, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x20, 0x0a, 0x0b, 0x44, - 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0b, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, - 0x07, 0x4d, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, - 0x4d, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x51, 0x75, 0x61, 0x6e, 0x74, - 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x51, 0x75, 0x61, 0x6e, 0x74, - 0x69, 0x74, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x05, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x43, 0x75, 0x72, - 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x43, 0x75, 0x72, - 0x72, 0x65, 0x6e, 0x63, 0x79, 0x42, 0x0d, 0x5a, 0x0b, 0x2e, 0x2f, 0x74, 0x72, 0x65, 0x61, 0x73, - 0x75, 0x72, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_treasurer_payment_model_proto_rawDescOnce sync.Once - file_treasurer_payment_model_proto_rawDescData = file_treasurer_payment_model_proto_rawDesc -) - -func file_treasurer_payment_model_proto_rawDescGZIP() []byte { - file_treasurer_payment_model_proto_rawDescOnce.Do(func() { - file_treasurer_payment_model_proto_rawDescData = protoimpl.X.CompressGZIP(file_treasurer_payment_model_proto_rawDescData) - }) - return file_treasurer_payment_model_proto_rawDescData -} - -var file_treasurer_payment_model_proto_msgTypes = make([]protoimpl.MessageInfo, 3) -var file_treasurer_payment_model_proto_goTypes = []interface{}{ - (*MainPaymentSettings)(nil), // 0: treasurer.MainPaymentSettings - (*Customer)(nil), // 1: treasurer.Customer - (*Item)(nil), // 2: treasurer.Item -} -var file_treasurer_payment_model_proto_depIdxs = []int32{ - 1, // 0: treasurer.MainPaymentSettings.Customer:type_name -> treasurer.Customer - 2, // 1: treasurer.MainPaymentSettings.Items:type_name -> treasurer.Item - 2, // [2:2] is the sub-list for method output_type - 2, // [2:2] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name -} - -func init() { file_treasurer_payment_model_proto_init() } -func file_treasurer_payment_model_proto_init() { - if File_treasurer_payment_model_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_treasurer_payment_model_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*MainPaymentSettings); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_treasurer_payment_model_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Customer); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_treasurer_payment_model_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Item); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_treasurer_payment_model_proto_rawDesc, - NumEnums: 0, - NumMessages: 3, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_treasurer_payment_model_proto_goTypes, - DependencyIndexes: file_treasurer_payment_model_proto_depIdxs, - MessageInfos: file_treasurer_payment_model_proto_msgTypes, - }.Build() - File_treasurer_payment_model_proto = out.File - file_treasurer_payment_model_proto_rawDesc = nil - file_treasurer_payment_model_proto_goTypes = nil - file_treasurer_payment_model_proto_depIdxs = nil -} diff --git a/internal/proto/treasurer/service.pb.go b/internal/proto/treasurer/service.pb.go index a6c2742..b6d0a83 100644 --- a/internal/proto/treasurer/service.pb.go +++ b/internal/proto/treasurer/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: treasurer/service.proto +// protoc-gen-go v1.25.0-devel +// protoc v3.14.0 +// source: service.proto package treasurer @@ -32,7 +32,7 @@ type GetBankCardPaymentLinkRequest struct { func (x *GetBankCardPaymentLinkRequest) Reset() { *x = GetBankCardPaymentLinkRequest{} if protoimpl.UnsafeEnabled { - mi := &file_treasurer_service_proto_msgTypes[0] + mi := &file_service_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -45,7 +45,7 @@ func (x *GetBankCardPaymentLinkRequest) String() string { func (*GetBankCardPaymentLinkRequest) ProtoMessage() {} func (x *GetBankCardPaymentLinkRequest) ProtoReflect() protoreflect.Message { - mi := &file_treasurer_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 { @@ -58,7 +58,7 @@ func (x *GetBankCardPaymentLinkRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetBankCardPaymentLinkRequest.ProtoReflect.Descriptor instead. func (*GetBankCardPaymentLinkRequest) Descriptor() ([]byte, []int) { - return file_treasurer_service_proto_rawDescGZIP(), []int{0} + return file_service_proto_rawDescGZIP(), []int{0} } func (x *GetBankCardPaymentLinkRequest) GetMainSettings() *MainPaymentSettings { @@ -79,7 +79,7 @@ type GetPaymentLinkRequest struct { func (x *GetPaymentLinkRequest) Reset() { *x = GetPaymentLinkRequest{} if protoimpl.UnsafeEnabled { - mi := &file_treasurer_service_proto_msgTypes[1] + mi := &file_service_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -92,7 +92,7 @@ func (x *GetPaymentLinkRequest) String() string { func (*GetPaymentLinkRequest) ProtoMessage() {} func (x *GetPaymentLinkRequest) ProtoReflect() protoreflect.Message { - mi := &file_treasurer_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 { @@ -105,7 +105,7 @@ func (x *GetPaymentLinkRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetPaymentLinkRequest.ProtoReflect.Descriptor instead. func (*GetPaymentLinkRequest) Descriptor() ([]byte, []int) { - return file_treasurer_service_proto_rawDescGZIP(), []int{1} + return file_service_proto_rawDescGZIP(), []int{1} } func (x *GetPaymentLinkRequest) GetMainSettings() *MainPaymentSettings { @@ -128,7 +128,7 @@ type GetB2BPaymentLinkRequest struct { func (x *GetB2BPaymentLinkRequest) Reset() { *x = GetB2BPaymentLinkRequest{} if protoimpl.UnsafeEnabled { - mi := &file_treasurer_service_proto_msgTypes[2] + mi := &file_service_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -141,7 +141,7 @@ func (x *GetB2BPaymentLinkRequest) String() string { func (*GetB2BPaymentLinkRequest) ProtoMessage() {} func (x *GetB2BPaymentLinkRequest) ProtoReflect() protoreflect.Message { - mi := &file_treasurer_service_proto_msgTypes[2] + mi := &file_service_proto_msgTypes[2] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -154,7 +154,7 @@ func (x *GetB2BPaymentLinkRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use GetB2BPaymentLinkRequest.ProtoReflect.Descriptor instead. func (*GetB2BPaymentLinkRequest) Descriptor() ([]byte, []int) { - return file_treasurer_service_proto_rawDescGZIP(), []int{2} + return file_service_proto_rawDescGZIP(), []int{2} } func (x *GetB2BPaymentLinkRequest) GetMainSettings() *MainPaymentSettings { @@ -189,7 +189,7 @@ type GetPaymentLinkResponse struct { func (x *GetPaymentLinkResponse) Reset() { *x = GetPaymentLinkResponse{} if protoimpl.UnsafeEnabled { - mi := &file_treasurer_service_proto_msgTypes[3] + mi := &file_service_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -202,7 +202,7 @@ func (x *GetPaymentLinkResponse) String() string { func (*GetPaymentLinkResponse) ProtoMessage() {} func (x *GetPaymentLinkResponse) ProtoReflect() protoreflect.Message { - mi := &file_treasurer_service_proto_msgTypes[3] + mi := &file_service_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -215,7 +215,7 @@ func (x *GetPaymentLinkResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use GetPaymentLinkResponse.ProtoReflect.Descriptor instead. func (*GetPaymentLinkResponse) Descriptor() ([]byte, []int) { - return file_treasurer_service_proto_rawDescGZIP(), []int{3} + return file_service_proto_rawDescGZIP(), []int{3} } func (x *GetPaymentLinkResponse) GetRedirectURL() string { @@ -225,43 +225,397 @@ func (x *GetPaymentLinkResponse) GetRedirectURL() string { return "" } -var File_treasurer_service_proto protoreflect.FileDescriptor +type DeleteSavedPaymentMethodsRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields -var file_treasurer_service_proto_rawDesc = []byte{ - 0x0a, 0x17, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2f, 0x73, 0x65, 0x72, 0x76, - 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x74, 0x72, 0x65, 0x61, 0x73, - 0x75, 0x72, 0x65, 0x72, 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, 0x1d, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2f, 0x70, 0x61, 0x79, - 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x22, 0x63, 0x0a, 0x1d, 0x47, 0x65, 0x74, 0x42, 0x61, 0x6e, 0x6b, 0x43, 0x61, 0x72, 0x64, 0x50, - 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x42, 0x0a, 0x0c, 0x4d, 0x61, 0x69, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, - 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, - 0x72, 0x65, 0x72, 0x2e, 0x4d, 0x61, 0x69, 0x6e, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x53, - 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x0c, 0x4d, 0x61, 0x69, 0x6e, 0x53, 0x65, 0x74, - 0x74, 0x69, 0x6e, 0x67, 0x73, 0x22, 0x5b, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, - 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x42, - 0x0a, 0x0c, 0x4d, 0x61, 0x69, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, - 0x2e, 0x4d, 0x61, 0x69, 0x6e, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x74, 0x74, - 0x69, 0x6e, 0x67, 0x73, 0x52, 0x0c, 0x4d, 0x61, 0x69, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, - 0x67, 0x73, 0x22, 0xb8, 0x01, 0x0a, 0x18, 0x47, 0x65, 0x74, 0x42, 0x32, 0x42, 0x50, 0x61, 0x79, - 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x42, 0x0a, 0x0c, 0x4d, 0x61, 0x69, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, - 0x72, 0x2e, 0x4d, 0x61, 0x69, 0x6e, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x74, - 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x0c, 0x4d, 0x61, 0x69, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, - 0x6e, 0x67, 0x73, 0x12, 0x26, 0x0a, 0x0e, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x50, 0x75, - 0x72, 0x70, 0x6f, 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x50, 0x61, 0x79, - 0x6d, 0x65, 0x6e, 0x74, 0x50, 0x75, 0x72, 0x70, 0x6f, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x07, 0x56, - 0x61, 0x74, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, - 0x6d, 0x70, 0x74, 0x79, 0x52, 0x07, 0x56, 0x61, 0x74, 0x44, 0x61, 0x74, 0x61, 0x22, 0x3a, 0x0a, - 0x16, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x52, 0x65, 0x64, 0x69, 0x72, - 0x65, 0x63, 0x74, 0x55, 0x52, 0x4c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x52, 0x65, - 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x55, 0x52, 0x4c, 0x32, 0xd4, 0x04, 0x0a, 0x10, 0x54, 0x72, + UserID string `protobuf:"bytes,1,opt,name=UserID,proto3" json:"UserID,omitempty"` +} + +func (x *DeleteSavedPaymentMethodsRequest) Reset() { + *x = DeleteSavedPaymentMethodsRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_service_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeleteSavedPaymentMethodsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteSavedPaymentMethodsRequest) ProtoMessage() {} + +func (x *DeleteSavedPaymentMethodsRequest) ProtoReflect() protoreflect.Message { + mi := &file_service_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteSavedPaymentMethodsRequest.ProtoReflect.Descriptor instead. +func (*DeleteSavedPaymentMethodsRequest) Descriptor() ([]byte, []int) { + return file_service_proto_rawDescGZIP(), []int{4} +} + +func (x *DeleteSavedPaymentMethodsRequest) GetUserID() string { + if x != nil { + return x.UserID + } + return "" +} + +type MainPaymentSettings struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Currency string `protobuf:"bytes,1,opt,name=Currency,proto3" json:"Currency,omitempty"` + Amount int64 `protobuf:"varint,2,opt,name=Amount,proto3" json:"Amount,omitempty"` + CallbackHostGRPC []string `protobuf:"bytes,3,rep,name=CallbackHostGRPC,proto3" json:"CallbackHostGRPC,omitempty"` + ReturnURL string `protobuf:"bytes,4,opt,name=ReturnURL,proto3" json:"ReturnURL,omitempty"` + UserID string `protobuf:"bytes,5,opt,name=UserID,proto3" json:"UserID,omitempty"` + ClientIP string `protobuf:"bytes,6,opt,name=ClientIP,proto3" json:"ClientIP,omitempty"` + Customer *Customer `protobuf:"bytes,7,opt,name=Customer,proto3" json:"Customer,omitempty"` + Items []*Item `protobuf:"bytes,8,rep,name=Items,proto3" json:"Items,omitempty"` + Auto bool `protobuf:"varint,9,opt,name=Auto,proto3" json:"Auto,omitempty"` + Recurrent bool `protobuf:"varint,10,opt,name=Recurrent,proto3" json:"Recurrent,omitempty"` +} + +func (x *MainPaymentSettings) Reset() { + *x = MainPaymentSettings{} + if protoimpl.UnsafeEnabled { + mi := &file_service_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MainPaymentSettings) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MainPaymentSettings) ProtoMessage() {} + +func (x *MainPaymentSettings) ProtoReflect() protoreflect.Message { + mi := &file_service_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use MainPaymentSettings.ProtoReflect.Descriptor instead. +func (*MainPaymentSettings) Descriptor() ([]byte, []int) { + return file_service_proto_rawDescGZIP(), []int{5} +} + +func (x *MainPaymentSettings) GetCurrency() string { + if x != nil { + return x.Currency + } + return "" +} + +func (x *MainPaymentSettings) GetAmount() int64 { + if x != nil { + return x.Amount + } + return 0 +} + +func (x *MainPaymentSettings) GetCallbackHostGRPC() []string { + if x != nil { + return x.CallbackHostGRPC + } + return nil +} + +func (x *MainPaymentSettings) GetReturnURL() string { + if x != nil { + return x.ReturnURL + } + return "" +} + +func (x *MainPaymentSettings) GetUserID() string { + if x != nil { + return x.UserID + } + return "" +} + +func (x *MainPaymentSettings) GetClientIP() string { + if x != nil { + return x.ClientIP + } + return "" +} + +func (x *MainPaymentSettings) GetCustomer() *Customer { + if x != nil { + return x.Customer + } + return nil +} + +func (x *MainPaymentSettings) GetItems() []*Item { + if x != nil { + return x.Items + } + return nil +} + +func (x *MainPaymentSettings) GetAuto() bool { + if x != nil { + return x.Auto + } + return false +} + +func (x *MainPaymentSettings) GetRecurrent() bool { + if x != nil { + return x.Recurrent + } + return false +} + +type Customer struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + FullName string `protobuf:"bytes,1,opt,name=FullName,proto3" json:"FullName,omitempty"` + INN string `protobuf:"bytes,2,opt,name=INN,proto3" json:"INN,omitempty"` + Email string `protobuf:"bytes,3,opt,name=Email,proto3" json:"Email,omitempty"` + Phone string `protobuf:"bytes,4,opt,name=Phone,proto3" json:"Phone,omitempty"` +} + +func (x *Customer) Reset() { + *x = Customer{} + if protoimpl.UnsafeEnabled { + mi := &file_service_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Customer) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Customer) ProtoMessage() {} + +func (x *Customer) ProtoReflect() protoreflect.Message { + mi := &file_service_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Customer.ProtoReflect.Descriptor instead. +func (*Customer) Descriptor() ([]byte, []int) { + return file_service_proto_rawDescGZIP(), []int{6} +} + +func (x *Customer) GetFullName() string { + if x != nil { + return x.FullName + } + return "" +} + +func (x *Customer) GetINN() string { + if x != nil { + return x.INN + } + return "" +} + +func (x *Customer) GetEmail() string { + if x != nil { + return x.Email + } + return "" +} + +func (x *Customer) GetPhone() string { + if x != nil { + return x.Phone + } + return "" +} + +type Item struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Description string `protobuf:"bytes,1,opt,name=Description,proto3" json:"Description,omitempty"` + Measure string `protobuf:"bytes,2,opt,name=Measure,proto3" json:"Measure,omitempty"` + Quantity string `protobuf:"bytes,3,opt,name=Quantity,proto3" json:"Quantity,omitempty"` + Money string `protobuf:"bytes,4,opt,name=Money,proto3" json:"Money,omitempty"` + Currency string `protobuf:"bytes,5,opt,name=Currency,proto3" json:"Currency,omitempty"` +} + +func (x *Item) Reset() { + *x = Item{} + if protoimpl.UnsafeEnabled { + mi := &file_service_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Item) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Item) ProtoMessage() {} + +func (x *Item) ProtoReflect() protoreflect.Message { + mi := &file_service_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Item.ProtoReflect.Descriptor instead. +func (*Item) Descriptor() ([]byte, []int) { + return file_service_proto_rawDescGZIP(), []int{7} +} + +func (x *Item) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *Item) GetMeasure() string { + if x != nil { + return x.Measure + } + return "" +} + +func (x *Item) GetQuantity() string { + if x != nil { + return x.Quantity + } + return "" +} + +func (x *Item) GetMoney() string { + if x != nil { + return x.Money + } + return "" +} + +func (x *Item) GetCurrency() string { + if x != nil { + return x.Currency + } + return "" +} + +var File_service_proto protoreflect.FileDescriptor + +var file_service_proto_rawDesc = []byte{ + 0x0a, 0x0d, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, + 0x09, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 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, 0x63, 0x0a, 0x1d, 0x47, 0x65, 0x74, 0x42, 0x61, + 0x6e, 0x6b, 0x43, 0x61, 0x72, 0x64, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, + 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x42, 0x0a, 0x0c, 0x4d, 0x61, 0x69, 0x6e, + 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, + 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x4d, 0x61, 0x69, 0x6e, 0x50, + 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x0c, + 0x4d, 0x61, 0x69, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x22, 0x5b, 0x0a, 0x15, + 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x42, 0x0a, 0x0c, 0x4d, 0x61, 0x69, 0x6e, 0x53, 0x65, 0x74, + 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x74, 0x72, + 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x4d, 0x61, 0x69, 0x6e, 0x50, 0x61, 0x79, 0x6d, + 0x65, 0x6e, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x0c, 0x4d, 0x61, 0x69, + 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x22, 0xb8, 0x01, 0x0a, 0x18, 0x47, 0x65, + 0x74, 0x42, 0x32, 0x42, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x42, 0x0a, 0x0c, 0x4d, 0x61, 0x69, 0x6e, 0x53, 0x65, + 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x74, + 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x4d, 0x61, 0x69, 0x6e, 0x50, 0x61, 0x79, + 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x0c, 0x4d, 0x61, + 0x69, 0x6e, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x26, 0x0a, 0x0e, 0x50, 0x61, + 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x50, 0x75, 0x72, 0x70, 0x6f, 0x73, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0e, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x50, 0x75, 0x72, 0x70, 0x6f, + 0x73, 0x65, 0x12, 0x30, 0x0a, 0x07, 0x56, 0x61, 0x74, 0x44, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x07, 0x56, 0x61, 0x74, + 0x44, 0x61, 0x74, 0x61, 0x22, 0x3a, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, + 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x20, + 0x0a, 0x0b, 0x52, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x55, 0x52, 0x4c, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0b, 0x52, 0x65, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x55, 0x52, 0x4c, + 0x22, 0x3a, 0x0a, 0x20, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x61, 0x76, 0x65, 0x64, 0x50, + 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x44, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x44, 0x22, 0xd1, 0x02, 0x0a, + 0x13, 0x4d, 0x61, 0x69, 0x6e, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x74, 0x74, + 0x69, 0x6e, 0x67, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, + 0x12, 0x16, 0x0a, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x06, 0x41, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2a, 0x0a, 0x10, 0x43, 0x61, 0x6c, 0x6c, + 0x62, 0x61, 0x63, 0x6b, 0x48, 0x6f, 0x73, 0x74, 0x47, 0x52, 0x50, 0x43, 0x18, 0x03, 0x20, 0x03, + 0x28, 0x09, 0x52, 0x10, 0x43, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x48, 0x6f, 0x73, 0x74, + 0x47, 0x52, 0x50, 0x43, 0x12, 0x1c, 0x0a, 0x09, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x55, 0x52, + 0x4c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x52, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x55, + 0x52, 0x4c, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x44, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x44, 0x12, 0x1a, 0x0a, 0x08, 0x43, 0x6c, + 0x69, 0x65, 0x6e, 0x74, 0x49, 0x50, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x43, 0x6c, + 0x69, 0x65, 0x6e, 0x74, 0x49, 0x50, 0x12, 0x2f, 0x0a, 0x08, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, + 0x65, 0x72, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, + 0x75, 0x72, 0x65, 0x72, 0x2e, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x52, 0x08, 0x43, + 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x12, 0x25, 0x0a, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, + 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, + 0x65, 0x72, 0x2e, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12, 0x12, + 0x0a, 0x04, 0x41, 0x75, 0x74, 0x6f, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x41, 0x75, + 0x74, 0x6f, 0x12, 0x1c, 0x0a, 0x09, 0x52, 0x65, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x18, + 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x52, 0x65, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, + 0x22, 0x64, 0x0a, 0x08, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x12, 0x1a, 0x0a, 0x08, + 0x46, 0x75, 0x6c, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, + 0x46, 0x75, 0x6c, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x49, 0x4e, 0x4e, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x49, 0x4e, 0x4e, 0x12, 0x14, 0x0a, 0x05, 0x45, 0x6d, + 0x61, 0x69, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x45, 0x6d, 0x61, 0x69, 0x6c, + 0x12, 0x14, 0x0a, 0x05, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x05, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x22, 0x90, 0x01, 0x0a, 0x04, 0x49, 0x74, 0x65, 0x6d, 0x12, + 0x20, 0x0a, 0x0b, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, + 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x4d, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x4d, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x51, + 0x75, 0x61, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x51, + 0x75, 0x61, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x4d, 0x6f, 0x6e, 0x65, 0x79, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x12, 0x1a, 0x0a, + 0x08, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x32, 0xb8, 0x05, 0x0a, 0x10, 0x54, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x5f, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x42, 0x61, 0x6e, 0x6b, 0x43, 0x61, 0x72, 0x64, 0x12, 0x20, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, @@ -299,63 +653,75 @@ var file_treasurer_service_proto_rawDesc = []byte{ 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, - 0x42, 0x0d, 0x5a, 0x0b, 0x2e, 0x2f, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x12, 0x62, 0x0a, 0x19, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x61, 0x76, 0x65, 0x64, 0x50, + 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x12, 0x2b, 0x2e, + 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x53, 0x61, 0x76, 0x65, 0x64, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4d, 0x65, 0x74, 0x68, + 0x6f, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 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, 0x0d, 0x5a, 0x0b, 0x2e, 0x2f, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, + 0x72, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - file_treasurer_service_proto_rawDescOnce sync.Once - file_treasurer_service_proto_rawDescData = file_treasurer_service_proto_rawDesc + file_service_proto_rawDescOnce sync.Once + file_service_proto_rawDescData = file_service_proto_rawDesc ) -func file_treasurer_service_proto_rawDescGZIP() []byte { - file_treasurer_service_proto_rawDescOnce.Do(func() { - file_treasurer_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_treasurer_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_treasurer_service_proto_rawDescData + return file_service_proto_rawDescData } -var file_treasurer_service_proto_msgTypes = make([]protoimpl.MessageInfo, 4) -var file_treasurer_service_proto_goTypes = []interface{}{ - (*GetBankCardPaymentLinkRequest)(nil), // 0: treasurer.GetBankCardPaymentLinkRequest - (*GetPaymentLinkRequest)(nil), // 1: treasurer.GetPaymentLinkRequest - (*GetB2BPaymentLinkRequest)(nil), // 2: treasurer.GetB2BPaymentLinkRequest - (*GetPaymentLinkResponse)(nil), // 3: treasurer.GetPaymentLinkResponse - (*MainPaymentSettings)(nil), // 4: treasurer.MainPaymentSettings - (*emptypb.Empty)(nil), // 5: google.protobuf.Empty +var file_service_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_service_proto_goTypes = []interface{}{ + (*GetBankCardPaymentLinkRequest)(nil), // 0: treasurer.GetBankCardPaymentLinkRequest + (*GetPaymentLinkRequest)(nil), // 1: treasurer.GetPaymentLinkRequest + (*GetB2BPaymentLinkRequest)(nil), // 2: treasurer.GetB2BPaymentLinkRequest + (*GetPaymentLinkResponse)(nil), // 3: treasurer.GetPaymentLinkResponse + (*DeleteSavedPaymentMethodsRequest)(nil), // 4: treasurer.DeleteSavedPaymentMethodsRequest + (*MainPaymentSettings)(nil), // 5: treasurer.MainPaymentSettings + (*Customer)(nil), // 6: treasurer.Customer + (*Item)(nil), // 7: treasurer.Item + (*emptypb.Empty)(nil), // 8: google.protobuf.Empty } -var file_treasurer_service_proto_depIdxs = []int32{ - 4, // 0: treasurer.GetBankCardPaymentLinkRequest.MainSettings:type_name -> treasurer.MainPaymentSettings - 4, // 1: treasurer.GetPaymentLinkRequest.MainSettings:type_name -> treasurer.MainPaymentSettings - 4, // 2: treasurer.GetB2BPaymentLinkRequest.MainSettings:type_name -> treasurer.MainPaymentSettings - 5, // 3: treasurer.GetB2BPaymentLinkRequest.VatData:type_name -> google.protobuf.Empty - 1, // 4: treasurer.TreasurerService.GetPaymentLinkBankCard:input_type -> treasurer.GetPaymentLinkRequest - 1, // 5: treasurer.TreasurerService.GetPaymentLinkYooMoney:input_type -> treasurer.GetPaymentLinkRequest - 1, // 6: treasurer.TreasurerService.GetPaymentLinkTinkoff:input_type -> treasurer.GetPaymentLinkRequest - 1, // 7: treasurer.TreasurerService.GetPaymentLinkSberbankB2B:input_type -> treasurer.GetPaymentLinkRequest - 1, // 8: treasurer.TreasurerService.GetPaymentLinkSBP:input_type -> treasurer.GetPaymentLinkRequest - 1, // 9: treasurer.TreasurerService.GetPaymentLinkSberPay:input_type -> treasurer.GetPaymentLinkRequest - 3, // 10: treasurer.TreasurerService.GetPaymentLinkBankCard:output_type -> treasurer.GetPaymentLinkResponse - 3, // 11: treasurer.TreasurerService.GetPaymentLinkYooMoney:output_type -> treasurer.GetPaymentLinkResponse - 3, // 12: treasurer.TreasurerService.GetPaymentLinkTinkoff:output_type -> treasurer.GetPaymentLinkResponse - 3, // 13: treasurer.TreasurerService.GetPaymentLinkSberbankB2B:output_type -> treasurer.GetPaymentLinkResponse - 3, // 14: treasurer.TreasurerService.GetPaymentLinkSBP:output_type -> treasurer.GetPaymentLinkResponse - 3, // 15: treasurer.TreasurerService.GetPaymentLinkSberPay:output_type -> treasurer.GetPaymentLinkResponse - 10, // [10:16] is the sub-list for method output_type - 4, // [4:10] is the sub-list for method input_type - 4, // [4:4] is the sub-list for extension type_name - 4, // [4:4] is the sub-list for extension extendee - 0, // [0:4] is the sub-list for field type_name +var file_service_proto_depIdxs = []int32{ + 5, // 0: treasurer.GetBankCardPaymentLinkRequest.MainSettings:type_name -> treasurer.MainPaymentSettings + 5, // 1: treasurer.GetPaymentLinkRequest.MainSettings:type_name -> treasurer.MainPaymentSettings + 5, // 2: treasurer.GetB2BPaymentLinkRequest.MainSettings:type_name -> treasurer.MainPaymentSettings + 8, // 3: treasurer.GetB2BPaymentLinkRequest.VatData:type_name -> google.protobuf.Empty + 6, // 4: treasurer.MainPaymentSettings.Customer:type_name -> treasurer.Customer + 7, // 5: treasurer.MainPaymentSettings.Items:type_name -> treasurer.Item + 1, // 6: treasurer.TreasurerService.GetPaymentLinkBankCard:input_type -> treasurer.GetPaymentLinkRequest + 1, // 7: treasurer.TreasurerService.GetPaymentLinkYooMoney:input_type -> treasurer.GetPaymentLinkRequest + 1, // 8: treasurer.TreasurerService.GetPaymentLinkTinkoff:input_type -> treasurer.GetPaymentLinkRequest + 1, // 9: treasurer.TreasurerService.GetPaymentLinkSberbankB2B:input_type -> treasurer.GetPaymentLinkRequest + 1, // 10: treasurer.TreasurerService.GetPaymentLinkSBP:input_type -> treasurer.GetPaymentLinkRequest + 1, // 11: treasurer.TreasurerService.GetPaymentLinkSberPay:input_type -> treasurer.GetPaymentLinkRequest + 4, // 12: treasurer.TreasurerService.DeleteSavedPaymentMethods:input_type -> treasurer.DeleteSavedPaymentMethodsRequest + 3, // 13: treasurer.TreasurerService.GetPaymentLinkBankCard:output_type -> treasurer.GetPaymentLinkResponse + 3, // 14: treasurer.TreasurerService.GetPaymentLinkYooMoney:output_type -> treasurer.GetPaymentLinkResponse + 3, // 15: treasurer.TreasurerService.GetPaymentLinkTinkoff:output_type -> treasurer.GetPaymentLinkResponse + 3, // 16: treasurer.TreasurerService.GetPaymentLinkSberbankB2B:output_type -> treasurer.GetPaymentLinkResponse + 3, // 17: treasurer.TreasurerService.GetPaymentLinkSBP:output_type -> treasurer.GetPaymentLinkResponse + 3, // 18: treasurer.TreasurerService.GetPaymentLinkSberPay:output_type -> treasurer.GetPaymentLinkResponse + 8, // 19: treasurer.TreasurerService.DeleteSavedPaymentMethods:output_type -> google.protobuf.Empty + 13, // [13:20] is the sub-list for method output_type + 6, // [6:13] is the sub-list for method input_type + 6, // [6:6] is the sub-list for extension type_name + 6, // [6:6] is the sub-list for extension extendee + 0, // [0:6] is the sub-list for field type_name } -func init() { file_treasurer_service_proto_init() } -func file_treasurer_service_proto_init() { - if File_treasurer_service_proto != nil { +func init() { file_service_proto_init() } +func file_service_proto_init() { + if File_service_proto != nil { return } - file_treasurer_payment_model_proto_init() if !protoimpl.UnsafeEnabled { - file_treasurer_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.(*GetBankCardPaymentLinkRequest); i { case 0: return &v.state @@ -367,7 +733,7 @@ func file_treasurer_service_proto_init() { return nil } } - file_treasurer_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.(*GetPaymentLinkRequest); i { case 0: return &v.state @@ -379,7 +745,7 @@ func file_treasurer_service_proto_init() { return nil } } - file_treasurer_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetB2BPaymentLinkRequest); i { case 0: return &v.state @@ -391,7 +757,7 @@ func file_treasurer_service_proto_init() { return nil } } - file_treasurer_service_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_service_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*GetPaymentLinkResponse); i { case 0: return &v.state @@ -403,23 +769,71 @@ func file_treasurer_service_proto_init() { return nil } } + file_service_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeleteSavedPaymentMethodsRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_service_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MainPaymentSettings); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_service_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Customer); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_service_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Item); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_treasurer_service_proto_rawDesc, + RawDescriptor: file_service_proto_rawDesc, NumEnums: 0, - NumMessages: 4, + NumMessages: 8, NumExtensions: 0, NumServices: 1, }, - GoTypes: file_treasurer_service_proto_goTypes, - DependencyIndexes: file_treasurer_service_proto_depIdxs, - MessageInfos: file_treasurer_service_proto_msgTypes, + GoTypes: file_service_proto_goTypes, + DependencyIndexes: file_service_proto_depIdxs, + MessageInfos: file_service_proto_msgTypes, }.Build() - File_treasurer_service_proto = out.File - file_treasurer_service_proto_rawDesc = nil - file_treasurer_service_proto_goTypes = nil - file_treasurer_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/treasurer/service_grpc.pb.go b/internal/proto/treasurer/service_grpc.pb.go index 699b0e5..23179f8 100644 --- a/internal/proto/treasurer/service_grpc.pb.go +++ b/internal/proto/treasurer/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: treasurer/service.proto package treasurer @@ -11,6 +7,7 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" + emptypb "google.golang.org/protobuf/types/known/emptypb" ) // This is a compile-time assertion to ensure that this generated file @@ -18,15 +15,6 @@ import ( // Requires gRPC-Go v1.32.0 or later. const _ = grpc.SupportPackageIsVersion7 -const ( - TreasurerService_GetPaymentLinkBankCard_FullMethodName = "/treasurer.TreasurerService/GetPaymentLinkBankCard" - TreasurerService_GetPaymentLinkYooMoney_FullMethodName = "/treasurer.TreasurerService/GetPaymentLinkYooMoney" - TreasurerService_GetPaymentLinkTinkoff_FullMethodName = "/treasurer.TreasurerService/GetPaymentLinkTinkoff" - TreasurerService_GetPaymentLinkSberbankB2B_FullMethodName = "/treasurer.TreasurerService/GetPaymentLinkSberbankB2B" - TreasurerService_GetPaymentLinkSBP_FullMethodName = "/treasurer.TreasurerService/GetPaymentLinkSBP" - TreasurerService_GetPaymentLinkSberPay_FullMethodName = "/treasurer.TreasurerService/GetPaymentLinkSberPay" -) - // TreasurerServiceClient is the client API for TreasurerService 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. @@ -37,6 +25,7 @@ type TreasurerServiceClient interface { GetPaymentLinkSberbankB2B(ctx context.Context, in *GetPaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) GetPaymentLinkSBP(ctx context.Context, in *GetPaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) GetPaymentLinkSberPay(ctx context.Context, in *GetPaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) + DeleteSavedPaymentMethods(ctx context.Context, in *DeleteSavedPaymentMethodsRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) } type treasurerServiceClient struct { @@ -49,7 +38,7 @@ func NewTreasurerServiceClient(cc grpc.ClientConnInterface) TreasurerServiceClie func (c *treasurerServiceClient) GetPaymentLinkBankCard(ctx context.Context, in *GetPaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) { out := new(GetPaymentLinkResponse) - err := c.cc.Invoke(ctx, TreasurerService_GetPaymentLinkBankCard_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, "/treasurer.TreasurerService/GetPaymentLinkBankCard", in, out, opts...) if err != nil { return nil, err } @@ -58,7 +47,7 @@ func (c *treasurerServiceClient) GetPaymentLinkBankCard(ctx context.Context, in func (c *treasurerServiceClient) GetPaymentLinkYooMoney(ctx context.Context, in *GetPaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) { out := new(GetPaymentLinkResponse) - err := c.cc.Invoke(ctx, TreasurerService_GetPaymentLinkYooMoney_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, "/treasurer.TreasurerService/GetPaymentLinkYooMoney", in, out, opts...) if err != nil { return nil, err } @@ -67,7 +56,7 @@ func (c *treasurerServiceClient) GetPaymentLinkYooMoney(ctx context.Context, in func (c *treasurerServiceClient) GetPaymentLinkTinkoff(ctx context.Context, in *GetPaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) { out := new(GetPaymentLinkResponse) - err := c.cc.Invoke(ctx, TreasurerService_GetPaymentLinkTinkoff_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, "/treasurer.TreasurerService/GetPaymentLinkTinkoff", in, out, opts...) if err != nil { return nil, err } @@ -76,7 +65,7 @@ func (c *treasurerServiceClient) GetPaymentLinkTinkoff(ctx context.Context, in * func (c *treasurerServiceClient) GetPaymentLinkSberbankB2B(ctx context.Context, in *GetPaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) { out := new(GetPaymentLinkResponse) - err := c.cc.Invoke(ctx, TreasurerService_GetPaymentLinkSberbankB2B_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, "/treasurer.TreasurerService/GetPaymentLinkSberbankB2B", in, out, opts...) if err != nil { return nil, err } @@ -85,7 +74,7 @@ func (c *treasurerServiceClient) GetPaymentLinkSberbankB2B(ctx context.Context, func (c *treasurerServiceClient) GetPaymentLinkSBP(ctx context.Context, in *GetPaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) { out := new(GetPaymentLinkResponse) - err := c.cc.Invoke(ctx, TreasurerService_GetPaymentLinkSBP_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, "/treasurer.TreasurerService/GetPaymentLinkSBP", in, out, opts...) if err != nil { return nil, err } @@ -94,7 +83,16 @@ func (c *treasurerServiceClient) GetPaymentLinkSBP(ctx context.Context, in *GetP func (c *treasurerServiceClient) GetPaymentLinkSberPay(ctx context.Context, in *GetPaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) { out := new(GetPaymentLinkResponse) - err := c.cc.Invoke(ctx, TreasurerService_GetPaymentLinkSberPay_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, "/treasurer.TreasurerService/GetPaymentLinkSberPay", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *treasurerServiceClient) DeleteSavedPaymentMethods(ctx context.Context, in *DeleteSavedPaymentMethodsRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { + out := new(emptypb.Empty) + err := c.cc.Invoke(ctx, "/treasurer.TreasurerService/DeleteSavedPaymentMethods", in, out, opts...) if err != nil { return nil, err } @@ -102,7 +100,7 @@ func (c *treasurerServiceClient) GetPaymentLinkSberPay(ctx context.Context, in * } // TreasurerServiceServer is the server API for TreasurerService service. -// All implementations should embed UnimplementedTreasurerServiceServer +// All implementations must embed UnimplementedTreasurerServiceServer // for forward compatibility type TreasurerServiceServer interface { GetPaymentLinkBankCard(context.Context, *GetPaymentLinkRequest) (*GetPaymentLinkResponse, error) @@ -111,9 +109,11 @@ type TreasurerServiceServer interface { GetPaymentLinkSberbankB2B(context.Context, *GetPaymentLinkRequest) (*GetPaymentLinkResponse, error) GetPaymentLinkSBP(context.Context, *GetPaymentLinkRequest) (*GetPaymentLinkResponse, error) GetPaymentLinkSberPay(context.Context, *GetPaymentLinkRequest) (*GetPaymentLinkResponse, error) + DeleteSavedPaymentMethods(context.Context, *DeleteSavedPaymentMethodsRequest) (*emptypb.Empty, error) + mustEmbedUnimplementedTreasurerServiceServer() } -// UnimplementedTreasurerServiceServer should be embedded to have forward compatible implementations. +// UnimplementedTreasurerServiceServer must be embedded to have forward compatible implementations. type UnimplementedTreasurerServiceServer struct { } @@ -135,6 +135,10 @@ func (UnimplementedTreasurerServiceServer) GetPaymentLinkSBP(context.Context, *G func (UnimplementedTreasurerServiceServer) GetPaymentLinkSberPay(context.Context, *GetPaymentLinkRequest) (*GetPaymentLinkResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetPaymentLinkSberPay not implemented") } +func (UnimplementedTreasurerServiceServer) DeleteSavedPaymentMethods(context.Context, *DeleteSavedPaymentMethodsRequest) (*emptypb.Empty, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeleteSavedPaymentMethods not implemented") +} +func (UnimplementedTreasurerServiceServer) mustEmbedUnimplementedTreasurerServiceServer() {} // UnsafeTreasurerServiceServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to TreasurerServiceServer will @@ -157,7 +161,7 @@ func _TreasurerService_GetPaymentLinkBankCard_Handler(srv interface{}, ctx conte } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: TreasurerService_GetPaymentLinkBankCard_FullMethodName, + FullMethod: "/treasurer.TreasurerService/GetPaymentLinkBankCard", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(TreasurerServiceServer).GetPaymentLinkBankCard(ctx, req.(*GetPaymentLinkRequest)) @@ -175,7 +179,7 @@ func _TreasurerService_GetPaymentLinkYooMoney_Handler(srv interface{}, ctx conte } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: TreasurerService_GetPaymentLinkYooMoney_FullMethodName, + FullMethod: "/treasurer.TreasurerService/GetPaymentLinkYooMoney", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(TreasurerServiceServer).GetPaymentLinkYooMoney(ctx, req.(*GetPaymentLinkRequest)) @@ -193,7 +197,7 @@ func _TreasurerService_GetPaymentLinkTinkoff_Handler(srv interface{}, ctx contex } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: TreasurerService_GetPaymentLinkTinkoff_FullMethodName, + FullMethod: "/treasurer.TreasurerService/GetPaymentLinkTinkoff", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(TreasurerServiceServer).GetPaymentLinkTinkoff(ctx, req.(*GetPaymentLinkRequest)) @@ -211,7 +215,7 @@ func _TreasurerService_GetPaymentLinkSberbankB2B_Handler(srv interface{}, ctx co } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: TreasurerService_GetPaymentLinkSberbankB2B_FullMethodName, + FullMethod: "/treasurer.TreasurerService/GetPaymentLinkSberbankB2B", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(TreasurerServiceServer).GetPaymentLinkSberbankB2B(ctx, req.(*GetPaymentLinkRequest)) @@ -229,7 +233,7 @@ func _TreasurerService_GetPaymentLinkSBP_Handler(srv interface{}, ctx context.Co } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: TreasurerService_GetPaymentLinkSBP_FullMethodName, + FullMethod: "/treasurer.TreasurerService/GetPaymentLinkSBP", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(TreasurerServiceServer).GetPaymentLinkSBP(ctx, req.(*GetPaymentLinkRequest)) @@ -247,7 +251,7 @@ func _TreasurerService_GetPaymentLinkSberPay_Handler(srv interface{}, ctx contex } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: TreasurerService_GetPaymentLinkSberPay_FullMethodName, + FullMethod: "/treasurer.TreasurerService/GetPaymentLinkSberPay", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(TreasurerServiceServer).GetPaymentLinkSberPay(ctx, req.(*GetPaymentLinkRequest)) @@ -255,6 +259,24 @@ func _TreasurerService_GetPaymentLinkSberPay_Handler(srv interface{}, ctx contex return interceptor(ctx, in, info, handler) } +func _TreasurerService_DeleteSavedPaymentMethods_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteSavedPaymentMethodsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TreasurerServiceServer).DeleteSavedPaymentMethods(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/treasurer.TreasurerService/DeleteSavedPaymentMethods", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TreasurerServiceServer).DeleteSavedPaymentMethods(ctx, req.(*DeleteSavedPaymentMethodsRequest)) + } + return interceptor(ctx, in, info, handler) +} + // TreasurerService_ServiceDesc is the grpc.ServiceDesc for TreasurerService service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -286,7 +308,11 @@ var TreasurerService_ServiceDesc = grpc.ServiceDesc{ MethodName: "GetPaymentLinkSberPay", Handler: _TreasurerService_GetPaymentLinkSberPay_Handler, }, + { + MethodName: "DeleteSavedPaymentMethods", + Handler: _TreasurerService_DeleteSavedPaymentMethods_Handler, + }, }, Streams: []grpc.StreamDesc{}, - Metadata: "treasurer/service.proto", + Metadata: "service.proto", } diff --git a/proto/treasurer/payment.model.proto b/proto/treasurer/payment.model.proto index c6af147..bd8f682 100644 --- a/proto/treasurer/payment.model.proto +++ b/proto/treasurer/payment.model.proto @@ -5,14 +5,16 @@ package treasurer; option go_package = "./treasurer"; message MainPaymentSettings { - string Currency = 1; - int64 Amount = 2; - repeated string CallbackHostGRPC = 3; - string ReturnURL = 4; + string Currency = 1; + int64 Amount = 2; + repeated string CallbackHostGRPC = 3; + string ReturnURL = 4; string UserID = 5; string ClientIP = 6; Customer Customer = 7; repeated Item Items = 8; + bool Auto = 9; + bool Recurrent = 10; } message Customer { diff --git a/proto/treasurer/service.proto b/proto/treasurer/service.proto index 9fcaec1..d9ebaa2 100644 --- a/proto/treasurer/service.proto +++ b/proto/treasurer/service.proto @@ -3,7 +3,7 @@ syntax = "proto3"; package treasurer; import "google/protobuf/empty.proto"; -import "treasurer/payment.model.proto"; +import "google/protobuf/empty.proto"; option go_package = "./treasurer"; @@ -14,6 +14,7 @@ service TreasurerService { rpc GetPaymentLinkSberbankB2B(GetPaymentLinkRequest) returns (GetPaymentLinkResponse) {} rpc GetPaymentLinkSBP(GetPaymentLinkRequest) returns (GetPaymentLinkResponse) {} rpc GetPaymentLinkSberPay(GetPaymentLinkRequest) returns (GetPaymentLinkResponse) {} + rpc DeleteSavedPaymentMethods(DeleteSavedPaymentMethodsRequest) returns (google.protobuf.Empty) {} } message GetBankCardPaymentLinkRequest { @@ -33,3 +34,7 @@ message GetB2BPaymentLinkRequest { message GetPaymentLinkResponse { string RedirectURL = 1; } + +message DeleteSavedPaymentMethodsRequest { + string UserID = 1; +} From e30209c739933a83fbf54ee782f77a7f1580c549 Mon Sep 17 00:00:00 2001 From: pasha1coil Date: Sat, 14 Jun 2025 05:38:14 +0300 Subject: [PATCH 02/20] added support auto paid --- internal/controller/grpc/payment.go | 2 + internal/models/payment.go | 1 + internal/models/yandex/payment.go | 32 ++++++++- internal/models/yandex/payment_create.go | 31 ++++---- .../payment_provider/yoomoney/provider.go | 72 ++++++++++++++----- internal/repository/payment_method.go | 61 ++++++++++++++++ internal/utils/parse_map.go | 9 +++ 7 files changed, 176 insertions(+), 32 deletions(-) create mode 100644 internal/repository/payment_method.go diff --git a/internal/controller/grpc/payment.go b/internal/controller/grpc/payment.go index 1c48c9c..34349ac 100644 --- a/internal/controller/grpc/payment.go +++ b/internal/controller/grpc/payment.go @@ -6,6 +6,7 @@ import ( "gitea.pena/PenaSide/treasurer/internal/models/yandex" "gitea.pena/PenaSide/treasurer/internal/payment_provider" "gitea.pena/PenaSide/treasurer/internal/utils" + "strconv" "strings" "sync" @@ -89,6 +90,7 @@ func (r *PaymentController) createPayment(ctx context.Context, paymentType model }, Items: utils.ProtoItems2ReceiptItems(in.MainSettings.Items), }), + "save_payment_method": strconv.FormatBool(in.MainSettings.Auto), } link, err := provider.CreateInvoice(ctx, request) if err != nil { diff --git a/internal/models/payment.go b/internal/models/payment.go index 8b1152c..8ddfb70 100644 --- a/internal/models/payment.go +++ b/internal/models/payment.go @@ -58,6 +58,7 @@ type CreatePayment[T any] struct { UserID string ClientIP string Requisites T + Auto bool } type BankCard struct { diff --git a/internal/models/yandex/payment.go b/internal/models/yandex/payment.go index 36c194f..3bcb927 100644 --- a/internal/models/yandex/payment.go +++ b/internal/models/yandex/payment.go @@ -1,5 +1,7 @@ package yandex +import "time" + // Payment description https://yookassa.ru/developers/api#payment_object type Payment struct { ID string `json:"id" bson:"id"` @@ -8,7 +10,7 @@ type Payment struct { Confirmation *ConfirmationRedirect `json:"confirmation" bson:"confirmation"` IncomeAmount *Amount `json:"income_amount,omitempty" bson:"income_amount,omitempty"` Description string `json:"description,omitempty" bson:"description,omitempty"` - PaymentMethod any `json:"payment_method,omitempty" bson:"payment_method,omitempty"` + PaymentMethod *PaymentMethod `json:"payment_method,omitempty" bson:"payment_method,omitempty"` Recipient Recipient `json:"recipient" bson:"recipient"` CapturedAt string `json:"captured_at,omitempty" bson:"captured_at,omitempty"` ExpiresAt string `json:"expires_at,omitempty" bson:"expires_at,omitempty"` @@ -42,3 +44,31 @@ const ( PaymentStatusSuccessfully PaymentStatus = "succeeded" PaymentStatusCanceled PaymentStatus = "canceled" ) + +type PaymentMethod struct { + ID string `json:"_id" bson:"_id,omitempty"` + UserID string `json:"userId" bson:"userId"` + Type string `json:"type" bson:"type"` + MethodID string `json:"id" bson:"id"` + Saved bool `json:"saved" bson:"saved"` + Card *Card `json:"card,omitempty" bson:"card,omitempty"` + Title string `json:"title" bson:"title"` + CreatedAt time.Time `json:"createdAt" bson:"createdAt"` + UpdatedAt time.Time `json:"updatedAt" bson:"updatedAt"` +} + +type Card struct { + First6 string `json:"first6" bson:"first6"` + Last4 string `json:"last4" bson:"last4"` + ExpiryMonth string `json:"expiry_month" bson:"expiry_month"` + ExpiryYear string `json:"expiry_year" bson:"expiry_year"` + CardType string `json:"card_type" bson:"card_type"` + CardProduct *CardProduct `json:"card_product,omitempty" bson:"card_product,omitempty"` + IssuerCountry string `json:"issuer_country" bson:"issuer_country"` + IssuerName string `json:"issuer_name" bson:"issuer_name"` +} + +type CardProduct struct { + Code string `json:"code" bson:"code"` + Name string `json:"name" bson:"name"` +} diff --git a/internal/models/yandex/payment_create.go b/internal/models/yandex/payment_create.go index 37d65df..aad6961 100644 --- a/internal/models/yandex/payment_create.go +++ b/internal/models/yandex/payment_create.go @@ -10,33 +10,34 @@ type CreatePaymentRequest[T any] struct { ClientIP string `json:"client_ip,omitempty"` Deal any `json:"deal,omitempty"` MerchantCustomerID any `json:"merchant_customer_id,omitempty"` - Receipt Receipt `json:"receipt,omitempty"` + Receipt Receipt `json:"receipt,omitempty"` + SavePaymentMethod bool `json:"save_payment_method"` } type Receipt struct { - Customer Customer `json:"customer,omitempty"` - Items []Item `json:"items,omitempty"` - TaxSystemCode int `json:"tax_system_code,omitempty"` + Customer Customer `json:"customer,omitempty"` + Items []Item `json:"items,omitempty"` + TaxSystemCode int `json:"tax_system_code,omitempty"` } type Item struct { - Description string `json:"description,omitempty"` - Amount ReceiptAmount `json:"amount,omitempty"` - VatCode int `json:"vat_code,omitempty"` - Quantity int64 `json:"quantity,omitempty"` - Measure string `json:"measure,omitempty"` - PaymentSubject string `json:"payment_subject,omitempty"` - PaymentMode string `json:"payment_mode,omitempty"` + Description string `json:"description,omitempty"` + Amount ReceiptAmount `json:"amount,omitempty"` + VatCode int `json:"vat_code,omitempty"` + Quantity int64 `json:"quantity,omitempty"` + Measure string `json:"measure,omitempty"` + PaymentSubject string `json:"payment_subject,omitempty"` + PaymentMode string `json:"payment_mode,omitempty"` } type ReceiptAmount struct { - Value string `json:"value,omitempty"` + Value string `json:"value,omitempty"` Currency string `json:"currency,omitempty"` } type Customer struct { FullName string `json:"full_name,omitempty"` - INN string `json:"inn,omitempty"` - Email string `json:"email,omitempty"` - Phone string `json:"phone,omitempty"` + INN string `json:"inn,omitempty"` + Email string `json:"email,omitempty"` + Phone string `json:"phone,omitempty"` } diff --git a/internal/payment_provider/yoomoney/provider.go b/internal/payment_provider/yoomoney/provider.go index 464475f..324a782 100644 --- a/internal/payment_provider/yoomoney/provider.go +++ b/internal/payment_provider/yoomoney/provider.go @@ -29,27 +29,30 @@ type Config struct { } type Provider struct { - logger *zap.Logger - config *Config - httpClient *resty.Client - repository *repository.PaymentRepository - callbackService *callback.Service + logger *zap.Logger + config *Config + httpClient *resty.Client + repository *repository.PaymentRepository + callbackService *callback.Service + paymentMethodRepository *repository.PaymentMethodRepository } type Deps struct { - Logger *zap.Logger - Config *Config - Repository *repository.PaymentRepository - CallbackService *callback.Service + Logger *zap.Logger + Config *Config + Repository *repository.PaymentRepository + CallbackService *callback.Service + PaymentMethodRepository *repository.PaymentMethodRepository } func New(deps Deps) (*Provider, errors.Error) { return &Provider{ - logger: deps.Logger, - config: deps.Config, - httpClient: resty.New(), - repository: deps.Repository, - callbackService: deps.CallbackService, + logger: deps.Logger, + config: deps.Config, + httpClient: resty.New(), + repository: deps.Repository, + callbackService: deps.CallbackService, + paymentMethodRepository: deps.PaymentMethodRepository, }, nil } @@ -100,8 +103,9 @@ func (p *Provider) CreateInvoice(ctx context.Context, req map[string]string) (st ReturnURL: request.ReturnURL, Enforce: true, }, - Capture: true, - ClientIP: request.ClientIP, + Capture: true, + ClientIP: request.ClientIP, + SavePaymentMethod: request.Auto, }). Post(p.config.PaymentsURL) @@ -163,6 +167,42 @@ func (p *Provider) handleWebhook(ctx *fiber.Ctx) error { p.logger.Error("failed to set payment complete", zap.Error(err)) return errors.HTTP(ctx, err) } + + if notification.Object.PaymentMethod != nil && notification.Object.PaymentMethod.Saved { + method := &yandex.PaymentMethod{ + UserID: payment.UserID, + MethodID: notification.Object.PaymentMethod.ID, + Type: notification.Object.PaymentMethod.Type, + Title: notification.Object.PaymentMethod.Title, + Saved: notification.Object.PaymentMethod.Saved, + } + + if notification.Object.PaymentMethod.Card != nil { + method.Card = &yandex.Card{ + First6: notification.Object.PaymentMethod.Card.First6, + Last4: notification.Object.PaymentMethod.Card.Last4, + ExpiryMonth: notification.Object.PaymentMethod.Card.ExpiryMonth, + ExpiryYear: notification.Object.PaymentMethod.Card.ExpiryYear, + CardType: notification.Object.PaymentMethod.Card.CardType, + IssuerName: notification.Object.PaymentMethod.Card.IssuerName, + IssuerCountry: notification.Object.PaymentMethod.Card.IssuerCountry, + } + } + + if notification.Object.PaymentMethod.Card.CardProduct != nil { + method.Card.CardProduct = &yandex.CardProduct{ + Code: notification.Object.PaymentMethod.Card.CardProduct.Code, + Name: notification.Object.PaymentMethod.Card.CardProduct.Name, + } + } + + if err := p.paymentMethodRepository.Save(ctx.Context(), method); err != nil { + p.logger.Error("failed to save payment method", zap.Error(err), + zap.String("userId", payment.UserID), zap.String("methodId", method.MethodID)) + // todo стоит ли возвращать ошибку? + } + } + case yandex.WebhookEventPaymentCanceled: payment, err = p.repository.SetPaymentStatus(ctx.Context(), notification.Object.ID, models.PaymentStatusCanceled) if err != nil { diff --git a/internal/repository/payment_method.go b/internal/repository/payment_method.go new file mode 100644 index 0000000..2d95eb5 --- /dev/null +++ b/internal/repository/payment_method.go @@ -0,0 +1,61 @@ +package repository + +import ( + "context" + "gitea.pena/PenaSide/treasurer/internal/models/yandex" + "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/mongo" + "go.uber.org/zap" +) + +type PaymentMethodRepositoryDeps struct { + Logger *zap.Logger + Collection *mongo.Collection +} + +type PaymentMethodRepository struct { + logger *zap.Logger + collection *mongo.Collection +} + +func NewPaymentMethodRepository(deps PaymentMethodRepositoryDeps) *PaymentMethodRepository { + return &PaymentMethodRepository{ + logger: deps.Logger, + collection: deps.Collection, + } +} + +func (r *PaymentMethodRepository) Save(ctx context.Context, method *yandex.PaymentMethod) error { + _, err := r.collection.InsertOne(ctx, method) + if err != nil { + r.logger.Error("failed to save payment method", zap.Error(err), zap.String("userId", method.UserID)) + return err + } + return nil +} + +func (r *PaymentMethodRepository) GetByUserID(ctx context.Context, userID string) ([]*yandex.PaymentMethod, error) { + cursor, err := r.collection.Find(ctx, bson.M{"userId": userID}) + if err != nil { + r.logger.Error("failed to find payment methods", zap.Error(err), zap.String("userId", userID)) + return nil, err + } + defer cursor.Close(ctx) + + var methods []*yandex.PaymentMethod + if err := cursor.All(ctx, &methods); err != nil { + r.logger.Error("failed to decode payment methods", zap.Error(err), zap.String("userId", userID)) + return nil, err + } + + return methods, nil +} + +func (r *PaymentMethodRepository) DeleteByUserID(ctx context.Context, userID string) error { + _, err := r.collection.DeleteMany(ctx, bson.M{"userId": userID}) + if err != nil { + r.logger.Error("failed to delete payment methods", zap.Error(err), zap.String("userId", userID)) + return err + } + return nil +} diff --git a/internal/utils/parse_map.go b/internal/utils/parse_map.go index 94fce23..558a4fd 100644 --- a/internal/utils/parse_map.go +++ b/internal/utils/parse_map.go @@ -29,6 +29,14 @@ func MapToCreatePaymentYandexReceipt(data map[string]string) (*models.CreatePaym return nil, fmt.Errorf("missing requisites field") } + auto := false + if val, ok := data["save_payment_method"]; ok && val != "" { + auto, err = strconv.ParseBool(val) + if err != nil { + return nil, fmt.Errorf("invalid save_payment_method field: %w", err) + } + } + payment := &models.CreatePayment[yandex.Receipt]{ Type: models.PaymentType(data["type"]), Currency: data["currency"], @@ -38,6 +46,7 @@ func MapToCreatePaymentYandexReceipt(data map[string]string) (*models.CreatePaym UserID: data["user_id"], ClientIP: data["client_ip"], Requisites: requisites, + Auto: auto, } return payment, nil From a1f734a87de007b9ba8150ac3f739727621cdb74 Mon Sep 17 00:00:00 2001 From: pasha1coil Date: Sat, 14 Jun 2025 08:59:36 +0300 Subject: [PATCH 03/20] added init payment method repository --- internal/app/app.go | 5 ++-- internal/controller/grpc/payment.go | 38 ++++++++++++++++++++++------- internal/initialize/controllers.go | 10 +++++--- internal/initialize/repositories.go | 10 ++++++-- internal/initialize/services.go | 5 ++-- proto/treasurer/payment.model.proto | 33 ------------------------- proto/treasurer/service.proto | 30 ++++++++++++++++++++++- 7 files changed, 78 insertions(+), 53 deletions(-) delete mode 100644 proto/treasurer/payment.model.proto diff --git a/internal/app/app.go b/internal/app/app.go index c226aac..3b090d2 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -72,8 +72,9 @@ func Run(ctx context.Context, config initialize.Config, logger *zap.Logger) (app } controllers, err := initialize.NewControllers(initialize.ControllersDeps{ - Logger: logger, - Services: *services, + Logger: logger, + Services: *services, + Repositories: *repositories, }) if err != nil { return err diff --git a/internal/controller/grpc/payment.go b/internal/controller/grpc/payment.go index 34349ac..b07e3ed 100644 --- a/internal/controller/grpc/payment.go +++ b/internal/controller/grpc/payment.go @@ -5,7 +5,9 @@ import ( "fmt" "gitea.pena/PenaSide/treasurer/internal/models/yandex" "gitea.pena/PenaSide/treasurer/internal/payment_provider" + "gitea.pena/PenaSide/treasurer/internal/repository" "gitea.pena/PenaSide/treasurer/internal/utils" + "google.golang.org/protobuf/types/known/emptypb" "strconv" "strings" "sync" @@ -17,15 +19,18 @@ import ( ) type PaymentControllerDeps struct { - Logger *zap.Logger - PaymentProviders []payment_provider.PaymentProvider + Logger *zap.Logger + PaymentProviders []payment_provider.PaymentProvider + PaymentMethodRepository *repository.PaymentMethodRepository } type PaymentController struct { - logger *zap.Logger - paymentProviders []payment_provider.PaymentProvider - providerMap map[models.PaymentType][]payment_provider.PaymentProvider - mu sync.RWMutex + logger *zap.Logger + paymentProviders []payment_provider.PaymentProvider + paymentMethodRepository *repository.PaymentMethodRepository + providerMap map[models.PaymentType][]payment_provider.PaymentProvider + mu sync.RWMutex + treasurer.UnimplementedTreasurerServiceServer } func NewPaymentController(deps PaymentControllerDeps) (*PaymentController, errors.Error) { @@ -38,9 +43,10 @@ func NewPaymentController(deps PaymentControllerDeps) (*PaymentController, error } controller := &PaymentController{ - logger: deps.Logger, - paymentProviders: deps.PaymentProviders, - providerMap: make(map[models.PaymentType][]payment_provider.PaymentProvider), + logger: deps.Logger, + paymentProviders: deps.PaymentProviders, + providerMap: make(map[models.PaymentType][]payment_provider.PaymentProvider), + paymentMethodRepository: deps.PaymentMethodRepository, } for _, provider := range deps.PaymentProviders { @@ -126,3 +132,17 @@ func (r *PaymentController) GetPaymentLinkSberPay(ctx context.Context, in *treas func (r *PaymentController) GetPaymentLinkSberbankB2B(ctx context.Context, in *treasurer.GetPaymentLinkRequest) (*treasurer.GetPaymentLinkResponse, error) { return r.createPayment(ctx, models.PaymentTypeSberB2B, in) } + +func (r *PaymentController) DeleteSavedPaymentMethods(ctx context.Context, in *treasurer.DeleteSavedPaymentMethodsRequest) (*emptypb.Empty, error) { + if in.UserID == "" { + r.logger.Error("empty user id provided") + return nil, errors.GRPC("user id is required", errors.NewWithMessage("user id is required", errors.ErrInvalidArgs)) + } + + err := r.paymentMethodRepository.DeleteByUserID(ctx, in.UserID) + if err != nil { + r.logger.Error("failed to delete payment methods", zap.Error(err), zap.String("userId", in.UserID)) + return nil, errors.GRPC("failed to delete payment methods", errors.NewWithMessage("failed to delete payment methods", errors.ErrInternalError)) + } + return &emptypb.Empty{}, nil +} diff --git a/internal/initialize/controllers.go b/internal/initialize/controllers.go index 55cee90..834467a 100644 --- a/internal/initialize/controllers.go +++ b/internal/initialize/controllers.go @@ -9,8 +9,9 @@ import ( ) type ControllersDeps struct { - Logger *zap.Logger - Services Services + Logger *zap.Logger + Services Services + Repositories Repositories } type Controllers struct { @@ -30,8 +31,9 @@ func NewControllers(deps ControllersDeps) (*Controllers, errors.Error) { } paymentControllerGRPC, err := grpc.NewPaymentController(grpc.PaymentControllerDeps{ - Logger: deps.Logger, - PaymentProviders: deps.Services.PaymentProviders, + Logger: deps.Logger, + PaymentProviders: deps.Services.PaymentProviders, + PaymentMethodRepository: deps.Repositories.PaymentMethod, }) if err != nil { return nil, err diff --git a/internal/initialize/repositories.go b/internal/initialize/repositories.go index 01b167d..228c637 100644 --- a/internal/initialize/repositories.go +++ b/internal/initialize/repositories.go @@ -13,7 +13,8 @@ type RepositoriesDeps struct { } type Repositories struct { - Payment *repository.PaymentRepository + Payment *repository.PaymentRepository + PaymentMethod *repository.PaymentMethodRepository } func NewRepositories(deps RepositoriesDeps) (*Repositories, errors.Error) { @@ -25,5 +26,10 @@ func NewRepositories(deps RepositoriesDeps) (*Repositories, errors.Error) { return nil, err } - return &Repositories{Payment: paymentRepository}, nil + paymentMethod := repository.NewPaymentMethodRepository(repository.PaymentMethodRepositoryDeps{ + Logger: deps.Logger, + Collection: deps.Database.Collection("payment_methods"), + }) + + return &Repositories{Payment: paymentRepository, PaymentMethod: paymentMethod}, nil } diff --git a/internal/initialize/services.go b/internal/initialize/services.go index 4e74372..1504b0a 100644 --- a/internal/initialize/services.go +++ b/internal/initialize/services.go @@ -99,8 +99,9 @@ func NewServices(deps ServicesDeps) (*Services, errors.Error) { WebhooksURL: deps.Config.YooMoneyWebhooksURL, PaymentsURL: deps.Config.YooMoneyPaymentsURL, }, - Repository: deps.Repositories.Payment, - CallbackService: callbackService, + Repository: deps.Repositories.Payment, + CallbackService: callbackService, + PaymentMethodRepository: deps.Repositories.PaymentMethod, }) if err != nil { return nil, err diff --git a/proto/treasurer/payment.model.proto b/proto/treasurer/payment.model.proto deleted file mode 100644 index bd8f682..0000000 --- a/proto/treasurer/payment.model.proto +++ /dev/null @@ -1,33 +0,0 @@ -syntax = "proto3"; - -package treasurer; - -option go_package = "./treasurer"; - -message MainPaymentSettings { - string Currency = 1; - int64 Amount = 2; - repeated string CallbackHostGRPC = 3; - string ReturnURL = 4; - string UserID = 5; - string ClientIP = 6; - Customer Customer = 7; - repeated Item Items = 8; - bool Auto = 9; - bool Recurrent = 10; -} - -message Customer { - string FullName = 1; - string INN = 2; - string Email = 3; - string Phone = 4; -} - -message Item { - string Description = 1; - string Measure = 2; - string Quantity = 3; - string Money = 4; - string Currency = 5; - } diff --git a/proto/treasurer/service.proto b/proto/treasurer/service.proto index d9ebaa2..30f63c0 100644 --- a/proto/treasurer/service.proto +++ b/proto/treasurer/service.proto @@ -2,7 +2,6 @@ syntax = "proto3"; package treasurer; -import "google/protobuf/empty.proto"; import "google/protobuf/empty.proto"; option go_package = "./treasurer"; @@ -38,3 +37,32 @@ message GetPaymentLinkResponse { message DeleteSavedPaymentMethodsRequest { string UserID = 1; } + + +message MainPaymentSettings { + string Currency = 1; + int64 Amount = 2; + repeated string CallbackHostGRPC = 3; + string ReturnURL = 4; + string UserID = 5; + string ClientIP = 6; + Customer Customer = 7; + repeated Item Items = 8; + bool Auto = 9; + bool Recurrent = 10; +} + +message Customer { + string FullName = 1; + string INN = 2; + string Email = 3; + string Phone = 4; +} + +message Item { + string Description = 1; + string Measure = 2; + string Quantity = 3; + string Money = 4; + string Currency = 5; +} \ No newline at end of file From 8f7f0db1420ec7d0713b6725e70db798df3f1ea6 Mon Sep 17 00:00:00 2001 From: pasha1coil Date: Sun, 15 Jun 2025 10:48:37 +0300 Subject: [PATCH 04/20] added logic recurrent payment --- internal/controller/grpc/payment.go | 1 + internal/models/payment.go | 1 + internal/models/yandex/payment_create.go | 7 ++ .../payment_provider/yoomoney/provider.go | 79 +++++++++++++++++++ internal/utils/parse_map.go | 8 ++ 5 files changed, 96 insertions(+) diff --git a/internal/controller/grpc/payment.go b/internal/controller/grpc/payment.go index b07e3ed..66a134c 100644 --- a/internal/controller/grpc/payment.go +++ b/internal/controller/grpc/payment.go @@ -97,6 +97,7 @@ func (r *PaymentController) createPayment(ctx context.Context, paymentType model Items: utils.ProtoItems2ReceiptItems(in.MainSettings.Items), }), "save_payment_method": strconv.FormatBool(in.MainSettings.Auto), + "recurrent": strconv.FormatBool(in.MainSettings.Recurrent), } link, err := provider.CreateInvoice(ctx, request) if err != nil { diff --git a/internal/models/payment.go b/internal/models/payment.go index 8ddfb70..4419546 100644 --- a/internal/models/payment.go +++ b/internal/models/payment.go @@ -59,6 +59,7 @@ type CreatePayment[T any] struct { ClientIP string Requisites T Auto bool + Recurrent bool } type BankCard struct { diff --git a/internal/models/yandex/payment_create.go b/internal/models/yandex/payment_create.go index aad6961..0e016e1 100644 --- a/internal/models/yandex/payment_create.go +++ b/internal/models/yandex/payment_create.go @@ -41,3 +41,10 @@ type Customer struct { Email string `json:"email,omitempty"` Phone string `json:"phone,omitempty"` } + +type CreateRecurrentPayment struct { + Amount Amount `json:"amount"` + Capture bool `json:"capture"` + PaymentMethodID string `json:"payment_method_id"` + Description string `json:"description,omitempty"` +} diff --git a/internal/payment_provider/yoomoney/provider.go b/internal/payment_provider/yoomoney/provider.go index 324a782..d3ca482 100644 --- a/internal/payment_provider/yoomoney/provider.go +++ b/internal/payment_provider/yoomoney/provider.go @@ -79,6 +79,11 @@ func (p *Provider) CreateInvoice(ctx context.Context, req map[string]string) (st p.logger.Error("failed to create payment yandex receipt by parse map", zap.Error(err)) return "", errors.NewWithMessage("failed to parse input request by parse map", errors.ErrInvalidArgs) } + + if request.Recurrent { + return p.CreateRecurrentPayment(ctx, request) + } + idempotenceKey := uuid.New().String() yandexPayment, err := p.httpClient.R(). @@ -250,3 +255,77 @@ func (p *Provider) handleWebhook(ctx *fiber.Ctx) error { return ctx.SendStatus(http.StatusOK) } + +func (p *Provider) CreateRecurrentPayment(ctx context.Context, request *models.CreatePayment[yandex.Receipt]) (string, errors.Error) { + methods, err := p.paymentMethodRepository.GetByUserID(ctx, request.UserID) + if err != nil { + p.logger.Error("failed to get payment methods", zap.Error(err), zap.String("userId", request.UserID)) + return "", errors.NewWithError(err, errors.ErrInternalError) + } + + if len(methods) == 0 { + p.logger.Warn("no saved payment methods found", zap.String("userId", request.UserID)) + return "", errors.NewWithMessage("no saved payment methods found", errors.ErrInvalidArgs) + } + + for _, method := range methods { + idempotenceKey := uuid.New().String() + + yandexPayment, err := p.httpClient.R(). + SetContext(ctx). + SetHeader("Content-Type", "application/json"). + SetHeader("Idempotence-Key", idempotenceKey). + SetHeader("Authorization", utils.ConvertYoomoneySercetsToAuth("Basic", p.config.StoreID, p.config.SecretKey)). + SetBody(&yandex.CreateRecurrentPayment{ + Amount: yandex.Amount{ + Value: utils.ConvertAmountToStringFloat(request.Amount), + Currency: request.Currency, + }, + PaymentMethodID: method.MethodID, + Capture: true, + }). + Post(p.config.PaymentsURL) + + if err != nil { + p.logger.Error("failed to create recurrent payment", zap.Error(err), zap.String("userId", request.UserID)) + return "", errors.NewWithError(fmt.Errorf("failed to create recurrent payment"), errors.ErrInternalError) + } + + if yandexPayment.StatusCode() != http.StatusOK { + p.logger.Error("unexpected status code from yandex", zap.Int("statusCode", yandexPayment.StatusCode()), zap.String("userId", request.UserID)) + return "", errors.NewWithError(fmt.Errorf("unexpected status code: %d", yandexPayment.StatusCode()), errors.ErrInternalError) + } + + var payment yandex.Payment + if err := json.Unmarshal(yandexPayment.Body(), &payment); err != nil { + p.logger.Error("failed to unmarshal payment response", zap.Error(err), zap.String("userId", request.UserID), zap.String("methodId", method.MethodID)) + return "", errors.NewWithError(err, errors.ErrInternalError) + } + if payment.Status != yandex.PaymentStatusSuccessfully { + p.logger.Error("payment not succeeded", zap.String("userId", request.UserID), zap.String("status", string(payment.Status))) + continue + } + + _, err = p.repository.Insert(ctx, &models.Payment{ + UserID: request.UserID, + PaymentID: payment.ID, + IdempotencePaymentID: idempotenceKey, + ClientIP: request.ClientIP, + Currency: request.Currency, + Amount: request.Amount, + Type: request.Type, + Status: models.PaymentStatusMap[string(payment.Status)], + Completed: false, + RawPaymentBody: payment, + CallbackHostGRPC: request.CallbackHostGRPC, + }) + if err != nil { + p.logger.Error("failed to save payment to database", zap.Error(err)) + return "", errors.NewWithError(fmt.Errorf("failed to save payment to database: %w", err), errors.ErrInternalError) + } + + return payment.ID, nil + } + + return "", errors.NewWithMessage("failed to create recurrent payment with any saved method", errors.ErrInternalError) +} diff --git a/internal/utils/parse_map.go b/internal/utils/parse_map.go index 558a4fd..b848707 100644 --- a/internal/utils/parse_map.go +++ b/internal/utils/parse_map.go @@ -36,6 +36,13 @@ func MapToCreatePaymentYandexReceipt(data map[string]string) (*models.CreatePaym return nil, fmt.Errorf("invalid save_payment_method field: %w", err) } } + recurrent := false + if val, ok := data["recurrent"]; ok && val != "" { + recurrent, err = strconv.ParseBool(val) + if err != nil { + return nil, fmt.Errorf("invalid recurrent field: %w", err) + } + } payment := &models.CreatePayment[yandex.Receipt]{ Type: models.PaymentType(data["type"]), @@ -47,6 +54,7 @@ func MapToCreatePaymentYandexReceipt(data map[string]string) (*models.CreatePaym ClientIP: data["client_ip"], Requisites: requisites, Auto: auto, + Recurrent: recurrent, } return payment, nil From 228edf6a1eda6b39d06d3f7ad3d89ec71a6532e8 Mon Sep 17 00:00:00 2001 From: pasha1coil Date: Thu, 19 Jun 2025 10:58:09 +0300 Subject: [PATCH 05/20] drop pkg closer from pj, now import it from common --- internal/app/app.go | 2 +- pkg/closer/closer.go | 37 ------------------------------------- 2 files changed, 1 insertion(+), 38 deletions(-) delete mode 100644 pkg/closer/closer.go diff --git a/internal/app/app.go b/internal/app/app.go index 3b090d2..dfe9734 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "gitea.pena/PenaSide/common/closer" "gitea.pena/PenaSide/common/mongo" "gitea.pena/PenaSide/treasurer/internal/server/grpc" "gitea.pena/PenaSide/treasurer/internal/server/http" @@ -11,7 +12,6 @@ import ( "gitea.pena/PenaSide/treasurer/internal/initialize" "gitea.pena/PenaSide/treasurer/internal/worker" - "gitea.pena/PenaSide/treasurer/pkg/closer" "go.uber.org/zap" ) diff --git a/pkg/closer/closer.go b/pkg/closer/closer.go deleted file mode 100644 index fdfbaf1..0000000 --- a/pkg/closer/closer.go +++ /dev/null @@ -1,37 +0,0 @@ -package closer - -import ( - "context" -) - -type Closer interface { - Close(ctx context.Context) error -} - -type CloserFunc func(ctx context.Context) error - -func (cf CloserFunc) Close(ctx context.Context) error { - return cf(ctx) -} - -type CloserGroup struct { - closers []Closer -} - -func NewCloserGroup() *CloserGroup { - return &CloserGroup{} -} - -func (cg *CloserGroup) Add(c Closer) { - cg.closers = append(cg.closers, c) -} - -func (cg *CloserGroup) Call(ctx context.Context) error { - var closeErr error - for i := len(cg.closers) - 1; i >= 0; i-- { - if err := cg.closers[i].Close(ctx); err != nil && closeErr == nil { - closeErr = err - } - } - return closeErr -} From 732a898a1143251da025cc31d9a89e2676029e69 Mon Sep 17 00:00:00 2001 From: Pasha Date: Mon, 21 Jul 2025 14:48:53 +0300 Subject: [PATCH 06/20] added new provider --- internal/models/payment.go | 1 + internal/payment_provider/alchemy/provider.go | 51 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 internal/payment_provider/alchemy/provider.go diff --git a/internal/models/payment.go b/internal/models/payment.go index 4419546..d86d5f8 100644 --- a/internal/models/payment.go +++ b/internal/models/payment.go @@ -80,6 +80,7 @@ const ( PaymentTypeMobile PaymentType = "mobile" PaymentTypeSBP PaymentType = "sbp" PaymentTypeSberB2B PaymentType = "b2bSberbank" + PaymentTypeAlchemy PaymentType = "alchemy" ) var ( diff --git a/internal/payment_provider/alchemy/provider.go b/internal/payment_provider/alchemy/provider.go new file mode 100644 index 0000000..65fe985 --- /dev/null +++ b/internal/payment_provider/alchemy/provider.go @@ -0,0 +1,51 @@ +package alchemy + +import ( + "context" + "gitea.pena/PenaSide/treasurer/internal/errors" + "gitea.pena/PenaSide/treasurer/internal/models" + "github.com/gofiber/fiber/v2" + "go.uber.org/zap" +) + +const ProviderName = "alchemy" + +type Config struct { +} + +type Provider struct { + logger *zap.Logger + config *Config +} + +type Deps struct { + Logger *zap.Logger + Config *Config +} + +func New(deps Deps) *Provider { + return &Provider{ + logger: deps.Logger, + config: deps.Config, + } +} + +func (p *Provider) GetName() string { + return ProviderName +} + +func (p *Provider) GetSupportedPaymentMethods() []models.PaymentType { + return []models.PaymentType{models.PaymentTypeAlchemy} +} + +func (p *Provider) CreateInvoice(ctx context.Context, req map[string]string) (string, errors.Error) { + return "", nil +} + +func (p *Provider) RegisterWebhookHandlers(router fiber.Router) { + router.Post("/webhook/alchemy", p.handleWebhook) +} + +func (p *Provider) handleWebhook(ctx *fiber.Ctx) error { + return nil +} From ca24a9c1f2d9998fb90811567708d0ace209d05f Mon Sep 17 00:00:00 2001 From: Pasha Date: Mon, 21 Jul 2025 17:31:44 +0300 Subject: [PATCH 07/20] start logic webhook and added model for webhook payload --- internal/models/alchemy/webhook.go | 39 +++++++++++++++++++ internal/payment_provider/alchemy/provider.go | 16 +++++++- 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 internal/models/alchemy/webhook.go diff --git a/internal/models/alchemy/webhook.go b/internal/models/alchemy/webhook.go new file mode 100644 index 0000000..f819fd9 --- /dev/null +++ b/internal/models/alchemy/webhook.go @@ -0,0 +1,39 @@ +package alchemy + +type AlchemyAddressActivityWebhook struct { + CreatedAt string `json:"createdAt"` + Event struct { + Activity []struct { + Asset string `json:"asset"` + BlockNum string `json:"blockNum"` + Category string `json:"category"` + //Erc1155Metadata interface{} `json:"erc1155Metadata"` + //Erc721TokenId interface{} `json:"erc721TokenId"` + FromAddress string `json:"fromAddress"` + Hash string `json:"hash"` + Log struct { + Address string `json:"address"` + BlockHash string `json:"blockHash"` + BlockNumber string `json:"blockNumber"` + Data string `json:"data"` + LogIndex string `json:"logIndex"` + Removed bool `json:"removed"` + Topics []string `json:"topics"` + TransactionHash string `json:"transactionHash"` + TransactionIndex string `json:"transactionIndex"` + } `json:"log"` + RawContract struct { + Address string `json:"address"` + Decimals int `json:"decimals"` + RawValue string `json:"rawValue"` + } `json:"rawContract"` + ToAddress string `json:"toAddress"` + //TypeTraceAddress interface{} `json:"typeTraceAddress"` + Value float64 `json:"value"` + } `json:"activity"` + Network string `json:"network"` + } `json:"event"` + ID string `json:"id"` + Type string `json:"type"` + WebhookId string `json:"webhookId"` +} diff --git a/internal/payment_provider/alchemy/provider.go b/internal/payment_provider/alchemy/provider.go index 65fe985..a0791a4 100644 --- a/internal/payment_provider/alchemy/provider.go +++ b/internal/payment_provider/alchemy/provider.go @@ -2,8 +2,10 @@ package alchemy import ( "context" + "fmt" "gitea.pena/PenaSide/treasurer/internal/errors" "gitea.pena/PenaSide/treasurer/internal/models" + "gitea.pena/PenaSide/treasurer/internal/models/alchemy" "github.com/gofiber/fiber/v2" "go.uber.org/zap" ) @@ -11,6 +13,7 @@ import ( const ProviderName = "alchemy" type Config struct { + WalletAddress string `json:"walletAddress"` } type Provider struct { @@ -47,5 +50,16 @@ func (p *Provider) RegisterWebhookHandlers(router fiber.Router) { } func (p *Provider) handleWebhook(ctx *fiber.Ctx) error { - return nil + var payload alchemy.AlchemyAddressActivityWebhook + if err := ctx.BodyParser(&payload); err != nil { + return ctx.Status(fiber.StatusBadRequest).SendString(fmt.Sprintf("failed to parse Alchemy webhook: %s", err.Error())) + } + + for _, act := range payload.Event.Activity { + if act.ToAddress != p.config.WalletAddress { + continue + } + //TODO: найти инвойс по act.Value и act.FromAddress + } + return ctx.SendStatus(fiber.StatusOK) } From bdd41ee12612964923aafa5e35552015b85fae98 Mon Sep 17 00:00:00 2001 From: Pasha Date: Mon, 21 Jul 2025 18:03:53 +0300 Subject: [PATCH 08/20] added full logic for webhook Alchemy --- internal/models/payment.go | 2 ++ internal/payment_provider/alchemy/provider.go | 24 +++++++++++--- internal/repository/payment.go | 33 +++++++++++++++++++ 3 files changed, 54 insertions(+), 5 deletions(-) diff --git a/internal/models/payment.go b/internal/models/payment.go index d86d5f8..29766b0 100644 --- a/internal/models/payment.go +++ b/internal/models/payment.go @@ -29,6 +29,8 @@ type Payment struct { Запрос будет отправляться по протоколу GRPC */ CallbackHostGRPC []string `json:"callbackHostGrpc" bson:"callbackHostGrpc"` + + WalletAddress string // for crypto } func (p *Payment) Sanitize() *Payment { diff --git a/internal/payment_provider/alchemy/provider.go b/internal/payment_provider/alchemy/provider.go index a0791a4..2b6ba5a 100644 --- a/internal/payment_provider/alchemy/provider.go +++ b/internal/payment_provider/alchemy/provider.go @@ -6,6 +6,7 @@ import ( "gitea.pena/PenaSide/treasurer/internal/errors" "gitea.pena/PenaSide/treasurer/internal/models" "gitea.pena/PenaSide/treasurer/internal/models/alchemy" + "gitea.pena/PenaSide/treasurer/internal/repository" "github.com/gofiber/fiber/v2" "go.uber.org/zap" ) @@ -17,13 +18,15 @@ type Config struct { } type Provider struct { - logger *zap.Logger - config *Config + repository *repository.PaymentRepository + logger *zap.Logger + config *Config } type Deps struct { - Logger *zap.Logger - Config *Config + Repository *repository.PaymentMethodRepository + Logger *zap.Logger + Config *Config } func New(deps Deps) *Provider { @@ -59,7 +62,18 @@ func (p *Provider) handleWebhook(ctx *fiber.Ctx) error { if act.ToAddress != p.config.WalletAddress { continue } - //TODO: найти инвойс по act.Value и act.FromAddress + amountStr := fmt.Sprintf("%v", act.Value) + payment, err := p.repository.FindByWalletAddressAndAmount(ctx.Context(), act.FromAddress, amountStr) + if err != nil { + if err.Type() == errors.ErrNotFound { + return ctx.Status(fiber.StatusNotFound).SendString(fmt.Sprintf("payment not found: %s", err.Error())) + } + return ctx.Status(fiber.StatusInternalServerError).SendString(fmt.Sprintf("internal error while searching payment: %s", err.Error())) + } + _, err = p.repository.SetPaymentComplete(ctx.Context(), payment.PaymentID) + if err != nil { + return ctx.Status(fiber.StatusInternalServerError).SendString(fmt.Sprintf("failed to set payment complete: %s", err.Error())) + } } return ctx.SendStatus(fiber.StatusOK) } diff --git a/internal/repository/payment.go b/internal/repository/payment.go index e4c8bee..316b3ee 100644 --- a/internal/repository/payment.go +++ b/internal/repository/payment.go @@ -31,6 +31,8 @@ var PaymentFields = struct { DeletedAt string RawPaymentBody string CallbackHostGRPC string + + WalletAddress string // for crypto }{ ID: "_id", UserID: "userId", @@ -48,6 +50,8 @@ var PaymentFields = struct { DeletedAt: "deletedAt", RawPaymentBody: "rawPaymentBody", CallbackHostGRPC: "callbackHostGrpc", + + WalletAddress: "walletAddress", } type PaymentRepositoryDeps struct { @@ -156,3 +160,32 @@ func (r *PaymentRepository) SetPaymentStatus(ctx context.Context, paymentID stri return &payment, nil } + +func (r *PaymentRepository) FindByWalletAddressAndAmount(ctx context.Context, walletAddress string, amount string) (*models.Payment, errors.Error) { + payment := models.Payment{} + filter := bson.M{ + PaymentFields.WalletAddress: walletAddress, + PaymentFields.Amount: amount, + PaymentFields.Completed: false, //не завершённые + } + if err := r.collection.FindOne(ctx, filter).Decode(&payment); err != nil { + r.logger.Error("failed to find payment by walletAddress and amount on of ", + zap.Error(err), + zap.String("walletAddress", walletAddress), + zap.String("amount", amount), + ) + + findErr := errors.NewWithError( + fmt.Errorf("failed to find payment by walletAddress and amount: %w", err), + errors.ErrInternalError, + ) + + if err == mongo.ErrNoDocuments { + return nil, findErr.SetType(errors.ErrNotFound) + } + + return nil, findErr + } + + return &payment, nil +} From 92d90b8ab9f2d036808943b9694b2f42d56aa378 Mon Sep 17 00:00:00 2001 From: Pasha Date: Mon, 21 Jul 2025 18:11:19 +0300 Subject: [PATCH 09/20] added todo --- internal/payment_provider/alchemy/provider.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/payment_provider/alchemy/provider.go b/internal/payment_provider/alchemy/provider.go index 2b6ba5a..f958080 100644 --- a/internal/payment_provider/alchemy/provider.go +++ b/internal/payment_provider/alchemy/provider.go @@ -44,6 +44,7 @@ func (p *Provider) GetSupportedPaymentMethods() []models.PaymentType { return []models.PaymentType{models.PaymentTypeAlchemy} } +// todo func (p *Provider) CreateInvoice(ctx context.Context, req map[string]string) (string, errors.Error) { return "", nil } From 4a4048d381b3063165c2d4cbd267687ef0ad648f Mon Sep 17 00:00:00 2001 From: Pasha Date: Mon, 21 Jul 2025 18:25:32 +0300 Subject: [PATCH 10/20] fix err amount - int64 --- internal/models/alchemy/webhook.go | 2 +- internal/payment_provider/alchemy/provider.go | 5 ++--- internal/repository/payment.go | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/internal/models/alchemy/webhook.go b/internal/models/alchemy/webhook.go index f819fd9..4e6886a 100644 --- a/internal/models/alchemy/webhook.go +++ b/internal/models/alchemy/webhook.go @@ -29,7 +29,7 @@ type AlchemyAddressActivityWebhook struct { } `json:"rawContract"` ToAddress string `json:"toAddress"` //TypeTraceAddress interface{} `json:"typeTraceAddress"` - Value float64 `json:"value"` + Value int64 `json:"value"` } `json:"activity"` Network string `json:"network"` } `json:"event"` diff --git a/internal/payment_provider/alchemy/provider.go b/internal/payment_provider/alchemy/provider.go index f958080..b55bce5 100644 --- a/internal/payment_provider/alchemy/provider.go +++ b/internal/payment_provider/alchemy/provider.go @@ -24,7 +24,7 @@ type Provider struct { } type Deps struct { - Repository *repository.PaymentMethodRepository + Repository *repository.PaymentRepository Logger *zap.Logger Config *Config } @@ -63,8 +63,7 @@ func (p *Provider) handleWebhook(ctx *fiber.Ctx) error { if act.ToAddress != p.config.WalletAddress { continue } - amountStr := fmt.Sprintf("%v", act.Value) - payment, err := p.repository.FindByWalletAddressAndAmount(ctx.Context(), act.FromAddress, amountStr) + payment, err := p.repository.FindByWalletAddressAndAmount(ctx.Context(), act.FromAddress, act.Value) if err != nil { if err.Type() == errors.ErrNotFound { return ctx.Status(fiber.StatusNotFound).SendString(fmt.Sprintf("payment not found: %s", err.Error())) diff --git a/internal/repository/payment.go b/internal/repository/payment.go index 316b3ee..ceeaf2a 100644 --- a/internal/repository/payment.go +++ b/internal/repository/payment.go @@ -161,7 +161,7 @@ func (r *PaymentRepository) SetPaymentStatus(ctx context.Context, paymentID stri return &payment, nil } -func (r *PaymentRepository) FindByWalletAddressAndAmount(ctx context.Context, walletAddress string, amount string) (*models.Payment, errors.Error) { +func (r *PaymentRepository) FindByWalletAddressAndAmount(ctx context.Context, walletAddress string, amount int64) (*models.Payment, errors.Error) { payment := models.Payment{} filter := bson.M{ PaymentFields.WalletAddress: walletAddress, @@ -172,7 +172,7 @@ func (r *PaymentRepository) FindByWalletAddressAndAmount(ctx context.Context, wa r.logger.Error("failed to find payment by walletAddress and amount on of ", zap.Error(err), zap.String("walletAddress", walletAddress), - zap.String("amount", amount), + zap.Int64("amount", amount), ) findErr := errors.NewWithError( From 570b1c0d2e0b317b9f9b9b5e2ce1eb5247c2d0a1 Mon Sep 17 00:00:00 2001 From: Pasha Date: Mon, 21 Jul 2025 18:33:23 +0300 Subject: [PATCH 11/20] added new mongo field crypto amount - float64 --- internal/models/alchemy/webhook.go | 2 +- internal/models/payment.go | 3 ++- internal/repository/payment.go | 8 +++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/internal/models/alchemy/webhook.go b/internal/models/alchemy/webhook.go index 4e6886a..f819fd9 100644 --- a/internal/models/alchemy/webhook.go +++ b/internal/models/alchemy/webhook.go @@ -29,7 +29,7 @@ type AlchemyAddressActivityWebhook struct { } `json:"rawContract"` ToAddress string `json:"toAddress"` //TypeTraceAddress interface{} `json:"typeTraceAddress"` - Value int64 `json:"value"` + Value float64 `json:"value"` } `json:"activity"` Network string `json:"network"` } `json:"event"` diff --git a/internal/models/payment.go b/internal/models/payment.go index 29766b0..46cdfda 100644 --- a/internal/models/payment.go +++ b/internal/models/payment.go @@ -30,7 +30,8 @@ type Payment struct { */ CallbackHostGRPC []string `json:"callbackHostGrpc" bson:"callbackHostGrpc"` - WalletAddress string // for crypto + WalletAddress string `json:"walletAddress" bson:"walletAddress"` // for crypto + CryptoAmount float64 `json:"cryptoAmount" bson:"cryptoAmount"` // for crypto } func (p *Payment) Sanitize() *Payment { diff --git a/internal/repository/payment.go b/internal/repository/payment.go index ceeaf2a..17b957b 100644 --- a/internal/repository/payment.go +++ b/internal/repository/payment.go @@ -33,6 +33,7 @@ var PaymentFields = struct { CallbackHostGRPC string WalletAddress string // for crypto + CryptoAmount string // for crypto }{ ID: "_id", UserID: "userId", @@ -52,6 +53,7 @@ var PaymentFields = struct { CallbackHostGRPC: "callbackHostGrpc", WalletAddress: "walletAddress", + CryptoAmount: "cryptoAmount", } type PaymentRepositoryDeps struct { @@ -161,18 +163,18 @@ func (r *PaymentRepository) SetPaymentStatus(ctx context.Context, paymentID stri return &payment, nil } -func (r *PaymentRepository) FindByWalletAddressAndAmount(ctx context.Context, walletAddress string, amount int64) (*models.Payment, errors.Error) { +func (r *PaymentRepository) FindByWalletAddressAndAmount(ctx context.Context, walletAddress string, cryptoAmount float64) (*models.Payment, errors.Error) { payment := models.Payment{} filter := bson.M{ PaymentFields.WalletAddress: walletAddress, - PaymentFields.Amount: amount, + PaymentFields.CryptoAmount: cryptoAmount, PaymentFields.Completed: false, //не завершённые } if err := r.collection.FindOne(ctx, filter).Decode(&payment); err != nil { r.logger.Error("failed to find payment by walletAddress and amount on of ", zap.Error(err), zap.String("walletAddress", walletAddress), - zap.Int64("amount", amount), + zap.Float64("amount", cryptoAmount), ) findErr := errors.NewWithError( From 330d8753e036a72b303cdf7e4de0ee31b651ed5e Mon Sep 17 00:00:00 2001 From: Pasha Date: Tue, 22 Jul 2025 14:16:36 +0300 Subject: [PATCH 12/20] added logic for create invoice --- internal/models/payment.go | 5 +- internal/payment_provider/alchemy/provider.go | 49 +++++++++++++++++-- internal/repository/payment.go | 31 +++++++----- 3 files changed, 68 insertions(+), 17 deletions(-) diff --git a/internal/models/payment.go b/internal/models/payment.go index 46cdfda..c14f90b 100644 --- a/internal/models/payment.go +++ b/internal/models/payment.go @@ -30,8 +30,9 @@ type Payment struct { */ CallbackHostGRPC []string `json:"callbackHostGrpc" bson:"callbackHostGrpc"` - WalletAddress string `json:"walletAddress" bson:"walletAddress"` // for crypto - CryptoAmount float64 `json:"cryptoAmount" bson:"cryptoAmount"` // for crypto + ToWalletAddress string `json:"toWalletAddress" bson:"toWalletAddress"` // for crypto our + FromWalletAddress string `json:"fromWalletAddress" bson:"fromWalletAddress"` // for crypto them + CryptoAmount float64 `json:"cryptoAmount" bson:"cryptoAmount"` // for crypto } func (p *Payment) Sanitize() *Payment { diff --git a/internal/payment_provider/alchemy/provider.go b/internal/payment_provider/alchemy/provider.go index b55bce5..802933c 100644 --- a/internal/payment_provider/alchemy/provider.go +++ b/internal/payment_provider/alchemy/provider.go @@ -9,6 +9,9 @@ import ( "gitea.pena/PenaSide/treasurer/internal/repository" "github.com/gofiber/fiber/v2" "go.uber.org/zap" + "strconv" + "strings" + "time" ) const ProviderName = "alchemy" @@ -44,9 +47,49 @@ func (p *Provider) GetSupportedPaymentMethods() []models.PaymentType { return []models.PaymentType{models.PaymentTypeAlchemy} } -// todo func (p *Provider) CreateInvoice(ctx context.Context, req map[string]string) (string, errors.Error) { - return "", nil + amountStr := req["cryptoAmount"] + fromWallet := req["fromWalletAddress"] + if amountStr == "" || fromWallet == "" { + p.logger.Error("amount or fromWallet address is empty", zap.String("fromWalletAddress", fromWallet), zap.String("cryptoAmount", amountStr)) + return "", errors.NewWithMessage("cryptoAmount and fromWalletAddress required", errors.ErrInvalidArgs) + } + + cryptoAmount, err := strconv.ParseFloat(amountStr, 64) + if err != nil { + p.logger.Error("failed to parse cryptoAmount from wallet address", zap.Error(err)) + return "", errors.NewWithMessage("invalid cryptoAmount", errors.ErrInvalidArgs) + } + + now := time.Now() + payment := &models.Payment{ + UserID: req["user_id"], + ClientIP: req["client_ip"], + Currency: req["currency"], + Type: models.PaymentType(req["type"]), + Status: models.PaymentStatusWaiting, + Completed: false, + IsDeleted: false, + CreatedAt: now, + UpdatedAt: now, + ToWalletAddress: p.config.WalletAddress, + FromWalletAddress: fromWallet, + CryptoAmount: cryptoAmount, + } + + var callbackHosts []string + if val, ok := req["callback_host_grpc"]; ok && val != "" { + callbackHosts = strings.Split(val, ",") + } + payment.CallbackHostGRPC = callbackHosts + + _, err = p.repository.Insert(ctx, payment) + if err != nil { + p.logger.Error("failed to insert payment into database", zap.Error(err)) + return "", errors.NewWithMessage(fmt.Sprintf("failed to insert payment into database: %v", err), errors.ErrInternalError) + } + + return p.config.WalletAddress, nil } func (p *Provider) RegisterWebhookHandlers(router fiber.Router) { @@ -63,7 +106,7 @@ func (p *Provider) handleWebhook(ctx *fiber.Ctx) error { if act.ToAddress != p.config.WalletAddress { continue } - payment, err := p.repository.FindByWalletAddressAndAmount(ctx.Context(), act.FromAddress, act.Value) + payment, err := p.repository.FindByWalletsAndAmount(ctx.Context(), act.ToAddress, act.FromAddress, act.Value) if err != nil { if err.Type() == errors.ErrNotFound { return ctx.Status(fiber.StatusNotFound).SendString(fmt.Sprintf("payment not found: %s", err.Error())) diff --git a/internal/repository/payment.go b/internal/repository/payment.go index 17b957b..eee0907 100644 --- a/internal/repository/payment.go +++ b/internal/repository/payment.go @@ -32,8 +32,10 @@ var PaymentFields = struct { RawPaymentBody string CallbackHostGRPC string - WalletAddress string // for crypto - CryptoAmount string // for crypto + WalletAddress string // for crypto + CryptoAmount string // for crypto + ToWalletAddress string + FromWalletAddress string }{ ID: "_id", UserID: "userId", @@ -52,8 +54,10 @@ var PaymentFields = struct { RawPaymentBody: "rawPaymentBody", CallbackHostGRPC: "callbackHostGrpc", - WalletAddress: "walletAddress", - CryptoAmount: "cryptoAmount", + WalletAddress: "walletAddress", + CryptoAmount: "cryptoAmount", + ToWalletAddress: "toWalletAddress", + FromWalletAddress: "fromWalletAddress", } type PaymentRepositoryDeps struct { @@ -163,22 +167,25 @@ func (r *PaymentRepository) SetPaymentStatus(ctx context.Context, paymentID stri return &payment, nil } -func (r *PaymentRepository) FindByWalletAddressAndAmount(ctx context.Context, walletAddress string, cryptoAmount float64) (*models.Payment, errors.Error) { +func (r *PaymentRepository) FindByWalletsAndAmount(ctx context.Context, toWalletAddress, fromWalletAddress string, cryptoAmount float64) (*models.Payment, errors.Error) { payment := models.Payment{} filter := bson.M{ - PaymentFields.WalletAddress: walletAddress, - PaymentFields.CryptoAmount: cryptoAmount, - PaymentFields.Completed: false, //не завершённые + PaymentFields.ToWalletAddress: toWalletAddress, + PaymentFields.FromWalletAddress: fromWalletAddress, + PaymentFields.CryptoAmount: cryptoAmount, + PaymentFields.Completed: false, + PaymentFields.Status: models.PaymentStatusWaiting, } if err := r.collection.FindOne(ctx, filter).Decode(&payment); err != nil { - r.logger.Error("failed to find payment by walletAddress and amount on of ", + r.logger.Error("failed to find payment by wallets and amount on of ", zap.Error(err), - zap.String("walletAddress", walletAddress), - zap.Float64("amount", cryptoAmount), + zap.String("toWalletAddress", toWalletAddress), + zap.String("fromWalletAddress", fromWalletAddress), + zap.Float64("cryptoAmount", cryptoAmount), ) findErr := errors.NewWithError( - fmt.Errorf("failed to find payment by walletAddress and amount: %w", err), + fmt.Errorf("failed to find payment by wallets and amount: %w", err), errors.ErrInternalError, ) From f0d3d0c9cdf1bd11eeb724cc264f8995f0e98fd5 Mon Sep 17 00:00:00 2001 From: Pasha Date: Tue, 22 Jul 2025 14:28:27 +0300 Subject: [PATCH 13/20] somme upd --- internal/payment_provider/alchemy/provider.go | 9 +++++---- internal/repository/payment.go | 1 - 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/payment_provider/alchemy/provider.go b/internal/payment_provider/alchemy/provider.go index 802933c..919f946 100644 --- a/internal/payment_provider/alchemy/provider.go +++ b/internal/payment_provider/alchemy/provider.go @@ -8,6 +8,7 @@ import ( "gitea.pena/PenaSide/treasurer/internal/models/alchemy" "gitea.pena/PenaSide/treasurer/internal/repository" "github.com/gofiber/fiber/v2" + "github.com/google/uuid" "go.uber.org/zap" "strconv" "strings" @@ -63,13 +64,12 @@ func (p *Provider) CreateInvoice(ctx context.Context, req map[string]string) (st now := time.Now() payment := &models.Payment{ + PaymentID: uuid.NewString(), UserID: req["user_id"], ClientIP: req["client_ip"], Currency: req["currency"], - Type: models.PaymentType(req["type"]), + Type: models.PaymentTypeAlchemy, Status: models.PaymentStatusWaiting, - Completed: false, - IsDeleted: false, CreatedAt: now, UpdatedAt: now, ToWalletAddress: p.config.WalletAddress, @@ -106,6 +106,7 @@ func (p *Provider) handleWebhook(ctx *fiber.Ctx) error { if act.ToAddress != p.config.WalletAddress { continue } + // todo нужно подумать как сделать так если сумма оплаты оказалась чуть больше ожидаемой... payment, err := p.repository.FindByWalletsAndAmount(ctx.Context(), act.ToAddress, act.FromAddress, act.Value) if err != nil { if err.Type() == errors.ErrNotFound { @@ -113,7 +114,7 @@ func (p *Provider) handleWebhook(ctx *fiber.Ctx) error { } return ctx.Status(fiber.StatusInternalServerError).SendString(fmt.Sprintf("internal error while searching payment: %s", err.Error())) } - _, err = p.repository.SetPaymentComplete(ctx.Context(), payment.PaymentID) + _, err = p.repository.SetPaymentStatus(ctx.Context(), payment.PaymentID, models.PaymentStatusSuccessfully) if err != nil { return ctx.Status(fiber.StatusInternalServerError).SendString(fmt.Sprintf("failed to set payment complete: %s", err.Error())) } diff --git a/internal/repository/payment.go b/internal/repository/payment.go index eee0907..a9fe888 100644 --- a/internal/repository/payment.go +++ b/internal/repository/payment.go @@ -173,7 +173,6 @@ func (r *PaymentRepository) FindByWalletsAndAmount(ctx context.Context, toWallet PaymentFields.ToWalletAddress: toWalletAddress, PaymentFields.FromWalletAddress: fromWalletAddress, PaymentFields.CryptoAmount: cryptoAmount, - PaymentFields.Completed: false, PaymentFields.Status: models.PaymentStatusWaiting, } if err := r.collection.FindOne(ctx, filter).Decode(&payment); err != nil { From 7b82cb8b5da32b7e39ff6671523bcf8679629f58 Mon Sep 17 00:00:00 2001 From: Pasha Date: Tue, 22 Jul 2025 14:32:56 +0300 Subject: [PATCH 14/20] initilize alchemy provider --- internal/initialize/config.go | 21 +++++++++++---------- internal/initialize/services.go | 11 ++++++++++- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/internal/initialize/config.go b/internal/initialize/config.go index 6384bd9..db5fca1 100644 --- a/internal/initialize/config.go +++ b/internal/initialize/config.go @@ -6,16 +6,17 @@ import ( ) type Config struct { - HttpURL string `env:"HTTP_URL" envDefault:"0.0.0.0:8080"` - HttpDomain string `env:"HTTP_DOMAIN" envDefault:"http://localhost:8080"` - GrpcURL string `env:"GRPC_URL,required" envDefault:"localhost:9000"` - YooMoneyStoreID string `env:"YOOMONEY_STORE_ID" envDefault:"storeid"` - YooMoneySecretKey string `env:"YOOMONEY_SECRET_KEY" envDefault:"secret"` - IsMock bool `env:"IS_MOCK" envDefault:"false"` - MockServiceHost string `env:"MOCK_SERVICE_HOST" envDefault:"http://treasurer-mock:8080"` - YooMoneyWebhooksURL string `env:"YOOMONEY_WEBHOOKS_URL" envDefault:"http://treasurer-mock:8080/webhooks"` - YooMoneyPaymentsURL string `env:"YOOMONEY_PAYMENTS_URL" envDefault:"http://treasurer-mock:8080/payments"` - Database mongo.Configuration + HttpURL string `env:"HTTP_URL" envDefault:"0.0.0.0:8080"` + HttpDomain string `env:"HTTP_DOMAIN" envDefault:"http://localhost:8080"` + GrpcURL string `env:"GRPC_URL,required" envDefault:"localhost:9000"` + YooMoneyStoreID string `env:"YOOMONEY_STORE_ID" envDefault:"storeid"` + YooMoneySecretKey string `env:"YOOMONEY_SECRET_KEY" envDefault:"secret"` + IsMock bool `env:"IS_MOCK" envDefault:"false"` + MockServiceHost string `env:"MOCK_SERVICE_HOST" envDefault:"http://treasurer-mock:8080"` + YooMoneyWebhooksURL string `env:"YOOMONEY_WEBHOOKS_URL" envDefault:"http://treasurer-mock:8080/webhooks"` + YooMoneyPaymentsURL string `env:"YOOMONEY_PAYMENTS_URL" envDefault:"http://treasurer-mock:8080/payments"` + AlchemyWalletAddress string `env:"ALCHEMY_WALLET_ADDRESS" envDefault:"0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"` + Database mongo.Configuration } func LoadConfig() (*Config, error) { diff --git a/internal/initialize/services.go b/internal/initialize/services.go index 1504b0a..6d94803 100644 --- a/internal/initialize/services.go +++ b/internal/initialize/services.go @@ -3,6 +3,7 @@ package initialize import ( "gitea.pena/PenaSide/treasurer/internal/errors" "gitea.pena/PenaSide/treasurer/internal/payment_provider" + "gitea.pena/PenaSide/treasurer/internal/payment_provider/alchemy" "gitea.pena/PenaSide/treasurer/internal/payment_provider/yoomoney" "gitea.pena/PenaSide/treasurer/internal/service/callback" "gitea.pena/PenaSide/treasurer/internal/service/mock" @@ -107,6 +108,14 @@ func NewServices(deps ServicesDeps) (*Services, errors.Error) { return nil, err } + alchemyProvider := alchemy.New(alchemy.Deps{ + Repository: deps.Repositories.Payment, + Logger: deps.Logger, + Config: &alchemy.Config{ + WalletAddress: deps.Config.AlchemyWalletAddress, + }, + }) + return &Services{ Callback: callbackService, Payment: paymentService, @@ -114,6 +123,6 @@ func NewServices(deps ServicesDeps) (*Services, errors.Error) { Status: statusService, //YandexWebhook: yandexWebhookService, Mock: mockService, - PaymentProviders: []payment_provider.PaymentProvider{yooMoneyProvider}, + PaymentProviders: []payment_provider.PaymentProvider{yooMoneyProvider, alchemyProvider}, }, nil } From 9416d90d23be064447a05618614057917de98609 Mon Sep 17 00:00:00 2001 From: Pasha Date: Tue, 22 Jul 2025 14:41:00 +0300 Subject: [PATCH 15/20] change proto --- proto/treasurer/service.proto | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/proto/treasurer/service.proto b/proto/treasurer/service.proto index 30f63c0..7a7a786 100644 --- a/proto/treasurer/service.proto +++ b/proto/treasurer/service.proto @@ -13,6 +13,7 @@ service TreasurerService { rpc GetPaymentLinkSberbankB2B(GetPaymentLinkRequest) returns (GetPaymentLinkResponse) {} rpc GetPaymentLinkSBP(GetPaymentLinkRequest) returns (GetPaymentLinkResponse) {} rpc GetPaymentLinkSberPay(GetPaymentLinkRequest) returns (GetPaymentLinkResponse) {} + rpc GetPaymentLinkAlchemy(GetPaymentLinkRequest) returns (GetPaymentLinkResponse) {} rpc DeleteSavedPaymentMethods(DeleteSavedPaymentMethodsRequest) returns (google.protobuf.Empty) {} } @@ -50,6 +51,10 @@ message MainPaymentSettings { repeated Item Items = 8; bool Auto = 9; bool Recurrent = 10; + // Для крипто-платежей: + string from_wallet_address = 11; + string to_wallet_address = 12; + double crypto_amount = 13; } message Customer { From c5a6570376e78e54e008a0ff60747bb96fe30dd8 Mon Sep 17 00:00:00 2001 From: Pasha Date: Tue, 22 Jul 2025 14:45:03 +0300 Subject: [PATCH 16/20] upd grpc/payment --- internal/controller/grpc/payment.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/controller/grpc/payment.go b/internal/controller/grpc/payment.go index 66a134c..c3f7e56 100644 --- a/internal/controller/grpc/payment.go +++ b/internal/controller/grpc/payment.go @@ -98,6 +98,9 @@ func (r *PaymentController) createPayment(ctx context.Context, paymentType model }), "save_payment_method": strconv.FormatBool(in.MainSettings.Auto), "recurrent": strconv.FormatBool(in.MainSettings.Recurrent), + "fromWalletAddress": in.MainSettings.FromWalletAddress, + "toWalletAddress": in.MainSettings.ToWalletAddress, + "cryptoAmount": fmt.Sprintf("%f", in.MainSettings.CryptoAmount), } link, err := provider.CreateInvoice(ctx, request) if err != nil { @@ -134,6 +137,10 @@ func (r *PaymentController) GetPaymentLinkSberbankB2B(ctx context.Context, in *t return r.createPayment(ctx, models.PaymentTypeSberB2B, in) } +func (r *PaymentController) GetPaymentLinkAlchemy(ctx context.Context, in *treasurer.GetPaymentLinkRequest) (*treasurer.GetPaymentLinkResponse, error) { + return r.createPayment(ctx, models.PaymentTypeAlchemy, in) +} + func (r *PaymentController) DeleteSavedPaymentMethods(ctx context.Context, in *treasurer.DeleteSavedPaymentMethodsRequest) (*emptypb.Empty, error) { if in.UserID == "" { r.logger.Error("empty user id provided") From 2497162aa77b960bbe8a343fde89ec8533ac4701 Mon Sep 17 00:00:00 2001 From: Pavel Date: Tue, 22 Jul 2025 14:48:37 +0300 Subject: [PATCH 17/20] gen proto --- internal/proto/treasurer/service.pb.go | 175 ++++++++++++-------- internal/proto/treasurer/service_grpc.pb.go | 36 ++++ 2 files changed, 144 insertions(+), 67 deletions(-) diff --git a/internal/proto/treasurer/service.pb.go b/internal/proto/treasurer/service.pb.go index b6d0a83..af92733 100644 --- a/internal/proto/treasurer/service.pb.go +++ b/internal/proto/treasurer/service.pb.go @@ -287,6 +287,10 @@ type MainPaymentSettings struct { Items []*Item `protobuf:"bytes,8,rep,name=Items,proto3" json:"Items,omitempty"` Auto bool `protobuf:"varint,9,opt,name=Auto,proto3" json:"Auto,omitempty"` Recurrent bool `protobuf:"varint,10,opt,name=Recurrent,proto3" json:"Recurrent,omitempty"` + // Для крипто-платежей: + FromWalletAddress string `protobuf:"bytes,11,opt,name=from_wallet_address,json=fromWalletAddress,proto3" json:"from_wallet_address,omitempty"` + ToWalletAddress string `protobuf:"bytes,12,opt,name=to_wallet_address,json=toWalletAddress,proto3" json:"to_wallet_address,omitempty"` + CryptoAmount float64 `protobuf:"fixed64,13,opt,name=crypto_amount,json=cryptoAmount,proto3" json:"crypto_amount,omitempty"` } func (x *MainPaymentSettings) Reset() { @@ -391,6 +395,27 @@ func (x *MainPaymentSettings) GetRecurrent() bool { return false } +func (x *MainPaymentSettings) GetFromWalletAddress() string { + if x != nil { + return x.FromWalletAddress + } + return "" +} + +func (x *MainPaymentSettings) GetToWalletAddress() string { + if x != nil { + return x.ToWalletAddress + } + return "" +} + +func (x *MainPaymentSettings) GetCryptoAmount() float64 { + if x != nil { + return x.CryptoAmount + } + return 0 +} + type Customer struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -578,7 +603,7 @@ var file_service_proto_rawDesc = []byte{ 0x22, 0x3a, 0x0a, 0x20, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x61, 0x76, 0x65, 0x64, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x44, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x44, 0x22, 0xd1, 0x02, 0x0a, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x44, 0x22, 0xd2, 0x03, 0x0a, 0x13, 0x4d, 0x61, 0x69, 0x6e, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x74, 0x74, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, @@ -600,67 +625,81 @@ var file_service_proto_rawDesc = []byte{ 0x0a, 0x04, 0x41, 0x75, 0x74, 0x6f, 0x18, 0x09, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x41, 0x75, 0x74, 0x6f, 0x12, 0x1c, 0x0a, 0x09, 0x52, 0x65, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x52, 0x65, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, - 0x22, 0x64, 0x0a, 0x08, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x12, 0x1a, 0x0a, 0x08, - 0x46, 0x75, 0x6c, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, - 0x46, 0x75, 0x6c, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x49, 0x4e, 0x4e, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x49, 0x4e, 0x4e, 0x12, 0x14, 0x0a, 0x05, 0x45, 0x6d, - 0x61, 0x69, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x45, 0x6d, 0x61, 0x69, 0x6c, - 0x12, 0x14, 0x0a, 0x05, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x05, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x22, 0x90, 0x01, 0x0a, 0x04, 0x49, 0x74, 0x65, 0x6d, 0x12, - 0x20, 0x0a, 0x0b, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, - 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x4d, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x07, 0x4d, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x51, - 0x75, 0x61, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x51, - 0x75, 0x61, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x4d, 0x6f, 0x6e, 0x65, 0x79, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x12, 0x1a, 0x0a, - 0x08, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x08, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x32, 0xb8, 0x05, 0x0a, 0x10, 0x54, 0x72, - 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x5f, - 0x0a, 0x16, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, - 0x42, 0x61, 0x6e, 0x6b, 0x43, 0x61, 0x72, 0x64, 0x12, 0x20, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, - 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, - 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x74, 0x72, 0x65, - 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, - 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, + 0x12, 0x2e, 0x0a, 0x13, 0x66, 0x72, 0x6f, 0x6d, 0x5f, 0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x5f, + 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x09, 0x52, 0x11, 0x66, + 0x72, 0x6f, 0x6d, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, + 0x12, 0x2a, 0x0a, 0x11, 0x74, 0x6f, 0x5f, 0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x5f, 0x61, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x74, 0x6f, 0x57, + 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x23, 0x0a, 0x0d, + 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x5f, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x0d, 0x20, + 0x01, 0x28, 0x01, 0x52, 0x0c, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x41, 0x6d, 0x6f, 0x75, 0x6e, + 0x74, 0x22, 0x64, 0x0a, 0x08, 0x43, 0x75, 0x73, 0x74, 0x6f, 0x6d, 0x65, 0x72, 0x12, 0x1a, 0x0a, + 0x08, 0x46, 0x75, 0x6c, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x46, 0x75, 0x6c, 0x6c, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x49, 0x4e, 0x4e, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x49, 0x4e, 0x4e, 0x12, 0x14, 0x0a, 0x05, 0x45, + 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x45, 0x6d, 0x61, 0x69, + 0x6c, 0x12, 0x14, 0x0a, 0x05, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x05, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x22, 0x90, 0x01, 0x0a, 0x04, 0x49, 0x74, 0x65, 0x6d, + 0x12, 0x20, 0x0a, 0x0b, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x4d, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x4d, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x12, 0x1a, 0x0a, 0x08, + 0x51, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, + 0x51, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x4d, 0x6f, 0x6e, 0x65, + 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x12, 0x1a, + 0x0a, 0x08, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x08, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x32, 0x98, 0x06, 0x0a, 0x10, 0x54, + 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x5f, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, - 0x6b, 0x59, 0x6f, 0x6f, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x12, 0x20, 0x2e, 0x74, 0x72, 0x65, 0x61, + 0x6b, 0x42, 0x61, 0x6e, 0x6b, 0x43, 0x61, 0x72, 0x64, 0x12, 0x20, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, - 0x12, 0x5e, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, - 0x6e, 0x6b, 0x54, 0x69, 0x6e, 0x6b, 0x6f, 0x66, 0x66, 0x12, 0x20, 0x2e, 0x74, 0x72, 0x65, 0x61, - 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, - 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x74, 0x72, - 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, - 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, - 0x12, 0x62, 0x0a, 0x19, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, - 0x6e, 0x6b, 0x53, 0x62, 0x65, 0x72, 0x62, 0x61, 0x6e, 0x6b, 0x42, 0x32, 0x42, 0x12, 0x20, 0x2e, - 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, - 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x21, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, - 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x00, 0x12, 0x5a, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, - 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x53, 0x42, 0x50, 0x12, 0x20, 0x2e, 0x74, 0x72, 0x65, 0x61, - 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, - 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x74, 0x72, - 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, - 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, - 0x12, 0x5e, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, - 0x6e, 0x6b, 0x53, 0x62, 0x65, 0x72, 0x50, 0x61, 0x79, 0x12, 0x20, 0x2e, 0x74, 0x72, 0x65, 0x61, - 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, - 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x74, 0x72, - 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, - 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, - 0x12, 0x62, 0x0a, 0x19, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x61, 0x76, 0x65, 0x64, 0x50, - 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x12, 0x2b, 0x2e, - 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, - 0x53, 0x61, 0x76, 0x65, 0x64, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4d, 0x65, 0x74, 0x68, - 0x6f, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 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, 0x0d, 0x5a, 0x0b, 0x2e, 0x2f, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, - 0x72, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x12, 0x5f, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, + 0x6e, 0x6b, 0x59, 0x6f, 0x6f, 0x4d, 0x6f, 0x6e, 0x65, 0x79, 0x12, 0x20, 0x2e, 0x74, 0x72, 0x65, + 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, + 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x74, + 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, + 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x12, 0x5e, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, + 0x69, 0x6e, 0x6b, 0x54, 0x69, 0x6e, 0x6b, 0x6f, 0x66, 0x66, 0x12, 0x20, 0x2e, 0x74, 0x72, 0x65, + 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, + 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x74, + 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, + 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x12, 0x62, 0x0a, 0x19, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, + 0x69, 0x6e, 0x6b, 0x53, 0x62, 0x65, 0x72, 0x62, 0x61, 0x6e, 0x6b, 0x42, 0x32, 0x42, 0x12, 0x20, + 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, + 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x21, 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, + 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5a, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, + 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x53, 0x42, 0x50, 0x12, 0x20, 0x2e, 0x74, 0x72, 0x65, + 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, + 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x74, + 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, + 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x12, 0x5e, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, + 0x69, 0x6e, 0x6b, 0x53, 0x62, 0x65, 0x72, 0x50, 0x61, 0x79, 0x12, 0x20, 0x2e, 0x74, 0x72, 0x65, + 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, + 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x74, + 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, + 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x12, 0x5e, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4c, + 0x69, 0x6e, 0x6b, 0x41, 0x6c, 0x63, 0x68, 0x65, 0x6d, 0x79, 0x12, 0x20, 0x2e, 0x74, 0x72, 0x65, + 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, + 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x74, + 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x61, 0x79, 0x6d, + 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x12, 0x62, 0x0a, 0x19, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x53, 0x61, 0x76, 0x65, 0x64, + 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x12, 0x2b, + 0x2e, 0x74, 0x72, 0x65, 0x61, 0x73, 0x75, 0x72, 0x65, 0x72, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, + 0x65, 0x53, 0x61, 0x76, 0x65, 0x64, 0x50, 0x61, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x4d, 0x65, 0x74, + 0x68, 0x6f, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 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, 0x0d, 0x5a, 0x0b, 0x2e, 0x2f, 0x74, 0x72, 0x65, 0x61, 0x73, + 0x75, 0x72, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -700,16 +739,18 @@ var file_service_proto_depIdxs = []int32{ 1, // 9: treasurer.TreasurerService.GetPaymentLinkSberbankB2B:input_type -> treasurer.GetPaymentLinkRequest 1, // 10: treasurer.TreasurerService.GetPaymentLinkSBP:input_type -> treasurer.GetPaymentLinkRequest 1, // 11: treasurer.TreasurerService.GetPaymentLinkSberPay:input_type -> treasurer.GetPaymentLinkRequest - 4, // 12: treasurer.TreasurerService.DeleteSavedPaymentMethods:input_type -> treasurer.DeleteSavedPaymentMethodsRequest - 3, // 13: treasurer.TreasurerService.GetPaymentLinkBankCard:output_type -> treasurer.GetPaymentLinkResponse - 3, // 14: treasurer.TreasurerService.GetPaymentLinkYooMoney:output_type -> treasurer.GetPaymentLinkResponse - 3, // 15: treasurer.TreasurerService.GetPaymentLinkTinkoff:output_type -> treasurer.GetPaymentLinkResponse - 3, // 16: treasurer.TreasurerService.GetPaymentLinkSberbankB2B:output_type -> treasurer.GetPaymentLinkResponse - 3, // 17: treasurer.TreasurerService.GetPaymentLinkSBP:output_type -> treasurer.GetPaymentLinkResponse - 3, // 18: treasurer.TreasurerService.GetPaymentLinkSberPay:output_type -> treasurer.GetPaymentLinkResponse - 8, // 19: treasurer.TreasurerService.DeleteSavedPaymentMethods:output_type -> google.protobuf.Empty - 13, // [13:20] is the sub-list for method output_type - 6, // [6:13] is the sub-list for method input_type + 1, // 12: treasurer.TreasurerService.GetPaymentLinkAlchemy:input_type -> treasurer.GetPaymentLinkRequest + 4, // 13: treasurer.TreasurerService.DeleteSavedPaymentMethods:input_type -> treasurer.DeleteSavedPaymentMethodsRequest + 3, // 14: treasurer.TreasurerService.GetPaymentLinkBankCard:output_type -> treasurer.GetPaymentLinkResponse + 3, // 15: treasurer.TreasurerService.GetPaymentLinkYooMoney:output_type -> treasurer.GetPaymentLinkResponse + 3, // 16: treasurer.TreasurerService.GetPaymentLinkTinkoff:output_type -> treasurer.GetPaymentLinkResponse + 3, // 17: treasurer.TreasurerService.GetPaymentLinkSberbankB2B:output_type -> treasurer.GetPaymentLinkResponse + 3, // 18: treasurer.TreasurerService.GetPaymentLinkSBP:output_type -> treasurer.GetPaymentLinkResponse + 3, // 19: treasurer.TreasurerService.GetPaymentLinkSberPay:output_type -> treasurer.GetPaymentLinkResponse + 3, // 20: treasurer.TreasurerService.GetPaymentLinkAlchemy:output_type -> treasurer.GetPaymentLinkResponse + 8, // 21: treasurer.TreasurerService.DeleteSavedPaymentMethods:output_type -> google.protobuf.Empty + 14, // [14:22] is the sub-list for method output_type + 6, // [6:14] is the sub-list for method input_type 6, // [6:6] is the sub-list for extension type_name 6, // [6:6] is the sub-list for extension extendee 0, // [0:6] is the sub-list for field type_name diff --git a/internal/proto/treasurer/service_grpc.pb.go b/internal/proto/treasurer/service_grpc.pb.go index 23179f8..0d68e3b 100644 --- a/internal/proto/treasurer/service_grpc.pb.go +++ b/internal/proto/treasurer/service_grpc.pb.go @@ -25,6 +25,7 @@ type TreasurerServiceClient interface { GetPaymentLinkSberbankB2B(ctx context.Context, in *GetPaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) GetPaymentLinkSBP(ctx context.Context, in *GetPaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) GetPaymentLinkSberPay(ctx context.Context, in *GetPaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) + GetPaymentLinkAlchemy(ctx context.Context, in *GetPaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) DeleteSavedPaymentMethods(ctx context.Context, in *DeleteSavedPaymentMethodsRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) } @@ -90,6 +91,15 @@ func (c *treasurerServiceClient) GetPaymentLinkSberPay(ctx context.Context, in * return out, nil } +func (c *treasurerServiceClient) GetPaymentLinkAlchemy(ctx context.Context, in *GetPaymentLinkRequest, opts ...grpc.CallOption) (*GetPaymentLinkResponse, error) { + out := new(GetPaymentLinkResponse) + err := c.cc.Invoke(ctx, "/treasurer.TreasurerService/GetPaymentLinkAlchemy", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *treasurerServiceClient) DeleteSavedPaymentMethods(ctx context.Context, in *DeleteSavedPaymentMethodsRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) { out := new(emptypb.Empty) err := c.cc.Invoke(ctx, "/treasurer.TreasurerService/DeleteSavedPaymentMethods", in, out, opts...) @@ -109,6 +119,7 @@ type TreasurerServiceServer interface { GetPaymentLinkSberbankB2B(context.Context, *GetPaymentLinkRequest) (*GetPaymentLinkResponse, error) GetPaymentLinkSBP(context.Context, *GetPaymentLinkRequest) (*GetPaymentLinkResponse, error) GetPaymentLinkSberPay(context.Context, *GetPaymentLinkRequest) (*GetPaymentLinkResponse, error) + GetPaymentLinkAlchemy(context.Context, *GetPaymentLinkRequest) (*GetPaymentLinkResponse, error) DeleteSavedPaymentMethods(context.Context, *DeleteSavedPaymentMethodsRequest) (*emptypb.Empty, error) mustEmbedUnimplementedTreasurerServiceServer() } @@ -135,6 +146,9 @@ func (UnimplementedTreasurerServiceServer) GetPaymentLinkSBP(context.Context, *G func (UnimplementedTreasurerServiceServer) GetPaymentLinkSberPay(context.Context, *GetPaymentLinkRequest) (*GetPaymentLinkResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetPaymentLinkSberPay not implemented") } +func (UnimplementedTreasurerServiceServer) GetPaymentLinkAlchemy(context.Context, *GetPaymentLinkRequest) (*GetPaymentLinkResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetPaymentLinkAlchemy not implemented") +} func (UnimplementedTreasurerServiceServer) DeleteSavedPaymentMethods(context.Context, *DeleteSavedPaymentMethodsRequest) (*emptypb.Empty, error) { return nil, status.Errorf(codes.Unimplemented, "method DeleteSavedPaymentMethods not implemented") } @@ -259,6 +273,24 @@ func _TreasurerService_GetPaymentLinkSberPay_Handler(srv interface{}, ctx contex return interceptor(ctx, in, info, handler) } +func _TreasurerService_GetPaymentLinkAlchemy_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetPaymentLinkRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TreasurerServiceServer).GetPaymentLinkAlchemy(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/treasurer.TreasurerService/GetPaymentLinkAlchemy", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TreasurerServiceServer).GetPaymentLinkAlchemy(ctx, req.(*GetPaymentLinkRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _TreasurerService_DeleteSavedPaymentMethods_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(DeleteSavedPaymentMethodsRequest) if err := dec(in); err != nil { @@ -308,6 +340,10 @@ var TreasurerService_ServiceDesc = grpc.ServiceDesc{ MethodName: "GetPaymentLinkSberPay", Handler: _TreasurerService_GetPaymentLinkSberPay_Handler, }, + { + MethodName: "GetPaymentLinkAlchemy", + Handler: _TreasurerService_GetPaymentLinkAlchemy_Handler, + }, { MethodName: "DeleteSavedPaymentMethods", Handler: _TreasurerService_DeleteSavedPaymentMethods_Handler, From e3df922f0a7baddf78479060370ec34e34fc5bdd Mon Sep 17 00:00:00 2001 From: Pasha Date: Tue, 22 Jul 2025 15:11:45 +0300 Subject: [PATCH 18/20] fix after tests --- internal/payment_provider/alchemy/provider.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/payment_provider/alchemy/provider.go b/internal/payment_provider/alchemy/provider.go index 919f946..03ed3d2 100644 --- a/internal/payment_provider/alchemy/provider.go +++ b/internal/payment_provider/alchemy/provider.go @@ -35,8 +35,9 @@ type Deps struct { func New(deps Deps) *Provider { return &Provider{ - logger: deps.Logger, - config: deps.Config, + logger: deps.Logger, + config: deps.Config, + repository: deps.Repository, } } From a6b0f06f884b16cf0085d36511ac60210caa8bf9 Mon Sep 17 00:00:00 2001 From: Pasha Date: Wed, 23 Jul 2025 16:19:30 +0300 Subject: [PATCH 19/20] 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 { From de662dea2bc1a787e912ccd3acb1b746c10818bd Mon Sep 17 00:00:00 2001 From: Pasha Date: Wed, 23 Jul 2025 16:26:43 +0300 Subject: [PATCH 20/20] added call SendOnCartPurchase --- internal/client/callback.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/client/callback.go b/internal/client/callback.go index 1105327..5918fb1 100644 --- a/internal/client/callback.go +++ b/internal/client/callback.go @@ -65,6 +65,10 @@ func (c *CallbackClient) SendOnSuccess(ctx context.Context, host string, event * return errors.NewWithError(fmt.Errorf("failed to send success callback: %w", err), errors.ErrInternalError) } + if err := c.SendOnCartPurchase(ctx, host, event); err != nil { + return err + } + return nil }