From 66dac4dadb4e64f98d1e213bf42cb19646e2346f Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 2 Aug 2018 14:33:56 +0700 Subject: [PATCH 1/5] Fix status code not available --- client.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index 4f56713..735fa82 100644 --- a/client.go +++ b/client.go @@ -103,7 +103,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 + } + v.(map[string]interface{})["status_code"] = string(res.StatusCode) } return nil From f2ac4da8d7678c635a50e56a25d1195328208bbd Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 2 Aug 2018 14:48:52 +0700 Subject: [PATCH 2/5] Change set value of StatusCode using reflection --- client.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index 735fa82..e9255e0 100644 --- a/client.go +++ b/client.go @@ -7,6 +7,8 @@ import ( "log" "net/http" "os" + "reflect" + "strconv" "time" ) @@ -106,7 +108,7 @@ func (c *Client) ExecuteRequest(req *http.Request, v interface{}) error { if err = json.Unmarshal(resBody, v); err != nil { return err } - v.(map[string]interface{})["status_code"] = string(res.StatusCode) + reflect.ValueOf(v).Elem().FieldByName("StatusCode").SetString(strconv.Itoa(res.StatusCode)) } return nil From 5e575a24c2c91d46544be77b8d726cd8c9276bd9 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 3 Aug 2018 16:19:24 +0700 Subject: [PATCH 3/5] Add BNI VA on PaymentType --- paysource.go | 4 ++++ paysource_test.go | 3 +++ 2 files changed, 7 insertions(+) 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) From cd37d339f167af948974e57f0994df99080e7ecb Mon Sep 17 00:00:00 2001 From: Rizda Dwi Prasetya Date: Fri, 3 Aug 2018 18:01:15 +0700 Subject: [PATCH 4/5] fix installment datatype Installment term should be `int` instead of slice --- request.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/request.go b/request.go index 31baf70..92ada1d 100644 --- a/request.go +++ b/request.go @@ -48,7 +48,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"` From 7915ed8e8abbc906f0fdbb278313fc210df6fc3c Mon Sep 17 00:00:00 2001 From: Arman Date: Mon, 6 Aug 2018 16:05:14 +0700 Subject: [PATCH 5/5] Omitempty for key in customer detail --- request.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/request.go b/request.go index d64f02d..a80b10a 100644 --- a/request.go +++ b/request.go @@ -22,13 +22,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"` }