added log
This commit is contained in:
1 parent
c01429d2a4
commit
e47e8c24d0
7 files changed
+400
-21
No files matched your search
@@ -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
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user