fix for proto migration

This commit is contained in:
Stephan D
2026-02-11 18:15:04 +01:00
parent fab07fdc8e
commit 7b53ca6cef
62 changed files with 517 additions and 554 deletions

View File

@@ -10,7 +10,8 @@ import (
"github.com/tech/sendico/pkg/model"
"github.com/tech/sendico/pkg/mutil/mzap"
paginationv1 "github.com/tech/sendico/pkg/proto/common/pagination/v1"
orchestratorv1 "github.com/tech/sendico/pkg/proto/payments/orchestrator/v1"
orchestratorv1 "github.com/tech/sendico/pkg/proto/payments/orchestration/v1"
sharedv1 "github.com/tech/sendico/pkg/proto/payments/shared/v1"
"github.com/tech/sendico/server/interface/api/sresponse"
mutil "github.com/tech/sendico/server/internal/mutil/param"
"go.mongodb.org/mongo-driver/v2/bson"
@@ -105,7 +106,7 @@ func listPaymentsPage(r *http.Request) (*paginationv1.CursorPageRequest, error)
return page, nil
}
func parsePaymentStateFilters(r *http.Request) ([]orchestratorv1.PaymentState, error) {
func parsePaymentStateFilters(r *http.Request) ([]sharedv1.PaymentState, error) {
query := r.URL.Query()
values := append([]string{}, query["state"]...)
values = append(values, query["states"]...)
@@ -114,7 +115,7 @@ func parsePaymentStateFilters(r *http.Request) ([]orchestratorv1.PaymentState, e
return nil, nil
}
states := make([]orchestratorv1.PaymentState, 0, len(values))
states := make([]sharedv1.PaymentState, 0, len(values))
for _, raw := range values {
for _, part := range strings.Split(raw, ",") {
trimmed := strings.TrimSpace(part)
@@ -135,7 +136,7 @@ func parsePaymentStateFilters(r *http.Request) ([]orchestratorv1.PaymentState, e
return states, nil
}
func paymentStateFromString(value string) (orchestratorv1.PaymentState, bool) {
func paymentStateFromString(value string) (sharedv1.PaymentState, bool) {
upper := strings.ToUpper(strings.TrimSpace(value))
if upper == "" {
return 0, false
@@ -143,9 +144,9 @@ func paymentStateFromString(value string) (orchestratorv1.PaymentState, bool) {
if !strings.HasPrefix(upper, "PAYMENT_STATE_") {
upper = "PAYMENT_STATE_" + upper
}
enumValue, ok := orchestratorv1.PaymentState_value[upper]
enumValue, ok := sharedv1.PaymentState_value[upper]
if !ok {
return 0, false
}
return orchestratorv1.PaymentState(enumValue), true
return sharedv1.PaymentState(enumValue), true
}

View File

@@ -9,11 +9,11 @@ import (
fxv1 "github.com/tech/sendico/pkg/proto/common/fx/v1"
moneyv1 "github.com/tech/sendico/pkg/proto/common/money/v1"
chainv1 "github.com/tech/sendico/pkg/proto/gateway/chain/v1"
orchestratorv1 "github.com/tech/sendico/pkg/proto/payments/orchestrator/v1"
sharedv1 "github.com/tech/sendico/pkg/proto/payments/shared/v1"
"github.com/tech/sendico/server/interface/api/srequest"
)
func mapPaymentIntent(intent *srequest.PaymentIntent) (*orchestratorv1.PaymentIntent, error) {
func mapPaymentIntent(intent *srequest.PaymentIntent) (*sharedv1.PaymentIntent, error) {
if intent == nil {
return nil, merrors.InvalidArgument("intent is required")
}
@@ -46,7 +46,7 @@ func mapPaymentIntent(intent *srequest.PaymentIntent) (*orchestratorv1.PaymentIn
return nil, err
}
return &orchestratorv1.PaymentIntent{
return &sharedv1.PaymentIntent{
Ref: uuid.New().String(),
Kind: kind,
Source: source,
@@ -108,19 +108,19 @@ func resolveSettlementCurrency(intent *srequest.PaymentIntent) string {
return ""
}
func mapPaymentEndpoint(endpoint *srequest.Endpoint, field string) (*orchestratorv1.PaymentEndpoint, error) {
func mapPaymentEndpoint(endpoint *srequest.Endpoint, field string) (*sharedv1.PaymentEndpoint, error) {
if endpoint == nil {
return nil, nil
}
var result orchestratorv1.PaymentEndpoint
var result sharedv1.PaymentEndpoint
switch endpoint.Type {
case srequest.EndpointTypeLedger:
payload, err := endpoint.DecodeLedger()
if err != nil {
return nil, merrors.InvalidArgument(field + " endpoint: " + err.Error())
}
result.Endpoint = &orchestratorv1.PaymentEndpoint_Ledger{
result.Endpoint = &sharedv1.PaymentEndpoint_Ledger{
Ledger: mapLedgerEndpoint(&payload),
}
case srequest.EndpointTypeManagedWallet:
@@ -132,7 +132,7 @@ func mapPaymentEndpoint(endpoint *srequest.Endpoint, field string) (*orchestrato
if err != nil {
return nil, merrors.InvalidArgument(field + " endpoint: " + err.Error())
}
result.Endpoint = &orchestratorv1.PaymentEndpoint_ManagedWallet{
result.Endpoint = &sharedv1.PaymentEndpoint_ManagedWallet{
ManagedWallet: mw,
}
case srequest.EndpointTypeExternalChain:
@@ -144,7 +144,7 @@ func mapPaymentEndpoint(endpoint *srequest.Endpoint, field string) (*orchestrato
if err != nil {
return nil, merrors.InvalidArgument(field + " endpoint: " + err.Error())
}
result.Endpoint = &orchestratorv1.PaymentEndpoint_ExternalChain{
result.Endpoint = &sharedv1.PaymentEndpoint_ExternalChain{
ExternalChain: ext,
}
case srequest.EndpointTypeCard:
@@ -152,7 +152,7 @@ func mapPaymentEndpoint(endpoint *srequest.Endpoint, field string) (*orchestrato
if err != nil {
return nil, merrors.InvalidArgument(field + " endpoint: " + err.Error())
}
result.Endpoint = &orchestratorv1.PaymentEndpoint_Card{
result.Endpoint = &sharedv1.PaymentEndpoint_Card{
Card: mapCardEndpoint(&payload),
}
case srequest.EndpointTypeCardToken:
@@ -160,7 +160,7 @@ func mapPaymentEndpoint(endpoint *srequest.Endpoint, field string) (*orchestrato
if err != nil {
return nil, merrors.InvalidArgument(field + " endpoint: " + err.Error())
}
result.Endpoint = &orchestratorv1.PaymentEndpoint_Card{
result.Endpoint = &sharedv1.PaymentEndpoint_Card{
Card: mapCardTokenEndpoint(&payload),
}
case "":
@@ -173,17 +173,17 @@ func mapPaymentEndpoint(endpoint *srequest.Endpoint, field string) (*orchestrato
return &result, nil
}
func mapLedgerEndpoint(endpoint *srequest.LedgerEndpoint) *orchestratorv1.LedgerEndpoint {
func mapLedgerEndpoint(endpoint *srequest.LedgerEndpoint) *sharedv1.LedgerEndpoint {
if endpoint == nil {
return nil
}
return &orchestratorv1.LedgerEndpoint{
return &sharedv1.LedgerEndpoint{
LedgerAccountRef: endpoint.LedgerAccountRef,
ContraLedgerAccountRef: endpoint.ContraLedgerAccountRef,
}
}
func mapManagedWalletEndpoint(endpoint *srequest.ManagedWalletEndpoint) (*orchestratorv1.ManagedWalletEndpoint, error) {
func mapManagedWalletEndpoint(endpoint *srequest.ManagedWalletEndpoint) (*sharedv1.ManagedWalletEndpoint, error) {
if endpoint == nil {
return nil, nil
}
@@ -191,13 +191,13 @@ func mapManagedWalletEndpoint(endpoint *srequest.ManagedWalletEndpoint) (*orches
if err != nil {
return nil, err
}
return &orchestratorv1.ManagedWalletEndpoint{
return &sharedv1.ManagedWalletEndpoint{
ManagedWalletRef: endpoint.ManagedWalletRef,
Asset: asset,
}, nil
}
func mapExternalChainEndpoint(endpoint *srequest.ExternalChainEndpoint) (*orchestratorv1.ExternalChainEndpoint, error) {
func mapExternalChainEndpoint(endpoint *srequest.ExternalChainEndpoint) (*sharedv1.ExternalChainEndpoint, error) {
if endpoint == nil {
return nil, nil
}
@@ -205,7 +205,7 @@ func mapExternalChainEndpoint(endpoint *srequest.ExternalChainEndpoint) (*orches
if err != nil {
return nil, err
}
return &orchestratorv1.ExternalChainEndpoint{
return &sharedv1.ExternalChainEndpoint{
Asset: asset,
Address: endpoint.Address,
Memo: endpoint.Memo,
@@ -237,7 +237,7 @@ func mapMoney(m *paymenttypes.Money) *moneyv1.Money {
}
}
func mapFXIntent(fx *srequest.FXIntent) (*orchestratorv1.FXIntent, error) {
func mapFXIntent(fx *srequest.FXIntent) (*sharedv1.FXIntent, error) {
if fx == nil {
return nil, nil
}
@@ -245,7 +245,7 @@ func mapFXIntent(fx *srequest.FXIntent) (*orchestratorv1.FXIntent, error) {
if err != nil {
return nil, err
}
return &orchestratorv1.FXIntent{
return &sharedv1.FXIntent{
Pair: mapCurrencyPair(fx.Pair),
Side: side,
Firm: fx.Firm,
@@ -255,11 +255,11 @@ func mapFXIntent(fx *srequest.FXIntent) (*orchestratorv1.FXIntent, error) {
}, nil
}
func mapCustomer(customer *srequest.Customer) *orchestratorv1.Customer {
func mapCustomer(customer *srequest.Customer) *sharedv1.Customer {
if customer == nil {
return nil
}
return &orchestratorv1.Customer{
return &sharedv1.Customer{
Id: strings.TrimSpace(customer.ID),
FirstName: strings.TrimSpace(customer.FirstName),
MiddleName: strings.TrimSpace(customer.MiddleName),
@@ -283,11 +283,11 @@ func mapCurrencyPair(pair *srequest.CurrencyPair) *fxv1.CurrencyPair {
}
}
func mapCardEndpoint(card *srequest.CardEndpoint) *orchestratorv1.CardEndpoint {
func mapCardEndpoint(card *srequest.CardEndpoint) *sharedv1.CardEndpoint {
if card == nil {
return nil
}
result := &orchestratorv1.CardEndpoint{
result := &sharedv1.CardEndpoint{
CardholderName: strings.TrimSpace(card.FirstName),
CardholderSurname: strings.TrimSpace(card.LastName),
ExpMonth: card.ExpMonth,
@@ -295,46 +295,46 @@ func mapCardEndpoint(card *srequest.CardEndpoint) *orchestratorv1.CardEndpoint {
Country: strings.TrimSpace(card.Country),
}
if pan := strings.TrimSpace(card.Pan); pan != "" {
result.Card = &orchestratorv1.CardEndpoint_Pan{Pan: pan}
result.Card = &sharedv1.CardEndpoint_Pan{Pan: pan}
}
return result
}
func mapCardTokenEndpoint(card *srequest.CardTokenEndpoint) *orchestratorv1.CardEndpoint {
func mapCardTokenEndpoint(card *srequest.CardTokenEndpoint) *sharedv1.CardEndpoint {
if card == nil {
return nil
}
return &orchestratorv1.CardEndpoint{
Card: &orchestratorv1.CardEndpoint_Token{Token: strings.TrimSpace(card.Token)},
return &sharedv1.CardEndpoint{
Card: &sharedv1.CardEndpoint_Token{Token: strings.TrimSpace(card.Token)},
MaskedPan: strings.TrimSpace(card.MaskedPan),
}
}
func mapPaymentKind(kind srequest.PaymentKind) (orchestratorv1.PaymentKind, error) {
func mapPaymentKind(kind srequest.PaymentKind) (sharedv1.PaymentKind, error) {
switch strings.TrimSpace(string(kind)) {
case "", string(srequest.PaymentKindUnspecified):
return orchestratorv1.PaymentKind_PAYMENT_KIND_UNSPECIFIED, nil
return sharedv1.PaymentKind_PAYMENT_KIND_UNSPECIFIED, nil
case string(srequest.PaymentKindPayout):
return orchestratorv1.PaymentKind_PAYMENT_KIND_PAYOUT, nil
return sharedv1.PaymentKind_PAYMENT_KIND_PAYOUT, nil
case string(srequest.PaymentKindInternalTransfer):
return orchestratorv1.PaymentKind_PAYMENT_KIND_INTERNAL_TRANSFER, nil
return sharedv1.PaymentKind_PAYMENT_KIND_INTERNAL_TRANSFER, nil
case string(srequest.PaymentKindFxConversion):
return orchestratorv1.PaymentKind_PAYMENT_KIND_FX_CONVERSION, nil
return sharedv1.PaymentKind_PAYMENT_KIND_FX_CONVERSION, nil
default:
return orchestratorv1.PaymentKind_PAYMENT_KIND_UNSPECIFIED, merrors.InvalidArgument("unsupported payment kind: " + string(kind))
return sharedv1.PaymentKind_PAYMENT_KIND_UNSPECIFIED, merrors.InvalidArgument("unsupported payment kind: " + string(kind))
}
}
func mapSettlementMode(mode srequest.SettlementMode) (orchestratorv1.SettlementMode, error) {
func mapSettlementMode(mode srequest.SettlementMode) (sharedv1.SettlementMode, error) {
switch strings.TrimSpace(string(mode)) {
case "", string(srequest.SettlementModeUnspecified):
return orchestratorv1.SettlementMode_SETTLEMENT_UNSPECIFIED, nil
return sharedv1.SettlementMode_SETTLEMENT_UNSPECIFIED, nil
case string(srequest.SettlementModeFixSource):
return orchestratorv1.SettlementMode_SETTLEMENT_FIX_SOURCE, nil
return sharedv1.SettlementMode_SETTLEMENT_FIX_SOURCE, nil
case string(srequest.SettlementModeFixReceived):
return orchestratorv1.SettlementMode_SETTLEMENT_FIX_RECEIVED, nil
return sharedv1.SettlementMode_SETTLEMENT_FIX_RECEIVED, nil
default:
return orchestratorv1.SettlementMode_SETTLEMENT_UNSPECIFIED, merrors.InvalidArgument("unsupported settlement mode: " + string(mode))
return sharedv1.SettlementMode_SETTLEMENT_UNSPECIFIED, merrors.InvalidArgument("unsupported settlement mode: " + string(mode))
}
}

View File

@@ -9,7 +9,8 @@ import (
"github.com/tech/sendico/pkg/merrors"
"github.com/tech/sendico/pkg/model"
"github.com/tech/sendico/pkg/mutil/mzap"
orchestratorv1 "github.com/tech/sendico/pkg/proto/payments/orchestrator/v1"
orchestratorv1 "github.com/tech/sendico/pkg/proto/payments/orchestration/v1"
sharedv1 "github.com/tech/sendico/pkg/proto/payments/shared/v1"
"github.com/tech/sendico/server/interface/api/srequest"
"github.com/tech/sendico/server/interface/api/sresponse"
mutil "github.com/tech/sendico/server/internal/mutil/param"
@@ -57,7 +58,7 @@ func (a *PaymentAPI) initiatePayment(r *http.Request, account *model.Account, to
}
}
var intent *orchestratorv1.PaymentIntent
var intent *sharedv1.PaymentIntent
if payload.Intent != nil {
applyCustomerIP(payload.Intent, r.RemoteAddr)
intent, err = mapPaymentIntent(payload.Intent)
@@ -67,7 +68,7 @@ func (a *PaymentAPI) initiatePayment(r *http.Request, account *model.Account, to
}
req := &orchestratorv1.InitiatePaymentRequest{
Meta: &orchestratorv1.RequestMeta{
Meta: &sharedv1.RequestMeta{
OrganizationRef: orgRef.Hex(),
},
IdempotencyKey: strings.TrimSpace(payload.IdempotencyKey),

View File

@@ -8,7 +8,8 @@ import (
"github.com/tech/sendico/pkg/api/http/response"
"github.com/tech/sendico/pkg/merrors"
"github.com/tech/sendico/pkg/model"
orchestratorv1 "github.com/tech/sendico/pkg/proto/payments/orchestrator/v1"
orchestratorv1 "github.com/tech/sendico/pkg/proto/payments/orchestration/v1"
sharedv1 "github.com/tech/sendico/pkg/proto/payments/shared/v1"
"github.com/tech/sendico/server/interface/api/srequest"
"github.com/tech/sendico/server/interface/api/sresponse"
mutil "github.com/tech/sendico/server/internal/mutil/param"
@@ -40,7 +41,7 @@ func (a *PaymentAPI) initiatePaymentsByQuote(r *http.Request, account *model.Acc
}
req := &orchestratorv1.InitiatePaymentsRequest{
Meta: &orchestratorv1.RequestMeta{
Meta: &sharedv1.RequestMeta{
OrganizationRef: orgRef.Hex(),
},
IdempotencyKey: strings.TrimSpace(payload.IdempotencyKey),

View File

@@ -8,7 +8,7 @@ import (
"github.com/tech/sendico/pkg/api/http/response"
"github.com/tech/sendico/pkg/merrors"
"github.com/tech/sendico/pkg/model"
orchestratorv1 "github.com/tech/sendico/pkg/proto/payments/orchestrator/v1"
sharedv1 "github.com/tech/sendico/pkg/proto/payments/shared/v1"
"github.com/tech/sendico/server/interface/api/srequest"
"github.com/tech/sendico/server/interface/api/sresponse"
mutil "github.com/tech/sendico/server/internal/mutil/param"
@@ -51,8 +51,8 @@ func (a *PaymentAPI) quotePayment(r *http.Request, account *model.Account, token
return response.BadPayload(a.logger, a.Name(), err)
}
req := &orchestratorv1.QuotePaymentRequest{
Meta: &orchestratorv1.RequestMeta{
req := &quotationv1.QuotePaymentRequest{
Meta: &sharedv1.RequestMeta{
OrganizationRef: orgRef.Hex(),
},
IdempotencyKey: payload.IdempotencyKey,
@@ -96,7 +96,7 @@ func (a *PaymentAPI) quotePayments(r *http.Request, account *model.Account, toke
return response.Auto(a.logger, a.Name(), err)
}
intents := make([]*orchestratorv1.PaymentIntent, 0, len(payload.Intents))
intents := make([]*sharedv1.PaymentIntent, 0, len(payload.Intents))
for i := range payload.Intents {
applyCustomerIP(&payload.Intents[i], r.RemoteAddr)
intent, err := mapPaymentIntent(&payload.Intents[i])
@@ -107,8 +107,8 @@ func (a *PaymentAPI) quotePayments(r *http.Request, account *model.Account, toke
intents = append(intents, intent)
}
req := &orchestratorv1.QuotePaymentsRequest{
Meta: &orchestratorv1.RequestMeta{
req := &quotationv1.QuotePaymentResponse{
Meta: &sharedv1.RequestMeta{
OrganizationRef: orgRef.Hex(),
},
IdempotencyKey: payload.IdempotencyKey,

View File

@@ -17,7 +17,7 @@ import (
msgconsumer "github.com/tech/sendico/pkg/messaging/consumer"
"github.com/tech/sendico/pkg/mlogger"
"github.com/tech/sendico/pkg/mservice"
orchestratorv1 "github.com/tech/sendico/pkg/proto/payments/orchestrator/v1"
orchestratorv1 "github.com/tech/sendico/pkg/proto/payments/orchestration/v1"
eapi "github.com/tech/sendico/server/interface/api"
mutil "github.com/tech/sendico/server/internal/mutil/param"
"go.mongodb.org/mongo-driver/v2/bson"
@@ -25,8 +25,8 @@ import (
)
type paymentClient interface {
QuotePayment(ctx context.Context, req *orchestratorv1.QuotePaymentRequest) (*orchestratorv1.QuotePaymentResponse, error)
QuotePayments(ctx context.Context, req *orchestratorv1.QuotePaymentsRequest) (*orchestratorv1.QuotePaymentsResponse, error)
QuotePayment(ctx context.Context, req *quotationv1.QuotePaymentRequest) (*quotationv1.QuotePaymentResponse, error)
QuotePayments(ctx context.Context, req *quotationv1.QuotePaymentRequest) (*quotationv1.QuotePaymentsResponse, error)
InitiatePayments(ctx context.Context, req *orchestratorv1.InitiatePaymentsRequest) (*orchestratorv1.InitiatePaymentsResponse, error)
InitiatePayment(ctx context.Context, req *orchestratorv1.InitiatePaymentRequest) (*orchestratorv1.InitiatePaymentResponse, error)
ListPayments(ctx context.Context, req *orchestratorv1.ListPaymentsRequest) (*orchestratorv1.ListPaymentsResponse, error)