-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from brokeyourbike/get-gbp-payment
Return correct value when fetching GBP transaction
- Loading branch information
Showing
4 changed files
with
125 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"transaction": { | ||
"amount": { | ||
"instructedAmount": 100.00, | ||
"currency": "GBP" | ||
}, | ||
"counterpartAccount": { | ||
"identification": { | ||
"iban": "string", | ||
"accountName": "string", | ||
"sortCode": "string", | ||
"accountNumber": "string", | ||
"reference": "string", | ||
"other": { | ||
"identification": "string", | ||
"schemeName": { | ||
"code": "BBAN", | ||
"proprietary": "string" | ||
}, | ||
"issuer": "string" | ||
} | ||
} | ||
}, | ||
"debitCreditCode": "CRDT", | ||
"endToEndIdentifier": "string", | ||
"transactionId": "6ea6dd13-eaad-4e1a-990c-6533a177dbb4", | ||
"transactionReference": "string", | ||
"transactionTime": "2019-08-24T14:15:22Z", | ||
"status": "ACCP", | ||
"ultimateBeneficiaryAccount": { | ||
"id": "e98f9678-582f-4b12-979b-a6f9f6dc9ce7", | ||
"iban": "string", | ||
"bban": "string", | ||
"upic": "string", | ||
"cuid": "string" | ||
}, | ||
"ultimateRemitterAccount": { | ||
"id": "09998c4f-eef4-43f8-beb5-46cd879439fb", | ||
"iban": "string", | ||
"bban": "string", | ||
"upic": "string", | ||
"cuid": "string" | ||
} | ||
}, | ||
"halLinks": [ | ||
{ | ||
"name": "string", | ||
"href": "string", | ||
"templated": true | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package clearbank_test | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
_ "embed" | ||
"io" | ||
"net/http" | ||
"testing" | ||
|
||
"github.com/brokeyourbike/clearbank-api-client-go" | ||
"github.com/google/uuid" | ||
"github.com/stretchr/testify/assert" | ||
mock "github.com/stretchr/testify/mock" | ||
) | ||
|
||
//go:embed testdata/transactions-fetch-one-for-account.json | ||
var transactionsFetchOneForAccount []byte | ||
|
||
func TestFetchTransactionForAccount(t *testing.T) { | ||
mockHttpClient := clearbank.NewMockHttpClient(t) | ||
client := clearbank.NewClient("token", nil, clearbank.WithHTTPClient(mockHttpClient)) | ||
|
||
resp := &http.Response{StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader(transactionsFetchOneForAccount))} | ||
mockHttpClient.On("Do", mock.AnythingOfType("*http.Request")).Return(resp, nil).Once() | ||
|
||
got, err := client.FetchTransactionForAccount(context.TODO(), uuid.New(), uuid.New()) | ||
assert.NoError(t, err) | ||
assert.Equal(t, "6ea6dd13-eaad-4e1a-990c-6533a177dbb4", got.Transaction.TransactionID.String()) | ||
} | ||
|
||
func TestFetchTransactionForVirtualAccount(t *testing.T) { | ||
mockHttpClient := clearbank.NewMockHttpClient(t) | ||
client := clearbank.NewClient("token", nil, clearbank.WithHTTPClient(mockHttpClient)) | ||
|
||
resp := &http.Response{StatusCode: http.StatusOK, Body: io.NopCloser(bytes.NewReader(transactionsFetchOneForAccount))} | ||
mockHttpClient.On("Do", mock.AnythingOfType("*http.Request")).Return(resp, nil).Once() | ||
|
||
got, err := client.FetchTransactionForVirtualAccount(context.TODO(), uuid.New(), uuid.New(), uuid.New()) | ||
assert.NoError(t, err) | ||
assert.Equal(t, "6ea6dd13-eaad-4e1a-990c-6533a177dbb4", got.Transaction.TransactionID.String()) | ||
} |