v1

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 30 Imported by: 0

Documentation

Overview

Package v1 is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

View Source
const (
	PaymentService_ProcessPayment_FullMethodName = "/payment.v1.PaymentService/ProcessPayment"
	PaymentService_GetPayment_FullMethodName     = "/payment.v1.PaymentService/GetPayment"
)

Variables

View Source
var (
	PaymentStatus_name = map[int32]string{
		0: "PAYMENT_STATUS_UNSPECIFIED",
		1: "PAYMENT_STATUS_PENDING",
		2: "PAYMENT_STATUS_SUCCESS",
		3: "PAYMENT_STATUS_FAILED",
	}
	PaymentStatus_value = map[string]int32{
		"PAYMENT_STATUS_UNSPECIFIED": 0,
		"PAYMENT_STATUS_PENDING":     1,
		"PAYMENT_STATUS_SUCCESS":     2,
		"PAYMENT_STATUS_FAILED":      3,
	}
)

Enum value maps for PaymentStatus.

View Source
var File_payment_v1_payment_proto protoreflect.FileDescriptor
View Source
var PaymentService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "payment.v1.PaymentService",
	HandlerType: (*PaymentServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "ProcessPayment",
			Handler:    _PaymentService_ProcessPayment_Handler,
		},
		{
			MethodName: "GetPayment",
			Handler:    _PaymentService_GetPayment_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "payment/v1/payment.proto",
}

PaymentService_ServiceDesc is the grpc.ServiceDesc for PaymentService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterPaymentServiceHandler added in v1.2.0

func RegisterPaymentServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterPaymentServiceHandler registers the http handlers for service PaymentService to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterPaymentServiceHandlerClient added in v1.2.0

func RegisterPaymentServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client PaymentServiceClient) error

RegisterPaymentServiceHandlerClient registers the http handlers for service PaymentService to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "PaymentServiceClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "PaymentServiceClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "PaymentServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares.

func RegisterPaymentServiceHandlerFromEndpoint added in v1.2.0

func RegisterPaymentServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterPaymentServiceHandlerFromEndpoint is same as RegisterPaymentServiceHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterPaymentServiceHandlerServer added in v1.2.0

func RegisterPaymentServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server PaymentServiceServer) error

RegisterPaymentServiceHandlerServer registers the http handlers for service PaymentService to "mux". UnaryRPC :call PaymentServiceServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterPaymentServiceHandlerFromEndpoint instead. GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call.

func RegisterPaymentServiceServer

func RegisterPaymentServiceServer(s grpc.ServiceRegistrar, srv PaymentServiceServer)

Types

type GetPaymentRequest

type GetPaymentRequest struct {
	Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	// contains filtered or unexported fields
}

Request to get details of a specific payment transaction.

func (*GetPaymentRequest) Descriptor deprecated

func (*GetPaymentRequest) Descriptor() ([]byte, []int)

Deprecated: Use GetPaymentRequest.ProtoReflect.Descriptor instead.

func (*GetPaymentRequest) GetId

func (x *GetPaymentRequest) GetId() int64

func (*GetPaymentRequest) ProtoMessage

func (*GetPaymentRequest) ProtoMessage()

func (*GetPaymentRequest) ProtoReflect

func (x *GetPaymentRequest) ProtoReflect() protoreflect.Message

func (*GetPaymentRequest) Reset

func (x *GetPaymentRequest) Reset()

func (*GetPaymentRequest) String

func (x *GetPaymentRequest) String() string

func (*GetPaymentRequest) Validate

func (m *GetPaymentRequest) Validate() error

Validate checks the field values on GetPaymentRequest with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.

func (*GetPaymentRequest) ValidateAll

func (m *GetPaymentRequest) ValidateAll() error

ValidateAll checks the field values on GetPaymentRequest with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in GetPaymentRequestMultiError, or nil if none found.

type GetPaymentRequestMultiError

type GetPaymentRequestMultiError []error

GetPaymentRequestMultiError is an error wrapping multiple validation errors returned by GetPaymentRequest.ValidateAll() if the designated constraints aren't met.

func (GetPaymentRequestMultiError) AllErrors

