Skip to content

Commit 5c2f40c

Browse files
committed
fix: check status 201 for created transaction
1 parent bfcd323 commit 5c2f40c

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

_example/idpay/main.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010

1111
func main() {
1212
c := client.New()
13-
i, err := idpay.New(c, "YOUR_API_KEY", true)
13+
i, err := idpay.New(c, "key", true)
1414
if err != nil {
1515
log.Fatal(err)
1616
}
@@ -22,11 +22,21 @@ func main() {
2222
Phone: "09151234567",
2323
2424
Desc: "example description",
25-
Callback: "http://example.com/callback",
25+
Callback: "https://example.com/callback",
2626
})
2727
if err != nil {
2828
log.Fatal(err)
2929
}
3030

3131
fmt.Println(resp)
32+
33+
verifyResp, err := i.VerifyTransaction(context.Background(), &idpay.VerifyRequest{
34+
Id: resp.Id,
35+
OrderId: "xxxxxxxx-xxxxxx-xxxx",
36+
})
37+
if err != nil {
38+
log.Fatal(err)
39+
}
40+
41+
fmt.Println(verifyResp)
3242
}

providers/idpay/idpay.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func request[RQ any, RS any](ctx context.Context, i *IdPay, req RQ, baseUrl stri
105105
return response, status.New(0, http.StatusInternalServerError, codes.Internal, err.Error())
106106
}
107107

108-
if resp.GetHttpResponse().StatusCode != http.StatusOK {
108+
if resp.GetHttpResponse().StatusCode != http.StatusOK|http.StatusCreated {
109109
if err := resp.GetJSON(errResp); err != nil {
110110
return response, status.New(0, http.StatusInternalServerError, codes.Internal, err.Error())
111111
}

0 commit comments

Comments
 (0)