visamasterpay: return gatewayResponse from GET /{id}/status
Some checks failed
CI/CD / Vet, test, build (push) Has been cancelled
CI/CD / Docker image (push) Has been cancelled
CI/CD / Deploy binary to server (push) Has been cancelled

The status check now carries GBÜS's last stored response for the
attempt alongside gatewayStatus - the fresh getOrderStatusExtended.do
answer when it was just checked, the stored one when the attempt was
already finalized, null if GBÜS never answered. The callback is
unchanged: it is public and only reports paid plus a message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-25 01:25:12 +05:00
parent 570d4c6d20
commit 742e078090
6 changed files with 42 additions and 26 deletions

View File

@@ -9929,7 +9929,7 @@ const docTemplate = `{
"BearerAuth": []
}
],
"description": "For when the frontend can't rely on GBÜS's redirect having reached the callback (e.g. the user closed the hosted payment page first) - re-verifies the latest attempt with GBÜS server-to-server, the same way the callback does, and finalizes it if needed. Safe to call repeatedly.",
"description": "For when the frontend can't rely on GBÜS's redirect having reached the callback (e.g. the user closed the hosted payment page first) - re-verifies the latest attempt with GBÜS server-to-server, the same way the callback does, and finalizes it if needed. gatewayResponse is GBÜS's last stored response for the attempt (null if GBÜS never answered). Safe to call repeatedly.",
"produces": [
"application/json"
],
@@ -13033,6 +13033,9 @@ const docTemplate = `{
"gatewayReference": {
"type": "string"
},
"gatewayResponse": {
"type": "object"
},
"gatewayStatus": {
"type": "string"
},

View File

@@ -9926,7 +9926,7 @@
"BearerAuth": []
}
],
"description": "For when the frontend can't rely on GBÜS's redirect having reached the callback (e.g. the user closed the hosted payment page first) - re-verifies the latest attempt with GBÜS server-to-server, the same way the callback does, and finalizes it if needed. Safe to call repeatedly.",
"description": "For when the frontend can't rely on GBÜS's redirect having reached the callback (e.g. the user closed the hosted payment page first) - re-verifies the latest attempt with GBÜS server-to-server, the same way the callback does, and finalizes it if needed. gatewayResponse is GBÜS's last stored response for the attempt (null if GBÜS never answered). Safe to call repeatedly.",
"produces": [
"application/json"
],
@@ -13030,6 +13030,9 @@
"gatewayReference": {
"type": "string"
},
"gatewayResponse": {
"type": "object"
},
"gatewayStatus": {
"type": "string"
},

View File

@@ -2131,6 +2131,8 @@ definitions:
type: number
gatewayReference:
type: string
gatewayResponse:
type: object
gatewayStatus:
type: string
gbusFeeTmt:
@@ -8872,7 +8874,8 @@ paths:
description: For when the frontend can't rely on GBÜS's redirect having reached
the callback (e.g. the user closed the hosted payment page first) - re-verifies
the latest attempt with GBÜS server-to-server, the same way the callback does,
and finalizes it if needed. Safe to call repeatedly.
and finalizes it if needed. gatewayResponse is GBÜS's last stored response
for the attempt (null if GBÜS never answered). Safe to call repeatedly.
parameters:
- description: Visa/master payment order ID
in: path

View File

@@ -30,7 +30,7 @@ const orderTypeSber = "sber"
const paymentReturningColumns = `id, order_id, order_number, payment_period, exchange_rate_usd, exchange_rate_rub, amount_tmt,
bank_fee_tmt, gbus_fee_tmt, tveb_fee_usd, tveb_fee_tmt, total_amount_tmt,
gateway_status, gateway_reference, created_at, updated_at`
gateway_status, gateway_reference, gateway_response, created_at, updated_at`
type repository struct {
client postgresql.Client
@@ -685,10 +685,13 @@ func scanPayment(row pgx.Row) (visamasterpay.PaymentResultDTO, error) {
if err := row.Scan(
&item.Id, &item.OrderId, &item.OrderNumber, &item.PaymentPeriod, &item.ExchangeRateUsd, &item.ExchangeRateRub, &item.AmountTmt,
&item.BankFeeTmt, &item.GbusFeeTmt, &item.TvebFeeUsd, &item.TvebFeeTmt, &item.TotalAmountTmt,
&item.GatewayStatus, &item.GatewayReference, &item.CreatedAt, &item.UpdatedAt,
&item.GatewayStatus, &item.GatewayReference, &item.GatewayResponse, &item.CreatedAt, &item.UpdatedAt,
); err != nil {
return visamasterpay.PaymentResultDTO{}, err
}
if len(item.GatewayResponse) == 0 {
item.GatewayResponse = json.RawMessage("null")
}
return item, nil
}

View File

@@ -1,6 +1,7 @@
package visamasterpay
import (
"encoding/json"
"time"
"online-back/internal/shared"
@@ -69,25 +70,28 @@ type CallbackResultDTO struct {
// as its own row in visa_master_order_payments (a full audit trail -
// failed attempts are kept, not overwritten by a retry) - deliberately not
// the full order+branch+user DTO owned by cards/visamaster (fetch that
// separately via GET /visa-master-payment-orders/:id).
// separately via GET /visa-master-payment-orders/:id). GatewayResponse is
// the last GBÜS response stored for the attempt (null if GBÜS never
// answered).
type PaymentResultDTO struct {
Id int64 `json:"id"`
OrderId int64 `json:"orderId"`
OrderNumber string `json:"orderNumber"`
Type string `json:"type"`
Paid bool `json:"paid"`
AmountUsd float64 `json:"amountUsd"`
ExchangeRateUsd float64 `json:"exchangeRateUsd"`
ExchangeRateRub *float64 `json:"exchangeRateRub,omitempty"`
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"`
PaymentPeriod time.Time `json:"paymentPeriod"`
GatewayStatus string `json:"gatewayStatus"`
GatewayReference *string `json:"gatewayReference,omitempty"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
Id int64 `json:"id"`
OrderId int64 `json:"orderId"`
OrderNumber string `json:"orderNumber"`
Type string `json:"type"`
Paid bool `json:"paid"`
AmountUsd float64 `json:"amountUsd"`
ExchangeRateUsd float64 `json:"exchangeRateUsd"`
ExchangeRateRub *float64 `json:"exchangeRateRub,omitempty"`
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"`
PaymentPeriod time.Time `json:"paymentPeriod"`
GatewayStatus string `json:"gatewayStatus"`
GatewayReference *string `json:"gatewayReference,omitempty"`
GatewayResponse json.RawMessage `json:"gatewayResponse" swaggertype:"object"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}

View File

@@ -114,7 +114,7 @@ func (h *handler) pay(c *gin.Context) {
// status godoc
// @Summary Re-check a visa/master/sber order's latest payment attempt
// @Description For when the frontend can't rely on GBÜS's redirect having reached the callback (e.g. the user closed the hosted payment page first) - re-verifies the latest attempt with GBÜS server-to-server, the same way the callback does, and finalizes it if needed. Safe to call repeatedly.
// @Description For when the frontend can't rely on GBÜS's redirect having reached the callback (e.g. the user closed the hosted payment page first) - re-verifies the latest attempt with GBÜS server-to-server, the same way the callback does, and finalizes it if needed. gatewayResponse is GBÜS's last stored response for the attempt (null if GBÜS never answered). Safe to call repeatedly.
// @Tags visa-master-payment
// @Produce json
// @Security BearerAuth