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
d1635b1e
Commit
d1635b1e
authored
Aug 10, 2018
by
Giorgos Adam
Committed by
GitHub
Aug 10, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #300 from Adyen/develop
Release 2.3.1
parents
527ab731
dee1944e
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
67 additions
and
38 deletions
+67
-38
Block/Redirect/Redirect.php
Block/Redirect/Redirect.php
+3
-11
Controller/Process/Json.php
Controller/Process/Json.php
+3
-2
Controller/Process/Result.php
Controller/Process/Result.php
+3
-9
Gateway/Command/PayByMailCommand.php
Gateway/Command/PayByMailCommand.php
+2
-9
Model/Cron.php
Model/Cron.php
+39
-3
Test/Unit/Helper/DataTest.php
Test/Unit/Helper/DataTest.php
+15
-2
composer.json
composer.json
+1
-1
etc/module.xml
etc/module.xml
+1
-1
No files found.
Block/Redirect/Redirect.php
View file @
d1635b1e
...
...
@@ -261,8 +261,6 @@ class Redirect extends \Magento\Payment\Block\Form
->
getBaseUrl
(
\Magento\Framework\UrlInterface
::
URL_TYPE_LINK
);
$formFields
[
'resURL'
]
=
$baseUrl
.
'adyen/process/result'
;
$hmacKey
=
$this
->
_adyenHelper
->
getHmac
();
if
(
$brandCode
)
{
$formFields
[
'brandCode'
]
=
$brandCode
;
...
...
@@ -307,15 +305,9 @@ class Redirect extends \Magento\Payment\Block\Form
$formFields
[
'dfValue'
]
=
$this
->
_order
->
getPayment
()
->
getAdditionalInformation
(
"df_value"
);
}
// Sort the array by key using SORT_STRING order
ksort
(
$formFields
,
SORT_STRING
);
// Generate the signing data string
$signData
=
implode
(
":"
,
array_map
([
$this
,
'escapeString'
],
array_merge
(
array_keys
(
$formFields
),
array_values
(
$formFields
))));
$merchantSig
=
base64_encode
(
hash_hmac
(
'sha256'
,
$signData
,
pack
(
"H*"
,
$hmacKey
),
true
));
// Sign request using secret key
$hmacKey
=
$this
->
_adyenHelper
->
getHmac
();
$merchantSig
=
\Adyen\Util\Util
::
calculateSha256Signature
(
$hmacKey
,
$formFields
);
$formFields
[
'merchantSig'
]
=
$merchantSig
;
$this
->
_adyenLogger
->
addAdyenDebug
(
print_r
(
$formFields
,
true
));
...
...
Controller/Process/Json.php
View file @
d1635b1e
...
...
@@ -99,7 +99,7 @@ class Json extends \Magento\Framework\App\Action\Action
$notificationMode
=
isset
(
$notificationItems
[
'live'
])
?
$notificationItems
[
'live'
]
:
""
;
if
(
$notificationMode
!=
""
&&
$this
->
_validateNotificationMode
(
$notificationMode
))
{
if
(
$notificationMode
!=
=
""
&&
$this
->
_validateNotificationMode
(
$notificationMode
))
{
foreach
(
$notificationItems
[
'notificationItems'
]
as
$notificationItem
)
{
...
...
@@ -154,7 +154,8 @@ class Json extends \Magento\Framework\App\Action\Action
{
$mode
=
$this
->
_adyenHelper
->
getAdyenAbstractConfigData
(
'demo_mode'
);
if
((
$mode
==
'1'
&&
$notificationMode
==
"false"
)
||
(
$mode
==
'0'
&&
$notificationMode
==
'true'
))
{
// Notification mode can be a string or a boolean
if
((
$mode
==
'1'
&&
(
$notificationMode
==
"false"
||
$notificationMode
==
false
))
||
(
$mode
==
'0'
&&
(
$notificationMode
==
'true'
||
$notificationMode
==
true
)))
{
return
true
;
}
return
false
;
...
...
Controller/Process/Result.php
View file @
d1635b1e
...
...
@@ -279,7 +279,6 @@ class Result extends \Magento\Framework\App\Action\Action
*/
protected
function
_authenticate
(
$response
)
{
$hmacKey
=
$this
->
_adyenHelper
->
getHmac
();
$merchantSigNotification
=
$response
[
'merchantSig'
];
// do it like this because $_GET is converting dot to underscore
...
...
@@ -297,14 +296,9 @@ class Result extends \Magento\Framework\App\Action\Action
// do not include the merchantSig in the merchantSig calculation
unset
(
$result
[
'merchantSig'
]);
// Sort the array by key using SORT_STRING order
ksort
(
$result
,
SORT_STRING
);
// Generate the signing data string
$signData
=
implode
(
":"
,
array_map
([
$this
,
'escapeString'
],
array_merge
(
array_keys
(
$result
),
array_values
(
$result
))));
$merchantSig
=
base64_encode
(
hash_hmac
(
'sha256'
,
$signData
,
pack
(
"H*"
,
$hmacKey
),
true
));
// Sign request using secret key
$hmacKey
=
$this
->
_adyenHelper
->
getHmac
();
$merchantSig
=
\Adyen\Util\Util
::
calculateSha256Signature
(
$hmacKey
,
$result
);
if
(
strcmp
(
$merchantSig
,
$merchantSigNotification
)
===
0
)
{
return
true
;
...
...
Gateway/Command/PayByMailCommand.php
View file @
d1635b1e
...
...
@@ -199,15 +199,8 @@ class PayByMailCommand implements CommandInterface
$formFields
[
'shopperReference'
]
=
$customerId
;
}
// Sort the array by key using SORT_STRING order
ksort
(
$formFields
,
SORT_STRING
);
// Generate the signing data string
$signData
=
implode
(
":"
,
array_map
([
$this
,
'escapeString'
],
array_merge
(
array_keys
(
$formFields
),
array_values
(
$formFields
))));
$merchantSig
=
base64_encode
(
hash_hmac
(
'sha256'
,
$signData
,
pack
(
"H*"
,
$hmacKey
),
true
));
// Sign request using secret key
$merchantSig
=
\Adyen\Util\Util
::
calculateSha256Signature
(
$hmacKey
,
$formFields
);
$formFields
[
'merchantSig'
]
=
$merchantSig
;
$this
->
_adyenLogger
->
addAdyenDebug
(
print_r
(
$formFields
,
true
));
...
...
Model/Cron.php
View file @
d1635b1e
...
...
@@ -187,6 +187,11 @@ class Cron
*/
protected
$_areaList
;
/**
* @var \Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory
*/
protected
$_orderStatusCollection
;
/**
* Cron constructor.
*
...
...
@@ -203,7 +208,9 @@ class Cron
* @param Api\PaymentRequest $paymentRequest
* @param Order\PaymentFactory $adyenOrderPaymentFactory
* @param ResourceModel\Order\Payment\CollectionFactory $adyenOrderPaymentCollectionFactory
* @param InvoiceFactory $adyenInvoiceFactory
* @param AreaList $areaList
* @param \Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory $orderStatusCollection
*/
public
function
__construct
(
\Magento\Framework\App\Config\ScopeConfigInterface
$scopeConfig
,
...
...
@@ -220,8 +227,10 @@ class Cron
\Adyen\Payment\Model\Order\PaymentFactory
$adyenOrderPaymentFactory
,
\Adyen\Payment\Model\ResourceModel\Order\Payment\CollectionFactory
$adyenOrderPaymentCollectionFactory
,
\Adyen\Payment\Model\InvoiceFactory
$adyenInvoiceFactory
,
AreaList
$areaList
)
{
AreaList
$areaList
,
\Magento\Sales\Model\ResourceModel\Order\Status\CollectionFactory
$orderStatusCollection
)
{
$this
->
_scopeConfig
=
$scopeConfig
;
$this
->
_adyenLogger
=
$adyenLogger
;
$this
->
_notificationFactory
=
$notificationFactory
;
...
...
@@ -237,6 +246,7 @@ class Cron
$this
->
_adyenOrderPaymentCollectionFactory
=
$adyenOrderPaymentCollectionFactory
;
$this
->
_adyenInvoiceFactory
=
$adyenInvoiceFactory
;
$this
->
_areaList
=
$areaList
;
$this
->
_orderStatusCollection
=
$orderStatusCollection
;
}
/**
...
...
@@ -645,6 +655,8 @@ class Cron
$acquirerReference
=
(
isset
(
$additionalData
[
'acquirerReference'
]))
?
$additionalData
[
'acquirerReference'
]
:
""
;
$authCode
=
(
isset
(
$additionalData
[
'authCode'
]))
?
$additionalData
[
'authCode'
]
:
""
;
$cardBin
=
(
isset
(
$additionalData
[
'cardBin'
]))
?
$additionalData
[
'cardBin'
]
:
""
;
$expiryDate
=
(
isset
(
$additionalData
[
'expiryDate'
]))
?
$additionalData
[
'expiryDate'
]
:
""
;
}
// if there is no server communication setup try to get last4 digits from reason field
...
...
@@ -685,6 +697,12 @@ class Cron
if
(
isset
(
$authCode
)
&&
$authCode
!=
""
)
{
$this
->
_order
->
getPayment
()
->
setAdditionalInformation
(
'adyen_auth_code'
,
$authCode
);
}
if
(
!
empty
(
$cardBin
))
{
$this
->
_order
->
getPayment
()
->
setAdditionalInformation
(
'adyen_card_bin'
,
$cardBin
);
}
if
(
!
empty
(
$expiryDate
))
{
$this
->
_order
->
getPayment
()
->
setAdditionalInformation
(
'adyen_expiry_date'
,
$expiryDate
);
}
}
/**
...
...
@@ -1137,6 +1155,8 @@ class Cron
// only do this if status in configuration is set
if
(
!
empty
(
$status
))
{
$this
->
_order
->
addStatusHistoryComment
(
__
(
'Payment is authorised waiting for capture'
),
$status
);
$this
->
_setState
(
$status
);
$this
->
_adyenLogger
->
addAdyenNotificationCronjob
(
'Order status is changed to Pre-authorised status, status is '
.
$status
);
...
...
@@ -1594,14 +1614,30 @@ class Cron
$comment
=
"Adyen Payment is in Manual Review check the Adyen platform"
;
}
}
$status
=
(
!
empty
(
$status
))
?
$status
:
$this
->
_order
->
getStatus
();
$this
->
_order
->
addStatusHistoryComment
(
__
(
$comment
),
$status
);
$this
->
_setState
(
$status
);
$this
->
_adyenLogger
->
addAdyenNotificationCronjob
(
'Order status is changed to authorised status, status is '
.
$status
);
}
/**
* Set State from Status
*/
protected
function
_setState
(
$status
)
{
$statusObject
=
$this
->
_orderStatusCollection
->
create
()
->
addFieldToFilter
(
'main_table.status'
,
$status
)
->
addFieldToFilter
(
'state_table.is_default'
,
true
)
->
joinStates
()
->
getFirstItem
();
$this
->
_order
->
setState
(
$statusObject
->
getState
());
$this
->
_adyenLogger
->
addAdyenNotificationCronjob
(
'State is changed to '
.
$statusObject
->
getState
());
}
/**
* Create shipment
...
...
Test/Unit/Helper/DataTest.php
View file @
d1635b1e
...
...
@@ -48,9 +48,22 @@ class DataTest extends \PHPUnit\Framework\TestCase
$assetRepo
=
$this
->
getSimpleMock
(
\Magento\Framework\View\Asset\Repository
::
class
);
$assetSource
=
$this
->
getSimpleMock
(
\Magento\Framework\View\Asset\Source
::
class
);
$notificationFactory
=
$this
->
getSimpleMock
(
\Adyen\Payment\Model\ResourceModel\Notification\CollectionFactory
::
class
);
$taxConfig
=
$this
->
getSimpleMock
(
\Magento\Tax\Model\Config
::
class
);
$taxCalculation
=
$this
->
getSimpleMock
(
\Magento\Tax\Model\Calculation
::
class
);
$this
->
dataHelper
=
new
\Adyen\Payment\Helper\Data
(
$context
,
$encryptor
,
$dataStorage
,
$country
,
$moduleList
,
$billingAgreementCollectionFactory
,
$assetRepo
,
$assetSource
,
$notificationFactory
);
$this
->
dataHelper
=
new
\Adyen\Payment\Helper\Data
(
$context
,
$encryptor
,
$dataStorage
,
$country
,
$moduleList
,
$billingAgreementCollectionFactory
,
$assetRepo
,
$assetSource
,
$notificationFactory
,
$taxConfig
,
$taxCalculation
);
}
public
function
testFormatAmount
()
...
...
composer.json
View file @
d1635b1e
...
...
@@ -2,7 +2,7 @@
"name"
:
"adyen/module-payment"
,
"description"
:
"Official Magento2 Plugin to connect to Payment Service Provider Adyen."
,
"type"
:
"magento2-module"
,
"version"
:
"2.3.
0
"
,
"version"
:
"2.3.
1
"
,
"license"
:
[
"OSL-3.0"
,
"AFL-3.0"
...
...
etc/module.xml
View file @
d1635b1e
...
...
@@ -24,7 +24,7 @@
-->
<config
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation=
"urn:magento:framework:Module/etc/module.xsd"
>
<module
name=
"Adyen_Payment"
setup_version=
"2.3.
0
"
>
<module
name=
"Adyen_Payment"
setup_version=
"2.3.
1
"
>
<sequence>
<module
name=
"Magento_Sales"
/>
<module
name=
"Magento_Quote"
/>
...
...
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