Total Lines | 34 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | package flutterwave |
||
2 | |||
3 | import ( |
||
4 | "context" |
||
5 | "encoding/json" |
||
6 | "fmt" |
||
7 | "net/http" |
||
8 | ) |
||
9 | |||
10 | // transactionsService is the API client for the `/v3/transactions` endpoint |
||
11 | type transactionsService service |
||
12 | |||
13 | // Verify the final status of a transaction |
||
14 | // |
||
15 | // API Docs: https://developer.flutterwave.com/reference/endpoints/transactions |
||
16 | func (service *transactionsService) Verify(ctx context.Context, transactionID int64) (*TransactionResponse, *Response, error) { |
||
17 | uri := fmt.Sprintf("/v3/transactions/%d/verify", transactionID) |
||
18 | |||
19 | request, err := service.client.newRequest(ctx, http.MethodGet, uri, nil) |
||
20 | if err != nil { |
||
21 | return nil, nil, err |
||
22 | } |
||
23 | |||
24 | response, err := service.client.do(request) |
||
25 | if err != nil { |
||
26 | return nil, response, err |
||
27 | } |
||
28 | |||
29 | var data TransactionResponse |
||
30 | if err = json.Unmarshal(*response.Body, &data); err != nil { |
||
31 | return nil, response, err |
||
32 | } |
||
33 | |||
34 | return &data, response, nil |
||
35 | } |
||
36 |