From 849b936a1630c4e4818e5d40e1ebe115a87fcf61 Mon Sep 17 00:00:00 2001 From: Imre Nagi Date: Sat, 27 Jul 2019 11:57:47 +0700 Subject: [PATCH 1/4] Enable go-mod for golang version > 1.11.x and change authentication type into string instead of accepting booolean --- .gitignore | 3 ++- .travis.yml | 2 ++ go.mod | 5 +++++ go.sum | 3 +++ request.go | 8 ++++---- 5 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 go.mod create mode 100644 go.sum diff --git a/.gitignore b/.gitignore index 723ef36..92c16db 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.idea \ No newline at end of file +.idea +main \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index a469c0b..d6e4111 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,8 @@ go: - "1.8.x" - "1.9.x" - "1.10.x" + - "1.11.x" + - "1.12.x" script: - go test ./... diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..1a388e4 --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module github.com/veritrans/go-midtrans + +go 1.12 + +require github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927 diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..7187f04 --- /dev/null +++ b/go.sum @@ -0,0 +1,3 @@ +github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927 h1:SKI1/fuSdodxmNNyVBR8d7X/HuLnRpvvFO0AgyQk764= +github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927/go.mod h1:h/aW8ynjgkuj+NQRlZcDbAbM1ORAbXjXX77sX7T289U= +github.com/veritrans/go-midtrans v0.0.0-20180710074703-234c054b1e86/go.mod h1:21mwYsDK+z+5kR2fvUB8n2yijZZm504Vjzk1s0rNQJg= diff --git a/request.go b/request.go index 4030fc2..216d43f 100644 --- a/request.go +++ b/request.go @@ -44,9 +44,9 @@ type TransactionDetails struct { // ExpiryDetail : Represent SNAP expiry details type ExpiryDetail struct { - StartTime string `json:"start_time,omitempty"` - Unit string `json:"unit"` - Duration int64 `json:"duration"` + StartTime string `json:"start_time,omitempty"` + Unit string `json:"unit"` + Duration int64 `json:"duration"` } // CreditCardDetail : Represent credit card detail @@ -60,7 +60,7 @@ type CreditCardDetail struct { // indicate if generated token should be saved for next charge SaveTokenID bool `json:"save_token_id,omitempty"` SavedTokenIDExpireAt string `json:"saved_token_id_expired_at,omitempty"` - Authentication bool `json:"authentication,omitempty"` + Authentication string `json:"authentication,omitempty"` } // PermataBankTransferDetail : Represent Permata bank_transfer detail From fac4578ded76ed2536e7cd202b67a7f299999307 Mon Sep 17 00:00:00 2001 From: Imre Nagi Date: Sat, 27 Jul 2019 22:55:12 +0700 Subject: [PATCH 2/4] Change GrossAmt to float64 --- request.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/request.go b/request.go index 216d43f..289c788 100644 --- a/request.go +++ b/request.go @@ -38,8 +38,8 @@ type CustDetail struct { // TransactionDetails : Represent transaction details type TransactionDetails struct { - OrderID string `json:"order_id"` - GrossAmt int64 `json:"gross_amount"` + OrderID string `json:"order_id"` + GrossAmt float64 `json:"gross_amount"` } // ExpiryDetail : Represent SNAP expiry details From 1f63be5de9fc319f04327bbd2d4de8c06a1b22d2 Mon Sep 17 00:00:00 2001 From: Imre Nagi Date: Sat, 27 Jul 2019 22:59:11 +0700 Subject: [PATCH 3/4] Fix error --- snap.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snap.go b/snap.go index 4254277..702de15 100644 --- a/snap.go +++ b/snap.go @@ -23,7 +23,7 @@ func (gateway *SnapGateway) Call(method, path string, body io.Reader, v interfac } // GetTokenQuick : Quickly get token without constructing the body manually -func (gateway *SnapGateway) GetTokenQuick(orderID string, grossAmount int64) (SnapResponse, error) { +func (gateway *SnapGateway) GetTokenQuick(orderID string, grossAmount float64) (SnapResponse, error) { return gateway.GetToken(&SnapReq{ TransactionDetails: TransactionDetails{ OrderID: orderID, From a2e1891972aad2091449d0a30c578b5616b3500b Mon Sep 17 00:00:00 2001 From: Imre Nagi Date: Sat, 27 Jul 2019 23:15:57 +0700 Subject: [PATCH 4/4] Add some missing fields --- request.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/request.go b/request.go index 289c788..cb341e6 100644 --- a/request.go +++ b/request.go @@ -2,13 +2,13 @@ package midtrans // ItemDetail : Represent the transaction details type ItemDetail struct { - ID string `json:"id"` - Name string `json:"name"` - Price int64 `json:"price"` - Qty int32 `json:"quantity"` - Brand string `json:"brand,omitempty"` - Category string `json:"category,omitempty"` - MerchantName string `json:"merchant_name,omitempty"` + ID string `json:"id"` + Name string `json:"name"` + Price float64 `json:"price"` + Qty int32 `json:"quantity"` + Brand string `json:"brand,omitempty"` + Category string `json:"category,omitempty"` + MerchantName string `json:"merchant_name,omitempty"` } // CustAddress : Represent the customer address @@ -38,6 +38,7 @@ type CustDetail struct { // TransactionDetails : Represent transaction details type TransactionDetails struct { + Currency string `json:"currency"` OrderID string `json:"order_id"` GrossAmt float64 `json:"gross_amount"` } @@ -54,12 +55,14 @@ type CreditCardDetail struct { Secure bool `json:"secure,omitempty"` TokenID string `json:"token_id"` Bank string `json:"bank,omitempty"` + Channel string `json:"channel,omitempty"` Bins []string `json:"bins,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"` SavedTokenIDExpireAt string `json:"saved_token_id_expired_at,omitempty"` + SaveCard bool `json:"save_card,omitempty"` Authentication string `json:"authentication,omitempty"` } @@ -192,6 +195,7 @@ type ChargeReq struct { Gopay *GopayDetail `json:"gopay,omitempty"` Items *[]ItemDetail `json:"item_details,omitempty"` + UserID string `json:"user_id"` CustField1 string `json:"custom_field1,omitempty"` CustField2 string `json:"custom_field2,omitempty"` CustField3 string `json:"custom_field3,omitempty"`