-
Notifications
You must be signed in to change notification settings - Fork 0
/
bank_transfer_test.go
50 lines (43 loc) · 1.45 KB
/
bank_transfer_test.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
40
41
42
43
44
45
46
47
48
49
50
package budpay
import (
"io"
"net/http"
"strings"
"testing"
"github.com/stretchr/testify/require"
)
func TestBankTransferCheckout(t *testing.T) {
requestResponseJSON := `{
"status": true,
"message": "Account generated successfully",
"data": {
"account_name": "Business Name / Firstname lastname",
"account_number": "1014692362",
"bank_name": "BudPay Bank"
}
}`
baseURL := "notreal.com"
hclient := &http.Client{Transport: RoundTripFunc(func(req *http.Request) *http.Response {
require.Equal(t, baseURL+"s2s/banktransfer/initialize", req.URL.String())
require.Equal(t, http.MethodPost, req.Method)
require.Equal(t, "application/json", req.Header.Get("Accept"))
require.Equal(t, "application/json", req.Header.Get("Content-Type"))
require.Equal(t, "Bearer testApiKey", req.Header.Get(AuthorizationHeaderKey))
return &http.Response{
StatusCode: http.StatusOK,
Body: io.NopCloser(strings.NewReader(requestResponseJSON)),
}
})}
client := BudPayClient{HTTPClient: hclient, apiKey: "testApiKey", encryptionkey: []byte("encryptKey"), BaseURL: baseURL}
client.HTTPClient = hclient
bankTransferRequest := &BankTransferRequest{
Email: "[email protected]",
Amount: "100",
Currency: "NGN",
Reference: "1253627873656276350",
Name: "Business Name / Firstname lastname",
}
customerResponse, err := client.BankTransferCheckout(bankTransferRequest)
require.NoError(t, err)
require.NotNil(t, customerResponse)
}