func (m GetPaymentRequestMultiError) AllErrors() []error

AllErrors returns a list of validation violation errors.

func (GetPaymentRequestMultiError) Error

Error returns a concatenation of all the error messages it wraps.

type GetPaymentRequestValidationError

type GetPaymentRequestValidationError struct {
	// contains filtered or unexported fields
}

GetPaymentRequestValidationError is the validation error returned by GetPaymentRequest.Validate if the designated constraints aren't met.

func (GetPaymentRequestValidationError) Cause

Cause function returns cause value.

func (GetPaymentRequestValidationError) Error

Error satisfies the builtin error interface

func (GetPaymentRequestValidationError) ErrorName

ErrorName returns error name.

func (GetPaymentRequestValidationError) Field

Field function returns field value.

func (GetPaymentRequestValidationError) Key

Key function returns key value.

func (GetPaymentRequestValidationError) Reason

Reason function returns reason value.

type GetPaymentResponse

type GetPaymentResponse struct {
	Payment *Payment `protobuf:"bytes,1,opt,name=payment,proto3" json:"payment,omitempty"`
	// contains filtered or unexported fields
}

Response returning the requested Payment record.

func (*GetPaymentResponse) Descriptor deprecated

func (*GetPaymentResponse) Descriptor() ([]byte, []int)

Deprecated: Use GetPaymentResponse.ProtoReflect.Descriptor instead.

func (*GetPaymentResponse) GetPayment

func (x *GetPaymentResponse) GetPayment() *Payment

func (*GetPaymentResponse) ProtoMessage

func (*GetPaymentResponse) ProtoMessage()

func (*GetPaymentResponse) ProtoReflect

func (x *GetPaymentResponse) ProtoReflect() protoreflect.Message

func (*GetPaymentResponse) Reset

func (x *GetPaymentResponse) Reset()

func (*GetPaymentResponse) String

func (x *GetPaymentResponse) String() string

func (*GetPaymentResponse) Validate

func (m *GetPaymentResponse) Validate() error

Validate checks the field values on GetPaymentResponse with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.

func (*GetPaymentResponse) ValidateAll

func (m *GetPaymentResponse) ValidateAll() error

ValidateAll checks the field values on GetPaymentResponse with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in GetPaymentResponseMultiError, or nil if none found.

type GetPaymentResponseMultiError

type GetPaymentResponseMultiError []error

GetPaymentResponseMultiError is an error wrapping multiple validation errors returned by GetPaymentResponse.ValidateAll() if the designated constraints aren't met.

func (GetPaymentResponseMultiError) AllErrors

func (m GetPaymentResponseMultiError) AllErrors() []error

AllErrors returns a list of validation violation errors.

func (GetPaymentResponseMultiError) Error

Error returns a concatenation of all the error messages it wraps.

type GetPaymentResponseValidationError

type GetPaymentResponseValidationError struct {
	// contains filtered or unexported fields
}

GetPaymentResponseValidationError is the validation error returned by GetPaymentResponse.Validate if the designated constraints aren't met.

func (GetPaymentResponseValidationError) Cause

Cause function returns cause value.

func (GetPaymentResponseValidationError) Error

Error satisfies the builtin error interface

func (GetPaymentResponseValidationError) ErrorName

ErrorName returns error name.

func (GetPaymentResponseValidationError) Field

Field function returns field value.

func (GetPaymentResponseValidationError) Key

Key function returns key value.

func (GetPaymentResponseValidationError) Reason

Reason function returns reason value.

type Payment

