2 Commits

Author SHA1 Message Date
90e160bdb2 shared: use one LocalizedText type everywhere
auth, user, userbranch and org/branches each declared their own identical
{en, ru, tm} struct; they now use shared.LocalizedText. No JSON change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 14:19:59 +05:00
75b551e281 api: return localized fields only in the requested ?lang=
appresult.Localize, the first admin middleware, rewrites JSON responses so
every {en, ru, tm} object becomes the plain string for ?lang= (tm, ru, en;
default tm), falling back tm -> ru -> en when that translation is empty.
?lang=all keeps the full objects for edit forms; other values are 400.
Key order and number precision are preserved; non-JSON responses and
/swagger are untouched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-24 14:19:24 +05:00
43 changed files with 208 additions and 6881 deletions

17
app.go
View File

@@ -24,6 +24,9 @@ import (
// @description Online payment system admin API. Localized fields ({en, ru, tm} objects) come back as a plain string in the language of the `lang` query parameter: tm, ru or en (default tm), falling back to tm, ru, en when that translation is empty. lang=all returns the full {en, ru, tm} objects (for edit forms); any other value is 400.
// @host localhost:5005
// @BasePath /api/admin
// @securityDefinitions.apikey BearerAuth
// @in header
// @name Authorization
// @schemes http
// @tag.name auth
// @tag.description Authentication
@@ -47,22 +50,12 @@ import (
// @tag.description Card rekwizit (card details) orders
// @tag.name activity-logs
// @tag.description User activity audit trail
// @tag.name visa-master-orders
// @tag.description Visa/Master and Sber student-transfer orders: list, view, create, edit, delete
// @tag.name visa-master-payment
// @tag.description Paying a Visa/Master or Sber order through GBÜS (HALKBANK): quote, pay, status re-check, bank callback
// @tag.name payment-history
// @tag.description Visa/Master we Sber töleg synanyşyklarynyň taryhy. Ulanylyş tertibi: 1) GET /payment-history - ähli tölegler; 2) GET /payment-history/{id} - bir sargydyň tölegleri; 3) GET /payment-history/payments/{id} - bir tölegiň jikme-jikligi; 4) GET /payment-history/{id}/gateway - sargydyň tölegleri GBÜS jogaplary bilen; 5) GET /payment-history/{id}/logs - sargydyň ädimme-ädim töleg loglary
// @tag.name visa-master-payment-orders
// @tag.description Visa/Master student-transfer payment orders
// @tag.name backups
// @tag.description Database SQL backups
// @tag.name currencies
// @tag.description Currency exchange rates
//
// Security definitions go last: swag reads every line after one as its
// attributes, so anything declared below it (tags, schemes) is dropped.
// @securityDefinitions.apikey BearerAuth
// @in header
// @name Authorization
func main() {
cfg := config.GetConfig()
logger := logging.GetLogger()

View File

@@ -1 +0,0 @@
DROP INDEX IF EXISTS visa_master_payment_logs_order_step_idx;

View File

@@ -1,5 +0,0 @@
-- payment-history reads each attempt's register/callback log rows
-- (formUrl, returnUrl, first callback) by order and step; without this
-- every row of a page scans all of its order's logs.
CREATE INDEX IF NOT EXISTS visa_master_payment_logs_order_step_idx
ON visa_master_payment_logs (order_id, step);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -52,7 +52,6 @@ func (h *handler) Register(router *gin.RouterGroup) {
// @Security BearerAuth
// @Param from query string false "Start date YYYY-MM-DD (inclusive)" default(Jan 1 of current year)
// @Param to query string false "End date YYYY-MM-DD (inclusive)" default(today)
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -87,7 +86,6 @@ func (h *handler) finance(c *gin.Context) {
// @Security BearerAuth
// @Param from query string false "Start date YYYY-MM-DD (inclusive)" default(Jan 1 of current year)
// @Param to query string false "End date YYYY-MM-DD (inclusive)" default(today)
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -113,7 +111,6 @@ func (h *handler) backlog(c *gin.Context) {
// @Security BearerAuth
// @Param from query string false "Start date YYYY-MM-DD (inclusive)" default(Jan 1 of current year)
// @Param to query string false "End date YYYY-MM-DD (inclusive)" default(today)
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -139,7 +136,6 @@ func (h *handler) branches(c *gin.Context) {
// @Security BearerAuth
// @Param from query string false "Start date YYYY-MM-DD (inclusive)" default(Jan 1 of current year)
// @Param to query string false "End date YYYY-MM-DD (inclusive)" default(today)
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -165,7 +161,6 @@ func (h *handler) products(c *gin.Context) {
// @Security BearerAuth
// @Param from query string false "Start date YYYY-MM-DD (inclusive)" default(Jan 1 of current year)
// @Param to query string false "End date YYYY-MM-DD (inclusive)" default(today)
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -192,7 +187,6 @@ func (h *handler) customers(c *gin.Context) {
// @Param from query string false "Start date YYYY-MM-DD (inclusive)" default(Jan 1 of current year)
// @Param to query string false "End date YYYY-MM-DD (inclusive)" default(today)
// @Param operator_limit query int false "Number of operators to return" default(10)
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError

View File

@@ -46,7 +46,6 @@ func (h *handler) Register(router *gin.RouterGroup) {
// @Param status query string false "Filter by status (pending, completed, failed)"
// @Param page query int false "Page number" default(1)
// @Param limit query int false "Items per page" default(10)
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -75,7 +74,6 @@ func (h *handler) list(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Backup ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -108,7 +106,6 @@ func (h *handler) getByID(c *gin.Context) {
// @Tags backups
// @Produce json
// @Security BearerAuth
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 201 {object} appresult.AppSuccess
// @Failure 500 {object} appresult.AppError
// @Router /backups [post]
@@ -130,7 +127,6 @@ func (h *handler) create(c *gin.Context) {
// @Produce application/sql
// @Security BearerAuth
// @Param id path int true "Backup ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {file} file
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -172,7 +168,6 @@ func (h *handler) download(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Backup ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError

View File

@@ -46,7 +46,6 @@ func (h *handler) Register(router *gin.RouterGroup) {
// @Param created_by query int false "Filter by creator user ID"
// @Param page query int false "Page number" default(1)
// @Param limit query int false "Items per page" default(10)
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -75,7 +74,6 @@ func (h *handler) list(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Card balance ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -113,7 +111,6 @@ func (h *handler) getByID(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param body body CreateCardBalanceDTO true "Card balance payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 201 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -144,7 +141,6 @@ func (h *handler) create(c *gin.Context) {
// @Security BearerAuth
// @Param id path int true "Card balance ID"
// @Param body body UpdateCardBalanceDTO true "Card balance payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -188,7 +184,6 @@ func (h *handler) update(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Card balance ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError

View File

@@ -49,7 +49,6 @@ func (h *handler) Register(router *gin.RouterGroup) {
// @Param region query string false "Filter by region"
// @Param page query int false "Page number" default(1)
// @Param limit query int false "Items per page" default(10)
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -78,7 +77,6 @@ func (h *handler) list(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Card order ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -116,7 +114,6 @@ func (h *handler) getByID(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param body body CreateCardOrderDTO true "Card order payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 201 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -148,7 +145,6 @@ func (h *handler) create(c *gin.Context) {
// @Security BearerAuth
// @Param id path int true "Card order ID"
// @Param body body UpdateCardOrderDTO true "Card order payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -193,7 +189,6 @@ func (h *handler) update(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Card order ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError

View File

@@ -48,7 +48,6 @@ func (h *handler) Register(router *gin.RouterGroup) {
// @Param region query string false "Filter by region"
// @Param page query int false "Page number" default(1)
// @Param limit query int false "Items per page" default(10)
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -77,7 +76,6 @@ func (h *handler) list(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Card pin order ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -115,7 +113,6 @@ func (h *handler) getByID(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param body body CreateCardPinOrderDTO true "Card pin order payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 201 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -146,7 +143,6 @@ func (h *handler) create(c *gin.Context) {
// @Security BearerAuth
// @Param id path int true "Card pin order ID"
// @Param body body UpdateCardPinOrderDTO true "Card pin order payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -190,7 +186,6 @@ func (h *handler) update(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Card pin order ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError

View File

@@ -48,7 +48,6 @@ func (h *handler) Register(router *gin.RouterGroup) {
// @Param region query string false "Filter by region"
// @Param page query int false "Page number" default(1)
// @Param limit query int false "Items per page" default(10)
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -77,7 +76,6 @@ func (h *handler) list(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Card rekwizit order ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -115,7 +113,6 @@ func (h *handler) getByID(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param body body CreateCardRekwizitOrderDTO true "Card rekwizit order payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 201 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -146,7 +143,6 @@ func (h *handler) create(c *gin.Context) {
// @Security BearerAuth
// @Param id path int true "Card rekwizit order ID"
// @Param body body UpdateCardRekwizitOrderDTO true "Card rekwizit order payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -190,7 +186,6 @@ func (h *handler) update(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Card rekwizit order ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError

View File

@@ -45,7 +45,6 @@ func (h *handler) Register(router *gin.RouterGroup) {
// @Param type query string false "Filter by card type"
// @Param page query int false "Page number" default(1)
// @Param limit query int false "Items per page" default(10)
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -74,7 +73,6 @@ func (h *handler) list(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Card ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -119,7 +117,6 @@ func (h *handler) getByID(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param body body CreateCardDTO true "Card payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 201 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -150,7 +147,6 @@ func (h *handler) create(c *gin.Context) {
// @Security BearerAuth
// @Param id path int true "Card ID"
// @Param body body UpdateCardDTO true "Card payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -194,7 +190,6 @@ func (h *handler) update(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Card ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError

View File

@@ -47,7 +47,6 @@ func (h *handler) Register(router *gin.RouterGroup) {
// @Param active query bool false "Filter by active"
// @Param page query int false "Page number" default(1)
// @Param limit query int false "Items per page" default(10)
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -76,7 +75,6 @@ func (h *handler) list(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Payment card ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -111,7 +109,6 @@ func (h *handler) getByID(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param body body CreatePaymentCardDTO true "Payment card payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 201 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -142,7 +139,6 @@ func (h *handler) create(c *gin.Context) {
// @Security BearerAuth
// @Param id path int true "Payment card ID"
// @Param body body UpdatePaymentCardDTO true "Payment card payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -184,7 +180,6 @@ func (h *handler) update(c *gin.Context) {
// @Security BearerAuth
// @Param id path int true "Payment card ID"
// @Param body body UpdatePaymentCardActiveDTO true "Active payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -224,7 +219,6 @@ func (h *handler) updateActive(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Payment card ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError

View File

@@ -44,7 +44,6 @@ func (h *handler) Register(router *gin.RouterGroup) {
// @Param reason_name query string false "Filter by title (en, ru, tm)"
// @Param page query int false "Page number" default(1)
// @Param limit query int false "Items per page" default(10)
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -73,7 +72,6 @@ func (h *handler) list(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Reason card ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -108,7 +106,6 @@ func (h *handler) getByID(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param body body CreateReasonCardDTO true "Reason card payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 201 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -139,7 +136,6 @@ func (h *handler) create(c *gin.Context) {
// @Security BearerAuth
// @Param id path int true "Reason card ID"
// @Param body body UpdateReasonCardDTO true "Reason card payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -179,7 +175,6 @@ func (h *handler) update(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Reason card ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError

View File

@@ -43,7 +43,7 @@ func (h *handler) Register(router *gin.RouterGroup) {
// list godoc
// @Summary List visa/master payment orders
// @Description Returns paginated visa/master payment orders; sber orders are excluded (see /visa-master-payment-orders/sber)
// @Tags visa-master-orders
// @Tags visa-master-payment-orders
// @Produce json
// @Security BearerAuth
// @Param name query string false "Filter by passport name or surname"
@@ -54,7 +54,6 @@ func (h *handler) Register(router *gin.RouterGroup) {
// @Param region query string false "Filter by region"
// @Param page query int false "Page number" default(1)
// @Param limit query int false "Items per page" default(10)
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -72,7 +71,7 @@ func (h *handler) list(c *gin.Context) {
// listSber godoc
// @Summary List sber payment orders
// @Description Returns paginated payment orders of type sber
// @Tags visa-master-orders
// @Tags visa-master-payment-orders
// @Produce json
// @Security BearerAuth
// @Param name query string false "Filter by passport name or surname"
@@ -82,7 +81,6 @@ func (h *handler) list(c *gin.Context) {
// @Param region query string false "Filter by region"
// @Param page query int false "Page number" default(1)
// @Param limit query int false "Items per page" default(10)
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -111,11 +109,10 @@ func (h *handler) respondList(c *gin.Context, filter ListFilter) {
// getByID godoc
// @Summary Get visa/master payment order by ID
// @Description Returns a single visa/master payment order with branch and user details
// @Tags visa-master-orders
// @Tags visa-master-payment-orders
// @Produce json
// @Security BearerAuth
// @Param id path int true "Visa/master payment order ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -148,12 +145,11 @@ func (h *handler) getByID(c *gin.Context) {
// create godoc
// @Summary Create visa/master payment order
// @Description Creates a new visa/master payment order
// @Tags visa-master-orders
// @Tags visa-master-payment-orders
// @Accept json
// @Produce json
// @Security BearerAuth
// @Param body body CreateVisaMasterPaymentOrderDTO true "Visa/master payment order payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 201 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -178,13 +174,12 @@ func (h *handler) create(c *gin.Context) {
// update godoc
// @Summary Update visa/master payment order
// @Description Updates an existing visa/master payment order
// @Tags visa-master-orders
// @Tags visa-master-payment-orders
// @Accept json
// @Produce json
// @Security BearerAuth
// @Param id path int true "Visa/master payment order ID"
// @Param body body UpdateVisaMasterPaymentOrderDTO true "Visa/master payment order payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -224,11 +219,10 @@ func (h *handler) update(c *gin.Context) {
// delete godoc
// @Summary Delete visa/master payment order
// @Description Deletes a visa/master payment order
// @Tags visa-master-orders
// @Tags visa-master-payment-orders
// @Produce json
// @Security BearerAuth
// @Param id path int true "Visa/master payment order ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError

View File

@@ -48,7 +48,6 @@ func (h *handler) Register(router *gin.RouterGroup) {
// @Param currency_to query string false "Filter by target currency"
// @Param page query int false "Page number" default(1)
// @Param limit query int false "Items per page" default(10)
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} ListCurrencyDTO
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -77,7 +76,6 @@ func (h *handler) list(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Currency ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} CurrencyDTO
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -112,7 +110,6 @@ func (h *handler) getByID(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param body body CreateCurrencyDTO true "Currency rate payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 201 {object} CurrencyDTO
// @Failure 400 {object} appresult.AppError
// @Failure 409 {object} appresult.AppError
@@ -150,7 +147,6 @@ func (h *handler) create(c *gin.Context) {
// @Security BearerAuth
// @Param id path int true "Currency ID"
// @Param body body UpdateCurrencyDTO true "Currency rate payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} CurrencyDTO
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -197,7 +193,6 @@ func (h *handler) update(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Currency ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError

View File

@@ -47,7 +47,6 @@ func (h *handler) Register(router *gin.RouterGroup) {
// @Security BearerAuth
// @Param year query int false "Year for the monthly trend chart" default(current year)
// @Param recent_limit query int false "Number of recent activity items to return" default(10)
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -76,7 +75,6 @@ func (h *handler) overview(c *gin.Context) {
// @Tags dashboard
// @Produce json
// @Security BearerAuth
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess{data=sysstats.Stats}
// @Failure 500 {object} appresult.AppError
// @Router /dashboard/server-stats [get]

View File

@@ -47,7 +47,6 @@ func (h *handler) Register(router *gin.RouterGroup) {
// @Param action query string false "Filter by action (create, update, delete)"
// @Param page query int false "Page number" default(1)
// @Param limit query int false "Items per page" default(10)
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -76,7 +75,6 @@ func (h *handler) list(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Activity log ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError

View File

@@ -55,7 +55,6 @@ func (h *handler) Register(router *gin.RouterGroup) {
// @Accept json
// @Produce json
// @Param body body LoginDTO true "Login payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 401 {object} appresult.AppError
@@ -92,7 +91,6 @@ func (h *handler) login(c *gin.Context) {
// @Accept json
// @Produce json
// @Param body body RegisterDTO true "Registration payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 409 {object} appresult.AppError
@@ -120,7 +118,6 @@ func (h *handler) register(c *gin.Context) {
// @Accept json
// @Produce json
// @Param body body VerifyDTO true "Verification payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 409 {object} appresult.AppError
@@ -148,7 +145,6 @@ func (h *handler) verify(c *gin.Context) {
// @Accept json
// @Produce json
// @Param body body ForgotPasswordDTO true "Forgot password payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -176,7 +172,6 @@ func (h *handler) forgotPassword(c *gin.Context) {
// @Accept json
// @Produce json
// @Param body body ResetPasswordDTO true "Reset password payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -222,7 +217,6 @@ func (h *handler) respondRegisterError(c *gin.Context, err error) {
// @Accept json
// @Produce json
// @Param body body RefreshTokenDTO true "Refresh token payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 401 {object} appresult.AppError
@@ -253,7 +247,6 @@ func (h *handler) refreshToken(c *gin.Context) {
// @Tags auth
// @Produce json
// @Security BearerAuth
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 401 {object} appresult.AppError
@@ -284,7 +277,6 @@ func (h *handler) getProfile(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param body body UpdateProfileDTO true "Profile payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 401 {object} appresult.AppError

View File

@@ -33,7 +33,6 @@ func (h *handler) Register(router *gin.RouterGroup) {
// @Tags permission
// @Produce json
// @Security BearerAuth
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Router /permissions [get]
func (h *handler) list(c *gin.Context) {

View File

@@ -46,7 +46,6 @@ func (h *handler) Register(router *gin.RouterGroup) {
// @Param role_name query string false "Filter by name or code"
// @Param page query int false "Page number" default(1)
// @Param limit query int false "Items per page" default(10)
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -75,7 +74,6 @@ func (h *handler) list(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Role ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -110,7 +108,6 @@ func (h *handler) getByID(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param body body CreateRoleDTO true "Role payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 201 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 403 {object} appresult.AppError
@@ -154,7 +151,6 @@ func (h *handler) create(c *gin.Context) {
// @Security BearerAuth
// @Param id path int true "Role ID"
// @Param body body UpdateRoleDTO true "Role payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 403 {object} appresult.AppError
@@ -206,7 +202,6 @@ func (h *handler) update(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Role ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 403 {object} appresult.AppError

View File

@@ -73,7 +73,6 @@ func (h *handler) RegisterPublic(engine *gin.Engine) {
// @Param username query string false "Alias for search"
// @Param page query int false "Page number" default(1)
// @Param limit query int false "Items per page" default(10)
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -107,7 +106,6 @@ func (h *handler) list(c *gin.Context) {
// @Param username query string false "Alias for search"
// @Param page query int false "Page number" default(1)
// @Param limit query int false "Items per page" default(10)
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -139,7 +137,6 @@ func (h *handler) listClients(c *gin.Context) {
// @Param username query string false "Alias for search"
// @Param page query int false "Page number" default(1)
// @Param limit query int false "Items per page" default(10)
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -169,7 +166,6 @@ func (h *handler) listStaff(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "User ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -207,7 +203,6 @@ func (h *handler) getByID(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param body body CreateUserDTO true "User payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 201 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 403 {object} appresult.AppError
@@ -247,7 +242,6 @@ func (h *handler) create(c *gin.Context) {
// @Security BearerAuth
// @Param id path int true "User ID"
// @Param body body UpdateUserDTO true "User payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 403 {object} appresult.AppError
@@ -309,7 +303,6 @@ func (h *handler) update(c *gin.Context) {
// @Security BearerAuth
// @Param id path int true "User ID"
// @Param body body SetUserRoleDTO true "Role"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 403 {object} appresult.AppError
@@ -371,7 +364,6 @@ func (h *handler) setRole(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "User ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 403 {object} appresult.AppError
@@ -555,7 +547,6 @@ func parseListFilter(c *gin.Context) (ListFilter, bool) {
// @Param file formData file true "this is a test file"
//
// @Security BearerAuth
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -598,7 +589,6 @@ func (h *handler) fileUpload(c *gin.Context) {
// @Tags file-upload
// @Produce octet-stream
// @Param file_name path string true "object name"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {file} binary
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -641,7 +631,6 @@ func (h *handler) getFile(c *gin.Context) {
// @Produce json
// @Param id path string true "object name"
// @Security BearerAuth
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 500 {object} appresult.AppError
// @Router /file/{id} [delete]

View File

@@ -40,7 +40,6 @@ func (h *handler) Register(router *gin.RouterGroup) {
// @Produce json
// @Security BearerAuth
// @Param body body CreateUserBranchDTO true "Branch-user payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 201 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -73,7 +72,6 @@ func (h *handler) create(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Branch-user ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError

View File

@@ -50,7 +50,6 @@ func (h *handler) Register(router *gin.RouterGroup) {
// @Param region query string false "Filter by region"
// @Param page query int false "Page number" default(1)
// @Param limit query int false "Items per page" default(10)
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -77,7 +76,6 @@ func (h *handler) list(c *gin.Context) {
// @Param region query string false "Filter by region"
// @Param page query int false "Page number" default(1)
// @Param limit query int false "Items per page" default(10)
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -110,7 +108,6 @@ func (h *handler) respondList(c *gin.Context, filter ListFilter) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Loan order ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -148,7 +145,6 @@ func (h *handler) getByID(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param body body CreateLoanOrderDTO true "Loan order payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 201 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -183,7 +179,6 @@ func (h *handler) create(c *gin.Context) {
// @Security BearerAuth
// @Param id path int true "Loan order ID"
// @Param body body UpdateLoanOrderDTO true "Loan order payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -227,7 +222,6 @@ func (h *handler) update(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Loan order ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError

View File

@@ -51,7 +51,6 @@ func (h *handler) Register(router *gin.RouterGroup) {
// @Param region query string false "Filter by region"
// @Param page query int false "Page number" default(1)
// @Param limit query int false "Items per page" default(10)
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -81,7 +80,6 @@ func (h *handler) list(c *gin.Context) {
// @Security BearerAuth
// @Param province_id query int true "Province ID"
// @Param active query bool false "Only active branches" default(true)
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -120,7 +118,6 @@ func (h *handler) listBranchesByProvince(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Loan paid off letter ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -158,7 +155,6 @@ func (h *handler) getByID(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param body body CreateLoanPaidLetterDTO true "Loan paid off letter payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 201 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -189,7 +185,6 @@ func (h *handler) create(c *gin.Context) {
// @Security BearerAuth
// @Param id path int true "Loan paid off letter ID"
// @Param body body UpdateLoanPaidLetterDTO true "Loan paid off letter payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -233,7 +228,6 @@ func (h *handler) update(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Loan paid off letter ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError

View File

@@ -48,7 +48,6 @@ func (h *handler) Register(router *gin.RouterGroup) {
// @Param active query bool false "Filter by active"
// @Param page query int false "Page number" default(1)
// @Param limit query int false "Items per page" default(10)
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -77,7 +76,6 @@ func (h *handler) list(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Loan document ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -112,7 +110,6 @@ func (h *handler) getByID(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param body body CreateLoanDocumentDTO true "Loan document payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 201 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -143,7 +140,6 @@ func (h *handler) create(c *gin.Context) {
// @Security BearerAuth
// @Param id path int true "Loan document ID"
// @Param body body UpdateLoanDocumentDTO true "Loan document payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -185,7 +181,6 @@ func (h *handler) update(c *gin.Context) {
// @Security BearerAuth
// @Param id path int true "Loan document ID"
// @Param body body UpdateLoanDocumentActiveDTO true "Active payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -225,7 +220,6 @@ func (h *handler) updateActive(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Loan document ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError

View File

@@ -46,7 +46,6 @@ func (h *handler) Register(router *gin.RouterGroup) {
// @Param passport_id query string false "Filter by passport ID"
// @Param page query int false "Page number" default(1)
// @Param limit query int false "Items per page" default(10)
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -75,7 +74,6 @@ func (h *handler) list(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Loan repayment ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -113,7 +111,6 @@ func (h *handler) getByID(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param body body CreateLoanRepaymentDTO true "Loan repayment payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 201 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -144,7 +141,6 @@ func (h *handler) create(c *gin.Context) {
// @Security BearerAuth
// @Param id path int true "Loan repayment ID"
// @Param body body UpdateLoanRepaymentDTO true "Loan repayment payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -188,7 +184,6 @@ func (h *handler) update(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Loan repayment ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError

View File

@@ -46,7 +46,6 @@ func (h *handler) Register(router *gin.RouterGroup) {
// @Param loan_type_name query string false "Filter by title (en, ru, tm)"
// @Param page query int false "Page number" default(1)
// @Param limit query int false "Items per page" default(10)
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -75,7 +74,6 @@ func (h *handler) list(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Loan type ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -110,7 +108,6 @@ func (h *handler) getByID(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param body body CreateLoanTypeDTO true "Loan type payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 201 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -141,7 +138,6 @@ func (h *handler) create(c *gin.Context) {
// @Security BearerAuth
// @Param id path int true "Loan type ID"
// @Param body body UpdateLoanTypeDTO true "Loan type payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -181,7 +177,6 @@ func (h *handler) update(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Loan type ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError

View File

@@ -53,7 +53,6 @@ func (h *handler) Register(router *gin.RouterGroup) {
// @Param unique_code query string false "Filter by unique code"
// @Param page query int false "Page number" default(1)
// @Param limit query int false "Items per page" default(10)
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -82,7 +81,6 @@ func (h *handler) list(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param active query bool false "Only active provinces" default(true)
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -112,7 +110,6 @@ func (h *handler) listRegions(c *gin.Context) {
// @Security BearerAuth
// @Param region query string true "Region name (en, ru or tm)"
// @Param active query bool false "Only active etraps" default(true)
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -147,7 +144,6 @@ func (h *handler) listEtraps(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Branch ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -188,7 +184,6 @@ func (h *handler) getByID(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param body body CreateBranchDTO true "Branch payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 201 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -223,7 +218,6 @@ func (h *handler) create(c *gin.Context) {
// @Security BearerAuth
// @Param id path int true "Branch ID"
// @Param body body UpdateBranchDTO true "Branch payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -267,7 +261,6 @@ func (h *handler) update(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Branch ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError

View File

@@ -51,7 +51,6 @@ func (h *handler) Register(router *gin.RouterGroup) {
// @Param active query bool false "Filter by active status"
// @Param page query int false "Page number" default(1)
// @Param limit query int false "Items per page" default(10)
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -80,7 +79,6 @@ func (h *handler) list(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Province ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -115,7 +113,6 @@ func (h *handler) getByID(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param body body CreateProvinceDTO true "Province payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 201 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -146,7 +143,6 @@ func (h *handler) create(c *gin.Context) {
// @Security BearerAuth
// @Param id path int true "Province ID"
// @Param body body UpdateProvinceDTO true "Province payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -186,7 +182,6 @@ func (h *handler) update(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param id path int true "Province ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError

View File

@@ -36,16 +36,9 @@ LEFT JOIN users u ON u.id = p.created_by`
// isSberSQL mirrors visamasterpay's isSber for the order joined as o.
const isSberSQL = `LOWER(TRIM(COALESCE(o.type, ''))) = 'sber'`
// paymentLogSQL selects from the order's visa_master_payment_logs rows of
// one step (served by visa_master_payment_logs_order_step_idx).
const paymentLogSQL = `FROM visa_master_payment_logs l WHERE l.order_id = p.order_id AND l.step = `
// historySelectColumns pulls only the handful of gateway_response fields a
// row needs (formUrl, cardAuthInfo) out in SQL rather than shipping every
// row's whole jsonb blob to Go and decoding it there. formUrl falls back to
// the register.do response logged for the attempt (gateway_response drops
// it once finalized), successUrl is the returnUrl logged with register.do,
// and the callback columns come from its first callback_received log.
// row's whole jsonb blob to Go and decoding it there.
const historySelectColumns = `p.id, p.order_id, COALESCE(p.order_number, ''), COALESCE(o.unique_id, ''), COALESCE(o.type, ''),
o.branch_id, b.name, COALESCE(o.passport_name, ''), COALESCE(o.passport_surname, ''), p.user_id,
p.amount_tmt, p.bank_fee_tmt, p.gbus_fee_tmt, p.tveb_fee_usd, p.tveb_fee_tmt, p.total_amount_tmt,
@@ -54,15 +47,10 @@ const historySelectColumns = `p.id, p.order_id, COALESCE(p.order_number, ''), CO
p.exchange_rate_usd, p.exchange_rate_rub, p.payment_period,
p.gateway_status, p.gateway_reference,
CASE WHEN ` + isSberSQL + ` THEN COALESCE(b.billing_sber_username, '') ELSE COALESCE(b.billing_visa_master_username, '') END,
CASE WHEN ` + isSberSQL + ` THEN 'billing_sber_username' ELSE 'billing_visa_master_username' END,
CASE WHEN ` + isSberSQL + ` THEN 'Sber tölegi' ELSE 'Visa/Master tölegi' END,
NULLIF(p.gateway_response->'cardAuthInfo'->>'cardholderName', ''),
NULLIF(COALESCE(p.gateway_response->'cardAuthInfo'->>'maskedPan', p.gateway_response->'cardAuthInfo'->>'pan'), ''),
COALESCE(NULLIF(p.gateway_response->>'formUrl', ''), (SELECT NULLIF(l.detail->>'formUrl', '') ` + paymentLogSQL + `'register_response'
AND l.detail->>'gbusOrderId' = p.gateway_reference ORDER BY l.id DESC LIMIT 1)),
(SELECT NULLIF(l.detail->>'returnUrl', '') ` + paymentLogSQL + `'register_request'
AND l.detail->>'paymentId' = p.id::text ORDER BY l.id DESC LIMIT 1),
(SELECT MIN(l.created_at) ` + paymentLogSQL + `'callback_received' AND l.detail->>'paymentId' = p.id::text),
NULLIF(p.gateway_response->>'formUrl', ''),
p.created_by, ` + shared.UserDisplaySQL + `,
p.created_at, p.updated_at`
@@ -117,58 +105,6 @@ func (r *repository) Get(ctx context.Context, paymentID int64) (paymenthistory.P
return detail, nil
}
func (r *repository) OrderPayments(ctx context.Context, orderID int64) ([]paymenthistory.PaymentHistoryItemDTO, error) {
whereClause, args := buildListQuery(paymenthistory.ListFilter{OrderId: &orderID})
query := `SELECT ` + historySelectColumns + historyFromClause + whereClause + ` ORDER BY p.id DESC`
rows, err := r.client.Query(ctx, query, args...)
if err != nil {
return nil, err
}
defer rows.Close()
items := []paymenthistory.PaymentHistoryItemDTO{}
for rows.Next() {
item, err := r.scanHistoryItem(rows)
if err != nil {
return nil, err
}
items = append(items, item)
}
if err := rows.Err(); err != nil {
return nil, err
}
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) {
@@ -266,6 +202,7 @@ func buildListQuery(filter paymenthistory.ListFilter) (whereClause string, args
func (r *repository) scanHistoryItem(row pgx.Row, extra ...interface{}) (paymenthistory.PaymentHistoryItemDTO, error) {
var item paymenthistory.PaymentHistoryItemDTO
var branchNameJSON []byte
var formURL *string
dest := []interface{}{
&item.Id, &item.OrderId, &item.OrderNumber, &item.OrderUniqueId, &item.Type,
&item.BranchId, &branchNameJSON, &item.PassportName, &item.PassportSurname, &item.UserId,
@@ -273,8 +210,8 @@ func (r *repository) scanHistoryItem(row pgx.Row, extra ...interface{}) (payment
&item.AmountMinor, &item.AmountUsd,
&item.ExchangeRateUsd, &item.ExchangeRateRub, &item.PaymentPeriod,
&item.GatewayStatus, &item.GatewayReference,
&item.ApiClient, &item.ApiClientName, &item.Description,
&item.CardholderName, &item.MaskedPan, &item.FormUrl, &item.SuccessUrl, &item.CallbackAt,
&item.ApiClient, &item.Description,
&item.CardholderName, &item.MaskedPan, &formURL,
&item.CreatedById, &item.CreatedByName,
&item.CreatedAt, &item.UpdatedAt,
}
@@ -286,17 +223,13 @@ func (r *repository) scanHistoryItem(row pgx.Row, extra ...interface{}) (payment
}
item.Paid = item.GatewayStatus == "success"
if item.CallbackAt != nil {
received := paymenthistory.CallbackReceived
item.CallbackStatus = &received
}
// A returnUrl only matters for an attempt GBÜS registered (has a
// formUrl). Ones registered before register_request logged its
// returnUrl fall back to the ReturnURL visamasterpay's Pay uses.
if item.FormUrl == nil {
item.SuccessUrl = nil
} else if item.SuccessUrl == nil {
// formUrl only survives in gateway_response while the attempt is still
// pending - once finalized, gateway_response is overwritten with the
// status-check response, which has no formUrl, so there's nothing to
// resume for a paid/failed row. SuccessUrl must match the ReturnURL
// visamasterpay registered with GBÜS (see its Pay).
if formURL != nil {
item.FormUrl = formURL
successURL := r.publicBaseURL + "/online/visa-master"
item.SuccessUrl = &successURL
}

View File

@@ -45,39 +45,28 @@ type PaymentHistoryItemDTO struct {
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), ApiClientName the branch setting it comes from
// (billing_visa_master_username or billing_sber_username), and
// Description the text sent with register.do - all as visamasterpay's
// Pay picks them.
ApiClient string `json:"apiClient"`
ApiClientName string `json:"apiClientName"`
Description string `json:"description"`
// (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 is GBÜS's hosted payment page and SuccessUrl the returnUrl it
// was registered with - set for every attempt register.do accepted,
// finalized ones included (unset if registration failed).
FormUrl *string `json:"formUrl,omitempty"`
SuccessUrl *string `json:"successUrl,omitempty"`
// CallbackStatus is CallbackReceived once GBÜS's redirect reached the
// callback for this attempt, at CallbackAt (its first time); both are
// unset if it never did (e.g. finalized by a /status check instead).
CallbackStatus *string `json:"callbackStatus,omitempty"`
CallbackAt *time.Time `json:"callbackAt,omitempty"`
CreatedById *int64 `json:"createdById,omitempty"`
CreatedByName string `json:"createdByName,omitempty"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
// 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
// holds a formUrl, so there's nothing left to resume.
FormUrl *string `json:"formUrl,omitempty"`
SuccessUrl *string `json:"successUrl,omitempty"`
CreatedById *int64 `json:"createdById,omitempty"`
CreatedByName string `json:"createdByName,omitempty"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
// CallbackReceived is PaymentHistoryItemDTO.CallbackStatus once the GBÜS
// callback reached an attempt.
const CallbackReceived = "received"
// 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.
@@ -86,50 +75,6 @@ type PaymentHistoryDetailDTO struct {
GatewayResponse json.RawMessage `json:"gatewayResponse,omitempty" swaggertype:"object"`
}
// PaymentGatewayDTO is one payment the way the per-order payment table
// shows it (paid or not, from which card, when, for which month) together
// with the last GBÜS (HALKBANK) response stored for it. Card fields are
// null until GBÜS reports cardAuthInfo; gatewayResponse is null if GBÜS
// never answered.
type PaymentGatewayDTO struct {
Id int64 `json:"id"`
OrderId int64 `json:"orderId"`
CardholderName *string `json:"cardholderName"`
MaskedPan *string `json:"maskedPan"`
PaymentYear int `json:"paymentYear"`
PaymentMonth int `json:"paymentMonth"`
CreatedAt time.Time `json:"createdAt"`
AmountUsd float64 `json:"amountUsd"`
AmountTmt float64 `json:"amountTmt"`
OrderNumber string `json:"orderNumber"`
Paid bool `json:"paid"`
GatewayStatus string `json:"gatewayStatus"`
GatewayResponse json.RawMessage `json:"gatewayResponse" swaggertype:"object"`
}
// NewPaymentGatewayDTO trims a payment detail down to PaymentGatewayDTO.
func NewPaymentGatewayDTO(detail PaymentHistoryDetailDTO) PaymentGatewayDTO {
gatewayResponse := detail.GatewayResponse
if len(gatewayResponse) == 0 {
gatewayResponse = json.RawMessage("null")
}
return PaymentGatewayDTO{
Id: detail.Id,
OrderId: detail.OrderId,
CardholderName: detail.CardholderName,
MaskedPan: detail.MaskedPan,
PaymentYear: detail.PaymentPeriod.Year(),
PaymentMonth: int(detail.PaymentPeriod.Month()),
CreatedAt: detail.CreatedAt,
AmountUsd: detail.AmountUsd,
AmountTmt: detail.AmountTmt,
OrderNumber: detail.OrderNumber,
Paid: detail.Paid,
GatewayStatus: detail.GatewayStatus,
GatewayResponse: gatewayResponse,
}
}
// 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.
@@ -167,7 +112,7 @@ type PaymentLogDTO struct {
Id int64 `json:"id"`
OrderId int64 `json:"orderId"`
Step string `json:"step"`
Detail json.RawMessage `json:"detail,omitempty" swaggertype:"object"`
Detail json.RawMessage `json:"detail,omitempty"`
CreatedById *int64 `json:"createdById,omitempty"`
CreatedByName string `json:"createdByName,omitempty"`
CreatedAt time.Time `json:"createdAt"`

View File

@@ -31,27 +31,24 @@ func (h *handler) Register(router *gin.RouterGroup) {
group := rbac.Group(router, baseURL, rbac.RequireStaff(perm.Cards))
group.GET("", h.list)
group.GET("/payments/:id", h.get)
group.GET("/:id/gateway", h.gateway)
group.GET("/:id", h.orderPayments)
group.GET("/:id/logs", h.logs)
group.GET("/:id", h.logs)
}
// list godoc
// @Summary Tölegleriň taryhy
// @Description Ähli sargytlaryň Visa/Master we Sber töleg synanyşyklaryny (tölenen, şowsuz, garaşylýan) sahypalap gaýtarýar. Tertip: sort/order boýunça (adaty ýagdaýda iň täzesi birinji). Bellik: diňe ulanyjynyň öz şahamçasynyň tölegleri görünýär.
// @Summary List payment history
// @Description Returns a paginated, branch-scoped audit trail of visa/master/sber payout attempts (paid, failed, or pending), across orders
// @Tags payment-history
// @Produce json
// @Security BearerAuth
// @Param order_id query int false "Sargyt ID-si boýunça süzmek"
// @Param branch_id query int false "Şahamça ID-si boýunça süzmek"
// @Param user_id query int false "Sargyt eýesiniň (müşderiniň) ulanyjy ID-si boýunça süzmek"
// @Param status query string false "GBÜS statusy boýunça süzmek (pending, success, failed)"
// @Param search query string false "Pasport ady/familiýasy ýa-da sargydyň unique ID-si boýunça gözlemek"
// @Param sort query string false "Tertiplenýän sütün" Enums(id, created_at, status, amount) default(id)
// @Param order query string false "Tertip ugry" Enums(asc, desc) default(desc)
// @Param page query int false "Sahypa belgisi" default(1)
// @Param limit query int false "Bir sahypadaky ýazgy sany" default(10)
// @Param lang query string false "Lokallaşdyrylan meýdanlaryň dili; all - doly {en, ru, tm} obýektleri" Enums(tm, ru, en, all) default(tm)
// @Param order_id query int false "Filter by order ID"
// @Param branch_id query int false "Filter by branch ID"
// @Param user_id query int false "Filter by order owner (client) user ID"
// @Param status query string false "Filter by gateway status (pending, success, failed)"
// @Param search query string false "Filter by passport name/surname or order unique ID"
// @Param sort query string false "Sort column" Enums(id, created_at, status, amount) default(id)
// @Param order query string false "Sort direction" Enums(asc, desc) default(desc)
// @Param page query int false "Page number" default(1)
// @Param limit query int false "Items per page" default(10)
// @Success 200 {object} ListPaymentHistoryDTO
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -74,13 +71,12 @@ func (h *handler) list(c *gin.Context) {
}
// get godoc
// @Summary Bir tölegiň jikme-jikligi
// @Description Töleg ID-si boýunça bir Visa/Master ýa-da Sber töleg synanyşygyny GBÜS-iň soňky jogaby (gatewayResponse) bilen gaýtarýar. Tertip: ýeke ýazgy. Bellik: taryh sanawyndaky bir setiriň jikme-jik görnüşi.
// @Summary Get a single payment attempt
// @Description Returns one visa/master/sber payout attempt by its payment ID, with the raw GBÜS response - the detail view behind a payment-history list row
// @Tags payment-history
// @Produce json
// @Security BearerAuth
// @Param id path int true "Töleg ID-si"
// @Param lang query string false "Lokallaşdyrylan meýdanlaryň dili; all - doly {en, ru, tm} obýektleri" Enums(tm, ru, en, all) default(tm)
// @Param id path int true "Payment ID"
// @Success 200 {object} PaymentHistoryDetailDTO
// @Failure 400 {object} appresult.AppError
// @Failure 403 {object} appresult.AppError
@@ -108,97 +104,23 @@ func (h *handler) get(c *gin.Context) {
if !h.guardOrder(c, result.OrderId) {
return
}
c.JSON(http.StatusOK, appresult.SuccessWithData(result))
}
// gateway godoc
// @Summary Sargydyň tölegleri GBÜS jogaplary bilen
// @Description Bir sargydyň ähli tölegini her biriniň GBÜS (HALKBANK) soňky jogaby (gatewayResponse) bilen gaýtarýar: tölendimi, haýsy kartdan tölendi (cardholderName/maskedPan), wagty (createdAt), töleg ýyly/aýy, mukdarlary we belgisi (orderNumber). Tertip: iň täzesi birinji. Bellik: GBÜS kart maglumatyny habar berýänçä cardholderName/maskedPan null, GBÜS asla jogap bermedik bolsa gatewayResponse null; tablisadaky ammar nyşany şu endpoint-den işleýär.
// @Tags payment-history
// @Produce json
// @Security BearerAuth
// @Param id path int true "Sargyt ID-si"
// @Param lang query string false "Lokallaşdyrylan meýdanlaryň dili; all - doly {en, ru, tm} obýektleri" Enums(tm, ru, en, all) default(tm)
// @Success 200 {array} PaymentGatewayDTO
// @Failure 400 {object} appresult.AppError
// @Failure 403 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
// @Router /payment-history/{id}/gateway [get]
func (h *handler) gateway(c *gin.Context) {
orderID, ok := shared.ParseID(c.Param("id"))
if !ok {
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
return
}
if !h.guardOrder(c, orderID) {
return
}
details, err := h.repository.OrderPaymentDetails(c.Request.Context(), orderID)
if err != nil {
h.logger.Errorf("list order payment gateway responses failed (order %d): %v", orderID, err)
c.JSON(http.StatusInternalServerError, appresult.ErrInternalServer)
return
}
result := make([]PaymentGatewayDTO, 0, len(details))
for _, detail := range details {
result = append(result, NewPaymentGatewayDTO(detail))
}
c.JSON(http.StatusOK, appresult.SuccessWithData(result))
}
// orderPayments godoc
// @Summary Sargydyň tölegleri
// @Description Bir sargydyň ähli Visa/Master we Sber töleg synanyşyklaryny gaýtarýar: her töleg üçin bir setir - tölendimi (paid/gatewayStatus), haýsy kartdan tölendi (cardholderName/maskedPan), wagty (createdAt) we döwri (paymentPeriod). Tertip: iň täzesi birinji. Bellik: bir tölegiň GBÜS jogaby /payment-history/payments/{id}, ähli tölegleriňki /payment-history/{id}/gateway, ädimme-ädim loglar /payment-history/{id}/logs salgysynda.
// @Tags payment-history
// @Produce json
// @Security BearerAuth
// @Param id path int true "Sargyt ID-si"
// @Param lang query string false "Lokallaşdyrylan meýdanlaryň dili; all - doly {en, ru, tm} obýektleri" Enums(tm, ru, en, all) default(tm)
// @Success 200 {array} PaymentHistoryItemDTO
// @Failure 400 {object} appresult.AppError
// @Failure 403 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
// @Router /payment-history/{id} [get]
func (h *handler) orderPayments(c *gin.Context) {
orderID, ok := shared.ParseID(c.Param("id"))
if !ok {
c.JSON(http.StatusBadRequest, appresult.ErrMissingParam)
return
}
if !h.guardOrder(c, orderID) {
return
}
result, err := h.repository.OrderPayments(c.Request.Context(), orderID)
if err != nil {
h.logger.Errorf("list order payments failed (order %d): %v", orderID, err)
c.JSON(http.StatusInternalServerError, appresult.ErrInternalServer)
return
}
c.JSON(http.StatusOK, appresult.SuccessWithData(result))
}
// logs godoc
// @Summary Sargydyň töleg loglary
// @Description Sargydyň tölegi işlenende ýazylan ähli ädimleri (visa_master_payment_logs) gaýtarýar. Tertip: iň täzesi birinji. Bellik: /payment-history/{id} setirlerinden garaşsyz, hakykatda näme bolandygynyň subutnamasy.
// @Summary Get payment logs for an order
// @Description Returns the full step-by-step audit trail (visa_master_payment_logs) recorded while processing an order's payout - evidence of what actually happened, independent of the summary rows returned by the list endpoint
// @Tags payment-history
// @Produce json
// @Security BearerAuth
// @Param id path int true "Sargyt ID-si"
// @Param lang query string false "Lokallaşdyrylan meýdanlaryň dili; all - doly {en, ru, tm} obýektleri" Enums(tm, ru, en, all) default(tm)
// @Success 200 {array} PaymentLogDTO
// @Param id path int true "Order ID"
// @Success 200 {object} appresult.AppSuccess
// @Failure 400 {object} appresult.AppError
// @Failure 403 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
// @Router /payment-history/{id}/logs [get]
// @Router /payment-history/{id} [get]
func (h *handler) logs(c *gin.Context) {
orderID, ok := shared.ParseID(c.Param("id"))
if !ok {

View File

@@ -1,133 +0,0 @@
package paymenthistory
import (
"context"
"encoding/json"
"net/http"
"net/http/httptest"
"testing"
"time"
"online-back/internal/identity/rbac"
"online-back/pkg/logging"
"github.com/gin-gonic/gin"
)
type fakeRepository struct {
Repository
orders map[int64][]PaymentHistoryDetailDTO
}
func (f fakeRepository) OrderPaymentDetails(_ context.Context, orderID int64) ([]PaymentHistoryDetailDTO, error) {
return append([]PaymentHistoryDetailDTO{}, f.orders[orderID]...), nil
}
func strPtr(s string) *string { return &s }
func gatewayRequest(t *testing.T, repo Repository, path string) *httptest.ResponseRecorder {
t.Helper()
gin.SetMode(gin.TestMode)
// Register's rbac.Group also demands a signed JWT; mount the handler
// directly behind an all-scope principal instead.
h := &handler{logger: logging.GetLogger(), repository: repo}
router := gin.New()
router.Use(func(c *gin.Context) {
c.Set("rbacPrincipal", &rbac.Principal{UserID: 1, Scope: rbac.ScopeAll})
})
router.GET("/payment-history/:id/gateway", h.gateway)
rec := httptest.NewRecorder()
router.ServeHTTP(rec, httptest.NewRequest(http.MethodGet, "/payment-history/"+path, nil))
return rec
}
func TestGatewayReturnsOrderPaymentsWithHalkbankJSON(t *testing.T) {
created := time.Date(2026, 10, 22, 8, 19, 57, 0, time.UTC)
paid := PaymentHistoryDetailDTO{
PaymentHistoryItemDTO: PaymentHistoryItemDTO{
Id: 2922, OrderId: 9437, OrderNumber: "221026131957",
CardholderName: strPtr("Amanowa guljemal"), MaskedPan: strPtr("993404**2453"),
PaymentPeriod: time.Date(2026, 10, 31, 0, 0, 0, 0, time.UTC), CreatedAt: created,
AmountUsd: 250, AmountTmt: 1063.44, Paid: true, GatewayStatus: "success",
Description: "Visa/Master tölegi",
},
GatewayResponse: json.RawMessage(`{"orderStatus":2,"actionCode":0}`),
}
failed := PaymentHistoryDetailDTO{PaymentHistoryItemDTO: PaymentHistoryItemDTO{Id: 2921, OrderId: 9437, GatewayStatus: "failed"}}
repo := fakeRepository{orders: map[int64][]PaymentHistoryDetailDTO{9437: {paid, failed}}}
rec := gatewayRequest(t, repo, "9437/gateway")
if rec.Code != http.StatusOK {
t.Fatalf("got %d %s", rec.Code, rec.Body.String())
}
var body struct {
Data []map[string]json.RawMessage `json:"data"`
}
if err := json.Unmarshal(rec.Body.Bytes(), &body); err != nil {
t.Fatal(err)
}
if len(body.Data) != 2 {
t.Fatalf("got %d payments, want 2", len(body.Data))
}
if got := string(body.Data[1]["id"]); got != "2921" {
t.Errorf("second payment id: got %s, want 2921", got)
}
want := map[string]string{
"id": `2922`, "orderId": `9437`, "cardholderName": `"Amanowa guljemal"`, "maskedPan": `"993404**2453"`,
"paymentYear": `2026`, "paymentMonth": `10`, "createdAt": `"2026-10-22T08:19:57Z"`,
"amountUsd": `250`, "amountTmt": `1063.44`, "orderNumber": `"221026131957"`,
"paid": `true`, "gatewayStatus": `"success"`, "gatewayResponse": `{"orderStatus":2,"actionCode":0}`,
}
if len(body.Data[0]) != len(want) {
t.Errorf("got fields %v, want exactly %d", body.Data[0], len(want))
}
for key, value := range want {
if got := string(body.Data[0][key]); got != value {
t.Errorf("%s: got %s, want %s", key, got, value)
}
}
}
func TestGatewayNullsWhenHalkbankNeverAnswered(t *testing.T) {
repo := fakeRepository{orders: map[int64][]PaymentHistoryDetailDTO{
3: {{PaymentHistoryItemDTO: PaymentHistoryItemDTO{Id: 7, OrderId: 3, GatewayStatus: "failed"}}},
}}
rec := gatewayRequest(t, repo, "3/gateway")
var body struct {
Data []map[string]json.RawMessage `json:"data"`
}
if err := json.Unmarshal(rec.Body.Bytes(), &body); err != nil {
t.Fatal(err)
}
if len(body.Data) != 1 {
t.Fatalf("got %d payments, want 1", len(body.Data))
}
for _, key := range []string{"cardholderName", "maskedPan", "gatewayResponse"} {
if got := string(body.Data[0][key]); got != "null" {
t.Errorf("%s: got %q, want null", key, got)
}
}
}
func TestGatewayEmptyOrderAndBadID(t *testing.T) {
repo := fakeRepository{orders: map[int64][]PaymentHistoryDetailDTO{}}
rec := gatewayRequest(t, repo, "999/gateway")
if rec.Code != http.StatusOK {
t.Fatalf("got %d %s", rec.Code, rec.Body.String())
}
var body struct {
Data json.RawMessage `json:"data"`
}
if err := json.Unmarshal(rec.Body.Bytes(), &body); err != nil {
t.Fatal(err)
}
if got := string(body.Data); got != "[]" {
t.Errorf("data: got %s, want []", got)
}
if rec := gatewayRequest(t, repo, "abc/gateway"); rec.Code != http.StatusBadRequest {
t.Errorf("abc/gateway: got %d, want %d", rec.Code, http.StatusBadRequest)
}
}

View File

@@ -6,12 +6,6 @@ type Repository interface {
List(ctx context.Context, filter ListFilter) (ListPaymentHistoryDTO, error)
// Get returns a single payout attempt by its visa_master_order_payments id.
Get(ctx context.Context, paymentID int64) (PaymentHistoryDetailDTO, error)
// OrderPayments returns every payout attempt of a single order, newest
// first - the per-order payment table, without paging.
OrderPayments(ctx context.Context, orderID int64) ([]PaymentHistoryItemDTO, error)
// OrderPaymentDetails is OrderPayments with each attempt's raw GBÜS
// response kept alongside it.
OrderPaymentDetails(ctx context.Context, orderID int64) ([]PaymentHistoryDetailDTO, error)
// Logs returns the full visa_master_payment_logs audit trail for a
// single order, newest first.
Logs(ctx context.Context, orderID int64) ([]PaymentLogDTO, error)

View File

@@ -36,7 +36,6 @@ func (h *handler) Register(router *gin.RouterGroup) {
// @Tags payment-settings
// @Produce json
// @Security BearerAuth
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} PaymentSettingsDTO
// @Failure 500 {object} appresult.AppError
// @Router /payment-settings [get]
@@ -59,7 +58,6 @@ func (h *handler) get(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param body body UpdatePaymentSettingsDTO true "Payment settings payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} PaymentSettingsDTO
// @Failure 400 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError

View File

@@ -46,7 +46,6 @@ func (h *handler) Register(router *gin.RouterGroup) {
// @Produce json
// @Security BearerAuth
// @Param search query string false "Filter by code, name or text"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} ListPaymentTextDTO
// @Failure 500 {object} appresult.AppError
// @Router /payment-texts [get]
@@ -78,7 +77,6 @@ func (h *handler) list(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param code path string true "Text code"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} PaymentTextDTO
// @Failure 404 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
@@ -121,7 +119,6 @@ func (h *handler) getByCode(c *gin.Context) {
// @Security BearerAuth
// @Param code path string true "Text code"
// @Param body body UpdatePaymentTextDTO true "Payment text payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} PaymentTextDTO
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -159,7 +156,6 @@ func (h *handler) update(c *gin.Context) {
// @Produce json
// @Security BearerAuth
// @Param code path string true "Text code"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} appresult.AppSuccess
// @Failure 403 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError

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, gateway_response, created_at, updated_at`
gateway_status, gateway_reference, created_at, updated_at`
type repository struct {
client postgresql.Client
@@ -306,17 +306,10 @@ func (r *repository) verifyPayment(ctx context.Context, paymentID int64, trigger
var gatewayStatus string
var gatewayReference *string
var createdBy *int64
// staleFailure flags a row finalized as failed while GBÜS still reported
// it in progress (checked before the card was even entered, by code
// predating StatusResult.InProgress) - it is re-checked like a pending one.
var staleFailure bool
err := r.client.QueryRow(ctx,
`SELECT order_id, gateway_status, gateway_reference, created_by,
COALESCE(gateway_status = 'failed' AND gateway_response->>'orderStatus' IN ('0', '1', '5')
AND COALESCE(gateway_response->>'errorCode', '0') IN ('', '0'), false)
FROM visa_master_order_payments WHERE id = $1 AND deleted_at IS NULL`,
`SELECT order_id, gateway_status, gateway_reference, created_by FROM visa_master_order_payments WHERE id = $1 AND deleted_at IS NULL`,
paymentID,
).Scan(&orderID, &gatewayStatus, &gatewayReference, &createdBy, &staleFailure)
).Scan(&orderID, &gatewayStatus, &gatewayReference, &createdBy)
if errors.Is(err, pgx.ErrNoRows) {
// Unknown payment id: there's no order to attach a log row to.
return visamasterpay.PaymentResultDTO{}, visamasterpay.ErrPaymentNotFound
@@ -361,7 +354,7 @@ func (r *repository) verifyPayment(ctx context.Context, paymentID int64, trigger
return item
}
if gatewayStatus != "pending" && !staleFailure {
if gatewayStatus != "pending" {
item, err := fetchPaymentByID(ctx, r.client, paymentID)
if err != nil {
fail("load_payment", err)
@@ -435,17 +428,6 @@ func (r *repository) verifyPayment(ctx context.Context, paymentID int64, trigger
fail("finalize_commit", err)
return visamasterpay.PaymentResultDTO{}, err
}
} else if status.InProgress() {
// Not paid yet but not over either (e.g. checked before the card was
// entered): keep it pending so a later callback/Status re-checks it,
// storing the response so the card shows up once GBÜS reports it.
item, err = updatePaymentStatus(ctx, r.client, paymentID, "pending", status.RawResponse)
if err != nil {
fail("save_payment_status", err)
return visamasterpay.PaymentResultDTO{}, err
}
step("payment_still_pending", map[string]interface{}{"orderStatus": status.OrderStatus, "actionCode": status.ActionCode})
return finish(item), nil
} else {
item, err = updatePaymentStatus(ctx, r.client, paymentID, "failed", status.RawResponse)
if err != nil {
@@ -464,8 +446,7 @@ func (r *repository) verifyPayment(ctx context.Context, paymentID int64, trigger
// HandleCallback does - 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). Safe to call repeatedly: it only hits GBÜS while the attempt is
// still "pending" (or a stale failure, see verifyPayment) and otherwise
// just returns the already-finalized row.
// still "pending" and otherwise just returns the already-finalized row.
func (r *repository) Status(ctx context.Context, orderID int64, requestedBy *int64) (visamasterpay.PaymentResultDTO, error) {
var paymentID int64
err := r.client.QueryRow(ctx,
@@ -662,9 +643,8 @@ func updatePaymentGatewayResult(ctx context.Context, q execer, paymentID int64,
return err
}
// updatePaymentStatus records a verified getOrderStatusExtended.do outcome
// (from HandleCallback/Status) - final, or still pending - and returns the
// updated row.
// updatePaymentStatus records the verified final outcome (from
// HandleCallback) and returns the updated row.
func updatePaymentStatus(ctx context.Context, q querier, paymentID int64, status string, response []byte) (visamasterpay.PaymentResultDTO, error) {
query := `
UPDATE visa_master_order_payments SET gateway_status = $1, gateway_response = $2,
@@ -685,13 +665,10 @@ 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.GatewayResponse, &item.CreatedAt, &item.UpdatedAt,
&item.GatewayStatus, &item.GatewayReference, &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,7 +1,6 @@
package visamasterpay
import (
"encoding/json"
"time"
"online-back/internal/shared"
@@ -70,28 +69,25 @@ 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). GatewayResponse is
// the last GBÜS response stored for the attempt (null if GBÜS never
// answered).
// separately via GET /visa-master-payment-orders/:id).
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"`
GatewayResponse json.RawMessage `json:"gatewayResponse" swaggertype:"object"`
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"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}

View File

@@ -40,11 +40,10 @@ func (h *handler) Register(router *gin.RouterGroup) {
// quote godoc
// @Summary Quote a visa/master/sber payment
// @Description Returns the current rate, configured fees, and max payable amount for an order's payout
// @Tags visa-master-payment
// @Tags visa-master-payment-orders
// @Produce json
// @Security BearerAuth
// @Param id path int true "Visa/master payment order ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} PaymentQuoteDTO
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -72,13 +71,12 @@ func (h *handler) quote(c *gin.Context) {
// pay godoc
// @Summary Start a visa/master/sber payout
// @Description Registers the payment with GBÜS and returns the hosted-payment-page URL to complete it on. The final outcome is only known once GBÜS redirects back to the callback, which verifies and finalizes it.
// @Tags visa-master-payment
// @Tags visa-master-payment-orders
// @Accept json
// @Produce json
// @Security BearerAuth
// @Param id path int true "Visa/master payment order ID"
// @Param body body PayOrderDTO true "Payment payload"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} PaymentInitResultDTO
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -114,12 +112,11 @@ 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. 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
// @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.
// @Tags visa-master-payment-orders
// @Produce json
// @Security BearerAuth
// @Param id path int true "Visa/master payment order ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} PaymentResultDTO
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
@@ -152,10 +149,9 @@ func (h *handler) status(c *gin.Context) {
// callback godoc
// @Summary GBÜS payment callback
// @Description GBÜS redirects the browser here after payment; the real outcome is verified server-to-server before anything is finalized
// @Tags visa-master-payment
// @Tags visa-master-payment-orders
// @Produce json
// @Param paymentId query int true "Payment attempt ID"
// @Param lang query string false "Language of localized fields; all returns the full {en, ru, tm} objects" Enums(tm, ru, en, all) default(tm)
// @Success 200 {object} CallbackResultDTO
// @Router /visa-master-payment-orders/callback [get]
func (h *handler) callback(c *gin.Context) {

View File

@@ -58,17 +58,6 @@ type StatusResult struct {
RawResponse []byte
}
// InProgress reports an unpaid order GBÜS may still complete - registered
// but not attempted yet (0), pre-authorized (1) or in 3-D Secure (5) - so
// it must stay re-checkable instead of being finalized as failed. Reversed
// (3), refunded (4), declined (6) or any gateway error are final.
func (r StatusResult) InProgress() bool {
if r.ErrorCode != "" && r.ErrorCode != "0" {
return false
}
return r.OrderStatus == 0 || r.OrderStatus == 1 || r.OrderStatus == 5
}
// Client is the gateway contract. Plug a real HTTPClient in once
// credentials are configured; LogClient is a stand-in for local/dev use.
type Client interface {

View File

@@ -27,27 +27,6 @@ func TestRegisterResultSuccess(t *testing.T) {
}
}
func TestStatusResultInProgress(t *testing.T) {
cases := []struct {
name string
r StatusResult
want bool
}{
{"registered, not attempted", StatusResult{OrderStatus: 0, ErrorCode: "0"}, true},
{"pre-authorized", StatusResult{OrderStatus: 1}, true},
{"3-D Secure", StatusResult{OrderStatus: 5, ErrorCode: "0"}, true},
{"paid", StatusResult{Paid: true, OrderStatus: 2}, false},
{"reversed", StatusResult{OrderStatus: 3}, false},
{"declined", StatusResult{OrderStatus: 6, ErrorCode: "0"}, false},
{"gateway error", StatusResult{OrderStatus: 0, ErrorCode: "6"}, false},
}
for _, c := range cases {
if got := c.r.InProgress(); got != c.want {
t.Errorf("%s: InProgress()=%v want %v", c.name, got, c.want)
}
}
}
func TestLogClientAlwaysPaid(t *testing.T) {
c := NewLogClient(nil)
reg, err := c.Register(context.Background(), RegisterRequest{OrderNumber: "vmo-1-2", ReturnURL: "https://x/cb"})
@@ -95,8 +74,8 @@ func TestHTTPClientCheckStatusPaidMapping(t *testing.T) {
body string
paid bool
}{
{`{"orderStatus":2,"actionCode":"0"}`, true}, // 2 = deposited
{`{"orderStatus":1,"actionCode":0}`, false}, // numeric actionCode still decodes
{`{"orderStatus":2,"actionCode":"0"}`, true}, // 2 = deposited
{`{"orderStatus":1,"actionCode":0}`, false}, // numeric actionCode still decodes
{`{"orderStatus":6,"actionCode":"declined"}`, false},
}
for _, tc := range cases {