/
search.go
39 lines (31 loc) · 891 Bytes
/
search.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package methods
import (
"encoding/json"
"github.com/dreygur/bkashgo/common"
"github.com/dreygur/bkashgo/hooks"
"github.com/dreygur/bkashgo/models"
)
// Search for Transactions
func (b *Bkash) Search(trxID string, token *models.TokenResponse) (*models.SearchTransactionResponse, error) {
if b.AppKey == "" || token.IdToken == "" || trxID == "" {
return nil, common.ErrEmptyRequiredField
}
executePayment := hooks.GenerateURI(b.IsLiveStore, common.BKASH_SEARCH_TRXN_URI)
request := models.SearchTransactionRequest{
TrxID: trxID,
}
jsonData, err := json.Marshal(request)
if err != nil {
return nil, err
}
body, err := hooks.DoRequest(jsonData, token.IdToken, b.AppKey, executePayment, true)
if err != nil {
return nil, err
}
var resp models.SearchTransactionResponse
err = json.Unmarshal(body, &resp)
if err != nil {
return nil, err
}
return &resp, nil
}