type Payment struct {
	Id            int64         `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	OrderId       int64         `protobuf:"varint,2,opt,name=order_id,json=orderId,proto3" json:"order_id,omitempty"`
	UserId        int64         `protobuf:"varint,3,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
	Amount        float64       `protobuf:"fixed64,4,opt,name=amount,proto3" json:"amount,omitempty"`
	Currency      string        `protobuf:"bytes,5,opt,name=currency,proto3" json:"currency,omitempty"` // e.g. USD, EUR
	Status        PaymentStatus `protobuf:"varint,6,opt,name=status,proto3,enum=payment.v1.PaymentStatus" json:"status,omitempty"`
	PaymentMethod string        `protobuf:"bytes,7,opt,name=payment_method,json=paymentMethod,proto3" json:"payment_method,omitempty"` // e.g., "stripe", "credit_card"
	TransactionId string        `protobuf:"bytes,8,opt,name=transaction_id,json=transactionId,proto3" json:"transaction_id,omitempty"` // External gateway ID. Empty if pending/failed.
	CreatedAt     string        `protobuf:"bytes,9,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
	UpdatedAt     string        `protobuf:"bytes,10,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"`
	// contains filtered or unexported fields
}

Payment represents an attempt to charge a user for an order.

func (*Payment) Descriptor deprecated

func (*Payment) Descriptor() ([]byte, []int)

Deprecated: Use Payment.ProtoReflect.Descriptor instead.

func (*Payment) GetAmount

func (x *Payment) GetAmount() float64

func (*Payment) GetCreatedAt

func (x *Payment) GetCreatedAt() string

func (*Payment) GetCurrency

func (x *Payment) GetCurrency() string

func (*Payment) GetId

func (x *Payment) GetId() int64

func (*Payment) GetOrderId

func (x *Payment) GetOrderId() int64

func (*Payment) GetPaymentMethod

func (x *Payment) GetPaymentMethod() string

func (*Payment) GetStatus

func (x *Payment) GetStatus() PaymentStatus

func (*Payment) GetTransactionId

func (x *Payment) GetTransactionId() string

func (*Payment) GetUpdatedAt

func (x *Payment) GetUpdatedAt() string

func (*Payment) GetUserId

func (x *Payment) GetUserId() int64

func (*Payment) ProtoMessage

func (*Payment) ProtoMessage()

func (*Payment) ProtoReflect

func (x *Payment) ProtoReflect() protoreflect.Message

func (*Payment) Reset

func (x *Payment) Reset()

func (*Payment) String

func (x *Payment) String() string

func (*Payment) Validate

func (m *Payment) Validate() error

Validate checks the field values on Payment with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.

func (*Payment) ValidateAll

func (m *Payment) ValidateAll() error

ValidateAll checks the field values on Payment with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in PaymentMultiError, or nil if none found.

type PaymentMultiError

type PaymentMultiError []error

PaymentMultiError is an error wrapping multiple validation errors returned by Payment.ValidateAll() if the designated constraints aren't met.

func (PaymentMultiError) AllErrors

func (m PaymentMultiError) AllErrors() []error

AllErrors returns a list of validation violation errors.

func (PaymentMultiError) Error

func (m PaymentMultiError) Error() string

Error returns a concatenation of all the error messages it wraps.

type PaymentServiceClient

type PaymentServiceClient interface {
	ProcessPayment(ctx context.Context, in *ProcessPaymentRequest, opts ...grpc.CallOption) (*ProcessPaymentResponse, error)
	GetPayment(ctx context.Context, in *GetPaymentRequest, opts ...grpc.CallOption) (*GetPaymentResponse, error)
}

PaymentServiceClient is the client API for PaymentService 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.

PaymentService provides operations to process and retrieve financial transactions.

type PaymentServiceServer

type PaymentServiceServer interface {
	ProcessPayment(context.Context, *ProcessPaymentRequest) (*ProcessPaymentResponse, error)
	GetPayment(context.Context, *GetPaymentRequest) (*GetPaymentResponse, error)
	// contains filtered or unexported methods
}

PaymentServiceServer is the server API for PaymentService service. All implementations must embed UnimplementedPaymentServiceServer for forward compatibility.

PaymentService provides operations to process and retrieve financial transactions.

type PaymentStatus

type PaymentStatus int32

Status of the payment transaction.

const (
	PaymentStatus_PAYMENT_STATUS_UNSPECIFIED PaymentStatus = 0
	PaymentStatus_PAYMENT_STATUS_PENDING     PaymentStatus = 1
	PaymentStatus_PAYMENT_STATUS_SUCCESS     PaymentStatus = 2
	PaymentStatus_PAYMENT_STATUS_FAILED      PaymentStatus = 3
)

func (PaymentStatus) Descriptor

func (PaymentStatus) Enum

func (x PaymentStatus) Enum() *PaymentStatus

func (PaymentStatus) EnumDescriptor deprecated

func (PaymentStatus) EnumDescriptor() ([]byte, []int)

Deprecated: Use PaymentStatus.Descriptor instead.

func (PaymentStatus) Number

func (PaymentStatus) String

func (x PaymentStatus) String() string

func (PaymentStatus) Type

type PaymentValidationError

type PaymentValidationError struct {
	// contains filtered or unexported fields
}

PaymentValidationError is the validation error returned by Payment.Validate if the designated constraints aren't met.

func (PaymentValidationError) Cause

func (e PaymentValidationError) Cause() error

Cause function returns cause value.

func (PaymentValidationError) Error

func (e PaymentValidationError) Error() string

Error satisfies the builtin error interface

func (PaymentValidationError) ErrorName

func (e PaymentValidationError) ErrorName() string

ErrorName returns error name.

func (PaymentValidationError) Field

func (e PaymentValidationError) Field() string

Field function returns field value.

func (PaymentValidationError) Key

func (e PaymentValidationError) Key() bool

Key function returns key value.

func (PaymentValidationError) Reason

func (e PaymentValidationError) Reason() string

Reason function returns reason value.

type ProcessPaymentRequest

type ProcessPaymentRequest struct {
	OrderId       int64   `protobuf:"varint,1,opt,name=order_id,json=orderId,proto3" json:"order_id,omitempty"`
	UserId        int64   `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
	Amount        float64 `protobuf:"fixed64,3,opt,name=amount,proto3" json:"amount,omitempty"`
	Currency      string  `protobuf:"bytes,4,opt,name=currency,proto3" json:"currency,omitempty"`
	PaymentMethod string  `protobuf:"bytes,5,opt,name=payment_method,json=paymentMethod,proto3" json:"payment_method,omitempty"`
	// contains filtered or unexported fields
}

