payment-history: payment detail with GBÜS response, sorting, newest-first logs
- GET /payment-history/payments/{id}: single payment attempt with the raw
gateway_response (last HALKBANK JSON) for the "storage" icon modal
- GET /payment-history: sort (id/created_at/status/amount) and order
(asc/desc, default desc) query params
- GET /payment-history/{id}: order logs now newest first
- index on visa_master_order_payments (gateway_status, id DESC)
- regenerate swagger docs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e5f01d0e94
commit
a715cd23ea
10 files changed
+2140
-60
No files matched your search
@@ -17,28 +17,44 @@ import (
|
||||
// pending) enriched with the order/branch/client/operator context needed to
|
||||
// display it in a history list, without requiring a separate lookup per row.
|
||||
type PaymentHistoryItemDTO struct {
|
||||
Id int64 `json:"id"`
|
||||
OrderId int64 `json:"orderId"`
|
||||
OrderNumber string `json:"orderNumber"`
|
||||
OrderUniqueId string `json:"orderUniqueId"`
|
||||
Type string `json:"type"`
|
||||
BranchId int64 `json:"branchId"`
|
||||
BranchName shared.LocalizedText `json:"branchName"`
|
||||
PassportName string `json:"passportName"`
|
||||
PassportSurname string `json:"passportSurname"`
|
||||
UserId int64 `json:"userId"`
|
||||
Paid bool `json:"paid"`
|
||||
AmountTmt float64 `json:"amountTmt"`
|
||||
BankFeeTmt float64 `json:"bankFeeTmt"`
|
||||
GbusFeeTmt *float64 `json:"gbusFeeTmt,omitempty"`
|
||||
TvebFeeUsd *float64 `json:"tvebFeeUsd,omitempty"`
|
||||
TvebFeeTmt *float64 `json:"tvebFeeTmt,omitempty"`
|
||||
TotalAmountTmt float64 `json:"totalAmountTmt"`
|
||||
ExchangeRateUsd float64 `json:"exchangeRateUsd"`
|
||||
ExchangeRateRub *float64 `json:"exchangeRateRub,omitempty"`
|
||||
PaymentPeriod time.Time `json:"paymentPeriod"`
|
||||
GatewayStatus string `json:"gatewayStatus"`
|
||||
GatewayReference *string `json:"gatewayReference,omitempty"`
|
||||
Id int64 `json:"id"`
|
||||
OrderId int64 `json:"orderId"`
|
||||
OrderNumber string `json:"orderNumber"`
|
||||
OrderUniqueId string `json:"orderUniqueId"`
|
||||
Type string `json:"type"`
|
||||
BranchId int64 `json:"branchId"`
|
||||
BranchName shared.LocalizedText `json:"branchName"`
|
||||
PassportName string `json:"passportName"`
|
||||
PassportSurname string `json:"passportSurname"`
|
||||
UserId int64 `json:"userId"`
|
||||
Paid bool `json:"paid"`
|
||||
AmountTmt float64 `json:"amountTmt"`
|
||||
BankFeeTmt float64 `json:"bankFeeTmt"`
|
||||
GbusFeeTmt *float64 `json:"gbusFeeTmt,omitempty"`
|
||||
TvebFeeUsd *float64 `json:"tvebFeeUsd,omitempty"`
|
||||
TvebFeeTmt *float64 `json:"tvebFeeTmt,omitempty"`
|
||||
TotalAmountTmt float64 `json:"totalAmountTmt"`
|
||||
// AmountMinor is the amount registered with GBÜS, in tetri.
|
||||
AmountMinor int64 `json:"amountMinor"`
|
||||
// AmountUsd is amount_tmt converted back at the attempt's own
|
||||
// exchange_rate_usd - the USD figure the payout was quoted in.
|
||||
AmountUsd float64 `json:"amountUsd"`
|
||||
ExchangeRateUsd float64 `json:"exchangeRateUsd"`
|
||||
ExchangeRateRub *float64 `json:"exchangeRateRub,omitempty"`
|
||||
PaymentPeriod time.Time `json:"paymentPeriod"`
|
||||
GatewayStatus string `json:"gatewayStatus"`
|
||||
GatewayReference *string `json:"gatewayReference,omitempty"`
|
||||
// ApiClient is the branch's GBÜS merchant username for this order type
|
||||
// (visa/master or sber) and Description the text sent with register.do -
|
||||
// both as visamasterpay's Pay picks them.
|
||||
ApiClient string `json:"apiClient"`
|
||||
Description string `json:"description"`
|
||||
// CardholderName/MaskedPan come from GBÜS's getOrderStatusExtended
|
||||
// cardAuthInfo, so they're only known once an attempt has been
|
||||
// finalized by the callback/status check (unset while pending, and for
|
||||
// attempts that never reached the card form).
|
||||
CardholderName *string `json:"cardholderName,omitempty"`
|
||||
MaskedPan *string `json:"maskedPan,omitempty"`
|
||||
// FormUrl/SuccessUrl are only set while the attempt is still pending
|
||||
// (awaiting the customer to finish paying on GBÜS's hosted page) - once
|
||||
// an attempt is finalized (success/failed), gateway_response no longer
|
||||
@@ -51,6 +67,14 @@ type PaymentHistoryItemDTO struct {
|
||||
UpdatedAt time.Time `json:"updatedAt"`
|
||||
}
|
||||
|
||||
// PaymentHistoryDetailDTO is a single payout attempt with the raw GBÜS
|
||||
// response kept alongside it - the list deliberately leaves the jsonb out
|
||||
// so pages stay small.
|
||||
type PaymentHistoryDetailDTO struct {
|
||||
PaymentHistoryItemDTO
|
||||
GatewayResponse json.RawMessage `json:"gatewayResponse,omitempty" swaggertype:"object"`
|
||||
}
|
||||
|
||||
// ListFilter narrows the history list. BranchIds is populated by
|
||||
// rbac.BindBranchIDs and takes priority over BranchId when set (see
|
||||
// rbac.AppendBranchIDs), the same way visamaster.ListFilter works.
|
||||
@@ -61,10 +85,20 @@ type ListFilter struct {
|
||||
UserId *int64
|
||||
Status *string // gateway_status: pending/success/failed
|
||||
Search string // matches order passport name/surname or unique id
|
||||
Sort string // one of SortColumns' keys; empty means id
|
||||
Desc bool
|
||||
Page int
|
||||
Limit int
|
||||
}
|
||||
|
||||
// SortColumns maps the accepted ?sort= values to their SQL expressions.
|
||||
var SortColumns = map[string]string{
|
||||
"id": "p.id",
|
||||
"created_at": "p.created_at",
|
||||
"status": "p.gateway_status",
|
||||
"amount": "p.amount_tmt",
|
||||
}
|
||||
|
||||
type ListPaymentHistoryDTO struct {
|
||||
Count int64 `json:"count"`
|
||||
Items []PaymentHistoryItemDTO `json:"items"`
|
||||
|
||||
Reference in new issue
Block a user