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
3194acc1
Commit
3194acc1
authored
Apr 24, 2018
by
Maikel Koek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[VM] B: Create Vault token at 3D Secure validation return
parent
114a3aca
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
1 deletion
+59
-1
Controller/Process/Validate3d.php
Controller/Process/Validate3d.php
+59
-1
No files found.
Controller/Process/Validate3d.php
View file @
3194acc1
...
...
@@ -23,6 +23,9 @@
namespace
Adyen\Payment\Controller\Process
;
use
Magento\Vault\Api\Data\PaymentTokenInterface
;
use
Magento\Vault\Api\Data\PaymentTokenFactoryInterface
;
class
Validate3d
extends
\Magento\Framework\App\Action\Action
{
/**
...
...
@@ -55,6 +58,11 @@ class Validate3d extends \Magento\Framework\App\Action\Action
*/
protected
$_orderRepository
;
/**
* @var PaymentTokenFactoryInterface
*/
private
$paymentTokenFactory
;
/**
* Validate3d constructor.
*
...
...
@@ -68,13 +76,15 @@ class Validate3d extends \Magento\Framework\App\Action\Action
\Adyen\Payment\Logger\AdyenLogger
$adyenLogger
,
\Adyen\Payment\Helper\Data
$adyenHelper
,
\Adyen\Payment\Model\Api\PaymentRequest
$paymentRequest
,
\Magento\Sales\Api\OrderRepositoryInterface
$orderRepository
\Magento\Sales\Api\OrderRepositoryInterface
$orderRepository
,
PaymentTokenFactoryInterface
$paymentTokenFactory
)
{
parent
::
__construct
(
$context
);
$this
->
_adyenLogger
=
$adyenLogger
;
$this
->
_adyenHelper
=
$adyenHelper
;
$this
->
_paymentRequest
=
$paymentRequest
;
$this
->
_orderRepository
=
$orderRepository
;
$this
->
paymentTokenFactory
=
$paymentTokenFactory
;
}
/**
...
...
@@ -135,6 +145,27 @@ class Validate3d extends \Magento\Framework\App\Action\Action
$order
->
getPayment
()
->
setAdditionalInformation
(
'3dSuccess'
,
true
);
$this
->
_orderRepository
->
save
(
$order
);
try
{
$additionalData
=
$result
[
'additionalData'
];
$token
=
$additionalData
[
'recurring.recurringDetailReference'
];
$expirationDate
=
$additionalData
[
'expiryDate'
];
$cardType
=
$additionalData
[
'paymentMethod'
];
$cardSummary
=
$additionalData
[
'cardSummary'
];
/** @var PaymentTokenInterface $paymentToken */
$paymentToken
=
$this
->
paymentTokenFactory
->
create
(
PaymentTokenFactoryInterface
::
TOKEN_TYPE_CREDIT_CARD
);
$paymentToken
->
setGatewayToken
(
$token
);
$paymentToken
->
setExpiresAt
(
$this
->
getExpirationDate
(
$expirationDate
));
$details
=
[
'type'
=>
$cardType
,
'maskedCC'
=>
$cardSummary
,
'expirationDate'
=>
$expirationDate
];
$paymentToken
->
setTokenDetails
(
json_encode
(
$details
));
}
catch
(
\Exception
$e
)
{
$this
->
_adyenLogger
->
error
(
print_r
(
$e
,
true
));
}
$this
->
_redirect
(
'checkout/onepage/success'
,
[
'_query'
=>
[
'utm_nooverride'
=>
'1'
]]);
}
else
{
$order
->
addStatusHistoryComment
(
__
(
'3D-secure validation was unsuccessful.'
))
->
save
();
...
...
@@ -169,6 +200,33 @@ class Validate3d extends \Magento\Framework\App\Action\Action
}
}
/**
* @param $expirationDate
* @return string
*/
private
function
getExpirationDate
(
$expirationDate
)
{
$expirationDate
=
explode
(
'/'
,
$expirationDate
);
//add leading zero to month
$month
=
sprintf
(
"%02d"
,
$expirationDate
[
0
]);
$expDate
=
new
\DateTime
(
$expirationDate
[
1
]
.
'-'
.
$month
.
'-'
.
'01'
.
' '
.
'00:00:00'
,
new
\DateTimeZone
(
'UTC'
)
);
// add one month
$expDate
->
add
(
new
\DateInterval
(
'P1M'
));
return
$expDate
->
format
(
'Y-m-d 00:00:00'
);
}
/**
* Called by validate3d controller when cc payment has 3D secure
*
...
...
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