From 5c2f40c8290a4793c52c682775d67c4c2419bea4 Mon Sep 17 00:00:00 2001 From: Javad Date: Sun, 8 Jan 2023 12:39:21 +0330 Subject: [PATCH] fix: check status 201 for created transaction --- _example/idpay/main.go | 14 ++++++++++++-- providers/idpay/idpay.go | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/_example/idpay/main.go b/_example/idpay/main.go index 9dd6271..a97da04 100644 --- a/_example/idpay/main.go +++ b/_example/idpay/main.go @@ -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) } @@ -22,11 +22,21 @@ func main() { Phone: "09151234567", Mail: "idpay@gmail.com", 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) } diff --git a/providers/idpay/idpay.go b/providers/idpay/idpay.go index 5897520..625a444 100644 --- a/providers/idpay/idpay.go +++ b/providers/idpay/idpay.go @@ -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()) }