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
fa758982
Commit
fa758982
authored
Dec 21, 2018
by
Rik ter Beek
Browse files
Options
Browse Files
Download
Plain Diff
fix rebase
parents
7e95d1ca
48811d7c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
168 additions
and
164 deletions
+168
-164
Gateway/Request/CcAuthorizationDataBuilder.php
Gateway/Request/CcAuthorizationDataBuilder.php
+65
-66
Helper/Data.php
Helper/Data.php
+90
-92
Model/Ui/AdyenGenericConfigProvider.php
Model/Ui/AdyenGenericConfigProvider.php
+6
-6
etc/di.xml
etc/di.xml
+7
-0
No files found.
Gateway/Request/CcAuthorizationDataBuilder.php
View file @
fa758982
...
...
@@ -38,79 +38,78 @@ class CcAuthorizationDataBuilder implements BuilderInterface
*/
private
$appState
;
/**
* CcAuthorizationDataBuilder constructor.
*
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Magento\Framework\Model\Context $context
*/
public
function
__construct
(
\Adyen\Payment\Helper\Data
$adyenHelper
,
\Magento\Framework\Model\Context
$context
)
{
$this
->
adyenHelper
=
$adyenHelper
;
$this
->
appState
=
$context
->
getAppState
();
}
/**
* CcAuthorizationDataBuilder constructor.
*
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Magento\Framework\Model\Context $context
*/
public
function
__construct
(
\Adyen\Payment\Helper\Data
$adyenHelper
,
\Magento\Framework\Model\Context
$context
)
{
$this
->
adyenHelper
=
$adyenHelper
;
$this
->
appState
=
$context
->
getAppState
();
}
/**
* @param array $buildSubject
* @return mixed
*/
public
function
build
(
array
$buildSubject
)
{
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject
=
\Magento\Payment\Gateway\Helper\SubjectReader
::
readPayment
(
$buildSubject
);
$payment
=
$paymentDataObject
->
getPayment
();
$order
=
$paymentDataObject
->
getOrder
();
$storeId
=
$order
->
getStoreId
();
$request
=
[];
/**
* @param array $buildSubject
* @return mixed
*/
public
function
build
(
array
$buildSubject
)
{
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject
=
\Magento\Payment\Gateway\Helper\SubjectReader
::
readPayment
(
$buildSubject
);
$payment
=
$paymentDataObject
->
getPayment
();
$order
=
$paymentDataObject
->
getOrder
();
$storeId
=
$order
->
getStoreId
();
$request
=
[];
$request
[
'paymentMethod'
][
'type'
]
=
"scheme"
;
$request
[
'paymentMethod'
][
'type'
]
=
"scheme"
;
if
(
$cardNumber
=
$payment
->
getAdditionalInformation
(
AdyenCcDataAssignObserver
::
CREDIT_CARD_NUMBER
))
{
$request
[
'paymentMethod'
][
'encryptedCardNumber'
]
=
$cardNumber
;
}
if
(
$cardNumber
=
$payment
->
getAdditionalInformation
(
AdyenCcDataAssignObserver
::
CREDIT_CARD_NUMBER
))
{
$request
[
'paymentMethod'
][
'encryptedCardNumber'
]
=
$cardNumber
;
}
if
(
$expiryMonth
=
$payment
->
getAdditionalInformation
(
AdyenCcDataAssignObserver
::
EXPIRY_MONTH
))
{
$request
[
'paymentMethod'
][
'encryptedExpiryMonth'
]
=
$expiryMonth
;
}
if
(
$expiryMonth
=
$payment
->
getAdditionalInformation
(
AdyenCcDataAssignObserver
::
EXPIRY_MONTH
))
{
$request
[
'paymentMethod'
][
'encryptedExpiryMonth'
]
=
$expiryMonth
;
}
if
(
$expiryYear
=
$payment
->
getAdditionalInformation
(
AdyenCcDataAssignObserver
::
EXPIRY_YEAR
))
{
$request
[
'paymentMethod'
][
'encryptedExpiryYear'
]
=
$expiryYear
;
}
if
(
$expiryYear
=
$payment
->
getAdditionalInformation
(
AdyenCcDataAssignObserver
::
EXPIRY_YEAR
))
{
$request
[
'paymentMethod'
][
'encryptedExpiryYear'
]
=
$expiryYear
;
}
if
(
$holderName
=
$payment
->
getAdditionalInformation
(
AdyenCcDataAssignObserver
::
HOLDER_NAME
))
{
$request
[
'paymentMethod'
][
'holderName'
]
=
$holderName
;
}
if
(
$holderName
=
$payment
->
getAdditionalInformation
(
AdyenCcDataAssignObserver
::
HOLDER_NAME
))
{
$request
[
'paymentMethod'
][
'holderName'
]
=
$holderName
;
}
if
(
$securityCode
=
$payment
->
getAdditionalInformation
(
AdyenCcDataAssignObserver
::
SECURITY_CODE
))
{
$request
[
'paymentMethod'
][
'encryptedSecurityCode'
]
=
$securityCode
;
}
if
(
$securityCode
=
$payment
->
getAdditionalInformation
(
AdyenCcDataAssignObserver
::
SECURITY_CODE
))
{
$request
[
'paymentMethod'
][
'encryptedSecurityCode'
]
=
$securityCode
;
}
// Remove from additional data
$payment
->
unsAdditionalInformation
(
AdyenCcDataAssignObserver
::
CREDIT_CARD_NUMBER
);
$payment
->
unsAdditionalInformation
(
AdyenCcDataAssignObserver
::
EXPIRY_MONTH
);
$payment
->
unsAdditionalInformation
(
AdyenCcDataAssignObserver
::
EXPIRY_YEAR
);
$payment
->
unsAdditionalInformation
(
AdyenCcDataAssignObserver
::
SECURITY_CODE
);
$payment
->
unsAdditionalInformation
(
AdyenCcDataAssignObserver
::
HOLDER_NAME
);
// Remove from additional data
$payment
->
unsAdditionalInformation
(
AdyenCcDataAssignObserver
::
CREDIT_CARD_NUMBER
);
$payment
->
unsAdditionalInformation
(
AdyenCcDataAssignObserver
::
EXPIRY_MONTH
);
$payment
->
unsAdditionalInformation
(
AdyenCcDataAssignObserver
::
EXPIRY_YEAR
);
$payment
->
unsAdditionalInformation
(
AdyenCcDataAssignObserver
::
SECURITY_CODE
);
$payment
->
unsAdditionalInformation
(
AdyenCcDataAssignObserver
::
HOLDER_NAME
);
/**
* if MOTO for backend is enabled use MOTO as shopper interaction type
*/
$enableMoto
=
$this
->
adyenHelper
->
getAdyenCcConfigDataFlag
(
'enable_moto'
,
$storeId
);
if
(
$this
->
appState
->
getAreaCode
()
===
\Magento\Backend\App\Area\FrontNameResolver
::
AREA_CODE
&&
$enableMoto
)
{
$request
[
'shopperInteraction'
]
=
"Moto"
;
}
// if installments is set add it into the request
if
(
$payment
->
getAdditionalInformation
(
AdyenCcDataAssignObserver
::
NUMBER_OF_INSTALLMENTS
)
&&
$payment
->
getAdditionalInformation
(
AdyenCcDataAssignObserver
::
NUMBER_OF_INSTALLMENTS
)
>
0
)
{
$request
[
'installments'
][
'value'
]
=
$payment
->
getAdditionalInformation
(
AdyenCcDataAssignObserver
::
NUMBER_OF_INSTALLMENTS
);
}
/**
* if MOTO for backend is enabled use MOTO as shopper interaction type
*/
$enableMoto
=
$this
->
adyenHelper
->
getAdyenCcConfigDataFlag
(
'enable_moto'
,
$storeId
);
if
(
$this
->
appState
->
getAreaCode
()
===
\Magento\Backend\App\Area\FrontNameResolver
::
AREA_CODE
&&
$enableMoto
)
{
$request
[
'shopperInteraction'
]
=
"Moto"
;
}
// if installments is set add it into the request
if
(
$payment
->
getAdditionalInformation
(
AdyenCcDataAssignObserver
::
NUMBER_OF_INSTALLMENTS
)
&&
$payment
->
getAdditionalInformation
(
AdyenCcDataAssignObserver
::
NUMBER_OF_INSTALLMENTS
)
>
0
)
{
$request
[
'installments'
][
'value'
]
=
$payment
->
getAdditionalInformation
(
AdyenCcDataAssignObserver
::
NUMBER_OF_INSTALLMENTS
);
}
return
$request
;
}
}
\ No newline at end of file
return
$request
;
}
}
Helper/Data.php
View file @
fa758982
...
...
@@ -34,9 +34,9 @@ class Data extends AbstractHelper
const
TEST
=
'test'
;
const
LIVE
=
'live'
;
const
CHECKOUT_CONTEXT_URL_LIVE
=
'https://checkoutshopper-live.adyen.com/checkoutshopper/'
;
const
CHECKOUT_CONTEXT_URL_TEST
=
'https://checkoutshopper-test.adyen.com/checkoutshopper/'
;
const
CHECKOUT_COMPONENT_JS_LIVE
=
'https://checkoutshopper-live.adyen.com/checkoutshopper/sdk/2.0.0-beta.4/adyen.js'
;
const
CHECKOUT_COMPONENT_JS_TEST
=
'https://checkoutshopper-test.adyen.com/checkoutshopper/sdk/2.0.0-beta.4/adyen.js'
;
const
CHECKOUT_CONTEXT_URL_TEST
=
'https://checkoutshopper-test.adyen.com/checkoutshopper/'
;
const
CHECKOUT_COMPONENT_JS_LIVE
=
'https://checkoutshopper-live.adyen.com/checkoutshopper/sdk/2.0.0-beta.4/adyen.js'
;
const
CHECKOUT_COMPONENT_JS_TEST
=
'https://checkoutshopper-test.adyen.com/checkoutshopper/sdk/2.0.0-beta.4/adyen.js'
;
/**
* @var \Magento\Framework\Encryption\EncryptorInterface
...
...
@@ -98,35 +98,35 @@ class Data extends AbstractHelper
*/
protected
$adyenLogger
;
/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
protected
$storeManager
;
/**
* @var \Magento\Framework\App\CacheInterface
*/
/**
* @var \Magento\Framework\App\CacheInterface
*/
protected
$cache
;
/**
* Data constructor.
*
* @param \Magento\Framework\App\Helper\Context $context
* @param \Magento\Framework\Encryption\EncryptorInterface $encryptor
* @param \Magento\Framework\Config\DataInterface $dataStorage
* @param \Magento\Directory\Model\Config\Source\Country $country
* @param \Magento\Framework\Module\ModuleListInterface $moduleList
* @param \Adyen\Payment\Model\ResourceModel\Billing\Agreement\CollectionFactory $billingAgreementCollectionFactory
* @param \Magento\Framework\View\Asset\Repository $assetRepo
* @param \Magento\Framework\View\Asset\Source $assetSource
* @param \Adyen\Payment\Model\ResourceModel\Notification\CollectionFactory $notificationFactory
* @param \Magento\Tax\Model\Config $taxConfig
* @param \Magento\Tax\Model\Calculation $taxCalculation
* @param \Magento\Framework\App\ProductMetadataInterface $productMetadata
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Framework\App\CacheInterface $cache
*/
/**
* Data constructor.
*
* @param \Magento\Framework\App\Helper\Context $context
* @param \Magento\Framework\Encryption\EncryptorInterface $encryptor
* @param \Magento\Framework\Config\DataInterface $dataStorage
* @param \Magento\Directory\Model\Config\Source\Country $country
* @param \Magento\Framework\Module\ModuleListInterface $moduleList
* @param \Adyen\Payment\Model\ResourceModel\Billing\Agreement\CollectionFactory $billingAgreementCollectionFactory
* @param \Magento\Framework\View\Asset\Repository $assetRepo
* @param \Magento\Framework\View\Asset\Source $assetSource
* @param \Adyen\Payment\Model\ResourceModel\Notification\CollectionFactory $notificationFactory
* @param \Magento\Tax\Model\Config $taxConfig
* @param \Magento\Tax\Model\Calculation $taxCalculation
* @param \Magento\Framework\App\ProductMetadataInterface $productMetadata
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Framework\App\CacheInterface $cache
*/
public
function
__construct
(
\Magento\Framework\App\Helper\Context
$context
,
\Magento\Framework\Encryption\EncryptorInterface
$encryptor
,
...
...
@@ -139,11 +139,10 @@ class Data extends AbstractHelper
\Adyen\Payment\Model\ResourceModel\Notification\CollectionFactory
$notificationFactory
,
\Magento\Tax\Model\Config
$taxConfig
,
\Magento\Tax\Model\Calculation
$taxCalculation
,
\Magento\Framework\App\ProductMetadataInterface
$productMetadata
,
\Adyen\Payment\Logger\AdyenLogger
$adyenLogger
,
\Magento\Store\Model\StoreManagerInterface
$storeManager
,
\Magento\Framework\App\CacheInterface
$cache
\Magento\Framework\App\ProductMetadataInterface
$productMetadata
,
\Adyen\Payment\Logger\AdyenLogger
$adyenLogger
,
\Magento\Store\Model\StoreManagerInterface
$storeManager
,
\Magento\Framework\App\CacheInterface
$cache
)
{
parent
::
__construct
(
$context
);
$this
->
_encryptor
=
$encryptor
;
...
...
@@ -601,12 +600,12 @@ class Data extends AbstractHelper
return
$secretWord
;
}
/**
* @desc Check if configuration is set to demo mode
*
* @param int|null $storeId
* @return mixed
*/
/**
* @desc Check if configuration is set to demo mode
*
* @param int|null $storeId
* @return mixed
*/
public
function
isDemoMode
(
$storeId
=
null
)
{
return
$this
->
getAdyenAbstractConfigDataFlag
(
'demo_mode'
,
$storeId
);
...
...
@@ -621,51 +620,51 @@ class Data extends AbstractHelper
return
$this
->
_encryptor
->
decrypt
(
trim
(
$this
->
getAdyenAbstractConfigData
(
'notification_password'
)));
}
/**
* @desc Retrieve the API key
*
* @param int|null $storeId
* @return string
*/
public
function
getAPIKey
(
$storeId
=
null
)
{
if
(
$this
->
isDemoMode
(
$storeId
))
{
$apiKey
=
$this
->
_encryptor
->
decrypt
(
trim
(
$this
->
getAdyenAbstractConfigData
(
'api_key_test'
,
$storeId
)));
}
else
{
$apiKey
=
$this
->
_encryptor
->
decrypt
(
trim
(
$this
->
getAdyenAbstractConfigData
(
'api_key_live'
,
$storeId
)));
}
return
$apiKey
;
}
/**
* @desc Retrieve the API key
*
* @param int|null $storeId
* @return string
*/
public
function
getAPIKey
(
$storeId
=
null
)
{
if
(
$this
->
isDemoMode
(
$storeId
))
{
$apiKey
=
$this
->
_encryptor
->
decrypt
(
trim
(
$this
->
getAdyenAbstractConfigData
(
'api_key_test'
,
$storeId
)));
}
else
{
$apiKey
=
$this
->
_encryptor
->
decrypt
(
trim
(
$this
->
getAdyenAbstractConfigData
(
'api_key_live'
,
$storeId
)));
}
return
$apiKey
;
}
/**
* @desc Retrieve the webserver username
*
* @param int|null $storeId
* @return string
*/
public
function
getWsUsername
(
$storeId
=
null
)
{
if
(
$this
->
isDemoMode
(
$storeId
))
{
$wsUsername
=
trim
(
$this
->
getAdyenAbstractConfigData
(
'ws_username_test'
,
$storeId
));
}
else
{
$wsUsername
=
trim
(
$this
->
getAdyenAbstractConfigData
(
'ws_username_live'
,
$storeId
));
}
return
$wsUsername
;
}
/**
* @desc Retrieve the webserver username
*
* @param int|null $storeId
* @return string
*/
public
function
getWsUsername
(
$storeId
=
null
)
{
if
(
$this
->
isDemoMode
(
$storeId
))
{
$wsUsername
=
trim
(
$this
->
getAdyenAbstractConfigData
(
'ws_username_test'
,
$storeId
));
}
else
{
$wsUsername
=
trim
(
$this
->
getAdyenAbstractConfigData
(
'ws_username_live'
,
$storeId
));
}
return
$wsUsername
;
}
/**
* @desc Retrieve the Live endpoint prefix key
*
* @param int|null $storeId
* @return string
*/
public
function
getLiveEndpointPrefix
(
$storeId
=
null
)
{
$prefix
=
trim
(
$this
->
getAdyenAbstractConfigData
(
'live_endpoint_url_prefix'
,
$storeId
));
return
$prefix
;
}
/**
* @desc Retrieve the Live endpoint prefix key
*
* @param int|null $storeId
* @return string
*/
public
function
getLiveEndpointPrefix
(
$storeId
=
null
)
{
$prefix
=
trim
(
$this
->
getAdyenAbstractConfigData
(
'live_endpoint_url_prefix'
,
$storeId
));
return
$prefix
;
}
/**
* @desc Cancels the order
...
...
@@ -1059,7 +1058,6 @@ class Data extends AbstractHelper
$notifications
=
$this
->
_notificationFactory
->
create
();
$notifications
->
unprocessedNotificationsFilter
();
return
$notifications
->
getSize
();
;
}
/**
...
...
@@ -1320,20 +1318,20 @@ class Data extends AbstractHelper
$apiKey
=
$this
->
getAPIKey
(
$storeId
);
$client
=
$this
->
createAdyenClient
();
$client
->
setApplicationName
(
"Magento 2 plugin"
);
$client
->
setApplicationName
(
"Magento 2 plugin"
);
$client
->
setXApiKey
(
$apiKey
);
$client
->
setAdyenPaymentSource
(
$this
->
getModuleName
(),
$this
->
getModuleVersion
());
$client
->
setAdyenPaymentSource
(
$this
->
getModuleName
(),
$this
->
getModuleVersion
());
$client
->
setExternalPlatform
(
$this
->
productMetadata
->
getName
(),
$this
->
productMetadata
->
getVersion
());
$client
->
setExternalPlatform
(
$this
->
productMetadata
->
getName
(),
$this
->
productMetadata
->
getVersion
());
if
(
$this
->
isDemoMode
(
$storeId
))
{
$client
->
setEnvironment
(
\Adyen\Environment
::
TEST
);
}
else
{
if
(
$this
->
isDemoMode
(
$storeId
))
{
$client
->
setEnvironment
(
\Adyen\Environment
::
TEST
);
}
else
{
$client
->
setEnvironment
(
\Adyen\Environment
::
LIVE
,
$this
->
getLiveEndpointPrefix
(
$storeId
));
}
}
$client
->
setLogger
(
$this
->
adyenLogger
);
$client
->
setLogger
(
$this
->
adyenLogger
);
return
$client
;
}
...
...
@@ -1442,5 +1440,5 @@ class Data extends AbstractHelper
}
return
self
::
CHECKOUT_COMPONENT_JS_LIVE
;
}
}
}
Model/Ui/AdyenGenericConfigProvider.php
View file @
fa758982
...
...
@@ -34,10 +34,10 @@ class AdyenGenericConfigProvider implements ConfigProviderInterface
*/
protected
$_adyenHelper
;
/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
protected
$storeManager
;
/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
protected
$storeManager
;
/**
* AdyenGenericConfigProvider constructor.
...
...
@@ -49,7 +49,7 @@ class AdyenGenericConfigProvider implements ConfigProviderInterface
\Magento\Store\Model\StoreManagerInterface
$storeManager
)
{
$this
->
_adyenHelper
=
$adyenHelper
;
$this
->
storeManager
=
$storeManager
;
$this
->
storeManager
=
$storeManager
;
}
/**
...
...
@@ -69,7 +69,7 @@ class AdyenGenericConfigProvider implements ConfigProviderInterface
$config
[
'payment'
][
'adyen'
][
'showLogo'
]
=
false
;
}
$config
[
'payment'
][
'checkoutCardComponentSource'
]
=
$this
->
_adyenHelper
->
getCheckoutCardComponentJs
(
$this
->
storeManager
->
getStore
()
->
getId
());
$config
[
'payment'
][
'checkoutCardComponentSource'
]
=
$this
->
_adyenHelper
->
getCheckoutCardComponentJs
(
$this
->
storeManager
->
getStore
()
->
getId
());
return
$config
;
}
...
...
etc/di.xml
View file @
fa758982
...
...
@@ -825,6 +825,13 @@
</arguments>
</virtualType>
<!--Checkout Response validator-->
<virtualType
name=
"CheckoutResponseValidator"
type=
"Adyen\Payment\Gateway\Validator\CheckoutResponseValidator"
>
<arguments>
<argument
name=
"loggerInterface"
xsi:type=
"object"
>
Adyen\Payment\Logger\AdyenLogger
</argument>
</arguments>
</virtualType>
<virtualType
name=
"PosCloudResponseValidator"
type=
"Adyen\Payment\Gateway\Validator\PosCloudResponseValidator"
>
<arguments>
<argument
name=
"loggerInterface"
xsi:type=
"object"
>
Adyen\Payment\Logger\AdyenLogger
</argument>
...
...
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