Skip to content

Commit

Permalink
Merge pull request #92 from Adyen/develop
Browse files Browse the repository at this point in the history
Release v4
  • Loading branch information
KadoBOT authored Nov 30, 2020
2 parents 800cc2b + 3cefa60 commit d5b8347
Show file tree
Hide file tree
Showing 448 changed files with 33,895 additions and 9,373 deletions.
30 changes: 15 additions & 15 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ You can use go modules to add our library to your project
### Go module

```bash
go get github.com/adyen/adyen-go-api-library/v3
go get github.com/adyen/adyen-go-api-library/v4
```

## Documentation
Expand All @@ -40,9 +40,9 @@ go get github.com/adyen/adyen-go-api-library/v3

```go
import (
"github.com/adyen/adyen-go-api-library/v3/src/checkout"
"github.com/adyen/adyen-go-api-library/v3/src/common"
"github.com/adyen/adyen-go-api-library/v3/src/adyen"
"github.com/adyen/adyen-go-api-library/v4/src/checkout"
"github.com/adyen/adyen-go-api-library/v4/src/common"
"github.com/adyen/adyen-go-api-library/v4/src/adyen"
)

client := adyen.NewClient(&common.Config{
Expand All @@ -59,9 +59,9 @@ res, httpRes, err := client.Checkout.PaymentMethods(&checkout.PaymentMethodsRequ

```go
import (
"github.com/adyen/adyen-go-api-library/v3/src/checkout"
"github.com/adyen/adyen-go-api-library/v3/src/common"
"github.com/adyen/adyen-go-api-library/v3/src/adyen"
"github.com/adyen/adyen-go-api-library/v4/src/checkout"
"github.com/adyen/adyen-go-api-library/v4/src/common"
"github.com/adyen/adyen-go-api-library/v4/src/adyen"
)

