Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/veritrans/go-midtrans
Browse files Browse the repository at this point in the history
* 'master' of https://github.com/veritrans/go-midtrans:
  Omitempty for key in customer detail
  fix installment datatype
  Add BNI VA on PaymentType
  Change set value of StatusCode using reflection
  Fix status code not available
  • Loading branch information
andhikamaheva committed Aug 20, 2018
2 parents 78d634e + dec72af commit fa8dda2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
7 changes: 6 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"log"
"net/http"
"os"
"reflect"
"strconv"
"time"
)

Expand Down Expand Up @@ -103,7 +105,10 @@ func (c *Client) ExecuteRequest(req *http.Request, v interface{}) error {
}

if v != nil {
return json.Unmarshal(resBody, v)
if err = json.Unmarshal(resBody, v); err != nil {
return err
}
reflect.ValueOf(v).Elem().FieldByName("StatusCode").SetString(strconv.Itoa(res.StatusCode))
}

return nil
Expand Down
4 changes: 4 additions & 0 deletions paysource.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ const (
// SourceBankTransfer : bank_transfer
SourceBankTransfer PaymentType = "bank_transfer"

// SourceBNIVA : bni_va
SourceBNIVA PaymentType = "bni_va"

// SourcePermataVA : permata_va
SourcePermataVA PaymentType = "permata_va"

Expand Down Expand Up @@ -76,6 +79,7 @@ var AllPaymentSource = []PaymentType{
SourceEchannel,
SourceIndosatDompetku,
SourceMandiriEcash,
SourceBNIVA,
SourcePermataVA,
SourceBCAVA,
SourceIndomaret,
Expand Down
3 changes: 3 additions & 0 deletions paysource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ func TestPaymentType(t *testing.T) {
is := is.New(t)
is.Equal("credit_card", midtrans.SourceCreditCard)
is.Equal("bank_transfer", midtrans.SourceBankTransfer)
is.Equal("bca_va", midtrans.SourceBCAVA)
is.Equal("permata_va", midtrans.SourcePermataVA)
is.Equal("bni_va", midtrans.SourceBNIVA)
is.Equal("cimb_clicks", midtrans.SourceCimbClicks)
is.Equal("danamon_online", midtrans.SourceDanamonOnline)
is.Equal("mandiri_clickpay", midtrans.SourceMandiriClickpay)
Expand Down
10 changes: 5 additions & 5 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ type CustAddress struct {
// CustDetail : Represent the customer detail
type CustDetail struct {
// first name
FName string `json:"first_name"`
FName string `json:"first_name,omitempty"`

// last name
LName string `json:"last_name"`
LName string `json:"last_name,omitempty"`

Email string `json:"email"`
Phone string `json:"phone"`
Email string `json:"email,omitempty"`
Phone string `json:"phone,omitempty"`
BillAddr *CustAddress `json:"billing_address,omitempty"`
ShipAddr *CustAddress `json:"customer_address,omitempty"`
}
Expand All @@ -52,7 +52,7 @@ type CreditCardDetail struct {
TokenID string `json:"token_id"`
Bank string `json:"bank,omitempty"`
Bins []string `json:"bins,omitempty"`
InstallmentTerm []int8 `json:"installment_term,omitempty"`
InstallmentTerm int8 `json:"installment_term,omitempty"`
Type string `json:"type,omitempty"`
// indicate if generated token should be saved for next charge
SaveTokenID bool `json:"save_token_id,omitempty"`
Expand Down

0 comments on commit fa8dda2

Please sign in to comment.