visamasterpay: return gatewayResponse from GET /{id}/status
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:
@@ -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"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -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"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package visamasterpay
|
package visamasterpay
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"online-back/internal/shared"
|
"online-back/internal/shared"
|
||||||
@@ -69,25 +70,28 @@ 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"`
|
||||||
OrderNumber string `json:"orderNumber"`
|
OrderNumber string `json:"orderNumber"`
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
Paid bool `json:"paid"`
|
Paid bool `json:"paid"`
|
||||||
AmountUsd float64 `json:"amountUsd"`
|
AmountUsd float64 `json:"amountUsd"`
|
||||||
ExchangeRateUsd float64 `json:"exchangeRateUsd"`
|
ExchangeRateUsd float64 `json:"exchangeRateUsd"`
|
||||||
ExchangeRateRub *float64 `json:"exchangeRateRub,omitempty"`
|
ExchangeRateRub *float64 `json:"exchangeRateRub,omitempty"`
|
||||||
AmountTmt float64 `json:"amountTmt"`
|
AmountTmt float64 `json:"amountTmt"`
|
||||||
BankFeeTmt float64 `json:"bankFeeTmt"`
|
BankFeeTmt float64 `json:"bankFeeTmt"`
|
||||||
GbusFeeTmt *float64 `json:"gbusFeeTmt,omitempty"`
|
GbusFeeTmt *float64 `json:"gbusFeeTmt,omitempty"`
|
||||||
TvebFeeUsd *float64 `json:"tvebFeeUsd,omitempty"`
|
TvebFeeUsd *float64 `json:"tvebFeeUsd,omitempty"`
|
||||||
TvebFeeTmt *float64 `json:"tvebFeeTmt,omitempty"`
|
TvebFeeTmt *float64 `json:"tvebFeeTmt,omitempty"`
|
||||||
TotalAmountTmt float64 `json:"totalAmountTmt"`
|
TotalAmountTmt float64 `json:"totalAmountTmt"`
|
||||||
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"`
|
||||||
CreatedAt time.Time `json:"createdAt"`
|
GatewayResponse json.RawMessage `json:"gatewayResponse" swaggertype:"object"`
|
||||||
UpdatedAt time.Time `json:"updatedAt"`
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
|
UpdatedAt time.Time `json:"updatedAt"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user