+source currency pick fix +fx side propagation
This commit is contained in:
@@ -3,6 +3,7 @@ package store
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -90,25 +91,39 @@ func (q *Quotes) Create(ctx context.Context, quote *model.PaymentQuoteRecord) er
|
||||
if quote.IdempotencyKey == "" {
|
||||
return merrors.InvalidArgument("quotesStore: idempotency key is required")
|
||||
}
|
||||
quote.ExecutionNote = strings.TrimSpace(quote.ExecutionNote)
|
||||
quote.RequestShape = model.QuoteRequestShape(strings.TrimSpace(string(quote.RequestShape)))
|
||||
if quote.RequestShape == "" || quote.RequestShape == model.QuoteRequestShapeUnspecified {
|
||||
return merrors.InvalidArgument("quotesStore: request shape is required")
|
||||
}
|
||||
if len(quote.Items) == 0 {
|
||||
return merrors.InvalidArgument("quotesStore: items are required")
|
||||
}
|
||||
if quote.RequestShape == model.QuoteRequestShapeSingle && len(quote.Items) != 1 {
|
||||
return merrors.InvalidArgument("quotesStore: single shape requires exactly one item")
|
||||
}
|
||||
if quote.ExpiresAt.IsZero() {
|
||||
return merrors.InvalidArgument("quotesStore: expires_at is required")
|
||||
}
|
||||
if quote.PurgeAt.IsZero() || quote.PurgeAt.Before(quote.ExpiresAt) {
|
||||
quote.PurgeAt = quote.ExpiresAt.Add(q.retention)
|
||||
}
|
||||
if quote.Intent.Attributes != nil {
|
||||
for k, v := range quote.Intent.Attributes {
|
||||
quote.Intent.Attributes[k] = strings.TrimSpace(v)
|
||||
for i := range quote.Items {
|
||||
item := quote.Items[i]
|
||||
if item == nil {
|
||||
return merrors.InvalidArgument("quotesStore: items[" + strconv.Itoa(i) + "] is required")
|
||||
}
|
||||
}
|
||||
if len(quote.Intents) > 0 {
|
||||
for i := range quote.Intents {
|
||||
if quote.Intents[i].Attributes == nil {
|
||||
continue
|
||||
}
|
||||
for k, v := range quote.Intents[i].Attributes {
|
||||
quote.Intents[i].Attributes[k] = strings.TrimSpace(v)
|
||||
if item.Intent == nil {
|
||||
return merrors.InvalidArgument("quotesStore: items[" + strconv.Itoa(i) + "].intent is required")
|
||||
}
|
||||
if item.Quote == nil {
|
||||
return merrors.InvalidArgument("quotesStore: items[" + strconv.Itoa(i) + "].quote is required")
|
||||
}
|
||||
if item.Status == nil {
|
||||
return merrors.InvalidArgument("quotesStore: items[" + strconv.Itoa(i) + "].status is required")
|
||||
}
|
||||
if item.Intent.Attributes != nil {
|
||||
for k, v := range item.Intent.Attributes {
|
||||
item.Intent.Attributes[k] = strings.TrimSpace(v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user