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
21cfa56a
Commit
21cfa56a
authored
Oct 16, 2018
by
attilak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Using DI instead of the object manager and create Adyen Clinet factory
function instead of WET
parent
d2419537
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
62 additions
and
127 deletions
+62
-127
Gateway/Http/Client/TransactionAuthorization.php
Gateway/Http/Client/TransactionAuthorization.php
+1
-26
Gateway/Http/Client/TransactionCancel.php
Gateway/Http/Client/TransactionCancel.php
+1
-25
Gateway/Http/Client/TransactionCapture.php
Gateway/Http/Client/TransactionCapture.php
+1
-25
Gateway/Http/Client/TransactionRefund.php
Gateway/Http/Client/TransactionRefund.php
+1
-25
Helper/Data.php
Helper/Data.php
+52
-2
Model/Api/PaymentRequest.php
Model/Api/PaymentRequest.php
+6
-24
No files found.
Gateway/Http/Client/TransactionAuthorization.php
View file @
21cfa56a
...
@@ -60,32 +60,7 @@ class TransactionAuthorization implements ClientInterface
...
@@ -60,32 +60,7 @@ class TransactionAuthorization implements ClientInterface
$this
->
_recurringType
=
$recurringType
;
$this
->
_recurringType
=
$recurringType
;
$this
->
_appState
=
$context
->
getAppState
();
$this
->
_appState
=
$context
->
getAppState
();
// initialize client
$this
->
_client
=
$this
->
_adyenHelper
->
initializeAdyenClient
();
$webserviceUsername
=
$this
->
_adyenHelper
->
getWsUsername
();
$webservicePassword
=
$this
->
_adyenHelper
->
getWsPassword
();
$client
=
new
\Adyen\Client
();
$client
->
setApplicationName
(
"Magento 2 plugin"
);
$client
->
setUsername
(
$webserviceUsername
);
$client
->
setPassword
(
$webservicePassword
);
$client
->
setAdyenPaymentSource
(
$this
->
_adyenHelper
->
getModuleName
(),
$this
->
_adyenHelper
->
getModuleVersion
());
$objectManager
=
\Magento\Framework\App\ObjectManager
::
getInstance
();
$productMetadata
=
$objectManager
->
get
(
'Magento\Framework\App\ProductMetadataInterface'
);
$client
->
setExternalPlatform
(
$productMetadata
->
getName
(),
$productMetadata
->
getVersion
());
if
(
$this
->
_adyenHelper
->
isDemoMode
())
{
$client
->
setEnvironment
(
\Adyen\Environment
::
TEST
);
}
else
{
$client
->
setEnvironment
(
\Adyen\Environment
::
LIVE
);
}
// assign magento log
$client
->
setLogger
(
$adyenLogger
);
$this
->
_client
=
$client
;
}
}
/**
/**
...
...
Gateway/Http/Client/TransactionCancel.php
View file @
21cfa56a
...
@@ -55,31 +55,7 @@ class TransactionCancel implements ClientInterface
...
@@ -55,31 +55,7 @@ class TransactionCancel implements ClientInterface
$this
->
_recurringType
=
$recurringType
;
$this
->
_recurringType
=
$recurringType
;
$this
->
_appState
=
$context
->
getAppState
();
$this
->
_appState
=
$context
->
getAppState
();
// initialize client
$this
->
_client
=
$this
->
_adyenHelper
->
initializeAdyenClient
();
$webserviceUsername
=
$this
->
_adyenHelper
->
getWsUsername
();
$webservicePassword
=
$this
->
_adyenHelper
->
getWsPassword
();
$client
=
new
\Adyen\Client
();
$client
->
setApplicationName
(
"Magento 2 plugin"
);
$client
->
setUsername
(
$webserviceUsername
);
$client
->
setPassword
(
$webservicePassword
);
$client
->
setAdyenPaymentSource
(
$this
->
_adyenHelper
->
getModuleName
(),
$this
->
_adyenHelper
->
getModuleVersion
());
$objectManager
=
\Magento\Framework\App\ObjectManager
::
getInstance
();
$productMetadata
=
$objectManager
->
get
(
'Magento\Framework\App\ProductMetadataInterface'
);
$client
->
setExternalPlatform
(
$productMetadata
->
getName
(),
$productMetadata
->
getVersion
());
if
(
$this
->
_adyenHelper
->
isDemoMode
())
{
$client
->
setEnvironment
(
\Adyen\Environment
::
TEST
);
}
else
{
$client
->
setEnvironment
(
\Adyen\Environment
::
LIVE
);
}
// assign magento log
$client
->
setLogger
(
$adyenLogger
);
$this
->
_client
=
$client
;
}
}
/**
/**
...
...
Gateway/Http/Client/TransactionCapture.php
View file @
21cfa56a
...
@@ -55,31 +55,7 @@ class TransactionCapture implements ClientInterface
...
@@ -55,31 +55,7 @@ class TransactionCapture implements ClientInterface
$this
->
_recurringType
=
$recurringType
;
$this
->
_recurringType
=
$recurringType
;
$this
->
_appState
=
$context
->
getAppState
();
$this
->
_appState
=
$context
->
getAppState
();
// initialize client
$this
->
_client
=
$this
->
_adyenHelper
->
initializeAdyenClient
();
$webserviceUsername
=
$this
->
_adyenHelper
->
getWsUsername
();
$webservicePassword
=
$this
->
_adyenHelper
->
getWsPassword
();
$client
=
new
\Adyen\Client
();
$client
->
setApplicationName
(
"Magento 2 plugin"
);
$client
->
setUsername
(
$webserviceUsername
);
$client
->
setPassword
(
$webservicePassword
);
$client
->
setAdyenPaymentSource
(
$this
->
_adyenHelper
->
getModuleName
(),
$this
->
_adyenHelper
->
getModuleVersion
());
$objectManager
=
\Magento\Framework\App\ObjectManager
::
getInstance
();
$productMetadata
=
$objectManager
->
get
(
'Magento\Framework\App\ProductMetadataInterface'
);
$client
->
setExternalPlatform
(
$productMetadata
->
getName
(),
$productMetadata
->
getVersion
());
if
(
$this
->
_adyenHelper
->
isDemoMode
())
{
$client
->
setEnvironment
(
\Adyen\Environment
::
TEST
);
}
else
{
$client
->
setEnvironment
(
\Adyen\Environment
::
LIVE
);
}
// assign magento log
$client
->
setLogger
(
$adyenLogger
);
$this
->
_client
=
$client
;
}
}
/**
/**
...
...
Gateway/Http/Client/TransactionRefund.php
View file @
21cfa56a
...
@@ -55,31 +55,7 @@ class TransactionRefund implements ClientInterface
...
@@ -55,31 +55,7 @@ class TransactionRefund implements ClientInterface
$this
->
_recurringType
=
$recurringType
;
$this
->
_recurringType
=
$recurringType
;
$this
->
_appState
=
$context
->
getAppState
();
$this
->
_appState
=
$context
->
getAppState
();
// initialize client
$this
->
_client
=
$this
->
_adyenHelper
->
initializeAdyenClient
();
$webserviceUsername
=
$this
->
_adyenHelper
->
getWsUsername
();
$webservicePassword
=
$this
->
_adyenHelper
->
getWsPassword
();
$client
=
new
\Adyen\Client
();
$client
->
setApplicationName
(
"Magento 2 plugin"
);
$client
->
setUsername
(
$webserviceUsername
);
$client
->
setPassword
(
$webservicePassword
);
$client
->
setAdyenPaymentSource
(
$this
->
_adyenHelper
->
getModuleName
(),
$this
->
_adyenHelper
->
getModuleVersion
());
$objectManager
=
\Magento\Framework\App\ObjectManager
::
getInstance
();
$productMetadata
=
$objectManager
->
get
(
'Magento\Framework\App\ProductMetadataInterface'
);
$client
->
setExternalPlatform
(
$productMetadata
->
getName
(),
$productMetadata
->
getVersion
());
if
(
$this
->
_adyenHelper
->
isDemoMode
())
{
$client
->
setEnvironment
(
\Adyen\Environment
::
TEST
);
}
else
{
$client
->
setEnvironment
(
\Adyen\Environment
::
LIVE
);
}
// assign magento log
$client
->
setLogger
(
$adyenLogger
);
$this
->
_client
=
$client
;
}
}
/**
/**
...
...
Helper/Data.php
View file @
21cfa56a
...
@@ -84,6 +84,16 @@ class Data extends AbstractHelper
...
@@ -84,6 +84,16 @@ class Data extends AbstractHelper
*/
*/
protected
$_taxCalculation
;
protected
$_taxCalculation
;
/**
* @var \Magento\Framework\App\ProductMetadataInterface
*/
protected
$productMetadata
;
/**
* @var \Adyen\Payment\Logger\AdyenLogger
*/
protected
$adyenLogger
;
/**
/**
* Data constructor.
* Data constructor.
*
*
...
@@ -95,6 +105,8 @@ class Data extends AbstractHelper
...
@@ -95,6 +105,8 @@ class Data extends AbstractHelper
* @param \Adyen\Payment\Model\ResourceModel\Billing\Agreement\CollectionFactory $billingAgreementCollectionFactory
* @param \Adyen\Payment\Model\ResourceModel\Billing\Agreement\CollectionFactory $billingAgreementCollectionFactory
* @param \Magento\Framework\View\Asset\Repository $assetRepo
* @param \Magento\Framework\View\Asset\Repository $assetRepo
* @param \Magento\Framework\View\Asset\Source $assetSource
* @param \Magento\Framework\View\Asset\Source $assetSource
* @param \Magento\Framework\App\ProductMetadataInterface $productMetadata
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
*/
*/
public
function
__construct
(
public
function
__construct
(
\Magento\Framework\App\Helper\Context
$context
,
\Magento\Framework\App\Helper\Context
$context
,
...
@@ -107,7 +119,10 @@ class Data extends AbstractHelper
...
@@ -107,7 +119,10 @@ class Data extends AbstractHelper
\Magento\Framework\View\Asset\Source
$assetSource
,
\Magento\Framework\View\Asset\Source
$assetSource
,
\Adyen\Payment\Model\ResourceModel\Notification\CollectionFactory
$notificationFactory
,
\Adyen\Payment\Model\ResourceModel\Notification\CollectionFactory
$notificationFactory
,
\Magento\Tax\Model\Config
$taxConfig
,
\Magento\Tax\Model\Config
$taxConfig
,
\Magento\Tax\Model\Calculation
$taxCalculation
\Magento\Tax\Model\Calculation
$taxCalculation
,
\Magento\Framework\App\ProductMetadataInterface
$productMetadata
,
\Adyen\Payment\Logger\AdyenLogger
$adyenLogger
)
{
)
{
parent
::
__construct
(
$context
);
parent
::
__construct
(
$context
);
$this
->
_encryptor
=
$encryptor
;
$this
->
_encryptor
=
$encryptor
;
...
@@ -120,6 +135,8 @@ class Data extends AbstractHelper
...
@@ -120,6 +135,8 @@ class Data extends AbstractHelper
$this
->
_notificationFactory
=
$notificationFactory
;
$this
->
_notificationFactory
=
$notificationFactory
;
$this
->
_taxConfig
=
$taxConfig
;
$this
->
_taxConfig
=
$taxConfig
;
$this
->
_taxCalculation
=
$taxCalculation
;
$this
->
_taxCalculation
=
$taxCalculation
;
$this
->
productMetadata
=
$productMetadata
;
$this
->
adyenLogger
=
$adyenLogger
;
}
}
/**
/**
...
@@ -1146,4 +1163,37 @@ class Data extends AbstractHelper
...
@@ -1146,4 +1163,37 @@ class Data extends AbstractHelper
}
}
return
$formFields
;
return
$formFields
;
}
}
}
\ No newline at end of file
/**
* Initializes and returns Adyen Client and sets the required parameters of it
*
* @param $storeId
* @return \Adyen\Client
* @throws \Adyen\AdyenException
*/
public
function
initializeAdyenClient
(
$storeId
=
null
)
{
// initialize client
$webserviceUsername
=
$this
->
getWsUsername
();
$webservicePassword
=
$this
->
getWsPassword
();
$client
=
new
\Adyen\Client
();
$client
->
setApplicationName
(
"Magento 2 plugin"
);
$client
->
setUsername
(
$webserviceUsername
);
$client
->
setPassword
(
$webservicePassword
);
$client
->
setAdyenPaymentSource
(
$this
->
getModuleName
(),
$this
->
getModuleVersion
());
$client
->
setExternalPlatform
(
$this
->
productMetadata
->
getName
(),
$this
->
productMetadata
->
getVersion
());
if
(
$this
->
isDemoMode
(
$storeId
))
{
$client
->
setEnvironment
(
\Adyen\Environment
::
TEST
);
}
else
{
$client
->
setEnvironment
(
\Adyen\Environment
::
LIVE
);
}
$client
->
setLogger
(
$this
->
adyenLogger
);
return
$client
;
}
}
Model/Api/PaymentRequest.php
View file @
21cfa56a
...
@@ -78,31 +78,13 @@ class PaymentRequest extends DataObject
...
@@ -78,31 +78,13 @@ class PaymentRequest extends DataObject
$this
->
_appState
=
$context
->
getAppState
();
$this
->
_appState
=
$context
->
getAppState
();
}
}
/**
* @param $storeId
* @return mixed
* @throws \Adyen\AdyenException
*/
private
function
createClient
(
$storeId
)
{
private
function
createClient
(
$storeId
)
{
// initialize client
$client
=
$this
->
_adyenHelper
->
initializeAdyenClient
(
$storeId
);
$webserviceUsername
=
$this
->
_adyenHelper
->
getWsUsername
(
$storeId
);
$webservicePassword
=
$this
->
_adyenHelper
->
getWsPassword
(
$storeId
);
$client
=
new
\Adyen\Client
();
$client
->
setApplicationName
(
"Magento 2 plugin"
);
$client
->
setUsername
(
$webserviceUsername
);
$client
->
setPassword
(
$webservicePassword
);
$client
->
setAdyenPaymentSource
(
$this
->
_adyenHelper
->
getModuleName
(),
$this
->
_adyenHelper
->
getModuleVersion
());
$objectManager
=
\Magento\Framework\App\ObjectManager
::
getInstance
();
$productMetadata
=
$objectManager
->
get
(
'Magento\Framework\App\ProductMetadataInterface'
);
$client
->
setExternalPlatform
(
$productMetadata
->
getName
(),
$productMetadata
->
getVersion
());
if
(
$this
->
_adyenHelper
->
isDemoMode
(
$storeId
))
{
$client
->
setEnvironment
(
\Adyen\Environment
::
TEST
);
}
else
{
$client
->
setEnvironment
(
\Adyen\Environment
::
LIVE
);
}
// assign magento log
$client
->
setLogger
(
$this
->
_adyenLogger
);
return
$client
;
return
$client
;
}
}
...
...
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