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..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,15 +38,16 @@ type CustDetail struct { // TransactionDetails : Represent transaction details type TransactionDetails struct { - OrderID string `json:"order_id"` - GrossAmt int64 `json:"gross_amount"` + Currency string `json:"currency"` + OrderID string `json:"order_id"` + GrossAmt float64 `json:"gross_amount"` } // 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 @@ -54,13 +55,15 @@ 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"` - Authentication bool `json:"authentication,omitempty"` + SaveCard bool `json:"save_card,omitempty"` + Authentication string `json:"authentication,omitempty"` } // PermataBankTransferDetail : Represent Permata bank_transfer detail @@ -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"` 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,