Request to charge a payment method for an order.

func (*ProcessPaymentRequest) Descriptor deprecated

func (*ProcessPaymentRequest) Descriptor() ([]byte, []int)

Deprecated: Use ProcessPaymentRequest.ProtoReflect.Descriptor instead.

func (*ProcessPaymentRequest) GetAmount

func (x *ProcessPaymentRequest) GetAmount() float64

func (*ProcessPaymentRequest) GetCurrency

func (x *ProcessPaymentRequest) GetCurrency() string

func (*ProcessPaymentRequest) GetOrderId

func (x *ProcessPaymentRequest) GetOrderId() int64

func (*ProcessPaymentRequest) GetPaymentMethod

func (x *ProcessPaymentRequest) GetPaymentMethod() string

func (*ProcessPaymentRequest) GetUserId

func (x *ProcessPaymentRequest) GetUserId() int64

func (*ProcessPaymentRequest) ProtoMessage

func (*ProcessPaymentRequest) ProtoMessage()

func (*ProcessPaymentRequest) ProtoReflect

func (x *ProcessPaymentRequest) ProtoReflect() protoreflect.Message

func (*ProcessPaymentRequest) Reset

func (x *ProcessPaymentRequest) Reset()

func (*ProcessPaymentRequest) String

func (x *ProcessPaymentRequest) String() string

func (*ProcessPaymentRequest) Validate

func (m *ProcessPaymentRequest) Validate() error

Validate checks the field values on ProcessPaymentRequest with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.

func (*ProcessPaymentRequest) ValidateAll

func (m *ProcessPaymentRequest) ValidateAll() error

ValidateAll checks the field values on ProcessPaymentRequest with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in ProcessPaymentRequestMultiError, or nil if none found.

type ProcessPaymentRequestMultiError

type ProcessPaymentRequestMultiError []error

ProcessPaymentRequestMultiError is an error wrapping multiple validation errors returned by ProcessPaymentRequest.ValidateAll() if the designated constraints aren't met.

func (ProcessPaymentRequestMultiError) AllErrors

func (m ProcessPaymentRequestMultiError) AllErrors() []error

AllErrors returns a list of validation violation errors.

func (ProcessPaymentRequestMultiError) Error

Error returns a concatenation of all the error messages it wraps.

