Skip to content

Commit

Permalink
update module path
Browse files Browse the repository at this point in the history
  • Loading branch information
pandudpn committed Jul 19, 2022
1 parent 59831e6 commit c9e8c67
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 27 deletions.
6 changes: 3 additions & 3 deletions config.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package pg

import (
"github.com/pandudpn/go-pg/utils"
"github.com/pandudpn/go-payment-gateway/utils"
"github.com/sirupsen/logrus"
)

Expand All @@ -17,13 +17,13 @@ type Config struct {
//
// Default: Staging
Environment env `json:"environment"`

// When set to true, this will log your request, response or error to stdout
// Use logrus as logging
//
// Default: true
Logging bool `json:"logging"`

// Format log when Logging is set to true
//
// Default: logrus.TextFormatter | [ts] - [level] - [message]
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module github.com/pandudpn/go-pg
module github.com/pandudpn/go-payment-gateway

go 1.18

require github.com/sirupsen/logrus v1.8.1

require (
github.com/google/uuid v1.3.0 // indirect
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
github.com/google/uuid v1.3.0
github.com/sirupsen/logrus v1.9.0
)

require golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
14 changes: 9 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
2 changes: 1 addition & 1 deletion internal/midtrans/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"net/http"
"strconv"

"github.com/pandudpn/go-pg/utils"
"github.com/pandudpn/go-payment-gateway/utils"
)

// SetUsername for Authorization Basic
Expand Down
6 changes: 3 additions & 3 deletions midtrans.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"
"time"

mds "github.com/pandudpn/go-pg/internal/midtrans"
"github.com/pandudpn/go-pg/utils"
mds "github.com/pandudpn/go-payment-gateway/internal/midtrans"
"github.com/pandudpn/go-payment-gateway/utils"
)

const (
Expand All @@ -22,7 +22,7 @@ type Midtrans struct {
credentials *Credentials
}

// CreateEWalletCharge charge a payment e-wallet
// CreateEWalletCharge charge a payment e-wallet to payment gateway midtrans
func (p *PG) CreateEWalletCharge(e *mds.EWallet) (*mds.ChargeResponse, error) {
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(10)*time.Second)
defer cancel()
Expand Down
20 changes: 10 additions & 10 deletions pg.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package pg

import (
"fmt"
"github.com/pandudpn/go-pg/utils"

"github.com/pandudpn/go-payment-gateway/utils"
)

const (
Expand All @@ -15,10 +15,10 @@ const (
type PG struct {
// configuration payment gateway
config *Config

// midtrans configuration
midtrans *Midtrans

// xendit configuration
xendit *Xendit
}
Expand All @@ -30,29 +30,29 @@ func New(cfg ...*Config) *PG {
midtrans: &Midtrans{uri: mdUriSandbox, credentials: &Credentials{}},
xendit: &Xendit{uri: xndUri, credentials: &Credentials{}},
}

if len(cfg) > 0 {
p.config = cfg[0]
}
// disable logging
if !p.config.Logging {
utils.DisableLogging()
}

// when configuration from parameter and env is production
// set all configuration to production
if p.config.Environment == Production {
p.SetProduction()
}

return p
}

// SetProduction environment and base url gateway
func (p *PG) SetProduction() {
// re-value env with Production
p.config.Environment = Production

// set production uri to all gateway
p.midtrans.uri = mdUriProduction
}
Expand All @@ -63,7 +63,7 @@ func (p *PG) SetMidtransCredentials(clientSecret string) error {
if !checkCredentials(p.config.Environment, clientSecret, midtrans) {
return fmt.Errorf("%s credentials invalid for environment %s", midtrans, p.config.Environment)
}

p.midtrans.credentials.ClientSecret = clientSecret
return nil
}
Expand All @@ -74,7 +74,7 @@ func (p *PG) SetXenditCredentials(clientSecret string) error {
if !checkCredentials(p.config.Environment, clientSecret, xendit) {
return fmt.Errorf("%s credentials invalid for environment %s", xendit, p.config.Environment)
}

p.xendit.credentials.ClientSecret = clientSecret
return nil
}

0 comments on commit c9e8c67

Please sign in to comment.