Skip to content

Commit

Permalink
Finished create payouts
Browse files Browse the repository at this point in the history
  • Loading branch information
andhikamaheva committed Oct 3, 2018
1 parent 940dab9 commit 81d7c51
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 65 deletions.
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (c *Client) ExecuteRequest(req *http.Request, v interface{}) error {
logger := c.Logger

if logLevel > 1 {
logger.Println("Request ", req.Method, ": ", req.URL.Host, req.URL.Path)
logger.Println("Request ", req.Method, ": ", req.URL)
}

start := time.Now()
Expand Down
66 changes: 6 additions & 60 deletions iris.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,71 +54,17 @@ func (gateway *IrisGateway) ValidateBankAccount(bankName string, account string)
return resp, nil
}

// CaptureCard : Capture an authorized transaction for card payment
func (gateway *IrisGateway) CaptureCard(req *CaptureReq) (Response, error) {
resp := Response{}
jsonReq, _ := json.Marshal(req)

err := gateway.Call("POST", "v2/capture", bytes.NewBuffer(jsonReq), &resp)
if err != nil {
gateway.Client.Logger.Println("Error capturing: ", err)
return resp, err
}

if resp.StatusMessage != "" {
gateway.Client.Logger.Println(resp.StatusMessage)
}

return resp, nil
}

// Approve : Approve order using order ID
func (gateway *IrisGateway) Approve(orderID string) (Response, error) {
resp := Response{}

err := gateway.Call("POST", "v2/"+orderID+"/approve", nil, &resp)
if err != nil {
gateway.Client.Logger.Println("Error approving: ", err)
return resp, err
}

if resp.StatusMessage != "" {
gateway.Client.Logger.Println(resp.StatusMessage)
}
// CreatePayouts : Create Payout with single or multiple payouts
func (gateway *IrisGateway) CreatePayouts(req PayoutReq) (Payout, error) {
resp := Payout{}

return resp, nil
}

// Cancel : Cancel order using order ID
func (gateway *IrisGateway) Cancel(orderID string) (Response, error) {
resp := Response{}

err := gateway.Call("POST", "v2/"+orderID+"/cancel", nil, &resp)
if err != nil {
gateway.Client.Logger.Println("Error approving: ", err)
return resp, err
}

if resp.StatusMessage != "" {
gateway.Client.Logger.Println(resp.StatusMessage)
}

return resp, nil
}

// Expire : change order status to expired using order ID
func (gateway *IrisGateway) Expire(orderID string) (Response, error) {
resp := Response{}
jsonReq, _ := json.Marshal(req)

err := gateway.Call("POST", "v2/"+orderID+"/expire", nil, &resp)
err := gateway.Call("POST", "api/v1/payouts", bytes.NewBuffer(jsonReq), &resp)
if err != nil {
gateway.Client.Logger.Println("Error approving: ", err)
gateway.Client.Logger.Println("Error create payouts: ", err)
return resp, err
}

if resp.StatusMessage != "" {
gateway.Client.Logger.Println(resp.StatusMessage)
}

return resp, nil
}
15 changes: 15 additions & 0 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,18 @@ type BeneficiariesReq struct {
AliasName string `json:"alias_name"`
Email string `json:"email,omitempty"`
}

// PayoutReq : Represent create payout
type PayoutReq struct {
Payouts []PayoutDetails `json:"payouts"`
}

// PayoutDetails : Represent Payout Details
type PayoutDetails struct {
BeneficiaryName string `json:"beneficiary_name"`
BeneficiaryAccount string `json:"beneficiary_account"`
BeneficiaryEmail string `json:"beneficiary_email,omitempty"`
Amount string `json:"amount"`
Notes string `json:"notes"`
BankAccountID string `json:"bank_account_id,omitempty"`
}
15 changes: 11 additions & 4 deletions response.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,21 @@ 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"`
AccountNo string `json:"account_no"`
BankName string `json:"bank_name"`
ReffNumber string `json:"retrieval_reff_num"`
}

// Payout : Response for Payouts
type Payout struct {
Payouts []PayoutDetailsResponse `json:"payouts"`
}

// PayoutDetailsResponse : Detail Response Payout
type PayoutDetailsResponse struct {
Status string `json:"status"`
ReferenceNo string `json:"reference_no"`
}

0 comments on commit 81d7c51

Please sign in to comment.