Skip to content

Commit

Permalink
Merge pull request #54 from hamidfzm/main
Browse files Browse the repository at this point in the history
Fix mellat provider not using client transporter
  • Loading branch information
Ja7ad authored Dec 10, 2024
2 parents db4b096 + 23e4a88 commit 300b30a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions providers/mellat/mellat.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,18 @@ func (m *Mellat) CreateTransaction(ctx context.Context, req *paymentRequest) (*P
if err != nil {
return nil, err
}
return request[*PaymentResponse]("POST", m.url, payload)
return request[*PaymentResponse](m.client, http.MethodPost, m.url, payload)
}

func (m *Mellat) VerifyTransaction(ctx context.Context, req *verifyRequest) (*VerifyResponse, error) {
payload, err := req.raw(m.username, m.password)
if err != nil {
return nil, err
}
return request[*VerifyResponse]("POST", m.url, payload)
return request[*VerifyResponse](m.client, http.MethodPost, m.url, payload)
}
func request[Rs response](
clientTransporter client.Transporter,
method, url string,
body []byte,
) (
Expand All @@ -60,7 +61,7 @@ func request[Rs response](
}
request.Header.Set("Content-Type", "text/xml")
request.Header.Set("charset", "utf-8")
resp, err := http.DefaultClient.Do(request)
resp, err := clientTransporter.GetClient().Do(request)
if err != nil {
return response, err
}
Expand All @@ -73,7 +74,10 @@ func request[Rs response](
return response, fmt.Errorf("error raw response: %v", string(responseBody))
}
if resp.StatusCode != http.StatusOK|http.StatusCreated {
return response, status.New(response.ResponseCode(), http.StatusFailedDependency, codes.OK, fmt.Sprintf("response code %v", response.ResponseCode()))
return response, status.New(
response.ResponseCode(), http.StatusFailedDependency, codes.OK,
fmt.Sprintf("response code %v", response.ResponseCode()),
)
}
if err := response.modifyResponse(); err != nil {
return response, err
Expand Down

0 comments on commit 300b30a

Please sign in to comment.