Skip to content

Commit

Permalink
fix: check status 201 for created transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
Ja7ad committed Jan 8, 2023
1 parent bfcd323 commit 5c2f40c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions _example/idpay/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

func main() {
c := client.New()
i, err := idpay.New(c, "YOUR_API_KEY", true)
i, err := idpay.New(c, "key", true)
if err != nil {
log.Fatal(err)
}
Expand All @@ -22,11 +22,21 @@ func main() {
Phone: "09151234567",
Mail: "[email protected]",
Desc: "example description",
Callback: "http://example.com/callback",
Callback: "https://example.com/callback",
})
if err != nil {
log.Fatal(err)
}

fmt.Println(resp)

verifyResp, err := i.VerifyTransaction(context.Background(), &idpay.VerifyRequest{
Id: resp.Id,
OrderId: "xxxxxxxx-xxxxxx-xxxx",
})
if err != nil {
log.Fatal(err)
}

fmt.Println(verifyResp)
}
2 changes: 1 addition & 1 deletion providers/idpay/idpay.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func request[RQ any, RS any](ctx context.Context, i *IdPay, req RQ, baseUrl stri
return response, status.New(0, http.StatusInternalServerError, codes.Internal, err.Error())
}

if resp.GetHttpResponse().StatusCode != http.StatusOK {
if resp.GetHttpResponse().StatusCode != http.StatusOK|http.StatusCreated {
if err := resp.GetJSON(errResp); err != nil {
return response, status.New(0, http.StatusInternalServerError, codes.Internal, err.Error())
}
Expand Down

0 comments on commit 5c2f40c

Please sign in to comment.