diff --git a/amazon/validator.go b/amazon/validator.go index 46a29c1..ea32c8f 100644 --- a/amazon/validator.go +++ b/amazon/validator.go @@ -102,6 +102,9 @@ func (c *Client) Verify(ctx context.Context, userID string, receiptID string) (I if resp.StatusCode < 200 || resp.StatusCode >= 300 { responseError := IAPResponseError{} err = json.NewDecoder(resp.Body).Decode(&responseError) + if err != nil { + return result, err + } return result, errors.New(responseError.Message) } diff --git a/appstore/validator.go b/appstore/validator.go index 1a0ff80..4786f01 100644 --- a/appstore/validator.go +++ b/appstore/validator.go @@ -98,7 +98,9 @@ func NewWithClient(client *http.Client) *Client { // Verify sends receipts and gets validation result func (c *Client) Verify(ctx context.Context, reqBody IAPRequest, result interface{}) error { b := new(bytes.Buffer) - json.NewEncoder(b).Encode(reqBody) + if err := json.NewEncoder(b).Encode(reqBody); err != nil { + return err + } req, err := http.NewRequest("POST", c.ProductionURL, b) if err != nil {