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
d443f4a8
Commit
d443f4a8
authored
Nov 12, 2018
by
Alessio Zampatti
Committed by
GitHub
Nov 12, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #337 from Adyen/PW-615
Re-merging "PW-615"
parents
3ecb944b
365b5b0b
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
48 additions
and
79 deletions
+48
-79
Block/Redirect/Redirect.php
Block/Redirect/Redirect.php
+1
-1
Gateway/Command/PayByMailCommand.php
Gateway/Command/PayByMailCommand.php
+1
-1
Gateway/Http/Client/TransactionPosCloudSync.php
Gateway/Http/Client/TransactionPosCloudSync.php
+21
-6
Gateway/Response/PaymentPosCloudHandler.php
Gateway/Response/PaymentPosCloudHandler.php
+5
-11
Gateway/Validator/PosCloudResponseValidator.php
Gateway/Validator/PosCloudResponseValidator.php
+6
-21
Helper/Data.php
Helper/Data.php
+9
-9
Model/AdyenInitiateTerminalApi.php
Model/AdyenInitiateTerminalApi.php
+3
-12
Model/Billing/Agreement.php
Model/Billing/Agreement.php
+1
-1
Model/Cron.php
Model/Cron.php
+0
-16
etc/adminhtml/system/adyen_oneclick.xml
etc/adminhtml/system/adyen_oneclick.xml
+1
-1
No files found.
Block/Redirect/Redirect.php
View file @
d443f4a8
...
...
@@ -538,4 +538,4 @@ class Redirect extends \Magento\Payment\Block\Form
{
return
$this
->
_checkoutSession
;
}
}
\ No newline at end of file
}
Gateway/Command/PayByMailCommand.php
View file @
d443f4a8
...
...
@@ -218,4 +218,4 @@ class PayByMailCommand implements CommandInterface
{
return
str_replace
(
':'
,
'\\:'
,
str_replace
(
'\\'
,
'\\\\'
,
$val
));
}
}
\ No newline at end of file
}
Gateway/Http/Client/TransactionPosCloudSync.php
View file @
d443f4a8
...
...
@@ -67,15 +67,15 @@ class TransactionPosCloudSync implements ClientInterface
*
* @param \Magento\Payment\Gateway\Http\TransferInterface $transferObject
* @return array
* @throws \Magento\Payment\Gateway\Http\ClientException
* @throws \Magento\Payment\Gateway\Http\ConverterException
* @throws \Magento\Framework\Exception\LocalizedException
*/
public
function
placeRequest
(
\Magento\Payment\Gateway\Http\TransferInterface
$transferObject
)
{
$request
=
$transferObject
->
getBody
();
if
(
!
empty
(
$request
[
'response'
]))
{
if
(
!
empty
(
$request
[
'response'
][
'SaleToPOIResponse'
][
'PaymentResponse'
]))
{
$paymentResponse
=
$request
[
'response'
][
'SaleToPOIResponse'
][
'PaymentResponse'
];
//Initiate has already a response
return
$
request
[
'response'
]
;
return
$
paymentResponse
;
}
//always do status call and return the response of the status call
$service
=
new
\Adyen\Service\PosPayment
(
$this
->
_client
);
...
...
@@ -123,8 +123,23 @@ class TransactionPosCloudSync implements ClientInterface
$response
=
$service
->
runTenderSync
(
$request
);
}
catch
(
\Adyen\AdyenException
$e
)
{
$response
[
'error'
]
=
$e
->
getMessage
();
return
$response
;
}
return
$response
;
if
(
!
empty
(
$response
[
'SaleToPOIResponse'
][
'TransactionStatusResponse'
]))
{
$statusResponse
=
$response
[
'SaleToPOIResponse'
][
'TransactionStatusResponse'
];
if
(
$statusResponse
[
'Response'
][
'Result'
]
==
'Failure'
)
{
$errorMsg
=
__
(
'In Progress'
);
throw
new
\Magento\Framework\Exception\LocalizedException
(
__
(
$errorMsg
));
}
else
{
$paymentResponse
=
$statusResponse
[
'RepeatedMessageResponse'
][
'RepeatedResponseMessageBody'
][
'PaymentResponse'
];
}
}
else
{
// probably SaleToPOIRequest, that means terminal unreachable, log the response as error
$this
->
adyenLogger
->
error
(
json_encode
(
$response
));
throw
new
\Magento\Framework\Exception\LocalizedException
(
__
(
"The terminal could not be reached."
));
}
return
$paymentResponse
;
}
}
\ No newline at end of file
}
Gateway/Response/PaymentPosCloudHandler.php
View file @
d443f4a8
...
...
@@ -58,10 +58,11 @@ class PaymentPosCloudHandler implements HandlerInterface
* Handles response
*
* @param array $handlingSubject
* @param array $
r
esponse
* @param array $
paymentR
esponse
* @return void
* @throws Exception
*/
public
function
handle
(
array
$handlingSubject
,
array
$
r
esponse
)
public
function
handle
(
array
$handlingSubject
,
array
$
paymentR
esponse
)
{
$payment
=
\Magento\Payment\Gateway\Helper\SubjectReader
::
readPayment
(
$handlingSubject
);
...
...
@@ -71,16 +72,9 @@ class PaymentPosCloudHandler implements HandlerInterface
// set transaction not to processing by default wait for notification
$payment
->
setIsTransactionPending
(
true
);
//
n
o not send order confirmation mail
//
d
o not send order confirmation mail
$payment
->
getOrder
()
->
setCanSendNewEmailFlag
(
false
);
if
(
!
empty
(
$response
[
'SaleToPOIResponse'
][
'TransactionStatusResponse'
]))
{
$statusResponse
=
$response
[
'SaleToPOIResponse'
][
'TransactionStatusResponse'
];
$paymentResponse
=
$statusResponse
[
'RepeatedMessageResponse'
][
'RepeatedResponseMessageBody'
][
'PaymentResponse'
];
}
else
{
$paymentResponse
=
$response
[
'SaleToPOIResponse'
][
'PaymentResponse'
];
}
// set transaction(status)
if
(
!
empty
(
$paymentResponse
)
&&
!
empty
(
$paymentResponse
[
'PaymentResult'
][
'PaymentAcquirerData'
][
'AcquirerTransactionID'
][
'TransactionID'
]))
{
$pspReference
=
$paymentResponse
[
'PaymentResult'
][
'PaymentAcquirerData'
][
'AcquirerTransactionID'
][
'TransactionID'
];
...
...
@@ -95,4 +89,4 @@ class PaymentPosCloudHandler implements HandlerInterface
$payment
->
setIsTransactionClosed
(
false
);
$payment
->
setShouldCloseParentTransaction
(
false
);
}
}
\ No newline at end of file
}
Gateway/Validator/PosCloudResponseValidator.php
View file @
d443f4a8
...
...
@@ -71,32 +71,17 @@ class PosCloudResponseValidator extends AbstractValidator
// Check for errors
if
(
!
empty
(
$response
[
'error'
]))
{
if
(
strpos
(
$response
[
'error'
],
"Could not connect"
)
!==
false
)
{
//
Do the
status call(try to place an order)
if
(
!
empty
(
$response
[
'code'
])
&&
$response
[
'code'
]
==
CURLE_OPERATION_TIMEOUTED
)
{
//
If the initiate call resulted in a timeout, do a
status call(try to place an order)
return
$this
->
createResult
(
$isValid
,
$errorMessages
);
}
else
{
// There is an error which is not a timeout, stop the transaction and show the error
$this
->
adyenLogger
->
error
(
json_encode
(
$response
));
throw
new
\Magento\Framework\Exception\LocalizedException
(
__
(
$response
[
'error'
]));
}
}
// We receive a SaleToPOIRequest when the terminal is not reachable
if
(
!
empty
(
$response
[
'SaleToPOIRequest'
])){
$this
->
adyenLogger
->
error
(
json_encode
(
$response
));
throw
new
\Magento\Framework\Exception\LocalizedException
(
__
(
"The terminal could not be reached."
));
}
// Check if Status or PaymentResponse
if
(
!
empty
(
$response
[
'SaleToPOIResponse'
][
'TransactionStatusResponse'
]))
{
$statusResponse
=
$response
[
'SaleToPOIResponse'
][
'TransactionStatusResponse'
];
if
(
$statusResponse
[
'Response'
][
'Result'
]
==
'Failure'
)
{
$errorMsg
=
__
(
'In Progress'
);
throw
new
\Magento\Framework\Exception\LocalizedException
(
__
(
$errorMsg
));
}
else
{
$paymentResponse
=
$statusResponse
[
'RepeatedMessageResponse'
][
'RepeatedResponseMessageBody'
][
'PaymentResponse'
];
}
}
else
{
$paymentResponse
=
$response
[
'SaleToPOIResponse'
][
'PaymentResponse'
];
// We have a paymentResponse from the terminal
$paymentResponse
=
$response
;
}
if
(
!
empty
(
$paymentResponse
)
&&
$paymentResponse
[
'Response'
][
'Result'
]
!=
'Success'
)
{
...
...
@@ -112,4 +97,4 @@ class PosCloudResponseValidator extends AbstractValidator
}
return
$this
->
createResult
(
$isValid
,
$errorMessages
);
}
}
\ No newline at end of file
}
Helper/Data.php
View file @
d443f4a8
...
...
@@ -1184,15 +1184,16 @@ class Data extends AbstractHelper
return
$formFields
;
}
public
function
getApiKey
()
/**
* @param integer|null $storeId
* @return string the X API Key for the specified or current store
*/
public
function
getApiKey
(
$storeId
=
null
)
{
switch
(
$this
->
isDemoMode
())
{
case
true
:
$apiKey
=
$this
->
_encryptor
->
decrypt
(
trim
(
$this
->
getAdyenPosCloudConfigData
(
'api_key_test'
)));
break
;
default
:
$apiKey
=
$this
->
_encryptor
->
decrypt
(
trim
(
$this
->
getAdyenPosCloudConfigData
(
'api_key_live'
)));
break
;
if
(
$this
->
isDemoMode
(
$storeId
))
{
$apiKey
=
$this
->
_encryptor
->
decrypt
(
trim
(
$this
->
getAdyenPosCloudConfigData
(
'api_key_test'
)));
}
else
{
$apiKey
=
$this
->
_encryptor
->
decrypt
(
trim
(
$this
->
getAdyenPosCloudConfigData
(
'api_key_live'
)));
}
return
$apiKey
;
}
...
...
@@ -1241,7 +1242,6 @@ class Data extends AbstractHelper
return
$formatted
;
}
/**
* Initializes and returns Adyen Client and sets the required parameters of it
*
...
...
Model/AdyenInitiateTerminalApi.php
View file @
d443f4a8
...
...
@@ -41,28 +41,20 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface
/**
* AdyenInitiateTerminalApi constructor.
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Encryption\EncryptorInterface $encryptor
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param
RecurringType $recurringType
* @param
\Magento\Checkout\Model\Session $_checkoutSession
* @param array $data
*/
public
function
__construct
(
\Magento\Framework\Model\Context
$context
,
\Magento\Framework\Encryption\EncryptorInterface
$encryptor
,
\Adyen\Payment\Helper\Data
$adyenHelper
,
\Adyen\Payment\Logger\AdyenLogger
$adyenLogger
,
\Adyen\Payment\Model\RecurringType
$recurringType
,
\Magento\Checkout\Model\Session
$_checkoutSession
,
array
$data
=
[]
)
{
$this
->
_encryptor
=
$encryptor
;
$this
->
_adyenHelper
=
$adyenHelper
;
$this
->
_adyenLogger
=
$adyenLogger
;
$this
->
_recurringType
=
$recurringType
;
$this
->
_appState
=
$context
->
getAppState
();
$this
->
_checkoutSession
=
$_checkoutSession
;
// initialize client
...
...
@@ -90,9 +82,8 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface
/**
* Trigger sync call on terminal
*
* @return mixed
* @throws \
Magento\Framework\Exception\Localized
Exception
* @throws \Exception
*/
public
function
initiate
()
{
...
...
@@ -189,4 +180,4 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface
$quote
->
save
();
return
$response
;
}
}
\ No newline at end of file
}
Model/Billing/Agreement.php
View file @
d443f4a8
...
...
@@ -162,4 +162,4 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement
{
return
json_decode
(
$this
->
getData
(
'agreement_data'
),
true
);
}
}
\ No newline at end of file
}
Model/Cron.php
View file @
d443f4a8
...
...
@@ -332,22 +332,6 @@ class Cron
continue
;
}
/**
* If the event is a RECURRING_CONTRACT wait an extra 5 minutes
* before processing so we are sure the RECURRING_CONTRACT
*/
if
(
trim
(
$notification
->
getEventCode
())
==
Notification
::
RECURRING_CONTRACT
&&
strtotime
(
$notification
->
getCreatedAt
())
>=
strtotime
(
'-5 minutes'
,
time
())
)
{
$this
->
_adyenLogger
->
addAdyenNotificationCronjob
(
"This is a recurring_contract notification wait an extra 5 minutes
before processing this to make sure the contract exists"
);
// set processing back to false
$this
->
_updateNotification
(
$notification
,
false
,
false
);
continue
;
}
// log the executed notification
$this
->
_adyenLogger
->
addAdyenNotificationCronjob
(
print_r
(
$notification
->
debug
(),
1
));
...
...
etc/adminhtml/system/adyen_oneclick.xml
View file @
d443f4a8
...
...
@@ -50,4 +50,4 @@
<config_path>
payment/adyen_oneclick/recurring_payment_type
</config_path>
</field>
</group>
</include>
\ No newline at end of file
</include>
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