Skip to content

Commit

Permalink
Release v3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
KadoBOT authored Sep 16, 2020
2 parents 2f23cb6 + 197afa1 commit 800cc2b
Show file tree
Hide file tree
Showing 36 changed files with 185 additions and 109 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/v2
go get github.com/adyen/adyen-go-api-library/v3
```

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

```go
import (
"github.com/adyen/adyen-go-api-library/v2/src/checkout"
"github.com/adyen/adyen-go-api-library/v2/src/common"
"github.com/adyen/adyen-go-api-library/v2/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/v3/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/v2/src/checkout"
"github.com/adyen/adyen-go-api-library/v2/src/common"
"github.com/adyen/adyen-go-api-library/v2/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/v3/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/v2/src/recurring"
"github.com/adyen/adyen-go-api-library/v2/src/common"
"github.com/adyen/adyen-go-api-library/v2/src/adyen"
"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"
)

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/v2/src/adyen"
"github.com/adyen/adyen-go-api-library/v2/src/common"
"github.com/adyen/adyen-go-api-library/v3/src/adyen"
"github.com/adyen/adyen-go-api-library/v3/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/v2/src/common"
"github.com/adyen/adyen-go-api-library/v2/src/checkout"
"github.com/adyen/adyen-go-api-library/v2/src/adyen"
"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"
)

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

go 1.13

require (
github.com/google/uuid v1.1.1
github.com/google/uuid v1.1.2
github.com/joho/godotenv v1.3.0
github.com/stretchr/testify v1.6.1
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
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/v2/src/adyen"
"github.com/adyen/adyen-go-api-library/v2/src/common"
"github.com/adyen/adyen-go-api-library/v3/src/adyen"
"github.com/adyen/adyen-go-api-library/v3/src/common"
)

func main() {
Expand Down
6 changes: 3 additions & 3 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/v2/src/adyen"
"github.com/adyen/adyen-go-api-library/v2/src/checkout"
"github.com/adyen/adyen-go-api-library/v2/src/common"
"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/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down
34 changes: 12 additions & 22 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/v2/src/binlookup"
checkout "github.com/adyen/adyen-go-api-library/v2/src/checkout"
checkoututility "github.com/adyen/adyen-go-api-library/v2/src/checkoututility"
common "github.com/adyen/adyen-go-api-library/v2/src/common"
notification "github.com/adyen/adyen-go-api-library/v2/src/notification"
payments "github.com/adyen/adyen-go-api-library/v2/src/payments"
payouts "github.com/adyen/adyen-go-api-library/v2/src/payouts"
platformsaccount "github.com/adyen/adyen-go-api-library/v2/src/platformsaccount"
platformsfund "github.com/adyen/adyen-go-api-library/v2/src/platformsfund"
platformshostedonboardingpage "github.com/adyen/adyen-go-api-library/v2/src/platformshostedonboardingpage"
platformsnotificationconfiguration "github.com/adyen/adyen-go-api-library/v2/src/platformsnotificationconfiguration"
recurring "github.com/adyen/adyen-go-api-library/v2/src/recurring"
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"
)

