added log
CI/CD / Vet, test, build (push) Has been cancelled
CI/CD / Docker image (push) Has been cancelled
CI/CD / Deploy binary to server (push) Has been cancelled

This commit is contained in:
guwandyk committed 2026-09-28 16:53:34 +05:00
1 parent c01429d2a4
commit e47e8c24d0
7 files changed
+400 -21

No files matched your search

+13 -2
View File
@@ -25,16 +25,27 @@ const mpiBaseURL = "https://mpi.gov.tm/payment/rest/"
// the gateway's own convention exactly rather than normalizing them.
type HTTPClient struct {
httpClient *http.Client
baseURL string
logger *logging.Logger
}
func NewHTTPClient(logger *logging.Logger) *HTTPClient {
return &HTTPClient{
httpClient: &http.Client{Timeout: 20 * time.Second},
baseURL: mpiBaseURL,
logger: logger,
}
}
// base returns the configured gateway base URL, falling back to the fixed
// GBÜS endpoint when the client was constructed without one.
func (c *HTTPClient) base() string {
if c.baseURL == "" {
return mpiBaseURL
}
return c.baseURL
}
type registerResponse struct {
OrderId string `json:"orderId"`
FormUrl string `json:"formUrl"`
@@ -55,7 +66,7 @@ func (c *HTTPClient) Register(ctx context.Context, req RegisterRequest) (Registe
"description": {req.Description},
}
body, err := c.do(ctx, http.MethodGet, mpiBaseURL+"register.do", query, nil)
body, err := c.do(ctx, http.MethodGet, c.base()+"register.do", query, nil)
if err != nil {
return RegisterResult{}, err
}
@@ -110,7 +121,7 @@ func (c *HTTPClient) CheckStatus(ctx context.Context, req StatusRequest) (Status
"password": {req.Password},
}
body, err := c.do(ctx, http.MethodPost, mpiBaseURL+"getOrderStatusExtended.do", nil, form)
body, err := c.do(ctx, http.MethodPost, c.base()+"getOrderStatusExtended.do", nil, form)
if err != nil {
return StatusResult{}, err
}