Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
Release 2.21.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
IngenicoEPayments authored and jenkins committed Jun 9, 2021
1 parent 41c52a9 commit f7af2ba
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 47 deletions.
2 changes: 1 addition & 1 deletion communicator/MetaDataProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func getPlatformIdentifier() string {
}

const sdkIdentifier = "GoServerSDK/v" + sdkVersion
const sdkVersion = "2.20.0"
const sdkVersion = "2.21.0"
const serverMetaInfoHeader = "X-GCS-ServerMetaInfo"

// NewMetaDataProviderWithBuilder creates a MetaDataProvider with the given MetaDataProviderBuilder
Expand Down
33 changes: 17 additions & 16 deletions domain/payment/RedirectPaymentMethodSpecificInput.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,24 @@ package payment

// RedirectPaymentMethodSpecificInput represents class RedirectPaymentMethodSpecificInput
type RedirectPaymentMethodSpecificInput struct {
ExpirationPeriod *int32 `json:"expirationPeriod,omitempty"`
IsRecurring *bool `json:"isRecurring,omitempty"`
PaymentProduct809SpecificInput *RedirectPaymentProduct809SpecificInput `json:"paymentProduct809SpecificInput,omitempty"`
PaymentProduct816SpecificInput *RedirectPaymentProduct816SpecificInput `json:"paymentProduct816SpecificInput,omitempty"`
PaymentProduct840SpecificInput *RedirectPaymentProduct840SpecificInput `json:"paymentProduct840SpecificInput,omitempty"`
PaymentProduct861SpecificInput *RedirectPaymentProduct861SpecificInput `json:"paymentProduct861SpecificInput,omitempty"`
PaymentProduct863SpecificInput *RedirectPaymentProduct863SpecificInput `json:"paymentProduct863SpecificInput,omitempty"`
PaymentProduct869SpecificInput *RedirectPaymentProduct869SpecificInput `json:"paymentProduct869SpecificInput,omitempty"`
PaymentProduct882SpecificInput *RedirectPaymentProduct882SpecificInput `json:"paymentProduct882SpecificInput,omitempty"`
PaymentProductID *int32 `json:"paymentProductId,omitempty"`
RecurringPaymentSequenceIndicator *string `json:"recurringPaymentSequenceIndicator,omitempty"`
RedirectionData *RedirectionData `json:"redirectionData,omitempty"`
RequiresApproval *bool `json:"requiresApproval,omitempty"`
ExpirationPeriod *int32 `json:"expirationPeriod,omitempty"`
IsRecurring *bool `json:"isRecurring,omitempty"`
PaymentProduct4101SpecificInput *RedirectPaymentProduct4101SpecificInput `json:"paymentProduct4101SpecificInput,omitempty"`
PaymentProduct809SpecificInput *RedirectPaymentProduct809SpecificInput `json:"paymentProduct809SpecificInput,omitempty"`
PaymentProduct816SpecificInput *RedirectPaymentProduct816SpecificInput `json:"paymentProduct816SpecificInput,omitempty"`
PaymentProduct840SpecificInput *RedirectPaymentProduct840SpecificInput `json:"paymentProduct840SpecificInput,omitempty"`
PaymentProduct861SpecificInput *RedirectPaymentProduct861SpecificInput `json:"paymentProduct861SpecificInput,omitempty"`
PaymentProduct863SpecificInput *RedirectPaymentProduct863SpecificInput `json:"paymentProduct863SpecificInput,omitempty"`
PaymentProduct869SpecificInput *RedirectPaymentProduct869SpecificInput `json:"paymentProduct869SpecificInput,omitempty"`
PaymentProduct882SpecificInput *RedirectPaymentProduct882SpecificInput `json:"paymentProduct882SpecificInput,omitempty"`
PaymentProductID *int32 `json:"paymentProductId,omitempty"`
RecurringPaymentSequenceIndicator *string `json:"recurringPaymentSequenceIndicator,omitempty"`
RedirectionData *RedirectionData `json:"redirectionData,omitempty"`
RequiresApproval *bool `json:"requiresApproval,omitempty"`
// Deprecated: Use redirectionData.returnUrl instead
ReturnURL *string `json:"returnUrl,omitempty"`
Token *string `json:"token,omitempty"`
Tokenize *bool `json:"tokenize,omitempty"`
ReturnURL *string `json:"returnUrl,omitempty"`
Token *string `json:"token,omitempty"`
Tokenize *bool `json:"tokenize,omitempty"`
}

