Skip to content

Commit

Permalink
Updated readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jcobhams authored and jcobhams committed Aug 3, 2020
1 parent fca1269 commit 032eab2
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 34 deletions.
1 change: 1 addition & 0 deletions general.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func (g *general) GetTransaction(reference string) (*GeneralTransactionResponse,
url := fmt.Sprintf("%v/v2/transactions/%v", g.APIBaseUrl, reference)
rawResponse, statusCode, err := g.getRequest(url, requestAuthTypeBearer)
if err != nil {
fmt.Println(err)
return nil, err
}

Expand Down
72 changes: 38 additions & 34 deletions testhelpers/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,43 @@ func mockTransactionStatusResponseData() string {
"requestSuccessful": true,
"responseMessage": "success",
"responseCode": "0",
"responseBody": {
"responseBody": %v
}`, FakeInflowNotificationPayload())
}

func mockGetBanksResponseData() string {
return fmt.Sprintf(`{
"requestSuccessful": true,
"responseMessage": "success",
"responseCode": "0",
"responseBody": [
{
"name": "Access bank",
"code": "044",
"ussdTemplate": "*901*Amount*AccountNumber#",
"baseUssdCode": "*901#",
"transferUssdTemplate": "*901*AccountNumber#"
},
{
"name": "Coronation Bank",
"code": "559",
"ussdTemplate": null,
"baseUssdCode": null,
"transferUssdTemplate": null
}
]
}`)
}

func GenerateTransactionHash(secretKey string) string {
rawStr := fmt.Sprintf("%v|%v|%v|%v|%v", secretKey, PaymentReference, Amount, PaidOn, TransferReference)
h := sha512.New()
h.Write([]byte(rawStr))
return fmt.Sprintf("%x", h.Sum(nil))
}

func FakeInflowNotificationPayload() string {
return fmt.Sprintf(`{
"transactionReference": "%v",
"paymentReference": "%v",
"amountPaid": "%v",
Expand Down Expand Up @@ -351,39 +387,7 @@ func mockTransactionStatusResponseData() string {
"name": "Damilare",
"age": "45"
}
}
}`, TransferReference, PaymentReference, Amount, Amount, PaidOn, GenerateTransactionHash(SecretKey), AccountName, Amount, CustomerEmail, CustomerName)
}

func mockGetBanksResponseData() string {
return fmt.Sprintf(`{
"requestSuccessful": true,
"responseMessage": "success",
"responseCode": "0",
"responseBody": [
{
"name": "Access bank",
"code": "044",
"ussdTemplate": "*901*Amount*AccountNumber#",
"baseUssdCode": "*901#",
"transferUssdTemplate": "*901*AccountNumber#"
},
{
"name": "Coronation Bank",
"code": "559",
"ussdTemplate": null,
"baseUssdCode": null,
"transferUssdTemplate": null
}
]
}`)
}

func GenerateTransactionHash(secretKey string) string {
rawStr := fmt.Sprintf("%v|%v|%v|%v|%v", secretKey, PaymentReference, Amount, PaidOn, TransferReference)
h := sha512.New()
h.Write([]byte(rawStr))
return fmt.Sprintf("%x", h.Sum(nil))
}`, TransferReference, PaymentReference, Amount, Amount, PaidOn, GenerateTransactionHash(SecretKey), AccountName, Amount, CustomerEmail, CustomerName)
}

//MockAPIServer initializes a test HTTP server useful for request mocking, Integration tests and Client configuration
Expand Down

0 comments on commit 032eab2

Please sign in to comment.