Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Adyen Magento2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shared Libs
Adyen Magento2
Commits
b5488960
Commit
b5488960
authored
Jun 14, 2016
by
Rik ter Beek
Committed by
GitHub
Jun 14, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #46 from Adyen/develop
Merge branch 'develop'
parents
ea6820f2
4ebc77df
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
808 additions
and
395 deletions
+808
-395
Api/AdyenPaymentMethodManagementInterface.php
Api/AdyenPaymentMethodManagementInterface.php
+43
-0
Api/GuestAdyenPaymentMethodManagementInterface.php
Api/GuestAdyenPaymentMethodManagementInterface.php
+43
-0
Helper/Data.php
Helper/Data.php
+1
-1
Helper/PaymentMethods.php
Helper/PaymentMethods.php
+427
-0
Model/AdyenHppConfigProvider.php
Model/AdyenHppConfigProvider.php
+4
-377
Model/AdyenPaymentMethodManagement.php
Model/AdyenPaymentMethodManagement.php
+58
-0
Model/Api/PaymentRequest.php
Model/Api/PaymentRequest.php
+12
-7
Model/GuestAdyenPaymentMethodManagement.php
Model/GuestAdyenPaymentMethodManagement.php
+68
-0
Model/Method/Oneclick.php
Model/Method/Oneclick.php
+2
-1
etc/di.xml
etc/di.xml
+2
-0
etc/webapi.xml
etc/webapi.xml
+47
-0
view/frontend/web/js/model/adyen-method-list.js
view/frontend/web/js/model/adyen-method-list.js
+13
-0
view/frontend/web/js/model/adyen-payment-service.js
view/frontend/web/js/model/adyen-payment-service.js
+31
-0
view/frontend/web/js/view/payment/method-renderer/adyen-cc-method.js
...nd/web/js/view/payment/method-renderer/adyen-cc-method.js
+6
-2
view/frontend/web/js/view/payment/method-renderer/adyen-hpp-method.js
...d/web/js/view/payment/method-renderer/adyen-hpp-method.js
+51
-7
No files found.
Api/AdyenPaymentMethodManagementInterface.php
0 → 100644
View file @
b5488960
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace
Adyen\Payment\Api
;
/**
* Interface GuestAdyenPaymentMethodManagementInterface
* @api
* @package Adyen\Payment\Api
*/
interface
AdyenPaymentMethodManagementInterface
{
/**
* Get payment information
*
* @param string $cartId
* @return \Magento\Checkout\Api\Data\PaymentDetailsInterface
*/
public
function
getPaymentMethods
(
$cartId
,
\Magento\Quote\Api\Data\AddressInterface
$shippingAddress
);
}
Api/GuestAdyenPaymentMethodManagementInterface.php
0 → 100644
View file @
b5488960
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace
Adyen\Payment\Api
;
/**
* Interface GuestAdyenPaymentMethodManagementInterface
* @api
* @package Adyen\Payment\Api
*/
interface
GuestAdyenPaymentMethodManagementInterface
{
/**
* Get payment information
*
* @param string $cartId
* @return \Magento\Checkout\Api\Data\PaymentDetailsInterface
*/
public
function
getPaymentMethods
(
$cartId
,
\Magento\Quote\Api\Data\AddressInterface
$shippingAddress
);
}
Helper/Data.php
View file @
b5488960
...
@@ -229,7 +229,7 @@ class Data extends AbstractHelper
...
@@ -229,7 +229,7 @@ class Data extends AbstractHelper
$streetName
=
$street
[
'0'
];
$streetName
=
$street
[
'0'
];
unset
(
$street
[
'0'
]);
unset
(
$street
[
'0'
]);
$streetNr
=
implode
(
' '
,
$street
);
$streetNr
=
implode
(
' '
,
$street
);
return
([
'name'
=>
$streetName
,
'house_number'
=>
$streetNr
]);
return
([
'name'
=>
trim
(
$streetName
)
,
'house_number'
=>
$streetNr
]);
}
}
/**
/**
...
...
Helper/PaymentMethods.php
0 → 100644
View file @
b5488960
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace
Adyen\Payment\Helper
;
use
Magento\Framework\App\Helper\AbstractHelper
;
/**
* @SuppressWarnings(PHPMD.LongVariable)
*/
class
PaymentMethods
extends
AbstractHelper
{
/**
* @var \Magento\Quote\Api\CartRepositoryInterface
*/
protected
$_quoteRepository
;
/**
* @var \Magento\Quote\Model\QuoteIdMaskFactory
*/
protected
$_quoteIdMaskFactory
;
/**
* @var \Magento\Framework\App\Config\ScopeConfigInterface $config
*/
protected
$_config
;
/**
* @var \Adyen\Payment\Helper\Data
*/
protected
$_adyenHelper
;
/**
* @var AdyenGenericConfig
*/
protected
$_genericConfig
;
/**
* @var \Magento\Checkout\Model\Session
*/
protected
$_session
;
/**
* @var \Magento\Framework\Locale\ResolverInterface
*/
protected
$_localeResolver
;
/**
* @var \Adyen\Payment\Logger\AdyenLogger
*/
protected
$_adyenLogger
;
/**
* @var Repository
*/
protected
$_assetRepo
;
/**
* @var RequestInterface
*/
protected
$_request
;
/**
* @var \Magento\Framework\View\Asset\Source
*/
protected
$_assetSource
;
/**
* PaymentMethods constructor.
* @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository
* @param \Magento\Quote\Model\QuoteIdMaskFactory $quoteIdMaskFactory
* @param \Magento\Framework\App\Config\ScopeConfigInterface $config
* @param Data $adyenHelper
* @param \Adyen\Payment\Model\AdyenGenericConfig $genericConfig
* @param \Magento\Checkout\Model\Session $session
* @param \Magento\Framework\Locale\ResolverInterface $localeResolver
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Magento\Framework\View\Asset\Repository $assetRepo
* @param \Magento\Framework\App\RequestInterface $request
* @param \Magento\Framework\View\Asset\Source $assetSource
*/
public
function
__construct
(
\Magento\Quote\Api\CartRepositoryInterface
$quoteRepository
,
\Magento\Quote\Model\QuoteIdMaskFactory
$quoteIdMaskFactory
,
\Magento\Framework\App\Config\ScopeConfigInterface
$config
,
\Adyen\Payment\Helper\Data
$adyenHelper
,
\Adyen\Payment\Model\AdyenGenericConfig
$genericConfig
,
\Magento\Checkout\Model\Session
$session
,
\Magento\Framework\Locale\ResolverInterface
$localeResolver
,
\Adyen\Payment\Logger\AdyenLogger
$adyenLogger
,
\Magento\Framework\View\Asset\Repository
$assetRepo
,
\Magento\Framework\App\RequestInterface
$request
,
\Magento\Framework\View\Asset\Source
$assetSource
)
{
$this
->
_quoteRepository
=
$quoteRepository
;
$this
->
_quoteIdMaskFactory
=
$quoteIdMaskFactory
;
$this
->
_config
=
$config
;
$this
->
_adyenHelper
=
$adyenHelper
;
$this
->
_genericConfig
=
$genericConfig
;
$this
->
_session
=
$session
;
$this
->
_localeResolver
=
$localeResolver
;
$this
->
_adyenLogger
=
$adyenLogger
;
$this
->
_assetRepo
=
$assetRepo
;
$this
->
_request
=
$request
;
$this
->
_assetSource
=
$assetSource
;
}
/**
* {@inheritDoc}
*/
public
function
getPaymentMethods
(
$quoteId
,
$country
=
null
)
{
// get quote from quoteId
$quote
=
$this
->
_quoteRepository
->
getActive
(
$quoteId
);
$store
=
$quote
->
getStore
();
$paymentMethods
=
$this
->
_addHppMethodsToConfig
(
$store
,
$country
);
return
$paymentMethods
;
}
/**
* @param $store
* @return array
*/
protected
function
_addHppMethodsToConfig
(
$store
,
$country
)
{
$paymentMethods
=
[];
$ccEnabled
=
$this
->
_config
->
getValue
(
'payment/'
.
\Adyen\Payment\Model\Method\Cc
::
METHOD_CODE
.
'/active'
);
$ccTypes
=
array_keys
(
$this
->
_adyenHelper
->
getCcTypesAltData
());
$sepaEnabled
=
$this
->
_config
->
getValue
(
'payment/'
.
\Adyen\Payment\Model\Method\Sepa
::
METHOD_CODE
.
'/active'
);
foreach
(
$this
->
_fetchHppMethods
(
$store
,
$country
)
as
$methodCode
=>
$methodData
)
{
/*
* skip payment methods if it is a creditcard that is enabled in adyen_cc
* or if payment is sepadirectdebit and SEPA api is enabled
*/
if
(
$ccEnabled
&&
in_array
(
$methodCode
,
$ccTypes
))
{
continue
;
}
elseif
(
$methodCode
==
'sepadirectdebit'
&&
$sepaEnabled
)
{
continue
;
}
$paymentMethods
[
$methodCode
]
=
$methodData
;
}
return
$paymentMethods
;
}
/**
* @param $store
* @return array
*/
protected
function
_fetchHppMethods
(
$store
,
$country
)
{
$skinCode
=
$this
->
_adyenHelper
->
getAdyenHppConfigData
(
'skin_code'
);
$merchantAccount
=
$this
->
_adyenHelper
->
getAdyenAbstractConfigData
(
'merchant_account'
);
if
(
!
$skinCode
||
!
$merchantAccount
)
{
return
[];
}
$adyFields
=
[
"paymentAmount"
=>
(
int
)
$this
->
_adyenHelper
->
formatAmount
(
$this
->
_getCurrentPaymentAmount
(),
$this
->
_getCurrentCurrencyCode
(
$store
)
),
"currencyCode"
=>
$this
->
_getCurrentCurrencyCode
(
$store
),
"merchantReference"
=>
"Get Payment methods"
,
"skinCode"
=>
$skinCode
,
"merchantAccount"
=>
$merchantAccount
,
"sessionValidity"
=>
date
(
DATE_ATOM
,
mktime
(
date
(
"H"
)
+
1
,
date
(
"i"
),
date
(
"s"
),
date
(
"m"
),
date
(
"j"
),
date
(
"Y"
))
),
"countryCode"
=>
$this
->
_getCurrentCountryCode
(
$store
,
$country
),
"shopperLocale"
=>
$this
->
_getCurrentLocaleCode
(
$store
)
];
$responseData
=
$this
->
_getDirectoryLookupResponse
(
$adyFields
,
$store
);
$paymentMethods
=
[];
if
(
isset
(
$responseData
[
'paymentMethods'
]))
{
foreach
(
$responseData
[
'paymentMethods'
]
as
$paymentMethod
)
{
$paymentMethodCode
=
$paymentMethod
[
'brandCode'
];
$paymentMethod
=
$this
->
_fieldMapPaymentMethod
(
$paymentMethod
);
// add icon location in result
if
(
$this
->
_genericConfig
->
showLogos
())
{
$params
=
[];
// use frontend area
$params
=
array_merge
([
'area'
=>
'frontend'
,
'_secure'
=>
$this
->
_request
->
isSecure
()],
$params
);
$asset
=
$this
->
_assetRepo
->
createAsset
(
'Adyen_Payment::images/logos/'
.
$paymentMethodCode
.
'.png'
,
$params
);
$placeholder
=
$this
->
_genericConfig
->
findRelativeSourceFilePath
(
$asset
);
$icon
=
null
;
if
(
$placeholder
)
{
list
(
$width
,
$height
)
=
getimagesize
(
$asset
->
getSourceFile
());
$icon
=
[
'url'
=>
$asset
->
getUrl
(),
'width'
=>
$width
,
'height'
=>
$height
];
}
$paymentMethod
[
'icon'
]
=
$icon
;
}
$paymentMethods
[
$paymentMethodCode
]
=
$paymentMethod
;
}
}
return
$paymentMethods
;
}
/**
* @return bool|int
*/
protected
function
_getCurrentPaymentAmount
()
{
if
((
$grandTotal
=
$this
->
_getQuote
()
->
getGrandTotal
())
>
0
)
{
return
$grandTotal
;
}
return
10
;
}
/**
* @param $store
* @return mixed
*/
protected
function
_getCurrentCurrencyCode
(
$store
)
{
return
$this
->
_getQuote
()
->
getQuoteCurrencyCode
()
?:
$store
->
getBaseCurrencyCode
();
}
/**
* @param $store
* @return int|mixed|string
*/
protected
function
_getCurrentCountryCode
(
$store
,
$country
)
{
// if fixed countryCode is setup in config use this
$countryCode
=
$this
->
_adyenHelper
->
getAdyenHppConfigData
(
'country_code'
,
$store
->
getId
());
if
(
$countryCode
!=
""
)
{
return
$countryCode
;
}
if
(
$country
!=
null
)
{
return
$country
;
}
if
(
$country
=
$this
->
_getQuote
()
->
getBillingAddress
()
->
getCountry
())
{
return
$country
;
}
$defaultCountry
=
$this
->
_config
->
getValue
(
\Magento\Tax\Model\Config
::
CONFIG_XML_PATH_DEFAULT_COUNTRY
,
\Magento\Store\Model\ScopeInterface
::
SCOPE_STORES
,
$store
->
getCode
()
);
if
(
$defaultCountry
)
{
return
$defaultCountry
;
}
return
""
;
}
/**
* @param $store
* @return mixed|string
*/
protected
function
_getCurrentLocaleCode
(
$store
)
{
$localeCode
=
$this
->
_adyenHelper
->
getAdyenAbstractConfigData
(
'shopper_locale'
,
$store
->
getId
());
if
(
$localeCode
!=
""
)
{
return
$localeCode
;
}
$locale
=
$this
->
_localeResolver
->
getLocale
();
if
(
$locale
)
{
return
$locale
;
}
// should have the vulue if not fall back to default
$localeCode
=
$this
->
_config
->
getValue
(
Data
::
XML_PATH_DEFAULT_LOCALE
,
\Magento\Store\Model\ScopeInterface
::
SCOPE_STORES
,
$store
->
getCode
()
);
return
$localeCode
;
}
/**
* @var array
*/
protected
$_fieldMapPaymentMethod
=
[
'name'
=>
'title'
];
/**
* @param $paymentMethod
* @return mixed
*/
protected
function
_fieldMapPaymentMethod
(
$paymentMethod
)
{
foreach
(
$this
->
_fieldMapPaymentMethod
as
$field
=>
$newField
)
{
if
(
isset
(
$paymentMethod
[
$field
]))
{
$paymentMethod
[
$newField
]
=
$paymentMethod
[
$field
];
unset
(
$paymentMethod
[
$field
]);
}
}
return
$paymentMethod
;
}
/**
* @param $requestParams
* @param $store
* @return array
* @throws \Adyen\AdyenException
*/
protected
function
_getDirectoryLookupResponse
(
$requestParams
,
$store
)
{
$cacheKey
=
$this
->
_getCacheKeyForRequest
(
$requestParams
,
$store
);
// initialize the adyen client
$client
=
new
\Adyen\Client
();
if
(
$this
->
_adyenHelper
->
isDemoMode
())
{
$client
->
setEnvironment
(
\Adyen\Environment
::
TEST
);
}
else
{
$client
->
setEnvironment
(
\Adyen\Environment
::
LIVE
);
}
// connect to magento log
$client
->
setLogger
(
$this
->
_adyenLogger
);
$hmacKey
=
$this
->
_adyenHelper
->
getHmac
();
// create and add signature
try
{
$requestParams
[
"merchantSig"
]
=
\Adyen\Util\Util
::
calculateSha256Signature
(
$hmacKey
,
$requestParams
);
}
catch
(
\Adyen\AdyenException
$e
)
{
$this
->
_adyenLogger
->
error
(
$e
->
getMessage
());
// return empty result
return
[];
}
// initialize service
$service
=
new
\Adyen\Service\DirectoryLookup
(
$client
);
try
{
$responseData
=
$service
->
directoryLookup
(
$requestParams
);
}
catch
(
\Adyen\AdyenException
$e
)
{
$this
->
_adyenLogger
->
error
(
"The Directory Lookup response is empty check your Adyen configuration in Magento."
);
// return empty result
return
[];
}
return
$responseData
;
}
/**
* @var array
*/
protected
$_cacheParams
=
array
(
'currencyCode'
,
'merchantReference'
,
'skinCode'
,
'merchantAccount'
,
'countryCode'
,
'shopperLocale'
,
);
/**
* @param $requestParams
* @param $store
* @return string
*/
protected
function
_getCacheKeyForRequest
(
$requestParams
,
$store
)
{
$cacheParams
=
[];
$cacheParams
[
'store'
]
=
$store
->
getId
();
foreach
(
$this
->
_cacheParams
as
$paramKey
)
{
if
(
isset
(
$requestParams
[
$paramKey
]))
{
$cacheParams
[
$paramKey
]
=
$requestParams
[
$paramKey
];
}
}
return
md5
(
implode
(
'|'
,
$cacheParams
));
}
/**
* @return \Magento\Quote\Model\Quote
*/
protected
function
_getQuote
()
{
return
$this
->
_session
->
getQuote
();
}
}
\ No newline at end of file
Model/AdyenHppConfigProvider.php
View file @
b5488960
...
@@ -30,51 +30,16 @@ use Magento\Directory\Helper\Data;
...
@@ -30,51 +30,16 @@ use Magento\Directory\Helper\Data;
class
AdyenHppConfigProvider
implements
ConfigProviderInterface
class
AdyenHppConfigProvider
implements
ConfigProviderInterface
{
{
/**
* @var \Magento\Framework\App\State
*/
protected
$_appState
;
/**
* @var \Magento\Checkout\Model\Session
*/
protected
$_session
;
/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
protected
$_storeManager
;
/**
/**
* @var PaymentHelper
* @var PaymentHelper
*/
*/
protected
$_paymentHelper
;
protected
$_paymentHelper
;
/**
* @var \Magento\Framework\Locale\ResolverInterface
*/
protected
$_localeResolver
;
/**
/**
* @var \Adyen\Payment\Helper\Data
* @var \Adyen\Payment\Helper\Data
*/
*/
protected
$_adyenHelper
;
protected
$_adyenHelper
;
/**
* @var \Adyen\Payment\Logger\AdyenLogger
*/
protected
$_adyenLogger
;
/**
* @var AdyenGenericConfig
*/
protected
$_genericConfig
;
/**
* @var \Magento\Framework\App\Config\ScopeConfigInterface $config
*/
protected
$_config
;
/**
/**
* @var string[]
* @var string[]
*/
*/
...
@@ -90,36 +55,15 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
...
@@ -90,36 +55,15 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
/**
/**
* AdyenHppConfigProvider constructor.
* AdyenHppConfigProvider constructor.
*
*
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Checkout\Model\Session $session
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param PaymentHelper $paymentHelper
* @param PaymentHelper $paymentHelper
* @param \Magento\Framework\Locale\ResolverInterface $localeResolver
* @param \Magento\Framework\App\Config\ScopeConfigInterface $config
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param AdyenGenericConfig $genericConfig
*/
*/
public
function
__construct
(
public
function
__construct
(
\Magento\Framework\Model\Context
$context
,
\Magento\Checkout\Model\Session
$session
,
\Magento\Store\Model\StoreManagerInterface
$storeManager
,
PaymentHelper
$paymentHelper
,
PaymentHelper
$paymentHelper
,
\Magento\Framework\Locale\ResolverInterface
$localeResolver
,
\Adyen\Payment\Helper\Data
$adyenHelper
\Magento\Framework\App\Config\ScopeConfigInterface
$config
,
\Adyen\Payment\Helper\Data
$adyenHelper
,
\Adyen\Payment\Logger\AdyenLogger
$adyenLogger
,
\Adyen\Payment\Model\AdyenGenericConfig
$genericConfig
)
{
)
{
$this
->
_appState
=
$context
->
getAppState
();
$this
->
_session
=
$session
;
$this
->
_storeManager
=
$storeManager
;
$this
->
_paymentHelper
=
$paymentHelper
;
$this
->
_paymentHelper
=
$paymentHelper
;
$this
->
_localeResolver
=
$localeResolver
;
$this
->
_config
=
$config
;
$this
->
_adyenHelper
=
$adyenHelper
;
$this
->
_adyenHelper
=
$adyenHelper
;
$this
->
_adyenLogger
=
$adyenLogger
;
$this
->
_genericConfig
=
$genericConfig
;
foreach
(
$this
->
_methodCodes
as
$code
)
{
foreach
(
$this
->
_methodCodes
as
$code
)
{
$this
->
methods
[
$code
]
=
$this
->
_paymentHelper
->
getMethodInstance
(
$code
);
$this
->
methods
[
$code
]
=
$this
->
_paymentHelper
->
getMethodInstance
(
$code
);
...
@@ -142,328 +86,11 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
...
@@ -142,328 +86,11 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
foreach
(
$this
->
_methodCodes
as
$code
)
{
foreach
(
$this
->
_methodCodes
as
$code
)
{
if
(
$this
->
methods
[
$code
]
->
isAvailable
())
{
if
(
$this
->
methods
[
$code
]
->
isAvailable
())
{
// get payment methods
$paymentMethodSelectionOnAdyen
=
$config
[
'payment'
]
[
'adyenHpp'
][
'paymentMethods'
]
=
$this
->
getAdyenHppPaymentMethods
();
$this
->
_adyenHelper
->
getAdyenHppConfigDataFlag
(
'payment_selection_on_adyen'
);
}
}
$paymentMethodSelectionOnAdyen
=
$this
->
_adyenHelper
->
getAdyenHppConfigDataFlag
(
'payment_selection_on_adyen'
);
$config
[
'payment'
]
[
'adyenHpp'
][
'isPaymentMethodSelectionOnAdyen'
]
=
$paymentMethodSelectionOnAdyen
;
$config
[
'payment'
]
[
'adyenHpp'
][
'isPaymentMethodSelectionOnAdyen'
]
=
$paymentMethodSelectionOnAdyen
;
return
$config
;
}
/**
* @return array|null
* @throws \Magento\Framework\Exception\LocalizedException
*/
public
function
getAdyenHppPaymentMethods
()
{
$paymentMethods
=
null
;
// is admin?
if
(
$this
->
_appState
->
getAreaCode
()
===
\Magento\Backend\App\Area\FrontNameResolver
::
AREA_CODE
)
{
//retrieve storeId from quote
$store
=
$this
->
_session
->
getQuote
()
->
getStore
();
}
else
{
$store
=
$this
->
_storeManager
->
getStore
();
}
// is adyen HPP enabled ?
$hppActive
=
$this
->
methods
[
'adyen_hpp'
]
->
isAvailable
();
if
(
$hppActive
)
{
$paymentMethods
=
$this
->
_addHppMethodsToConfig
(
$store
);
}
return
$paymentMethods
;
}
/**
* @param $store
* @return array
*/
protected
function
_addHppMethodsToConfig
(
$store
)
{
$paymentMethods
=
[];
$ccEnabled
=
$this
->
_config
->
getValue
(
'payment/'
.
\Adyen\Payment\Model\Method\Cc
::
METHOD_CODE
.
'/active'
);
$ccTypes
=
array_keys
(
$this
->
_adyenHelper
->
getCcTypesAltData
());
$sepaEnabled
=
$this
->
_config
->
getValue
(
'payment/'
.
\Adyen\Payment\Model\Method\Sepa
::
METHOD_CODE
.
'/active'
);
foreach
(
$this
->
_fetchHppMethods
(
$store
)
as
$methodCode
=>
$methodData
)
{
/*
* skip payment methods if it is a creditcard that is enabled in adyen_cc
* or if payment is sepadirectdebit and SEPA api is enabled
*/
if
(
$ccEnabled
&&
in_array
(
$methodCode
,
$ccTypes
))
{
continue
;
}
elseif
(
$methodCode
==
'sepadirectdebit'
&&
$sepaEnabled
)
{
continue
;
}
$paymentMethods
[
$methodCode
]
=
$methodData
;
}
return
$paymentMethods
;
}
}
/**
* @param $store
* @return array
*/
protected
function
_fetchHppMethods
(
$store
)
{
$skinCode
=
$this
->
_adyenHelper
->
getAdyenHppConfigData
(
'skin_code'
);
$merchantAccount
=
$this
->
_adyenHelper
->
getAdyenAbstractConfigData
(
'merchant_account'
);
if
(
!
$skinCode
||
!
$merchantAccount
)
{
return
[];
}
}
return
$config
;
$adyFields
=
[
"paymentAmount"
=>
(
int
)
$this
->
_adyenHelper
->
formatAmount
(
$this
->
_getCurrentPaymentAmount
(),
$this
->
_getCurrentCurrencyCode
(
$store
)),
"currencyCode"
=>
$this
->
_getCurrentCurrencyCode
(
$store
),
"merchantReference"
=>
"Get Payment methods"
,
"skinCode"
=>
$skinCode
,
"merchantAccount"
=>
$merchantAccount
,
"sessionValidity"
=>
date
(
DATE_ATOM
,
mktime
(
date
(
"H"
)
+
1
,
date
(
"i"
),
date
(
"s"
),
date
(
"m"
),
date
(
"j"
),
date
(
"Y"
))
),
"countryCode"
=>
$this
->
_getCurrentCountryCode
(
$store
),
"shopperLocale"
=>
$this
->
_getCurrentLocaleCode
(
$store
)
];
$responseData
=
$this
->
_getDirectoryLookupResponse
(
$adyFields
,
$store
);
$paymentMethods
=
[];
if
(
isset
(
$responseData
[
'paymentMethods'
]))
{
foreach
(
$responseData
[
'paymentMethods'
]
as
$paymentMethod
)
{
$paymentMethodCode
=
$paymentMethod
[
'brandCode'
];
$paymentMethod
=
$this
->
_fieldMapPaymentMethod
(
$paymentMethod
);
// add icon location in result
if
(
$this
->
_genericConfig
->
showLogos
())
{
$asset
=
$this
->
_genericConfig
->
createAsset
(
'Adyen_Payment::images/logos/'
.
$paymentMethodCode
.
'.png'
);
$placeholder
=
$this
->
_genericConfig
->
findRelativeSourceFilePath
(
$asset
);
$icon
=
null
;
if
(
$placeholder
)
{
list
(
$width
,
$height
)
=
getimagesize
(
$asset
->
getSourceFile
());
$icon
=
[
'url'
=>
$asset
->
getUrl
(),
'width'
=>
$width
,
'height'
=>
$height
];
}
$paymentMethod
[
'icon'
]
=
$icon
;
}
$paymentMethods
[
$paymentMethodCode
]
=
$paymentMethod
;
}
}
return
$paymentMethods
;
}
/**
* @return bool|int
*/
protected
function
_getCurrentPaymentAmount
()
{
if
((
$grandTotal
=
$this
->
_getQuote
()
->
getGrandTotal
())
>
0
)
{
return
$grandTotal
;
}
return
10
;
}
/**
* @param $store
* @return mixed
*/
protected
function
_getCurrentCurrencyCode
(
$store
)
{
return
$this
->
_getQuote
()
->
getQuoteCurrencyCode
()
?:
$store
->
getBaseCurrencyCode
();
}
/**
* @param $store
* @return int|mixed|string
*/
protected
function
_getCurrentCountryCode
(
$store
)
{
// if fixed countryCode is setup in config use this
$countryCode
=
$this
->
_adyenHelper
->
getAdyenHppConfigData
(
'country_code'
,
$store
->
getId
());
if
(
$countryCode
!=
""
)
{
return
$countryCode
;
}
if
(
$country
=
$this
->
_getQuote
()
->
getBillingAddress
()
->
getCountry
())
{
return
$country
;
}
$defaultCountry
=
$this
->
_config
->
getValue
(
\Magento\Tax\Model\Config
::
CONFIG_XML_PATH_DEFAULT_COUNTRY
,
\Magento\Store\Model\ScopeInterface
::
SCOPE_STORES
,
$store
->
getCode
()
);
if
(
$defaultCountry
)
{
return
$defaultCountry
;
}
return
""
;
}
/**
* @param $store
* @return mixed|string
*/
protected
function
_getCurrentLocaleCode
(
$store
)
{
$localeCode
=
$this
->
_adyenHelper
->
getAdyenAbstractConfigData
(
'shopper_locale'
,
$store
->
getId
());
if
(
$localeCode
!=
""
)
{
return
$localeCode
;
}
$locale
=
$this
->
_localeResolver
->
getLocale
();
if
(
$locale
)
{
return
$locale
;
}
// should have the vulue if not fall back to default
$localeCode
=
$this
->
_config
->
getValue
(
Data
::
XML_PATH_DEFAULT_LOCALE
,
\Magento\Store\Model\ScopeInterface
::
SCOPE_STORES
,
$store
->
getCode
()
);
return
$localeCode
;
}
/**
* @var array
*/
protected
$_fieldMapPaymentMethod
=
[
'name'
=>
'title'
];
/**
* @param $paymentMethod
* @return mixed
*/
protected
function
_fieldMapPaymentMethod
(
$paymentMethod
)
{
foreach
(
$this
->
_fieldMapPaymentMethod
as
$field
=>
$newField
)
{
if
(
isset
(
$paymentMethod
[
$field
]))
{
$paymentMethod
[
$newField
]
=
$paymentMethod
[
$field
];
unset
(
$paymentMethod
[
$field
]);
}
}
return
$paymentMethod
;
}
/**
* @param $requestParams
* @param $store
* @return array
* @throws \Adyen\AdyenException
*/
protected
function
_getDirectoryLookupResponse
(
$requestParams
,
$store
)
{
$cacheKey
=
$this
->
_getCacheKeyForRequest
(
$requestParams
,
$store
);
// initialize the adyen client
$client
=
new
\Adyen\Client
();
if
(
$this
->
_adyenHelper
->
isDemoMode
())
{
$client
->
setEnvironment
(
\Adyen\Environment
::
TEST
);
}
else
{
$client
->
setEnvironment
(
\Adyen\Environment
::
LIVE
);
}
// connect to magento log
$client
->
setLogger
(
$this
->
_adyenLogger
);
$hmacKey
=
$this
->
_adyenHelper
->
getHmac
();
// create and add signature
try
{
$requestParams
[
"merchantSig"
]
=
\Adyen\Util\Util
::
calculateSha256Signature
(
$hmacKey
,
$requestParams
);
}
catch
(
\Adyen\AdyenException
$e
)
{
$this
->
_adyenLogger
->
error
(
$e
->
getMessage
());
// return empty result
return
[];
}
// initialize service
$service
=
new
\Adyen\Service\DirectoryLookup
(
$client
);
try
{
$responseData
=
$service
->
directoryLookup
(
$requestParams
);
}
catch
(
\Adyen\AdyenException
$e
)
{
$this
->
_adyenLogger
->
error
(
"The Directory Lookup response is empty check your Adyen configuration in Magento."
);
// return empty result
return
[];
}
return
$responseData
;
}
/**
* @var array
*/
protected
$_cacheParams
=
array
(
'currencyCode'
,
'merchantReference'
,
'skinCode'
,
'merchantAccount'
,
'countryCode'
,
'shopperLocale'
,
);
/**
* @param $requestParams
* @param $store
* @return string
*/
protected
function
_getCacheKeyForRequest
(
$requestParams
,
$store
)
{
$cacheParams
=
[];
$cacheParams
[
'store'
]
=
$store
->
getId
();
foreach
(
$this
->
_cacheParams
as
$paramKey
)
{
if
(
isset
(
$requestParams
[
$paramKey
]))
{
$cacheParams
[
$paramKey
]
=
$requestParams
[
$paramKey
];
}
}
return
md5
(
implode
(
'|'
,
$cacheParams
));
}
/**
* @return \Magento\Quote\Model\Quote
*/
protected
function
_getQuote
()
{
return
$this
->
_session
->
getQuote
();
}
/**
* Create a file asset that's subject of fallback system
*
* @param string $fileId
* @param array $params
* @return \Magento\Framework\View\Asset\File
*/
protected
function
_createAsset
(
$fileId
,
array
$params
=
[])
{
$params
=
array_merge
([
'_secure'
=>
$this
->
request
->
isSecure
()],
$params
);
return
$this
->
assetRepo
->
createAsset
(
$fileId
,
$params
);
}
}
}
}
\ No newline at end of file
Model/AdyenPaymentMethodManagement.php
0 → 100644
View file @
b5488960
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace
Adyen\Payment\Model
;
class
AdyenPaymentMethodManagement
implements
\Adyen\Payment\Api\AdyenPaymentMethodManagementInterface
{
/**
* @var \Adyen\Payment\Helper\PaymentMethods
*/
protected
$_paymentMethodsHelper
;
/**
* AdyenPaymentMethodManagement constructor.
*
* @param \Adyen\Payment\Helper\PaymentMethods $paymentMethodsHelper
*/
public
function
__construct
(
\Adyen\Payment\Helper\PaymentMethods
$paymentMethodsHelper
)
{
$this
->
_paymentMethodsHelper
=
$paymentMethodsHelper
;
}
/**
* {@inheritDoc}
*/
public
function
getPaymentMethods
(
$cartId
,
\Magento\Quote\Api\Data\AddressInterface
$shippingAddress
=
null
)
{
// if shippingAddress is provided use this country
$country
=
null
;
if
(
$shippingAddress
)
{
$country
=
$shippingAddress
->
getCountryId
();
}
return
$this
->
_paymentMethodsHelper
->
getPaymentMethods
(
$cartId
,
$country
);
}
}
\ No newline at end of file
Model/Api/PaymentRequest.php
View file @
b5488960
...
@@ -262,7 +262,7 @@ class PaymentRequest extends DataObject
...
@@ -262,7 +262,7 @@ class PaymentRequest extends DataObject
if
(
$paymentMethodCode
==
\Adyen\Payment\Model\Method\Cc
::
METHOD_CODE
||
if
(
$paymentMethodCode
==
\Adyen\Payment\Model\Method\Cc
::
METHOD_CODE
||
$paymentMethodCode
==
\Adyen\Payment\Model\Method\Oneclick
::
METHOD_CODE
)
{
$paymentMethodCode
==
\Adyen\Payment\Model\Method\Oneclick
::
METHOD_CODE
)
{
// If cse is enabled add encrypted card date into request
// If cse is enabled add encrypted card date into request
if
(
$this
->
_adyenHelper
->
getAdyenCcConfigDataFlag
(
'cse_enabled'
))
{
if
(
$this
->
_adyenHelper
->
getAdyenCcConfigDataFlag
(
'cse_enabled'
,
$storeId
))
{
$request
[
'additionalData'
][
'card.encrypted.json'
]
=
$request
[
'additionalData'
][
'card.encrypted.json'
]
=
$payment
->
getAdditionalInformation
(
"encrypted_data"
);
$payment
->
getAdditionalInformation
(
"encrypted_data"
);
}
else
{
}
else
{
...
@@ -303,7 +303,8 @@ class PaymentRequest extends DataObject
...
@@ -303,7 +303,8 @@ class PaymentRequest extends DataObject
public
function
authorise3d
(
$payment
)
public
function
authorise3d
(
$payment
)
{
{
$order
=
$payment
->
getOrder
();
$order
=
$payment
->
getOrder
();
$merchantAccount
=
$this
->
_adyenHelper
->
getAdyenAbstractConfigData
(
"merchant_account"
);
$storeId
=
$order
->
getStoreId
();
$merchantAccount
=
$this
->
_adyenHelper
->
getAdyenAbstractConfigData
(
"merchant_account"
,
$storeId
);
$shopperIp
=
$order
->
getRemoteIp
();
$shopperIp
=
$order
->
getRemoteIp
();
$md
=
$payment
->
getAdditionalInformation
(
'md'
);
$md
=
$payment
->
getAdditionalInformation
(
'md'
);
...
@@ -338,8 +339,9 @@ class PaymentRequest extends DataObject
...
@@ -338,8 +339,9 @@ class PaymentRequest extends DataObject
*/
*/
public
function
capture
(
\Magento\Payment\Model\InfoInterface
$payment
,
$amount
)
public
function
capture
(
\Magento\Payment\Model\InfoInterface
$payment
,
$amount
)
{
{
$storeId
=
$payment
->
getOrder
()
->
getStoreId
();
$pspReference
=
$this
->
_getPspReference
(
$payment
);
$pspReference
=
$this
->
_getPspReference
(
$payment
);
$merchantAccount
=
$this
->
_adyenHelper
->
getAdyenAbstractConfigData
(
"merchant_account"
);
$merchantAccount
=
$this
->
_adyenHelper
->
getAdyenAbstractConfigData
(
"merchant_account"
,
$storeId
);
$currency
=
$payment
->
getOrder
()
->
getBaseCurrencyCode
();
$currency
=
$payment
->
getOrder
()
->
getBaseCurrencyCode
();
//format the amount to minor units
//format the amount to minor units
...
@@ -385,8 +387,9 @@ class PaymentRequest extends DataObject
...
@@ -385,8 +387,9 @@ class PaymentRequest extends DataObject
*/
*/
public
function
cancelOrRefund
(
\Magento\Payment\Model\InfoInterface
$payment
)
public
function
cancelOrRefund
(
\Magento\Payment\Model\InfoInterface
$payment
)
{
{
$storeId
=
$payment
->
getOrder
()
->
getStoreId
();
$pspReference
=
$this
->
_getPspReference
(
$payment
);
$pspReference
=
$this
->
_getPspReference
(
$payment
);
$merchantAccount
=
$this
->
_adyenHelper
->
getAdyenAbstractConfigData
(
"merchant_account"
);
$merchantAccount
=
$this
->
_adyenHelper
->
getAdyenAbstractConfigData
(
"merchant_account"
,
$storeId
);
$request
=
[
$request
=
[
"merchantAccount"
=>
$merchantAccount
,
"merchantAccount"
=>
$merchantAccount
,
...
@@ -424,8 +427,9 @@ class PaymentRequest extends DataObject
...
@@ -424,8 +427,9 @@ class PaymentRequest extends DataObject
*/
*/
public
function
refund
(
\Magento\Payment\Model\InfoInterface
$payment
,
$amount
)
public
function
refund
(
\Magento\Payment\Model\InfoInterface
$payment
,
$amount
)
{
{
$storeId
=
$payment
->
getOrder
()
->
getStoreId
();
$pspReference
=
$this
->
_getPspReference
(
$payment
);
$pspReference
=
$this
->
_getPspReference
(
$payment
);
$merchantAccount
=
$this
->
_adyenHelper
->
getAdyenAbstractConfigData
(
"merchant_account"
);
$merchantAccount
=
$this
->
_adyenHelper
->
getAdyenAbstractConfigData
(
"merchant_account"
,
$storeId
);
$currency
=
$payment
->
getOrder
()
->
getBaseCurrencyCode
();
$currency
=
$payment
->
getOrder
()
->
getBaseCurrencyCode
();
//format the amount to minor units
//format the amount to minor units
...
@@ -536,12 +540,13 @@ class PaymentRequest extends DataObject
...
@@ -536,12 +540,13 @@ class PaymentRequest extends DataObject
*
*
* @param $recurringDetailReference
* @param $recurringDetailReference
* @param $shopperReference
* @param $shopperReference
* @param $storeId
* @return bool
* @return bool
* @throws \Magento\Framework\Exception\LocalizedException
* @throws \Magento\Framework\Exception\LocalizedException
*/
*/
public
function
disableRecurringContract
(
$recurringDetailReference
,
$shopperReference
)
public
function
disableRecurringContract
(
$recurringDetailReference
,
$shopperReference
,
$storeId
)
{
{
$merchantAccount
=
$this
->
_adyenHelper
->
getAdyenAbstractConfigData
(
"merchant_account"
);
$merchantAccount
=
$this
->
_adyenHelper
->
getAdyenAbstractConfigData
(
"merchant_account"
,
$storeId
);
$request
=
[
$request
=
[
"merchantAccount"
=>
$merchantAccount
,
"merchantAccount"
=>
$merchantAccount
,
...
...
Model/GuestAdyenPaymentMethodManagement.php
0 → 100644
View file @
b5488960
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace
Adyen\Payment\Model
;
class
GuestAdyenPaymentMethodManagement
implements
\Adyen\Payment\Api\GuestAdyenPaymentMethodManagementInterface
{
/**
* @var \Magento\Quote\Model\QuoteIdMaskFactory
*/
protected
$_quoteIdMaskFactory
;
/**
* @var \Adyen\Payment\Helper\PaymentMethods
*/
protected
$_paymentMethodsHelper
;
/**
* GuestAdyenPaymentMethodManagement constructor.
*
* @param \Magento\Quote\Model\QuoteIdMaskFactory $quoteIdMaskFactory
* @param \Adyen\Payment\Helper\PaymentMethods $paymentMethodsHelper
*/
public
function
__construct
(
\Magento\Quote\Model\QuoteIdMaskFactory
$quoteIdMaskFactory
,
\Adyen\Payment\Helper\PaymentMethods
$paymentMethodsHelper
)
{
$this
->
_quoteIdMaskFactory
=
$quoteIdMaskFactory
;
$this
->
_paymentMethodsHelper
=
$paymentMethodsHelper
;
}
/**
* {@inheritDoc}
*/
public
function
getPaymentMethods
(
$cartId
,
\Magento\Quote\Api\Data\AddressInterface
$shippingAddress
=
null
)
{
$quoteIdMask
=
$this
->
_quoteIdMaskFactory
->
create
()
->
load
(
$cartId
,
'masked_id'
);
$quoteId
=
$quoteIdMask
->
getQuoteId
();
// if shippingAddress is provided use this country
$country
=
null
;
if
(
$shippingAddress
)
{
$country
=
$shippingAddress
->
getCountryId
();
}
return
$this
->
_paymentMethodsHelper
->
getPaymentMethods
(
$quoteId
,
$country
);
}
}
\ No newline at end of file
Model/Method/Oneclick.php
View file @
b5488960
...
@@ -108,7 +108,8 @@ class Oneclick extends \Adyen\Payment\Model\Method\Cc
...
@@ -108,7 +108,8 @@ class Oneclick extends \Adyen\Payment\Model\Method\Cc
try
{
try
{
$this
->
_paymentRequest
->
disableRecurringContract
(
$this
->
_paymentRequest
->
disableRecurringContract
(
$agreement
->
getReferenceId
(),
$agreement
->
getReferenceId
(),
$agreement
->
getCustomerReference
()
$agreement
->
getCustomerReference
(),
$agreement
->
getStoreId
()
);
);
}
catch
(
Exception
$e
)
{
}
catch
(
Exception
$e
)
{
throw
new
\Magento\Framework\Exception\LocalizedException
(
__
(
'Failed to disable this contract'
));
throw
new
\Magento\Framework\Exception\LocalizedException
(
__
(
'Failed to disable this contract'
));
...
...
etc/di.xml
View file @
b5488960
...
@@ -87,4 +87,6 @@
...
@@ -87,4 +87,6 @@
<argument
name=
"dataStorage"
xsi:type=
"object"
>
adyenPaymentConfigDataStorage
</argument>
<argument
name=
"dataStorage"
xsi:type=
"object"
>
adyenPaymentConfigDataStorage
</argument>
</arguments>
</arguments>
</type>
</type>
<preference
for=
"Adyen\Payment\Api\GuestAdyenPaymentMethodManagementInterface"
type=
"Adyen\Payment\Model\GuestAdyenPaymentMethodManagement"
/>
<preference
for=
"Adyen\Payment\Api\AdyenPaymentMethodManagementInterface"
type=
"Adyen\Payment\Model\AdyenPaymentMethodManagement"
/>
</config>
</config>
\ No newline at end of file
etc/webapi.xml
0 → 100644
View file @
b5488960
<?xml version="1.0"?>
<!--
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
-->
<routes
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation=
"urn:magento:module:Magento_Webapi:etc/webapi.xsd"
>
<route
url=
"/V1/guest-carts/:cartId/retrieve-adyen-payment-methods"
method=
"POST"
>
<service
class=
"Adyen\Payment\Api\GuestAdyenPaymentMethodManagementInterface"
method=
"getPaymentMethods"
/>
<resources>
<resource
ref=
"anonymous"
/>
</resources>
</route>
<route
url=
"/V1/carts/mine/retrieve-adyen-payment-methods"
method=
"POST"
>
<service
class=
"Adyen\Payment\Api\AdyenPaymentMethodManagementInterface"
method=
"getPaymentMethods"
/>
<resources>
<resource
ref=
"self"
/>
</resources>
<data>
<parameter
name=
"cartId"
force=
"true"
>
%cart_id%
</parameter>
</data>
</route>
</routes>
\ No newline at end of file
view/frontend/web/js/model/adyen-method-list.js
0 → 100755
View file @
b5488960
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
define
(
[
'
ko
'
],
function
(
ko
)
{
'
use strict
'
;
return
ko
.
observableArray
([]);
}
);
view/frontend/web/js/model/adyen-payment-service.js
0 → 100644
View file @
b5488960
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
define
(
[
'
underscore
'
,
'
Magento_Checkout/js/model/quote
'
,
'
Adyen_Payment/js/model/adyen-method-list
'
,
],
function
(
_
,
quote
,
methodList
)
{
'
use strict
'
;
return
{
/**
* Populate the list of payment methods
* @param {Array} methods
*/
setPaymentMethods
:
function
(
methods
)
{
methodList
(
methods
);
},
/**
* Get the list of available payment methods.
* @returns {Array}
*/
getAvailablePaymentMethods
:
function
()
{
return
methodList
();
}
};
}
);
view/frontend/web/js/view/payment/method-renderer/adyen-cc-method.js
View file @
b5488960
...
@@ -29,9 +29,10 @@ define(
...
@@ -29,9 +29,10 @@ define(
'
Adyen_Payment/js/action/place-order
'
,
'
Adyen_Payment/js/action/place-order
'
,
'
mage/translate
'
,
'
mage/translate
'
,
'
Magento_Checkout/js/model/payment/additional-validators
'
,
'
Magento_Checkout/js/model/payment/additional-validators
'
,
'
Magento_Customer/js/model/customer
'
,
'
adyen/encrypt
'
'
adyen/encrypt
'
],
],
function
(
_
,
$
,
Component
,
placeOrderAction
,
$t
,
additionalValidators
,
adyenEncrypt
)
{
function
(
_
,
$
,
Component
,
placeOrderAction
,
$t
,
additionalValidators
,
customer
,
adyenEncrypt
)
{
'
use strict
'
;
'
use strict
'
;
return
Component
.
extend
({
return
Component
.
extend
({
...
@@ -141,7 +142,10 @@ define(
...
@@ -141,7 +142,10 @@ define(
return
window
.
checkoutConfig
.
payment
.
adyenCc
.
generationTime
;
return
window
.
checkoutConfig
.
payment
.
adyenCc
.
generationTime
;
},
},
canCreateBillingAgreement
:
function
()
{
canCreateBillingAgreement
:
function
()
{
if
(
customer
.
isLoggedIn
())
{
return
window
.
checkoutConfig
.
payment
.
adyenCc
.
canCreateBillingAgreement
;
return
window
.
checkoutConfig
.
payment
.
adyenCc
.
canCreateBillingAgreement
;
}
return
false
;
},
},
isShowLegend
:
function
()
{
isShowLegend
:
function
()
{
return
true
;
return
true
;
...
...
view/frontend/web/js/view/payment/method-renderer/adyen-hpp-method.js
View file @
b5488960
...
@@ -30,9 +30,14 @@ define(
...
@@ -30,9 +30,14 @@ define(
'
Magento_Checkout/js/action/select-payment-method
'
,
'
Magento_Checkout/js/action/select-payment-method
'
,
'
Magento_Checkout/js/model/quote
'
,
'
Magento_Checkout/js/model/quote
'
,
'
Magento_Checkout/js/checkout-data
'
,
'
Magento_Checkout/js/checkout-data
'
,
'
Magento_Checkout/js/model/payment/additional-validators
'
'
Magento_Checkout/js/model/payment/additional-validators
'
,
'
mage/storage
'
,
'
Magento_Checkout/js/model/url-builder
'
,
'
Adyen_Payment/js/model/adyen-payment-service
'
,
'
Magento_Customer/js/model/customer
'
,
'
Magento_Checkout/js/model/full-screen-loader
'
],
],
function
(
ko
,
$
,
Component
,
setPaymentMethodAction
,
selectPaymentMethodAction
,
quote
,
checkoutData
,
additionalValidators
)
{
function
(
ko
,
$
,
Component
,
setPaymentMethodAction
,
selectPaymentMethodAction
,
quote
,
checkoutData
,
additionalValidators
,
storage
,
urlBuilder
,
adyenPaymentService
,
customer
,
fullScreenLoader
)
{
'
use strict
'
;
'
use strict
'
;
var
brandCode
=
ko
.
observable
(
null
);
var
brandCode
=
ko
.
observable
(
null
);
var
paymentMethod
=
ko
.
observable
(
null
);
var
paymentMethod
=
ko
.
observable
(
null
);
...
@@ -51,14 +56,53 @@ define(
...
@@ -51,14 +56,53 @@ define(
]);
]);
return
this
;
return
this
;
},
},
initialize
:
function
()
{
this
.
_super
();
fullScreenLoader
.
startLoader
();
// reset variable:
adyenPaymentService
.
setPaymentMethods
();
// retrieve payment methods
var
serviceUrl
,
payload
;
if
(
customer
.
isLoggedIn
())
{
serviceUrl
=
urlBuilder
.
createUrl
(
'
/carts/mine/retrieve-adyen-payment-methods
'
,
{});
}
else
{
serviceUrl
=
urlBuilder
.
createUrl
(
'
/guest-carts/:cartId/retrieve-adyen-payment-methods
'
,
{
cartId
:
quote
.
getQuoteId
()
});
}
payload
=
{
cartId
:
quote
.
getQuoteId
(),
shippingAddress
:
quote
.
shippingAddress
()
};
storage
.
post
(
serviceUrl
,
JSON
.
stringify
(
payload
)
).
done
(
function
(
response
)
{
adyenPaymentService
.
setPaymentMethods
(
response
);
fullScreenLoader
.
stopLoader
();
}
).
fail
(
function
(
error
)
{
console
.
log
(
JSON
.
stringify
(
error
));
fullScreenLoader
.
stopLoader
();
});
},
getAdyenHppPaymentMethods
:
function
()
{
getAdyenHppPaymentMethods
:
function
()
{
var
self
=
this
;
var
self
=
this
;
// convert to list so you can iterate
var
paymentList
=
_
.
map
(
window
.
checkoutConfig
.
payment
.
adyenHpp
.
paymentMethods
,
function
(
value
,
key
)
{
if
(
key
==
"
ideal
"
)
{
var
paymentMethods
=
adyenPaymentService
.
getAvailablePaymentMethods
();
var
paymentList
=
_
.
map
(
paymentMethods
,
function
(
value
)
{
if
(
value
.
brandCode
==
"
ideal
"
)
{
return
{
return
{
'
value
'
:
key
,
'
value
'
:
value
.
brandCode
,
'
name
'
:
value
,
'
name
'
:
value
,
'
method
'
:
self
.
item
.
method
,
'
method
'
:
self
.
item
.
method
,
'
issuerIds
'
:
value
.
issuers
,
'
issuerIds
'
:
value
.
issuers
,
...
@@ -72,7 +116,7 @@ define(
...
@@ -72,7 +116,7 @@ define(
}
}
}
else
{
}
else
{
return
{
return
{
'
value
'
:
key
,
'
value
'
:
value
.
brandCode
,
'
name
'
:
value
,
'
name
'
:
value
,
'
method
'
:
self
.
item
.
method
,
'
method
'
:
self
.
item
.
method
,
getCode
:
function
()
{
getCode
:
function
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment