idempotency key delivery fix

This commit is contained in:
Stephan D
2026-01-21 16:50:47 +01:00
parent 87f99be01d
commit bd5dfb4f26
11 changed files with 63 additions and 24 deletions

View File

@@ -69,7 +69,10 @@ func (h *quotePaymentCommand) Execute(
return h.mapQuoteErr(err)
}
return gsresponse.Success(&orchestratorv1.QuotePaymentResponse{Quote: quoteProto})
return gsresponse.Success(&orchestratorv1.QuotePaymentResponse{
IdempotencyKey: req.GetIdempotencyKey(),
Quote: quoteProto,
})
}
func (h *quotePaymentCommand) prepareQuoteCtx(req *orchestratorv1.QuotePaymentRequest) (*quoteCtx, error) {
@@ -315,9 +318,10 @@ func (h *quotePaymentsCommand) Execute(
)
return gsresponse.Success(&orchestratorv1.QuotePaymentsResponse{
QuoteRef: quoteRef,
Aggregate: aggregate,
Quotes: quotes,
IdempotencyKey: req.GetIdempotencyKey(),
QuoteRef: quoteRef,
Aggregate: aggregate,
Quotes: quotes,
})
}

View File

@@ -248,6 +248,7 @@ message QuotePaymentsResponse {
string quote_ref = 1;
PaymentQuoteAggregate aggregate = 2;
repeated PaymentQuote quotes = 3;
string idempotency_key = 4;
}
message InitiatePaymentsRequest {

View File

@@ -35,7 +35,6 @@ type FxQuote struct {
}
type PaymentQuote struct {
IdempotencyKey string `json:"idempotencyKey"`
QuoteRef string `json:"quoteRef,omitempty"`
DebitAmount *model.Money `json:"debitAmount,omitempty"`
ExpectedSettlementAmount *model.Money `json:"expectedSettlementAmount,omitempty"`
@@ -67,8 +66,9 @@ type Payment struct {
}
type paymentQuoteResponse struct {
authResponse `json:",inline"`
Quote *PaymentQuote `json:"quote"`
authResponse `json:",inline"`
IdempotencyKey string `json:"idempotencyKey,omitempty"`
Quote *PaymentQuote `json:"quote"`
}
type paymentQuotesResponse struct {
@@ -88,10 +88,11 @@ type paymentResponse struct {
}
// PaymentQuote wraps a payment quote with refreshed access token.
func PaymentQuoteResponse(logger mlogger.Logger, quote *orchestratorv1.PaymentQuote, token *TokenData) http.HandlerFunc {
func PaymentQuoteResponse(logger mlogger.Logger, idempotencyKey string, quote *orchestratorv1.PaymentQuote, token *TokenData) http.HandlerFunc {
return response.Ok(logger, paymentQuoteResponse{
Quote: toPaymentQuote(quote),
authResponse: authResponse{AccessToken: *token},
Quote: toPaymentQuote(quote),
IdempotencyKey: idempotencyKey,
authResponse: authResponse{AccessToken: *token},
})
}
@@ -216,9 +217,10 @@ func toPaymentQuotes(resp *orchestratorv1.QuotePaymentsResponse) *PaymentQuotes
quotes = nil
}
return &PaymentQuotes{
QuoteRef: resp.GetQuoteRef(),
Aggregate: toPaymentQuoteAggregate(resp.GetAggregate()),
Quotes: quotes,
IdempotencyKey: resp.GetIdempotencyKey(),
QuoteRef: resp.GetQuoteRef(),
Aggregate: toPaymentQuoteAggregate(resp.GetAggregate()),
Quotes: quotes,
}
}

View File

@@ -65,7 +65,7 @@ func (a *PaymentAPI) quotePayment(r *http.Request, account *model.Account, token
return response.Auto(a.logger, a.Name(), err)
}
return sresponse.PaymentQuoteResponse(a.logger, resp.GetQuote(), token)
return sresponse.PaymentQuoteResponse(a.logger, resp.GetIdempotencyKey(), resp.GetQuote(), token)
}
func (a *PaymentAPI) quotePayments(r *http.Request, account *model.Account, token *sresponse.TokenData) http.HandlerFunc {