Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go 12 And Change Authentication to accept string instead of bool #41

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea
.idea
main
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ go:
- "1.8.x"
- "1.9.x"
- "1.10.x"
- "1.11.x"
- "1.12.x"

script:
- go test ./...
Expand Down
5 changes: 5 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/veritrans/go-midtrans

go 1.12

require github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
30 changes: 17 additions & 13 deletions request.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -38,29 +38,32 @@ 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
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
Expand Down Expand Up @@ -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"`
Expand Down
2 changes: 1 addition & 1 deletion snap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down