// Constants used for the client API
Expand Down Expand Up @@ -252,13 +252,3 @@ func (c *APIClient) SetEnvironment(env common.Environment, liveEndpointURLPrefix
func (c *APIClient) GetConfig() *common.Config {
return c.client.Cfg
}

/*
SetIdempotencyKey A idempotency key is added to the request headers once. A subsequent request using the same
idempotency key will be processed as if it was the first request.
This header option is not persistent which means that whenever you want to use a idempotency key, you need to
"SetIdempotencyKey" again before each request.
*/
func (c *APIClient) SetIdempotencyKey(i string) {
c.client.Cfg.AddDefaultHeader("Idempotency-Key", i)
}
6 changes: 3 additions & 3 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/v2/src/checkout"
"github.com/adyen/adyen-go-api-library/v2/src/common"
"github.com/adyen/adyen-go-api-library/v2/src/recurring"
"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/joho/godotenv"

"github.com/stretchr/testify/assert"
Expand Down
2 changes: 1 addition & 1 deletion src/binlookup/api_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
_context "context"
_nethttp "net/http"

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

// BinLookup BinLookup service
Expand Down
2 changes: 1 addition & 1 deletion src/checkout/api_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
_context "context"
_nethttp "net/http"

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

// Checkout Checkout service
Expand Down
2 changes: 1 addition & 1 deletion src/checkout/model_payment_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
package checkout

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

// PaymentResponse struct for PaymentResponse
Expand Down
2 changes: 1 addition & 1 deletion src/checkout/model_payment_verification_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

package checkout

import "github.com/adyen/adyen-go-api-library/v2/src/common"
import "github.com/adyen/adyen-go-api-library/v3/src/common"

// PaymentVerificationResponse struct for PaymentVerificationResponse
type PaymentVerificationResponse struct {
Expand Down
2 changes: 1 addition & 1 deletion src/checkoututility/api_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
_context "context"
_nethttp "net/http"

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

// CheckoutUtility CheckoutUtility service
Expand Down
29 changes: 24 additions & 5 deletions src/common/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,6 @@ func (c *Client) MakeHTTPPostRequest(req interface{}, res interface{}, path stri

httpResponse, err := c.CallAPI(r)

_, ok := c.Cfg.DefaultHeader["Idempotency-Key"]
if ok {
delete(c.Cfg.DefaultHeader, "Idempotency-Key")
}

if err != nil || httpResponse == nil {
return httpResponse, err
}
Expand Down Expand Up @@ -247,6 +242,10 @@ func (c *Client) PrepareRequest(
localVarRequest.Header.Add(header, value)
}

if key, ok := IdempotencyKey(ctx); ok {
localVarRequest.Header.Add("Idempotency-Key", key)
}

return localVarRequest, nil
}

Expand Down Expand Up @@ -531,3 +530,23 @@ func (e APIError) Error() string {
}
return e.Err
}

var ctxKeyIdempotencyKey = 1

/*
WithIdempotencyKey returns a context with an Idempotency-Key added to the provided context.
Pass this context as the first context to a call to Adyen, and the idempotency
key will be added to the header
*/
func WithIdempotencyKey(ctx context.Context, idempotencyKey string) context.Context {
return context.WithValue(ctx, ctxKeyIdempotencyKey, idempotencyKey)
}

func IdempotencyKey(ctx context.Context) (string, bool) {
if ctx == nil {
return "", false
}
ikey := ctx.Value(ctxKeyIdempotencyKey)
key, ok := ikey.(string)
return key, ok
}
7 changes: 1 addition & 6 deletions src/common/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const (

const (
LibName = "adyen-go-api-library"
LibVersion = "2.2.0"
LibVersion = "3.0.0"
)

// Config stores the configuration of the API client
Expand Down Expand Up @@ -98,8 +98,3 @@ func (c *Config) GetCheckoutEndpoint() (string, error) {
}
return c.CheckoutEndpoint, nil
}

// AddDefaultHeader adds a new HTTP header to the default header in the Request
func (c *Config) AddDefaultHeader(key string, value string) {
c.DefaultHeader[key] = value
}
2 changes: 1 addition & 1 deletion src/hmacvalidator/hmacvalidator.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"strconv"
"strings"

"github.com/adyen/adyen-go-api-library/v2/src/notification"
"github.com/adyen/adyen-go-api-library/v3/src/notification"
)

// CalculateHmac calculates the SHA-256 HMAC for the given data and key
Expand Down
2 changes: 1 addition & 1 deletion src/hmacvalidator/hmacvalidator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"testing"
"time"

"github.com/adyen/adyen-go-api-library/v2/src/notification"
"github.com/adyen/adyen-go-api-library/v3/src/notification"
"github.com/stretchr/testify/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion src/notification/notification_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package notification
import (
"encoding/json"

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

// NotificationService used to namespace this util under the client for consistency and for future prooffing if this ever requires api access
Expand Down
2 changes: 1 addition & 1 deletion src/payments/api_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
_context "context"
_nethttp "net/http"

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

// Payments Payments service
Expand Down
2 changes: 1 addition & 1 deletion src/payments/model_payment_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

package payments

import "github.com/adyen/adyen-go-api-library/v2/src/common"
import "github.com/adyen/adyen-go-api-library/v3/src/common"

// PaymentResult struct for PaymentResult
type PaymentResult struct {
Expand Down
2 changes: 1 addition & 1 deletion src/payouts/api_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
_context "context"
_nethttp "net/http"

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

// Payouts Payouts service
Expand Down
2 changes: 1 addition & 1 deletion src/payouts/model_payout_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

package payouts

import "github.com/adyen/adyen-go-api-library/v2/src/common"
import "github.com/adyen/adyen-go-api-library/v3/src/common"

// PayoutResponse struct for PayoutResponse
type PayoutResponse struct {
Expand Down
2 changes: 1 addition & 1 deletion src/platformsaccount/api_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
_context "context"
_nethttp "net/http"

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

// PlatformsAccount PlatformsAccount service
Expand Down
2 changes: 1 addition & 1 deletion src/platformsfund/api_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
_context "context"
_nethttp "net/http"

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

// PlatformsFund PlatformsFund service
Expand Down
2 changes: 1 addition & 1 deletion src/platformshostedonboardingpage/api_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
_context "context"
_nethttp "net/http"

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

// PlatformsHostedOnboardingPage PlatformsHostedOnboardingPage service
Expand Down
2 changes: 1 addition & 1 deletion src/platformsnotificationconfiguration/api_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
_context "context"
_nethttp "net/http"

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

// PlatformsNotificationConfiguration PlatformsNotificationConfiguration service
Expand Down
2 changes: 1 addition & 1 deletion src/recurring/api_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
_context "context"
_nethttp "net/http"

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

// Recurring Recurring service
Expand Down
Loading

0 comments on commit 800cc2b

Please sign in to comment.