type ProcessPaymentRequestValidationError

type ProcessPaymentRequestValidationError struct {
	// contains filtered or unexported fields
}

ProcessPaymentRequestValidationError is the validation error returned by ProcessPaymentRequest.Validate if the designated constraints aren't met.

func (ProcessPaymentRequestValidationError) Cause

Cause function returns cause value.

func (ProcessPaymentRequestValidationError) Error

Error satisfies the builtin error interface

func (ProcessPaymentRequestValidationError) ErrorName

ErrorName returns error name.

func (ProcessPaymentRequestValidationError) Field

Field function returns field value.

func (ProcessPaymentRequestValidationError) Key

Key function returns key value.

func (ProcessPaymentRequestValidationError) Reason

Reason function returns reason value.

type ProcessPaymentResponse

type ProcessPaymentResponse struct {
	Payment *Payment `protobuf:"bytes,1,opt,name=payment,proto3" json:"payment,omitempty"`
	// contains filtered or unexported fields
}

Response mapping the newly created/processed Payment record.

func (*ProcessPaymentResponse) Descriptor deprecated

func (*ProcessPaymentResponse) Descriptor() ([]byte, []int)

Deprecated: Use ProcessPaymentResponse.ProtoReflect.Descriptor instead.

func (*ProcessPaymentResponse) GetPayment

func (x *ProcessPaymentResponse) GetPayment() *Payment

func (*ProcessPaymentResponse) ProtoMessage

func (*ProcessPaymentResponse) ProtoMessage()

func (*ProcessPaymentResponse) ProtoReflect

func (x *ProcessPaymentResponse) ProtoReflect() protoreflect.Message

func (*ProcessPaymentResponse) Reset

func (x *ProcessPaymentResponse) Reset()

func (*ProcessPaymentResponse) String

func (x *ProcessPaymentResponse) String() string

func (*ProcessPaymentResponse) Validate

func (m *ProcessPaymentResponse) Validate() error

Validate checks the field values on ProcessPaymentResponse with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.

func (*ProcessPaymentResponse) ValidateAll

func (m *ProcessPaymentResponse) ValidateAll() error

ValidateAll checks the field values on ProcessPaymentResponse with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in ProcessPaymentResponseMultiError, or nil if none found.

type ProcessPaymentResponseMultiError

type ProcessPaymentResponseMultiError []error

ProcessPaymentResponseMultiError is an error wrapping multiple validation errors returned by ProcessPaymentResponse.ValidateAll() if the designated constraints aren't met.

func (ProcessPaymentResponseMultiError) AllErrors

func (m ProcessPaymentResponseMultiError) AllErrors() []error

AllErrors returns a list of validation violation errors.

func (ProcessPaymentResponseMultiError) Error

Error returns a concatenation of all the error messages it wraps.

type ProcessPaymentResponseValidationError

type ProcessPaymentResponseValidationError struct {
	// contains filtered or unexported fields
}

ProcessPaymentResponseValidationError is the validation error returned by ProcessPaymentResponse.Validate if the designated constraints aren't met.

func (ProcessPaymentResponseValidationError) Cause

Cause function returns cause value.

func (ProcessPaymentResponseValidationError) Error

Error satisfies the builtin error interface

func (ProcessPaymentResponseValidationError) ErrorName

ErrorName returns error name.

func (ProcessPaymentResponseValidationError) Field

Field function returns field value.

func (ProcessPaymentResponseValidationError) Key

Key function returns key value.

func (ProcessPaymentResponseValidationError) Reason

Reason function returns reason value.

type UnimplementedPaymentServiceServer

type UnimplementedPaymentServiceServer struct{}

UnimplementedPaymentServiceServer must be embedded to have forward compatible implementations.

NOTE: this should be embedded by value instead of pointer to avoid a nil pointer dereference when methods are called.

func (UnimplementedPaymentServiceServer) GetPayment

func (UnimplementedPaymentServiceServer) ProcessPayment

type UnsafePaymentServiceServer

type UnsafePaymentServiceServer interface {
	// contains filtered or unexported methods
}

UnsafePaymentServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to PaymentServiceServer will result in compilation errors.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL