Skip to content

Commit

Permalink
Finished CreateBeneficiaries and ValidateBankAccount
Browse files Browse the repository at this point in the history
  • Loading branch information
andhikamaheva committed Sep 27, 2018
1 parent e74c4b5 commit 940dab9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
10 changes: 4 additions & 6 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package midtrans

import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"log"
Expand Down Expand Up @@ -120,12 +119,11 @@ func (c *Client) ExecuteRequest(req *http.Request, v interface{}) error {
return err
}

fmt.Println(v)

if reflect.ValueOf(v).Elem().FieldByName("StatuCode").IsValid() == true {
reflect.ValueOf(v).Elem().FieldByName("StatusCode").SetString(strconv.Itoa(res.StatusCode))
if reflect.TypeOf(v).Elem().Kind() != reflect.Map {
if reflect.ValueOf(v).Elem().FieldByName("StatusCode").IsValid() {
reflect.ValueOf(v).Elem().FieldByName("StatusCode").SetString(strconv.Itoa(res.StatusCode))
}
}

}

return nil
Expand Down
8 changes: 4 additions & 4 deletions iris.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ func (gateway *IrisGateway) Call(method, path string, body io.Reader, v interfac
}

// CreateBeneficiaries : Perform transaction using ChargeReq
func (gateway *IrisGateway) CreateBeneficiaries(req *BeneficiariesReq) (interface{}, error) {
resp := make(map[string]interface{})
func (gateway *IrisGateway) CreateBeneficiaries(req *BeneficiariesReq) (map[string]interface{}, error) {
var resp map[string]interface{}
jsonReq, _ := json.Marshal(req)

err := gateway.Call("POST", "api/v1/beneficiaries", bytes.NewBuffer(jsonReq), &resp)
Expand All @@ -42,8 +42,8 @@ func (gateway *IrisGateway) CreateBeneficiaries(req *BeneficiariesReq) (interfac
}

// ValidateBankAccount : get order status using order ID
func (gateway *IrisGateway) ValidateBankAccount(bankName string, account string) (ValidateBankAcount, error) {
resp := ValidateBankAcount{}
func (gateway *IrisGateway) ValidateBankAccount(bankName string, account string) (map[string]interface{}, error) {
var resp map[string]interface{}

err := gateway.Call("GET", "api/v1/account_validation?bank="+bankName+"&account="+account, nil, &resp)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions response.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ type Beneficiaries struct {
Email string `json:"email"`
}

type Status struct {
Status string `json:"status"`
}

// ValidateBankAcount : Response for BankAcount
type ValidateBankAcount struct {
AccountName string `json:"account_name"`
Expand Down

0 comments on commit 940dab9

Please sign in to comment.