Use standard http package instead of gorequest
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -22,3 +22,5 @@ _testmain.go
|
|||||||
*.exe
|
*.exe
|
||||||
*.test
|
*.test
|
||||||
*.prof
|
*.prof
|
||||||
|
|
||||||
|
coverage.txt
|
||||||
|
|||||||
@@ -4,11 +4,9 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/parnurzeal/gorequest"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -96,22 +94,22 @@ func NewWithConfig(config Config) Client {
|
|||||||
func (c Client) Verify(userID string, receiptID string) (IAPResponse, error) {
|
func (c Client) Verify(userID string, receiptID string) (IAPResponse, error) {
|
||||||
result := IAPResponse{}
|
result := IAPResponse{}
|
||||||
url := fmt.Sprintf("%v/version/1.0/verifyReceiptId/developer/%v/user/%v/receiptId/%v", c.URL, c.Secret, userID, receiptID)
|
url := fmt.Sprintf("%v/version/1.0/verifyReceiptId/developer/%v/user/%v/receiptId/%v", c.URL, c.Secret, userID, receiptID)
|
||||||
res, body, errs := gorequest.New().
|
client := http.Client{
|
||||||
Get(url).
|
Timeout: c.TimeOut,
|
||||||
Timeout(c.TimeOut).
|
|
||||||
End()
|
|
||||||
|
|
||||||
if errs != nil {
|
|
||||||
return result, fmt.Errorf("%v", errs)
|
|
||||||
}
|
}
|
||||||
|
resp, err := client.Get(url)
|
||||||
|
if err != nil {
|
||||||
|
return result, fmt.Errorf("%v", err)
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
if res.StatusCode < 200 || res.StatusCode >= 300 {
|
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||||
responseError := IAPResponseError{}
|
responseError := IAPResponseError{}
|
||||||
json.NewDecoder(strings.NewReader(body)).Decode(&responseError)
|
err = json.NewDecoder(resp.Body).Decode(&responseError)
|
||||||
return result, errors.New(responseError.Message)
|
return result, errors.New(responseError.Message)
|
||||||
}
|
}
|
||||||
|
|
||||||
err := json.NewDecoder(strings.NewReader(body)).Decode(&result)
|
err = json.NewDecoder(resp.Body).Decode(&result)
|
||||||
|
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user