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
85a08120
Commit
85a08120
authored
Jun 23, 2017
by
Rik ter Beek
Committed by
GitHub
Jun 23, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #128 from Adyen/develop
Merge from "develop"
parents
8cdfe5de
d7691ceb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
37 deletions
+23
-37
Helper/Data.php
Helper/Data.php
+10
-24
Model/Api/PaymentRequest.php
Model/Api/PaymentRequest.php
+13
-13
No files found.
Helper/Data.php
View file @
85a08120
...
...
@@ -480,9 +480,9 @@ class Data extends AbstractHelper
* @desc Check if configuration is set to demo mode
* @return mixed
*/
public
function
isDemoMode
()
public
function
isDemoMode
(
$storeId
=
null
)
{
return
$this
->
getAdyenAbstractConfigDataFlag
(
'demo_mode'
);
return
$this
->
getAdyenAbstractConfigDataFlag
(
'demo_mode'
,
$storeId
);
}
/**
...
...
@@ -498,12 +498,12 @@ class Data extends AbstractHelper
* @desc Retrieve the webserver username
* @return string
*/
public
function
getWsUsername
()
public
function
getWsUsername
(
$storeId
=
null
)
{
if
(
$this
->
isDemoMode
())
{
$wsUsername
=
trim
(
$this
->
getAdyenAbstractConfigData
(
'ws_username_test'
));
if
(
$this
->
isDemoMode
(
$storeId
))
{
$wsUsername
=
trim
(
$this
->
getAdyenAbstractConfigData
(
'ws_username_test'
,
$storeId
));
}
else
{
$wsUsername
=
trim
(
$this
->
getAdyenAbstractConfigData
(
'ws_username_live'
));
$wsUsername
=
trim
(
$this
->
getAdyenAbstractConfigData
(
'ws_username_live'
,
$storeId
));
}
return
$wsUsername
;
}
...
...
@@ -512,30 +512,16 @@ class Data extends AbstractHelper
* @desc Retrieve the webserver password
* @return string
*/
public
function
getWsPassword
()
public
function
getWsPassword
(
$storeId
=
null
)
{
if
(
$this
->
isDemoMode
())
{
$wsPassword
=
$this
->
_encryptor
->
decrypt
(
trim
(
$this
->
getAdyenAbstractConfigData
(
'ws_password_test'
)));
if
(
$this
->
isDemoMode
(
$storeId
))
{
$wsPassword
=
$this
->
_encryptor
->
decrypt
(
trim
(
$this
->
getAdyenAbstractConfigData
(
'ws_password_test'
,
$storeId
)));
}
else
{
$wsPassword
=
$this
->
_encryptor
->
decrypt
(
trim
(
$this
->
getAdyenAbstractConfigData
(
'ws_password_live'
)));
$wsPassword
=
$this
->
_encryptor
->
decrypt
(
trim
(
$this
->
getAdyenAbstractConfigData
(
'ws_password_live'
,
$storeId
)));
}
return
$wsPassword
;
}
/**
* @desc Retrieve the webserver url defined in the config.xlm only
* @return string
*/
public
function
getWsUrl
()
{
if
(
$this
->
isDemoMode
())
{
$url
=
$this
->
getAdyenAbstractConfigData
(
'ws_url_test'
);
}
else
{
$url
=
$this
->
getAdyenAbstractConfigData
(
'ws_url_live'
);
}
return
$url
;
}
/**
* @desc Cancels the order
* @param $order
...
...
Model/Api/PaymentRequest.php
View file @
85a08120
...
...
@@ -43,11 +43,6 @@ class PaymentRequest extends DataObject
*/
protected
$_adyenLogger
;
/**
* @var \Adyen\Client
*/
protected
$_client
;
/**
* @var \Adyen\Payment\Model\RecurringType
*/
...
...
@@ -81,26 +76,28 @@ class PaymentRequest extends DataObject
$this
->
_adyenLogger
=
$adyenLogger
;
$this
->
_recurringType
=
$recurringType
;
$this
->
_appState
=
$context
->
getAppState
();
}
private
function
createClient
(
$storeId
)
{
// initialize client
$webserviceUsername
=
$this
->
_adyenHelper
->
getWsUsername
();
$webservicePassword
=
$this
->
_adyenHelper
->
getWsPassword
();
$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
);
if
(
$this
->
_adyenHelper
->
isDemoMode
())
{
if
(
$this
->
_adyenHelper
->
isDemoMode
(
$storeId
))
{
$client
->
setEnvironment
(
\Adyen\Environment
::
TEST
);
}
else
{
$client
->
setEnvironment
(
\Adyen\Environment
::
LIVE
);
}
// assign magento log
$client
->
setLogger
(
$adyenLogger
);
$client
->
setLogger
(
$
this
->
_
adyenLogger
);
$this
->
_client
=
$client
;
return
$client
;
}
/**
...
...
@@ -128,7 +125,8 @@ class PaymentRequest extends DataObject
];
try
{
$service
=
new
\Adyen\Service\Payment
(
$this
->
_client
);
$client
=
$this
->
createClient
(
$storeId
);
$service
=
new
\Adyen\Service\Payment
(
$client
);
$result
=
$service
->
authorise3D
(
$request
);
}
catch
(
\Adyen\AdyenException
$e
)
{
throw
new
\Magento\Framework\Exception\LocalizedException
(
__
(
'3D secure failed'
));
...
...
@@ -203,7 +201,8 @@ class PaymentRequest extends DataObject
];
// call lib
$service
=
new
\Adyen\Service\Recurring
(
$this
->
_client
);
$client
=
$this
->
createClient
(
$storeId
);
$service
=
new
\Adyen\Service\Recurring
(
$client
);
$result
=
$service
->
listRecurringDetails
(
$request
);
return
$result
;
...
...
@@ -229,7 +228,8 @@ class PaymentRequest extends DataObject
];
// call lib
$service
=
new
\Adyen\Service\Recurring
(
$this
->
_client
);
$client
=
$this
->
createClient
(
$storeId
);
$service
=
new
\Adyen\Service\Recurring
(
$client
);
try
{
$result
=
$service
->
disable
(
$request
);
...
...
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