From 07fcb4d0ead9de15914d3e6fd5313cde81a85ac9 Mon Sep 17 00:00:00 2001 From: Okechukwu Ugwu Date: Tue, 16 Jul 2024 11:21:36 +0100 Subject: [PATCH] Adyen: add applepay/googlepay support (#198) --- connectorconfig/adyen.go | 27 ++++++++++++++++++++++----- connectorconfig/library.go | 4 +++- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/connectorconfig/adyen.go b/connectorconfig/adyen.go index de4ce2a..10c8873 100644 --- a/connectorconfig/adyen.go +++ b/connectorconfig/adyen.go @@ -17,11 +17,13 @@ const ( ) type AdyenCredentials struct { - Environment AdyenEnvironment `json:"environment" yaml:"environment" validate:"required,oneof=sandbox production"` - MerchantAccount string `json:"merchantAccount" yaml:"merchantAccount" validate:"required"` - ApiKey *string `json:"apiKey" yaml:"apiKey" validate:"required"` - ApiPrefix string `json:"apiPrefix" yaml:"apiPrefix" validate:"required"` - HMACKey *string `json:"hmacKey" yaml:"hmacKey" validate:"required"` + Environment AdyenEnvironment `json:"environment" yaml:"environment" validate:"required,oneof=sandbox production"` + MerchantAccount string `json:"merchantAccount" yaml:"merchantAccount" validate:"required"` + ApiKey *string `json:"apiKey" yaml:"apiKey" validate:"required"` + ApiPrefix string `json:"apiPrefix" yaml:"apiPrefix" validate:"required"` + HMACKey *string `json:"hmacKey" yaml:"hmacKey" validate:"required"` + GooglePay *GooglePayCredentials `json:"googlePay,omitempty" yaml:"googlePay,omitempty"` + ApplePay *ApplePayCredentials `json:"applePay,omitempty" yaml:"applePay,omitempty"` } func (c *AdyenCredentials) GetMID() string { @@ -99,3 +101,18 @@ func (c *AdyenCredentials) IsRecoveryAgent() bool { func (c *AdyenCredentials) Supports3RI() bool { return false } + +func (c *AdyenCredentials) GetGooglePayParams() map[string]string { + return map[string]string{ + "gateway": "adyen", + "gatewayMerchantId": c.GetGooglePay().GetGoogleCardMerchantId(), + } +} + +func (c *AdyenCredentials) GetGooglePay() *GooglePayCredentials { + return c.GooglePay +} + +func (c *AdyenCredentials) GetApplePay() *ApplePayCredentials { + return c.ApplePay +} diff --git a/connectorconfig/library.go b/connectorconfig/library.go index 447f921..297f624 100644 --- a/connectorconfig/library.go +++ b/connectorconfig/library.go @@ -124,7 +124,9 @@ var LibraryRegister = map[Library]LibraryDef{ DisplayName: "Adyen", Credentials: func() Credentials { return &AdyenCredentials{} }, SupportsMethod: func(methodType chtype.PaymentMethodType, methodProvider chtype.PaymentMethodProvider) bool { - return methodType == chtype.PAYMENT_METHOD_TYPE_CARD + return methodType == chtype.PAYMENT_METHOD_TYPE_CARD || + (methodType == chtype.PAYMENT_METHOD_TYPE_DIGITALWALLET && methodProvider == chtype.PAYMENT_METHOD_PROVIDER_APPLEPAY) || + (methodType == chtype.PAYMENT_METHOD_TYPE_DIGITALWALLET && methodProvider == chtype.PAYMENT_METHOD_PROVIDER_GOOGLEPAY) }, }, LibraryApplePay: {