payment-history: GET /{id}/gateway - all of an order's payments with their HALKBANK JSON
The gateway view now takes an order ID and returns every payment of the
order, newest first, each in the same PaymentGatewayDTO shape with its
own last stored GBÜS response. It moves from /payments/{id}/gateway to
/{id}/gateway, next to the other order-scoped routes (/{id}, /{id}/logs).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ef3a1baee2
commit
a3cbb52f4b
7 files changed
+182
-118
No files matched your search
@@ -142,6 +142,33 @@ func (r *repository) OrderPayments(ctx context.Context, orderID int64) ([]paymen
|
||||
return items, nil
|
||||
}
|
||||
|
||||
func (r *repository) OrderPaymentDetails(ctx context.Context, orderID int64) ([]paymenthistory.PaymentHistoryDetailDTO, error) {
|
||||
whereClause, args := buildListQuery(paymenthistory.ListFilter{OrderId: &orderID})
|
||||
query := `SELECT ` + historySelectColumns + `, p.gateway_response` + historyFromClause + whereClause + ` ORDER BY p.id DESC`
|
||||
|
||||
rows, err := r.client.Query(ctx, query, args...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
details := []paymenthistory.PaymentHistoryDetailDTO{}
|
||||
for rows.Next() {
|
||||
var detail paymenthistory.PaymentHistoryDetailDTO
|
||||
item, err := r.scanHistoryItem(rows, &detail.GatewayResponse)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
detail.PaymentHistoryItemDTO = item
|
||||
details = append(details, detail)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return details, nil
|
||||
}
|
||||
|
||||
// OwnerInfo returns orderID's owning user/branch, so the handler can run
|
||||
// rbac.GuardOrder before returning its logs to a branch/own-scoped caller.
|
||||
func (r *repository) OwnerInfo(ctx context.Context, orderID int64) (*int64, int64, error) {
|
||||
|
||||
Reference in new issue
Block a user