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
731bbdbc
Commit
731bbdbc
authored
Jun 05, 2020
by
acampos1916
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for code smells
parent
1dc9d21c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
44 deletions
+51
-44
Gateway/Response/VaultDetailsHandler.php
Gateway/Response/VaultDetailsHandler.php
+51
-44
No files found.
Gateway/Response/VaultDetailsHandler.php
View file @
731bbdbc
...
...
@@ -133,61 +133,64 @@ class VaultDetailsHandler implements HandlerInterface
*/
private
function
getVaultPaymentToken
(
array
$response
,
$payment
)
{
$paymentToken
=
null
;
if
(
!
empty
(
$response
[
'additionalData'
]))
{
$additionalData
=
$response
[
'additionalData'
];
if
(
empty
(
$response
[
'additionalData'
]))
{
return
null
;
}
$additionalData
=
$response
[
'additionalData'
];
foreach
(
self
::
ADDITIONAL_DATA_ERRORS
as
$key
=>
$errorMsg
)
{
if
(
empty
(
$additionalData
[
$key
]))
{
$this
->
adyenLogger
->
error
(
$errorMsg
);
return
null
;
}
$paymentToken
=
null
;
foreach
(
self
::
ADDITIONAL_DATA_ERRORS
as
$key
=>
$errorMsg
)
{
if
(
empty
(
$additionalData
[
$key
]))
{
$this
->
adyenLogger
->
error
(
$errorMsg
);
return
null
;
}
}
try
{
try
{
// Check if paymentToken exists already
$paymentToken
=
$this
->
paymentTokenManagement
->
getByGatewayToken
(
$additionalData
[
self
::
RECURRING_DETAIL_REFERENCE
],
$payment
->
getMethodInstance
()
->
getCode
(),
$payment
->
getOrder
()
->
getCustomerId
());
// Check if paymentToken exists already
$paymentToken
=
$this
->
paymentTokenManagement
->
getByGatewayToken
(
$additionalData
[
self
::
RECURRING_DETAIL_REFERENCE
],
$payment
->
getMethodInstance
()
->
getCode
(),
$payment
->
getOrder
()
->
getCustomerId
());
$paymentTokenSaveRequired
=
false
;
$paymentTokenSaveRequired
=
false
;
// In case the payment token does not exist, create it based on the additionalData
if
(
is_null
(
$paymentToken
))
{
/** @var PaymentTokenInterface $paymentToken */
$paymentToken
=
$this
->
paymentTokenFactory
->
create
(
PaymentTokenFactoryInterface
::
TOKEN_TYPE_CREDIT_CARD
);
// In case the payment token does not exist, create it based on the additionalData
if
(
is_null
(
$paymentToken
))
{
/** @var PaymentTokenInterface $paymentToken */
$paymentToken
=
$this
->
paymentTokenFactory
->
create
(
PaymentTokenFactoryInterface
::
TOKEN_TYPE_CREDIT_CARD
);
$paymentToken
->
setGatewayToken
(
$additionalData
[
self
::
RECURRING_DETAIL_REFERENCE
]);
$paymentToken
->
setGatewayToken
(
$additionalData
[
self
::
RECURRING_DETAIL_REFERENCE
]);
if
(
strpos
(
$additionalData
[
self
::
PAYMENT_METHOD
],
"paywithgoogle"
)
!==
false
&&
!
empty
(
$additionalData
[
'paymentMethodVariant'
]))
{
$additionalData
[
self
::
PAYMENT_METHOD
]
=
$additionalData
[
'paymentMethodVariant'
];
$paymentToken
->
setIsVisible
(
false
);
}
}
else
{
$paymentTokenSaveRequired
=
true
;
if
(
strpos
(
$additionalData
[
self
::
PAYMENT_METHOD
],
"paywithgoogle"
)
!==
false
&&
!
empty
(
$additionalData
[
'paymentMethodVariant'
]))
{
$additionalData
[
self
::
PAYMENT_METHOD
]
=
$additionalData
[
'paymentMethodVariant'
];
$paymentToken
->
setIsVisible
(
false
);
}
}
else
{
$paymentTokenSaveRequired
=
true
;
}
$paymentToken
->
setExpiresAt
(
$this
->
getExpirationDate
(
$additionalData
[
self
::
EXPIRY_DATE
]));
$paymentToken
->
setExpiresAt
(
$this
->
getExpirationDate
(
$additionalData
[
self
::
EXPIRY_DATE
]));
$details
=
[
'type'
=>
$additionalData
[
self
::
PAYMENT_METHOD
],
'maskedCC'
=>
$additionalData
[
self
::
CARD_SUMMARY
],
'expirationDate'
=>
$additionalData
[
self
::
EXPIRY_DATE
]
];
$details
=
[
'type'
=>
$additionalData
[
self
::
PAYMENT_METHOD
],
'maskedCC'
=>
$additionalData
[
self
::
CARD_SUMMARY
],
'expirationDate'
=>
$additionalData
[
self
::
EXPIRY_DATE
]
];
$paymentToken
->
setTokenDetails
(
json_encode
(
$details
));
$paymentToken
->
setTokenDetails
(
json_encode
(
$details
));
// If the token is updated, it needs to be saved to keep the changes
if
(
$paymentTokenSaveRequired
)
{
$this
->
paymentTokenRepository
->
save
(
$paymentToken
);
}
}
catch
(
\Exception
$e
)
{
$this
->
adyenLogger
->
error
(
print_r
(
$e
,
true
));
// If the token is updated, it needs to be saved to keep the changes
if
(
$paymentTokenSaveRequired
)
{
$this
->
paymentTokenRepository
->
save
(
$paymentToken
);
}
}
catch
(
\Exception
$e
)
{
$this
->
adyenLogger
->
error
(
print_r
(
$e
,
true
));
}
return
$paymentToken
;
...
...
@@ -198,8 +201,10 @@ class VaultDetailsHandler implements HandlerInterface
* @return string
* @throws \Exception
*/
private
function
getExpirationDate
(
$expirationDate
)
{
private
function
getExpirationDate
(
$expirationDate
)
{
$expirationDate
=
explode
(
'/'
,
$expirationDate
);
//add leading zero to month
...
...
@@ -226,8 +231,10 @@ class VaultDetailsHandler implements HandlerInterface
* @param InfoInterface $payment
* @return OrderPaymentExtensionInterface
*/
private
function
getExtensionAttributes
(
InfoInterface
$payment
)
{
private
function
getExtensionAttributes
(
InfoInterface
$payment
)
{
$extensionAttributes
=
$payment
->
getExtensionAttributes
();
if
(
null
===
$extensionAttributes
)
{
$extensionAttributes
=
$this
->
paymentExtensionFactory
->
create
();
...
...
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