diff --git a/client.go b/client.go index 4f56713..e9255e0 100644 --- a/client.go +++ b/client.go @@ -7,6 +7,8 @@ import ( "log" "net/http" "os" + "reflect" + "strconv" "time" ) @@ -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 diff --git a/paysource.go b/paysource.go index eb323a0..a42697a 100644 --- a/paysource.go +++ b/paysource.go @@ -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" @@ -76,6 +79,7 @@ var AllPaymentSource = []PaymentType{ SourceEchannel, SourceIndosatDompetku, SourceMandiriEcash, + SourceBNIVA, SourcePermataVA, SourceBCAVA, SourceIndomaret, diff --git a/paysource_test.go b/paysource_test.go index 261090e..5975ef2 100644 --- a/paysource_test.go +++ b/paysource_test.go @@ -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) diff --git a/request.go b/request.go index 12c91ef..d11c401 100644 --- a/request.go +++ b/request.go @@ -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"` } @@ -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"`