// NewRedirectPaymentMethodSpecificInput constructs a new RedirectPaymentMethodSpecificInput
Expand Down
15 changes: 15 additions & 0 deletions domain/payment/RedirectPaymentProduct4101SpecificInput.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// This class was auto-generated from the API references found at
// https://epayments-api.developer-ingenico.com/s2sapi/v1/

package payment

// RedirectPaymentProduct4101SpecificInput represents class RedirectPaymentProduct4101SpecificInput
type RedirectPaymentProduct4101SpecificInput struct {
IntegrationType *string `json:"integrationType,omitempty"`
Vpa *string `json:"vpa,omitempty"`
}

// NewRedirectPaymentProduct4101SpecificInput constructs a new RedirectPaymentProduct4101SpecificInput
func NewRedirectPaymentProduct4101SpecificInput() *RedirectPaymentProduct4101SpecificInput {
return &RedirectPaymentProduct4101SpecificInput{}
}
1 change: 1 addition & 0 deletions domain/payment/SdkDataInput.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package payment

// SdkDataInput represents class SdkDataInput
type SdkDataInput struct {
// Deprecated: No replacement
DeviceInfo *string `json:"deviceInfo,omitempty"`
DeviceRenderOptions *DeviceRenderOptions `json:"deviceRenderOptions,omitempty"`
SdkAppID *string `json:"sdkAppId,omitempty"`
Expand Down
36 changes: 6 additions & 30 deletions webhooks/Helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package webhooks
import (
"crypto/hmac"
"crypto/sha256"
"crypto/subtle"
"encoding/base64"
"errors"
"fmt"
Expand All @@ -20,7 +21,7 @@ var (
// ErrNilSecretKeyStore occurs when the provided secretKeyStore is nil
ErrNilSecretKeyStore = errors.New("nil secretKeyStore")

multipleHeaderFormat = `enocuntered multiple occurrences of header "%v"`
multipleHeaderFormat = `encountered multiple occurrences of header "%v"`
headerNotFoundFormat = `could not find header "%v"`
compareFailedFormat = `failed to validate signature "%v"`
)
Expand Down Expand Up @@ -85,10 +86,11 @@ func (h *Helper) validate(body string, requestHeaders []communication.Header) er

unencodedResult := mac.Sum(nil)

expectedSignature := base64.StdEncoding.EncodeToString(unencodedResult)

isValid := areEqualSignatures(signature, expectedSignature)
encoder := base64.StdEncoding
expectedSignature := make([]byte, encoder.EncodedLen(len(unencodedResult)))
encoder.Encode(expectedSignature, unencodedResult)

isValid := subtle.ConstantTimeCompare([]byte(signature), expectedSignature) == 1
if !isValid {
sve, err := NewSignatureValidationError(fmt.Sprintf(compareFailedFormat, signature))
if err != nil {
Expand All @@ -114,32 +116,6 @@ func NewHelper(marshaller communicator.Marshaller, secretKeyStore SecretKeyStore
return &Helper{marshaller, secretKeyStore}, nil
}

func areEqualSignatures(signature, expectedSignature string) bool {
signatureRunes := []rune(signature)
expectedSignatureRunes := []rune(expectedSignature)

length := len(signatureRunes)
expectedLength := len(expectedSignatureRunes)

limit := max(256, max(length, expectedLength))

result := true

for i := 0; i < limit; i++ {
if i < length && i < expectedLength {
result = result && (signatureRunes[i] == expectedSignatureRunes[i])
} else {
if i >= length && i >= expectedLength {
result = result && true
} else {
result = result && false
}
}
}

return result
}

func validateAPIVersion(event *webhooks.Event) error {
if *event.APIVersion != connectsdk.APIVersion {
ame, err := NewAPIVersionMismatchError(*event.APIVersion, connectsdk.APIVersion)
Expand Down

0 comments on commit f7af2ba

Please sign in to comment.