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
2773ec48
Commit
2773ec48
authored
Apr 24, 2018
by
Maikel Koek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[VM] +: Save Vault token at 3D Secure payment return
parent
29dbe5e3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
1 deletion
+48
-1
Controller/Process/Validate3d.php
Controller/Process/Validate3d.php
+48
-1
No files found.
Controller/Process/Validate3d.php
View file @
2773ec48
...
...
@@ -23,8 +23,12 @@
namespace
Adyen\Payment\Controller\Process
;
use
Magento\Payment\Model\InfoInterface
;
use
Magento\Vault\Api\Data\PaymentTokenInterface
;
use
Magento\Vault\Api\Data\PaymentTokenFactoryInterface
;
use
Magento\Sales\Api\Data\OrderPaymentExtensionInterface
;
use
Magento\Sales\Api\Data\OrderPaymentExtensionInterfaceFactory
;
use
Magento\Sales\Model\ResourceModel\Order\Payment
as
OrderPaymentResource
;
class
Validate3d
extends
\Magento\Framework\App\Action\Action
{
...
...
@@ -63,6 +67,16 @@ class Validate3d extends \Magento\Framework\App\Action\Action
*/
private
$paymentTokenFactory
;
/**
* @var OrderPaymentExtensionInterfaceFactory
*/
private
$paymentExtensionFactory
;
/**
* @var OrderPaymentResource
*/
private
$orderPaymentResource
;
/**
* Validate3d constructor.
*
...
...
@@ -70,6 +84,10 @@ class Validate3d extends \Magento\Framework\App\Action\Action
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Model\Api\PaymentRequest $paymentRequest
* @param \Magento\Sales\Api\OrderRepositoryInterface $orderRepository
* @param PaymentTokenFactoryInterface $paymentTokenFactory
* @param OrderPaymentExtensionInterfaceFactory $paymentExtensionFactory
* @param OrderPaymentResource $orderPaymentResource
*/
public
function
__construct
(
\Magento\Framework\App\Action\Context
$context
,
...
...
@@ -77,7 +95,9 @@ class Validate3d extends \Magento\Framework\App\Action\Action
\Adyen\Payment\Helper\Data
$adyenHelper
,
\Adyen\Payment\Model\Api\PaymentRequest
$paymentRequest
,
\Magento\Sales\Api\OrderRepositoryInterface
$orderRepository
,
PaymentTokenFactoryInterface
$paymentTokenFactory
PaymentTokenFactoryInterface
$paymentTokenFactory
,
OrderPaymentExtensionInterfaceFactory
$paymentExtensionFactory
,
OrderPaymentResource
$orderPaymentResource
)
{
parent
::
__construct
(
$context
);
$this
->
_adyenLogger
=
$adyenLogger
;
...
...
@@ -85,6 +105,8 @@ class Validate3d extends \Magento\Framework\App\Action\Action
$this
->
_paymentRequest
=
$paymentRequest
;
$this
->
_orderRepository
=
$orderRepository
;
$this
->
paymentTokenFactory
=
$paymentTokenFactory
;
$this
->
paymentExtensionFactory
=
$paymentExtensionFactory
;
$this
->
orderPaymentResource
=
$orderPaymentResource
;
}
/**
...
...
@@ -163,6 +185,16 @@ class Validate3d extends \Magento\Framework\App\Action\Action
'expirationDate'
=>
$expirationDate
];
$paymentToken
->
setTokenDetails
(
json_encode
(
$details
));
$extensionAttributes
=
$this
->
getExtensionAttributes
(
$order
->
getPayment
());
$extensionAttributes
->
setVaultPaymentToken
(
$paymentToken
);
$orderPayment
=
$order
->
getPayment
()
->
setExtensionAttributes
(
$extensionAttributes
);
$add
=
unserialize
(
$orderPayment
->
getAdditionalData
());
$add
[
'force_save'
]
=
true
;
$orderPayment
->
setAdditionalData
(
serialize
(
$add
));
$this
->
orderPaymentResource
->
save
(
$orderPayment
);
}
catch
(
\Exception
$e
)
{
$this
->
_adyenLogger
->
error
((
string
)
$e
->
getMessage
());
}
...
...
@@ -201,6 +233,21 @@ class Validate3d extends \Magento\Framework\App\Action\Action
}
}
/**
* Get payment extension attributes
* @param InfoInterface $payment
* @return OrderPaymentExtensionInterface
*/
private
function
getExtensionAttributes
(
InfoInterface
$payment
)
{
$extensionAttributes
=
$payment
->
getExtensionAttributes
();
if
(
null
===
$extensionAttributes
)
{
$extensionAttributes
=
$this
->
paymentExtensionFactory
->
create
();
$payment
->
setExtensionAttributes
(
$extensionAttributes
);
}
return
$extensionAttributes
;
}
/**
* @param $expirationDate
* @return string
...
...
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