visamasterpay: return gatewayResponse from GET /{id}/status
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:
guwandykandClaude Opus 5.5 committed 2026-10-25 01:25:12 +05:00
1 parent 570d4c6d20
commit 742e078090
6 files changed
+23 -7

No files matched your search

+4 -1
View File
@@ -9929,7 +9929,7 @@ const docTemplate = `{
"BearerAuth": [] "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": [ "produces": [
"application/json" "application/json"
], ],
@@ -13033,6 +13033,9 @@ const docTemplate = `{
"gatewayReference": { "gatewayReference": {
"type": "string" "type": "string"
}, },
"gatewayResponse": {
"type": "object"
},
"gatewayStatus": { "gatewayStatus": {
"type": "string" "type": "string"
}, },
+4 -1
View File
@@ -9926,7 +9926,7 @@
"BearerAuth": [] "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": [ "produces": [
"application/json" "application/json"
], ],
@@ -13030,6 +13030,9 @@
"gatewayReference": { "gatewayReference": {
"type": "string" "type": "string"
}, },
"gatewayResponse": {
"type": "object"
},
"gatewayStatus": { "gatewayStatus": {
"type": "string" "type": "string"
}, },
+4 -1
View File
@@ -2131,6 +2131,8 @@ definitions:
type: number type: number
gatewayReference: gatewayReference:
type: string type: string
gatewayResponse:
type: object
gatewayStatus: gatewayStatus:
type: string type: string
gbusFeeTmt: gbusFeeTmt:
@@ -8872,7 +8874,8 @@ paths:
description: For when the frontend can't rely on GBÜS's redirect having reached 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 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, 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: parameters:
- description: Visa/master payment order ID - description: Visa/master payment order ID
in: path in: path
@@ -30,7 +30,7 @@ const orderTypeSber = "sber"
const paymentReturningColumns = `id, order_id, order_number, payment_period, exchange_rate_usd, exchange_rate_rub, amount_tmt, 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, 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 { type repository struct {
client postgresql.Client client postgresql.Client
@@ -685,10 +685,13 @@ func scanPayment(row pgx.Row) (visamasterpay.PaymentResultDTO, error) {
if err := row.Scan( if err := row.Scan(
&item.Id, &item.OrderId, &item.OrderNumber, &item.PaymentPeriod, &item.ExchangeRateUsd, &item.ExchangeRateRub, &item.AmountTmt, &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.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 { ); err != nil {
return visamasterpay.PaymentResultDTO{}, err return visamasterpay.PaymentResultDTO{}, err
} }
if len(item.GatewayResponse) == 0 {
item.GatewayResponse = json.RawMessage("null")
}
return item, nil return item, nil
} }
+5 -1
View File
@@ -1,6 +1,7 @@
package visamasterpay package visamasterpay
import ( import (
"encoding/json"
"time" "time"
"online-back/internal/shared" "online-back/internal/shared"
@@ -69,7 +70,9 @@ type CallbackResultDTO struct {
// as its own row in visa_master_order_payments (a full audit trail - // as its own row in visa_master_order_payments (a full audit trail -
// failed attempts are kept, not overwritten by a retry) - deliberately not // failed attempts are kept, not overwritten by a retry) - deliberately not
// the full order+branch+user DTO owned by cards/visamaster (fetch that // 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 { type PaymentResultDTO struct {
Id int64 `json:"id"` Id int64 `json:"id"`
OrderId int64 `json:"orderId"` OrderId int64 `json:"orderId"`
@@ -88,6 +91,7 @@ type PaymentResultDTO struct {
PaymentPeriod time.Time `json:"paymentPeriod"` PaymentPeriod time.Time `json:"paymentPeriod"`
GatewayStatus string `json:"gatewayStatus"` GatewayStatus string `json:"gatewayStatus"`
GatewayReference *string `json:"gatewayReference,omitempty"` GatewayReference *string `json:"gatewayReference,omitempty"`
GatewayResponse json.RawMessage `json:"gatewayResponse" swaggertype:"object"`
CreatedAt time.Time `json:"createdAt"` CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"` UpdatedAt time.Time `json:"updatedAt"`
} }
+1 -1
View File
@@ -114,7 +114,7 @@ func (h *handler) pay(c *gin.Context) {
// status godoc // status godoc
// @Summary Re-check a visa/master/sber order's latest payment attempt // @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 // @Tags visa-master-payment
// @Produce json // @Produce json
// @Security BearerAuth // @Security BearerAuth