fixed error
This commit is contained in:
@@ -73,11 +73,33 @@ func (c *HTTPClient) Register(ctx context.Context, req RegisterRequest) (Registe
|
||||
}
|
||||
|
||||
type statusResponse struct {
|
||||
OrderStatus int `json:"orderStatus"`
|
||||
ActionCode string `json:"actionCode"`
|
||||
ActionCodeDescription string `json:"actionCodeDescription"`
|
||||
ErrorCode string `json:"errorCode"`
|
||||
ErrorMessage string `json:"errorMessage"`
|
||||
OrderStatus int `json:"orderStatus"`
|
||||
ActionCode flexibleString `json:"actionCode"`
|
||||
ActionCodeDescription string `json:"actionCodeDescription"`
|
||||
ErrorCode string `json:"errorCode"`
|
||||
ErrorMessage string `json:"errorMessage"`
|
||||
}
|
||||
|
||||
// flexibleString unmarshals a JSON string or a JSON number into a Go
|
||||
// string. GBÜS is documented to send actionCode as a string, but some
|
||||
// deployments send it as a bare number, so decoding must accept either.
|
||||
type flexibleString string
|
||||
|
||||
func (s *flexibleString) UnmarshalJSON(data []byte) error {
|
||||
if string(data) == "null" {
|
||||
*s = ""
|
||||
return nil
|
||||
}
|
||||
if len(data) > 0 && data[0] == '"' {
|
||||
var str string
|
||||
if err := json.Unmarshal(data, &str); err != nil {
|
||||
return err
|
||||
}
|
||||
*s = flexibleString(str)
|
||||
return nil
|
||||
}
|
||||
*s = flexibleString(data)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *HTTPClient) CheckStatus(ctx context.Context, req StatusRequest) (StatusResult, error) {
|
||||
@@ -101,7 +123,7 @@ func (c *HTTPClient) CheckStatus(ctx context.Context, req StatusRequest) (Status
|
||||
return StatusResult{
|
||||
Paid: parsed.OrderStatus == 2,
|
||||
OrderStatus: parsed.OrderStatus,
|
||||
ActionCode: parsed.ActionCode,
|
||||
ActionCode: string(parsed.ActionCode),
|
||||
ActionCodeDescription: parsed.ActionCodeDescription,
|
||||
ErrorCode: parsed.ErrorCode,
|
||||
ErrorMessage: parsed.ErrorMessage,
|
||||
|
||||
Reference in New Issue
Block a user