client := adyen.NewClient(&common.Config{
Expand All @@ -79,9 +79,9 @@ res, httpRes, err := client.Checkout.PaymentMethods(&checkout.PaymentMethodsRequ

```go
import (
"github.com/adyen/adyen-go-api-library/v3/src/recurring"
"github.com/adyen/adyen-go-api-library/v3/src/common"
"github.com/adyen/adyen-go-api-library/v3/src/adyen"
"github.com/adyen/adyen-go-api-library/v4/src/recurring"
"github.com/adyen/adyen-go-api-library/v4/src/common"
"github.com/adyen/adyen-go-api-library/v4/src/adyen"
)

client := adyen.NewClient(&common.Config{
Expand All @@ -104,8 +104,8 @@ res, httpRes, err := client.Recurring.ListRecurringDetails(&recurring.RecurringD

```go
import (
"github.com/adyen/adyen-go-api-library/v3/src/adyen"
"github.com/adyen/adyen-go-api-library/v3/src/common"
"github.com/adyen/adyen-go-api-library/v4/src/adyen"
"github.com/adyen/adyen-go-api-library/v4/src/common"
)

client := adyen.NewClient(&common.Config{
Expand All @@ -120,9 +120,9 @@ notification, err := client.Notification.HandleNotificationRequest(jsonRequestSt

```go
import (
"github.com/adyen/adyen-go-api-library/v3/src/common"
"github.com/adyen/adyen-go-api-library/v3/src/checkout"
"github.com/adyen/adyen-go-api-library/v3/src/adyen"
"github.com/adyen/adyen-go-api-library/v4/src/common"
"github.com/adyen/adyen-go-api-library/v4/src/checkout"
"github.com/adyen/adyen-go-api-library/v4/src/adyen"
)

client := adyen.NewClient(&common.Config{
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/adyen/adyen-go-api-library/v3
module github.com/adyen/adyen-go-api-library/v4

go 1.13

Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ package main
import (
"fmt"

"github.com/adyen/adyen-go-api-library/v3/src/adyen"
"github.com/adyen/adyen-go-api-library/v3/src/common"
"github.com/adyen/adyen-go-api-library/v4/src/adyen"
"github.com/adyen/adyen-go-api-library/v4/src/common"
)

func main() {
Expand Down
8 changes: 4 additions & 4 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
"strings"
"testing"

"github.com/adyen/adyen-go-api-library/v3/src/adyen"
"github.com/adyen/adyen-go-api-library/v3/src/checkout"
"github.com/adyen/adyen-go-api-library/v3/src/common"
"github.com/adyen/adyen-go-api-library/v4/src/adyen"
"github.com/adyen/adyen-go-api-library/v4/src/checkout"
"github.com/adyen/adyen-go-api-library/v4/src/common"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand All @@ -29,7 +29,7 @@ func Test_main(t *testing.T) {
require.NotNil(t, client.Checkout.Client)
require.NotNil(t, client.Checkout.Client.Cfg)
require.Equal(t, common.TestEnv, client.Checkout.Client.Cfg.Environment)
assert.Equal(t, "https://checkout-test.adyen.com/checkout/v52", client.Checkout.BasePath())
assert.Equal(t, "https://checkout-test.adyen.com/checkout/v65", client.Checkout.BasePath())

t.Run("Create a API request that should fail", func(t *testing.T) {
res, httpRes, err := client.Checkout.PaymentMethods(&checkout.PaymentMethodsRequest{})
Expand Down
57 changes: 31 additions & 26 deletions src/adyen/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ import (
"fmt"
"net/http"

binlookup "github.com/adyen/adyen-go-api-library/v3/src/binlookup"
checkout "github.com/adyen/adyen-go-api-library/v3/src/checkout"
checkoututility "github.com/adyen/adyen-go-api-library/v3/src/checkoututility"
common "github.com/adyen/adyen-go-api-library/v3/src/common"
notification "github.com/adyen/adyen-go-api-library/v3/src/notification"
payments "github.com/adyen/adyen-go-api-library/v3/src/payments"
payouts "github.com/adyen/adyen-go-api-library/v3/src/payouts"
platformsaccount "github.com/adyen/adyen-go-api-library/v3/src/platformsaccount"
platformsfund "github.com/adyen/adyen-go-api-library/v3/src/platformsfund"
platformshostedonboardingpage "github.com/adyen/adyen-go-api-library/v3/src/platformshostedonboardingpage"
platformsnotificationconfiguration "github.com/adyen/adyen-go-api-library/v3/src/platformsnotificationconfiguration"
recurring "github.com/adyen/adyen-go-api-library/v3/src/recurring"
binlookup "github.com/adyen/adyen-go-api-library/v4/src/binlookup"
checkout "github.com/adyen/adyen-go-api-library/v4/src/checkout"
common "github.com/adyen/adyen-go-api-library/v4/src/common"
disputes "github.com/adyen/adyen-go-api-library/v4/src/disputes"
notification "github.com/adyen/adyen-go-api-library/v4/src/notification"
payments "github.com/adyen/adyen-go-api-library/v4/src/payments"
payouts "github.com/adyen/adyen-go-api-library/v4/src/payouts"
platformsaccount "github.com/adyen/adyen-go-api-library/v4/src/platformsaccount"
platformsfund "github.com/adyen/adyen-go-api-library/v4/src/platformsfund"
platformshostedonboardingpage "github.com/adyen/adyen-go-api-library/v4/src/platformshostedonboardingpage"
platformsnotificationconfiguration "github.com/adyen/adyen-go-api-library/v4/src/platformsnotificationconfiguration"
recurring "github.com/adyen/adyen-go-api-library/v4/src/recurring"
)

// Constants used for the client API
Expand All @@ -31,21 +31,23 @@ const (
EndpointLiveSuffix = "-pal-live.adyenpayments.com"
MarketpayEndpointTest = "https://cal-test.adyen.com/cal/services"
MarketpayEndpointLive = "https://cal-live.adyen.com/cal/services"
MarketpayAccountAPIVersion = "v5"
MarketpayFundAPIVersion = "v5"
MarketpayNotificationAPIVersion = "v5"
MarketpayHopAPIVersion = "v1"
APIVersion = "v52"
MarketpayAccountAPIVersion = "v6"
MarketpayFundAPIVersion = "v6"
MarketpayNotificationAPIVersion = "v6"
MarketpayHopAPIVersion = "v6"
APIVersion = "v64"
RecurringAPIVersion = "v49"
CheckoutEndpointTest = "https://checkout-test.adyen.com/checkout"
CheckoutEndpointLiveSuffix = "-checkout-live.adyenpayments.com/checkout"
CheckoutAPIVersion = "v52"
CheckoutAPIVersion = "v65"
BinLookupPalSuffix = "/pal/servlet/BinLookup/"
BinLookupAPIVersion = "v50"
CheckoutUtilityAPIVersion = "v1"
TerminalAPIEndpointTest = "https://terminal-api-test.adyen.com"
TerminalAPIEndpointLive = "https://terminal-api-live.adyen.com"
EndpointProtocol = "https://"
DisputesEndpointTest = "https://ca-test.adyen.com/ca/services/DisputeService"
DisputesEndpointLive = "https://ca-live.adyen.com/ca/services/DisputeService"
DisputesAPIVersion = "v30"
)

// APIClient manages communication with the Adyen Checkout API API v51
Expand All @@ -54,7 +56,6 @@ type APIClient struct {
client *common.Client
// API Services
Checkout *checkout.Checkout
CheckoutUtility *checkoututility.CheckoutUtility
Payments *payments.Payments
Payouts *payouts.Payouts
Recurring *recurring.Recurring
Expand All @@ -64,6 +65,7 @@ type APIClient struct {
PlatformsFund *platformsfund.PlatformsFund
PlatformsHostedOnboardingPage *platformshostedonboardingpage.PlatformsHostedOnboardingPage
PlatformsNotificationConfiguration *platformsnotificationconfiguration.PlatformsNotificationConfiguration
Disputes *disputes.Disputes
}

// NewClient creates a new API client. Requires Config object.
Expand Down Expand Up @@ -155,12 +157,6 @@ func NewClient(cfg *common.Config) *APIClient {
return fmt.Sprintf("%s/%s", c.client.Cfg.CheckoutEndpoint, CheckoutAPIVersion)
},
}
c.CheckoutUtility = &checkoututility.CheckoutUtility{
Client: c.client,
BasePath: func() string {
return fmt.Sprintf("%s/%s", c.client.Cfg.CheckoutEndpoint, CheckoutUtilityAPIVersion)
},
}
c.Payments = &payments.Payments{
Client: c.client,
BasePath: func() string {
Expand Down Expand Up @@ -217,6 +213,13 @@ func NewClient(cfg *common.Config) *APIClient {
},
}

c.Disputes = &disputes.Disputes{
Client: c.client,
BasePath: func() string {
return fmt.Sprintf("%s/%s", c.client.Cfg.DisputesEndpoint, DisputesAPIVersion)
},
}

return c
}

Expand All @@ -230,6 +233,7 @@ func (c *APIClient) SetEnvironment(env common.Environment, liveEndpointURLPrefix
if env == common.LiveEnv {
c.client.Cfg.Environment = env
c.client.Cfg.MarketPayEndpoint = MarketpayEndpointLive
c.client.Cfg.DisputesEndpoint = DisputesEndpointLive
if liveEndpointURLPrefix != "" {
c.client.Cfg.Endpoint = EndpointProtocol + liveEndpointURLPrefix + EndpointLiveSuffix
c.client.Cfg.CheckoutEndpoint = EndpointProtocol + liveEndpointURLPrefix + CheckoutEndpointLiveSuffix
Expand All @@ -244,6 +248,7 @@ func (c *APIClient) SetEnvironment(env common.Environment, liveEndpointURLPrefix
c.client.Cfg.MarketPayEndpoint = MarketpayEndpointTest
c.client.Cfg.CheckoutEndpoint = CheckoutEndpointTest
c.client.Cfg.TerminalApiCloudEndpoint = TerminalAPIEndpointTest
c.client.Cfg.DisputesEndpoint = DisputesEndpointTest
}
}

Expand Down
10 changes: 4 additions & 6 deletions src/adyen/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (
"testing"
"time"

"github.com/adyen/adyen-go-api-library/v3/src/checkout"
"github.com/adyen/adyen-go-api-library/v3/src/common"
"github.com/adyen/adyen-go-api-library/v3/src/recurring"
"github.com/adyen/adyen-go-api-library/v4/src/checkout"
"github.com/adyen/adyen-go-api-library/v4/src/common"
"github.com/adyen/adyen-go-api-library/v4/src/recurring"
"github.com/joho/godotenv"

"github.com/stretchr/testify/assert"
Expand All @@ -32,9 +32,7 @@ func Test_api(t *testing.T) {
require.NotNil(t, client.client.Cfg)
require.NotNil(t, client.client.Cfg.HTTPClient)
require.NotNil(t, client.Checkout)
require.NotNil(t, client.CheckoutUtility)
assert.Equal(t, "https://checkout-test.adyen.com/checkout/v52", client.Checkout.BasePath())
assert.Equal(t, "https://checkout-test.adyen.com/checkout/v1", client.CheckoutUtility.BasePath())
assert.Equal(t, "https://checkout-test.adyen.com/checkout/v65", client.Checkout.BasePath())

t.Run("Create a API request that should fail", func(t *testing.T) {
res, httpRes, err := client.Checkout.PaymentMethods(&checkout.PaymentMethodsRequest{})
Expand Down
Loading

0 comments on commit d5b8347

Please sign in to comment.