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
aa89f491
Commit
aa89f491
authored
Jul 27, 2016
by
Rik ter Beek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#67 Adyen CC and Adyen Oneclick are now using the Facade implementation
parent
482fd41f
Changes
25
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
1302 additions
and
642 deletions
+1302
-642
Controller/Process/Validate3d.php
Controller/Process/Validate3d.php
+38
-2
Gateway/Request/Authorize3DSecureDataBuilder.php
Gateway/Request/Authorize3DSecureDataBuilder.php
+64
-0
Gateway/Request/BrowserInfoDataBuilder.php
Gateway/Request/BrowserInfoDataBuilder.php
+15
-10
Gateway/Request/CcAuthorizationDataBuilder.php
Gateway/Request/CcAuthorizationDataBuilder.php
+98
-0
Gateway/Request/CustomerDataBuilder.php
Gateway/Request/CustomerDataBuilder.php
+0
-2
Gateway/Request/CustomerIpDataBuilder.php
Gateway/Request/CustomerIpDataBuilder.php
+43
-0
Gateway/Request/OneclickAuthorizationBuilder.php
Gateway/Request/OneclickAuthorizationBuilder.php
+79
-0
Gateway/Request/PaymentDataBuilder.php
Gateway/Request/PaymentDataBuilder.php
+2
-5
Gateway/Request/RecurringDataBuilder.php
Gateway/Request/RecurringDataBuilder.php
+2
-2
Gateway/Request/SepaAuthorizationBuilder.php
Gateway/Request/SepaAuthorizationBuilder.php
+1
-0
Gateway/Response/PaymentCommentHistoryHandler.php
Gateway/Response/PaymentCommentHistoryHandler.php
+7
-1
Gateway/Validator/GeneralResponseValidator.php
Gateway/Validator/GeneralResponseValidator.php
+77
-5
Helper/PaymentMethods.php
Helper/PaymentMethods.php
+6
-2
Model/AdyenGenericConfigProvider.php
Model/AdyenGenericConfigProvider.php
+0
-3
Model/Api/PaymentRequest.php
Model/Api/PaymentRequest.php
+3
-81
Model/Method/Cc.php
Model/Method/Cc.php
+0
-464
Model/Method/Pos.php
Model/Method/Pos.php
+7
-3
Model/Ui/AdyenCcConfigProvider.php
Model/Ui/AdyenCcConfigProvider.php
+264
-0
Model/Ui/AdyenOneclickConfigProvider.php
Model/Ui/AdyenOneclickConfigProvider.php
+140
-45
Observer/AdyenCcDataAssignObserver.php
Observer/AdyenCcDataAssignObserver.php
+76
-0
Observer/AdyenOneclickDataAssignObserver.php
Observer/AdyenOneclickDataAssignObserver.php
+129
-0
etc/config.xml
etc/config.xml
+29
-3
etc/di.xml
etc/di.xml
+214
-12
etc/events.xml
etc/events.xml
+6
-0
etc/frontend/di.xml
etc/frontend/di.xml
+2
-2
No files found.
Controller/Process/Validate3d.php
View file @
aa89f491
...
...
@@ -45,21 +45,29 @@ class Validate3d extends \Magento\Framework\App\Action\Action
*/
protected
$_adyenHelper
;
/**
* @var \Adyen\Payment\Model\Api\PaymentRequest
*/
protected
$_paymentRequest
;
/**
* Validate3d constructor.
*
* @param \Magento\Framework\App\Action\Context $context
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Model\Api\PaymentRequest $paymentRequest
*/
public
function
__construct
(
\Magento\Framework\App\Action\Context
$context
,
\Adyen\Payment\Logger\AdyenLogger
$adyenLogger
,
\Adyen\Payment\Helper\Data
$adyenHelper
\Adyen\Payment\Helper\Data
$adyenHelper
,
\Adyen\Payment\Model\Api\PaymentRequest
$paymentRequest
)
{
parent
::
__construct
(
$context
);
$this
->
_adyenLogger
=
$adyenLogger
;
$this
->
_adyenHelper
=
$adyenHelper
;
$this
->
_paymentRequest
=
$paymentRequest
;
}
/**
...
...
@@ -93,7 +101,17 @@ class Validate3d extends \Magento\Framework\App\Action\Action
$order
->
getPayment
()
->
setAdditionalInformation
(
'paResponse'
,
$requestPaRes
);
try
{
$result
=
$order
->
getPayment
()
->
getMethodInstance
()
->
authorise3d
(
$order
->
getPayment
());
/**
* Magento should allow this.
* https://github.com/magento/magento2/issues/5819
*/
// $result = $order->getPayment()->getMethodInstance()->executeCommand(
// 'authorise_3d',
// ['payment' => $order->getPayment(), 'amount' => $order->getGrandTotal()]
// );
// old fashion way:
$result
=
$this
->
_authorise3d
(
$order
->
getPayment
());
}
catch
(
\Exception
$e
)
{
$this
->
_adyenLogger
->
addAdyenResult
(
"Process 3D secure payment was refused"
);
$result
=
'Refused'
;
...
...
@@ -134,6 +152,24 @@ class Validate3d extends \Magento\Framework\App\Action\Action
}
}
/**
* Called by validate3d controller when cc payment has 3D secure
*
* @param $payment
* @return mixed
* @throws \Exception
*/
protected
function
_authorise3d
(
$payment
)
{
try
{
$response
=
$this
->
_paymentRequest
->
authorise3d
(
$payment
);
}
catch
(
\Exception
$e
)
{
throw
$e
;
}
$responseCode
=
$response
[
'resultCode'
];
return
$responseCode
;
}
/**
* Get order object
*
...
...
Gateway/Request/Authorize3DSecureDataBuilder.php
0 → 100644
View file @
aa89f491
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace
Adyen\Payment\Gateway\Request
;
use
Magento\Payment\Gateway\Request\BuilderInterface
;
/**
* Payment Data Builder
*/
class
Authorize3DSecureDataBuilder
implements
BuilderInterface
{
/**
* @var \Adyen\Payment\Helper\Data
*/
private
$adyenHelper
;
/**
* PaymentDataBuilder constructor.
*
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public
function
__construct
(
\Adyen\Payment\Helper\Data
$adyenHelper
)
{
$this
->
adyenHelper
=
$adyenHelper
;
}
/**
* @param array $buildSubject
* @return array
*/
public
function
build
(
array
$buildSubject
)
{
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject
=
\Magento\Payment\Gateway\Helper\SubjectReader
::
readPayment
(
$buildSubject
);
$payment
=
$paymentDataObject
->
getPayment
();
$md
=
$payment
->
getAdditionalInformation
(
'md'
);
$paResponse
=
$payment
->
getAdditionalInformation
(
'paResponse'
);
return
[
"md"
=>
$md
,
"paResponse"
=>
$paResponse
,
];
}
}
\ No newline at end of file
Gateway/
Config/SepaConfig
.php
→
Gateway/
Request/BrowserInfoDataBuilder
.php
View file @
aa89f491
...
...
@@ -20,22 +20,27 @@
*
* Author: Adyen <magento@adyen.com>
*/
namespace
Adyen\Payment\Gateway\Request
;
namespace
Adyen\Payment\Gateway\Config
;
use
Magento\Payment\Gateway\Request\BuilderInterface
;
/**
*
Class Config
*
Payment Data Builder
*/
class
SepaConfig
extends
\Magento\Payment\Gateway\Config\Config
class
BrowserInfoDataBuilder
implements
BuilderInterface
{
const
KEY_ACTIVE
=
'active'
;
/**
*
Get Payment configuration status
* @return
bool
*
@param array $buildSubject
* @return
array
*/
public
function
isActive
(
)
public
function
build
(
array
$buildSubject
)
{
return
(
bool
)
$this
->
getValue
(
self
::
KEY_ACTIVE
);
return
[
'browserInfo'
=>
[
'userAgent'
=>
$_SERVER
[
'HTTP_USER_AGENT'
],
'acceptHeader'
=>
$_SERVER
[
'HTTP_ACCEPT'
]
]
];
}
}
}
\ No newline at end of file
Gateway/Request/CcAuthorizationDataBuilder.php
0 → 100644
View file @
aa89f491
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace
Adyen\Payment\Gateway\Request
;
use
Magento\Payment\Gateway\Request\BuilderInterface
;
class
CcAuthorizationDataBuilder
implements
BuilderInterface
{
/**
* @var \Adyen\Payment\Helper\Data
*/
private
$adyenHelper
;
/**
* @var \Magento\Framework\App\State
*/
private
$appState
;
/**
* CcAuthorizationDataBuilder constructor.
*
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Magento\Framework\Model\Context $context
*/
public
function
__construct
(
\Adyen\Payment\Helper\Data
$adyenHelper
,
\Magento\Framework\Model\Context
$context
)
{
$this
->
adyenHelper
=
$adyenHelper
;
$this
->
appState
=
$context
->
getAppState
();
}
/**
* @param array $buildSubject
* @return mixed
*/
public
function
build
(
array
$buildSubject
)
{
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject
=
\Magento\Payment\Gateway\Helper\SubjectReader
::
readPayment
(
$buildSubject
);
$payment
=
$paymentDataObject
->
getPayment
();
$order
=
$paymentDataObject
->
getOrder
();
$storeId
=
$order
->
getStoreId
();
$request
=
[];
if
(
$this
->
adyenHelper
->
getAdyenCcConfigDataFlag
(
'cse_enabled'
,
$storeId
))
{
$request
[
'additionalData'
][
'card.encrypted.json'
]
=
$payment
->
getAdditionalInformation
(
"encrypted_data"
);
}
else
{
$requestCreditCardDetails
=
[
"expiryMonth"
=>
$payment
->
getCcExpMonth
(),
"expiryYear"
=>
$payment
->
getCcExpYear
(),
"holderName"
=>
$payment
->
getCcOwner
(),
"number"
=>
$payment
->
getCcNumber
(),
"cvc"
=>
$payment
->
getCcCid
(),
];
$cardDetails
[
'card'
]
=
$requestCreditCardDetails
;
$request
=
array_merge
(
$request
,
$cardDetails
);
}
/**
* if MOTO for backend is enabled use MOTO as shopper interaction type
*/
$enableMoto
=
$this
->
adyenHelper
->
getAdyenCcConfigDataFlag
(
'enable_moto'
,
$storeId
);
if
(
$this
->
appState
->
getAreaCode
()
===
\Magento\Backend\App\Area\FrontNameResolver
::
AREA_CODE
&&
$enableMoto
)
{
$request
[
'shopperInteraction'
]
=
"Moto"
;
}
// if installments is set add it into the request
if
(
$payment
->
getAdditionalInformation
(
'number_of_installments'
)
&&
$payment
->
getAdditionalInformation
(
'number_of_installments'
)
>
0
)
{
$request
[
'installments'
][
'value'
]
=
$payment
->
getAdditionalInformation
(
'number_of_installments'
);
}
return
$request
;
}
}
\ No newline at end of file
Gateway/Request/CustomerDataBuilder.php
View file @
aa89f491
...
...
@@ -48,13 +48,11 @@ class CustomerDataBuilder implements BuilderInterface
$order
=
$paymentDataObject
->
getOrder
();
$billingAddress
=
$order
->
getBillingAddress
();
$customerEmail
=
$billingAddress
->
getEmail
();
$shopperIp
=
$order
->
getRemoteIp
();
$realOrderId
=
$order
->
getOrderIncrementId
();
$customerId
=
$order
->
getCustomerId
();
$shopperReference
=
(
!
empty
(
$customerId
))
?
$customerId
:
self
::
GUEST_ID
.
$realOrderId
;
return
[
"shopperIP"
=>
$shopperIp
,
"shopperEmail"
=>
$customerEmail
,
"shopperReference"
=>
$shopperReference
];
...
...
Gateway/Request/CustomerIpDataBuilder.php
0 → 100644
View file @
aa89f491
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace
Adyen\Payment\Gateway\Request
;
use
Magento\Payment\Gateway\Request\BuilderInterface
;
/**
* Class CustomerDataBuilder
*/
class
CustomerIpDataBuilder
implements
BuilderInterface
{
/**
* @param array $buildSubject
* @return array
*/
public
function
build
(
array
$buildSubject
)
{
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject
=
\Magento\Payment\Gateway\Helper\SubjectReader
::
readPayment
(
$buildSubject
);
$order
=
$paymentDataObject
->
getOrder
();
return
[
'shopperIP'
=>
$order
->
getRemoteIp
()];
}
}
Gateway/Request/OneclickAuthorizationBuilder.php
0 → 100644
View file @
aa89f491
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace
Adyen\Payment\Gateway\Request
;
use
Magento\Payment\Gateway\Request\BuilderInterface
;
class
OneclickAuthorizationBuilder
implements
BuilderInterface
{
/**
* @var \Adyen\Payment\Helper\Data
*/
private
$adyenHelper
;
/**
* CaptureDataBuilder constructor.
*
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public
function
__construct
(
\Adyen\Payment\Helper\Data
$adyenHelper
)
{
$this
->
adyenHelper
=
$adyenHelper
;
}
/**
* @param array $buildSubject
* @return mixed
*/
public
function
build
(
array
$buildSubject
)
{
$request
=
[];
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject
=
\Magento\Payment\Gateway\Helper\SubjectReader
::
readPayment
(
$buildSubject
);
$payment
=
$paymentDataObject
->
getPayment
();
$recurringDetailReference
=
$payment
->
getAdditionalInformation
(
"recurring_detail_reference"
);
if
(
$payment
->
getAdditionalInformation
(
'customer_interaction'
))
{
$shopperInteraction
=
"Ecommerce"
;
}
else
{
$shopperInteraction
=
"ContAuth"
;
}
$request
[
'selectedRecurringDetailReference'
]
=
$recurringDetailReference
;
$request
[
'shopperInteraction'
]
=
$shopperInteraction
;
/*
* For recurring Ideal and Sofort needs to be converted to SEPA
* for this it is mandatory to set selectBrand to sepadirectdebit
*/
if
(
!
$payment
->
getAdditionalInformation
(
'customer_interaction'
))
{
if
(
$payment
->
getCcType
()
==
"directEbanking"
||
$payment
->
getCcType
()
==
"ideal"
)
{
$request
[
'selectedBrand'
]
=
"sepadirectdebit"
;
}
}
return
$request
;
}
}
\ No newline at end of file
Gateway/Request/PaymentDataBuilder.php
View file @
aa89f491
...
...
@@ -56,17 +56,14 @@ class PaymentDataBuilder implements BuilderInterface
$order
=
$paymentDataObject
->
getOrder
();
$orderCurrencyCode
=
$order
->
getCurrencyCode
();
$amount
=
$order
->
getGrandTotalAmount
();
$browserInfo
=
[
'userAgent'
=>
$_SERVER
[
'HTTP_USER_AGENT'
],
'acceptHeader'
=>
$_SERVER
[
'HTTP_ACCEPT'
]];
$amount
=
[
'currency'
=>
$orderCurrencyCode
,
'value'
=>
$this
->
adyenHelper
->
formatAmount
(
$amount
,
$orderCurrencyCode
)];
return
[
"amount"
=>
$amount
,
"reference"
=>
$order
->
getOrderIncrementId
(),
"fraudOffset"
=>
"0"
,
"browserInfo"
=>
$browserInfo
"fraudOffset"
=>
"0"
];
}
}
\ No newline at end of file
Gateway/Request/RecurringDataBuilder.php
View file @
aa89f491
...
...
@@ -73,7 +73,7 @@ class RecurringDataBuilder implements BuilderInterface
// set the recurring type
$recurringContractType
=
null
;
if
(
$recurringType
)
{
if
(
$paymentMethodCode
==
\Adyen\Payment\Model\
Method\Oneclick
::
METHOD_
CODE
)
{
if
(
$paymentMethodCode
==
\Adyen\Payment\Model\
Ui\AdyenOneclickConfigProvider
::
CODE
)
{
/*
* For ONECLICK look at the recurringPaymentType that the merchant
* has selected in Adyen ONECLICK settings
...
...
@@ -83,7 +83,7 @@ class RecurringDataBuilder implements BuilderInterface
}
else
{
$recurringContractType
=
\Adyen\Payment\Model\RecurringType
::
RECURRING
;
}
}
else
if
(
$paymentMethodCode
==
\Adyen\Payment\Model\
Method\Cc
::
METHOD_
CODE
)
{
}
else
if
(
$paymentMethodCode
==
\Adyen\Payment\Model\
Ui\AdyenCcConfigProvider
::
CODE
)
{
if
(
$payment
->
getAdditionalInformation
(
"store_cc"
)
==
""
&&
(
$recurringType
==
"ONECLICK,RECURRING"
||
$recurringType
==
"RECURRING"
))
{
$recurringContractType
=
\Adyen\Payment\Model\RecurringType
::
RECURRING
;
...
...
Gateway/Request/SepaAuthorizationBuilder.php
View file @
aa89f491
...
...
@@ -36,6 +36,7 @@ class SepaAuthorizationBuilder implements BuilderInterface
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject
=
\Magento\Payment\Gateway\Helper\SubjectReader
::
readPayment
(
$buildSubject
);
$payment
=
$paymentDataObject
->
getPayment
();
$request
=
[];
// set brand to sepa
$request
[
'selectedBrand'
]
=
"sepadirectdebit"
;
...
...
Gateway/Response/PaymentCommentHistoryHandler.php
View file @
aa89f491
...
...
@@ -43,7 +43,13 @@ class PaymentCommentHistoryHandler implements HandlerInterface
if
(
isset
(
$response
[
'resultCode'
]))
{
$responseCode
=
$response
[
'resultCode'
];
}
else
{
$responseCode
=
""
;
// try to get response from response key (used for modifications
if
(
isset
(
$response
[
'response'
]))
{
$responseCode
=
$response
[
'response'
];
}
else
{
$responseCode
=
""
;
}
}
if
(
isset
(
$response
[
'pspReference'
]))
{
...
...
Gateway/Validator/GeneralResponseValidator.php
View file @
aa89f491
...
...
@@ -27,6 +27,24 @@ use Magento\Payment\Gateway\Validator\AbstractValidator;
class
GeneralResponseValidator
extends
AbstractValidator
{
/**
* @var Psr\Log\LoggerInterface
*/
private
$logger
;
/**
* GeneralResponseValidator constructor.
* @param ResultInterfaceFactory $resultFactory
* @param \Psr\Log\LoggerInterface $loggerInterface
*/
public
function
__construct
(
\Magento\Payment\Gateway\Validator\ResultInterfaceFactory
$resultFactory
,
\Psr\Log\LoggerInterface
$loggerInterface
)
{
$this
->
logger
=
$loggerInterface
;
parent
::
__construct
(
$resultFactory
);
}
/**
* @param array $validationSubject
* @return \Magento\Payment\Gateway\Validator\ResultInterface
...
...
@@ -37,6 +55,7 @@ class GeneralResponseValidator extends AbstractValidator
$paymentDataObjectInterface
=
\Magento\Payment\Gateway\Helper\SubjectReader
::
readPayment
(
$validationSubject
);
$payment
=
$paymentDataObjectInterface
->
getPayment
();
$payment
->
setAdditionalInformation
(
'3dActive'
,
false
);
$isValid
=
true
;
$errorMessages
=
[];
...
...
@@ -46,20 +65,73 @@ class GeneralResponseValidator extends AbstractValidator
case
"Authorised"
:
$payment
->
setAdditionalInformation
(
'pspReference'
,
$response
[
'pspReference'
]);
break
;
case
"RedirectShopper"
:
$payment
->
setAdditionalInformation
(
'3dActive'
,
true
);
$payment
->
setAdditionalInformation
(
'pspReference'
,
$response
[
'pspReference'
]);
$issuerUrl
=
$response
[
'issuerUrl'
];
$paReq
=
$response
[
'paRequest'
];
$md
=
$response
[
'md'
];
if
(
!
empty
(
$paReq
)
&&
!
empty
(
$md
)
&&
!
empty
(
$issuerUrl
))
{
$payment
->
setAdditionalInformation
(
'issuerUrl'
,
$response
[
'issuerUrl'
]);
$payment
->
setAdditionalInformation
(
'paRequest'
,
$response
[
'paRequest'
]);
$payment
->
setAdditionalInformation
(
'md'
,
$response
[
'md'
]);
}
else
{
$isValid
=
false
;
$errorMsg
=
__
(
'3D secure is not valid.'
);
$this
->
logger
->
error
(
$errorMsg
);;
$errorMessages
[]
=
$errorMsg
;
}
break
;
case
"Refused"
:
$errorMsg
=
__
(
'The payment is REFUSED.'
);
$this
->
_logger
->
critical
(
$errorMsg
);
$errorMessages
[]
=
$errorMsg
;
$isValid
=
false
;
if
(
$response
[
'refusalReason'
])
{
$refusalReason
=
$response
[
'refusalReason'
];
switch
(
$refusalReason
)
{
case
"Transaction Not Permitted"
:
$errorMsg
=
__
(
'The transaction is not permitted.'
);
break
;
case
"CVC Declined"
:
$errorMsg
=
__
(
'Declined due to the Card Security Code(CVC) being incorrect. Please check your CVC code!'
);
break
;
case
"Restricted Card"
:
$errorMsg
=
__
(
'The card is restricted.'
);
break
;
case
"803 PaymentDetail not found"
:
$errorMsg
=
__
(
'The payment is REFUSED because the saved card is removed. Please try an other payment method.'
);
break
;
case
"Expiry month not set"
:
$errorMsg
=
__
(
'The expiry month is not set. Please check your expiry month!'
);
break
;
default
:
$errorMsg
=
__
(
'The payment is REFUSED.'
);
break
;
}
}
else
{
$errorMsg
=
__
(
'The payment is REFUSED.'
);
}
// exeption is to general
// $this->logger->critical($errorMsg);
// $errorMessages[] = $errorMsg;
// this will result the specific error
throw
new
\Magento\Framework\Exception\LocalizedException
(
__
(
$errorMsg
));
break
;
default
:
$isValid
=
false
;
$errorMsg
=
__
(
'Error with payment method please select different payment method.'
);
$this
->
_
logger
->
critical
(
$errorMsg
);
$this
->
logger
->
critical
(
$errorMsg
);
$errorMessages
[]
=
$errorMsg
;
break
;
}
}
else
{
$errorMsg
=
__
(
'Error with payment method please select different payment method.'
);
$this
->
_
logger
->
critical
(
$errorMsg
);
$this
->
logger
->
critical
(
$errorMsg
);
$errorMessages
[]
=
$errorMsg
;
}
...
...
Helper/PaymentMethods.php
View file @
aa89f491
...
...
@@ -139,9 +139,11 @@ class PaymentMethods extends AbstractHelper
{
$paymentMethods
=
[];
$ccEnabled
=
$this
->
_config
->
getValue
(
'payment/'
.
\Adyen\Payment\Model\
Method\Cc
::
METHOD_
CODE
.
'/active'
);
$ccEnabled
=
$this
->
_config
->
getValue
(
'payment/'
.
\Adyen\Payment\Model\
Ui\AdyenCcConfigProvider
::
CODE
.
'/active'
);
$ccTypes
=
array_keys
(
$this
->
_adyenHelper
->
getCcTypesAltData
());
$sepaEnabled
=
$this
->
_config
->
getValue
(
'payment/'
.
\Adyen\Payment\Model\Method\Sepa
::
METHOD_CODE
.
'/active'
);
$sepaEnabled
=
$this
->
_config
->
getValue
(
'payment/'
.
\Adyen\Payment\Model\Ui\AdyenSepaConfigProvider
::
CODE
.
'/active'
);
foreach
(
$this
->
_fetchHppMethods
(
$store
,
$country
)
as
$methodCode
=>
$methodData
)
{
/*
...
...
@@ -162,6 +164,7 @@ class PaymentMethods extends AbstractHelper
/**
* @param $store
* @param $country
* @return array
*/
protected
function
_fetchHppMethods
(
$store
,
$country
)
...
...
@@ -240,6 +243,7 @@ class PaymentMethods extends AbstractHelper
return
10
;
}
/**
* @param $store
* @return mixed
...
...
Model/AdyenGenericConfigProvider.php
View file @
aa89f491
...
...
@@ -47,11 +47,8 @@ class AdyenGenericConfigProvider implements ConfigProviderInterface
* @var string[]
*/
protected
$_methodCodes
=
[
\Adyen\Payment\Model\Method\Cc
::
METHOD_CODE
,
\Adyen\Payment\Model\Method\Hpp
::
METHOD_CODE
,
\Adyen\Payment\Model\Method\Oneclick
::
METHOD_CODE
,
\Adyen\Payment\Model\Method\Pos
::
METHOD_CODE
,
// \Adyen\Payment\Model\Method\Sepa::METHOD_CODE,
\Adyen\Payment\Model\Method\Boleto
::
METHOD_CODE
];
...
...
Model/Api/PaymentRequest.php
View file @
aa89f491
...
...
@@ -151,26 +151,7 @@ class PaymentRequest extends DataObject
// set the recurring type
$recurringContractType
=
null
;
if
(
$recurringType
)
{
if
(
$paymentMethodCode
==
\Adyen\Payment\Model\Method\Oneclick
::
METHOD_CODE
)
{
/*
* For ONECLICK look at the recurringPaymentType that the merchant
* has selected in Adyen ONECLICK settings
*/
if
(
$payment
->
getAdditionalInformation
(
'customer_interaction'
))
{
$recurringContractType
=
\Adyen\Payment\Model\RecurringType
::
ONECLICK
;
}
else
{
$recurringContractType
=
\Adyen\Payment\Model\RecurringType
::
RECURRING
;
}
}
else
if
(
$paymentMethodCode
==
\Adyen\Payment\Model\Method\Cc
::
METHOD_CODE
)
{
if
(
$payment
->
getAdditionalInformation
(
"store_cc"
)
==
""
&&
(
$recurringType
==
"ONECLICK,RECURRING"
||
$recurringType
==
"RECURRING"
))
{
$recurringContractType
=
\Adyen\Payment\Model\RecurringType
::
RECURRING
;
}
elseif
(
$payment
->
getAdditionalInformation
(
"store_cc"
)
==
"1"
)
{
$recurringContractType
=
$recurringType
;
}
}
else
{
$recurringContractType
=
$recurringType
;
}
$recurringContractType
=
$recurringType
;
}
if
(
$recurringContractType
)
{
...
...
@@ -225,31 +206,8 @@ class PaymentRequest extends DataObject
$recurringDetailReference
=
null
;
// define the shopper interaction
if
(
$this
->
_appState
->
getAreaCode
()
===
\Magento\Backend\App\Area\FrontNameResolver
::
AREA_CODE
&&
$paymentMethodCode
==
\Adyen\Payment\Model\Method\Cc
::
METHOD_CODE
&&
$enableMoto
)
{
// if MOTO for backend is enabled use MOTO as shopper interaction type
$shopperInteraction
=
"Moto"
;
}
else
if
(
$paymentMethodCode
==
\Adyen\Payment\Model\Method\Oneclick
::
METHOD_CODE
)
{
$recurringDetailReference
=
$payment
->
getAdditionalInformation
(
"recurring_detail_reference"
);
if
(
$payment
->
getAdditionalInformation
(
'customer_interaction'
))
{
$shopperInteraction
=
"Ecommerce"
;
}
else
{
$shopperInteraction
=
"ContAuth"
;
}
$shopperInteraction
=
"Ecommerce"
;
/*
* For recurring Ideal and Sofort needs to be converted to SEPA
* for this it is mandatory to set selectBrand to sepadirectdebit
*/
if
(
!
$payment
->
getAdditionalInformation
(
'customer_interaction'
))
{
if
(
$payment
->
getCcType
()
==
"directEbanking"
||
$payment
->
getCcType
()
==
"ideal"
)
{
$request
[
'selectedBrand'
]
=
"sepadirectdebit"
;
}
}
}
else
{
$shopperInteraction
=
"Ecommerce"
;
}
if
(
$shopperInteraction
)
{
$request
[
'shopperInteraction'
]
=
$shopperInteraction
;
...
...
@@ -264,43 +222,7 @@ class PaymentRequest extends DataObject
$request
[
'selectedBrand'
]
=
"sepadirectdebit"
;
}
if
(
$paymentMethodCode
==
\Adyen\Payment\Model\Method\Cc
::
METHOD_CODE
||
$paymentMethodCode
==
\Adyen\Payment\Model\Method\Oneclick
::
METHOD_CODE
)
{
// If cse is enabled add encrypted card date into request
if
(
$this
->
_adyenHelper
->
getAdyenCcConfigDataFlag
(
'cse_enabled'
,
$storeId
))
{
$request
[
'additionalData'
][
'card.encrypted.json'
]
=
$payment
->
getAdditionalInformation
(
"encrypted_data"
);
}
else
{
$requestCreditCardDetails
=
[
"expiryMonth"
=>
$payment
->
getCcExpMonth
(),
"expiryYear"
=>
$payment
->
getCcExpYear
(),
"holderName"
=>
$payment
->
getCcOwner
(),
"number"
=>
$payment
->
getCcNumber
(),
"cvc"
=>
$payment
->
getCcCid
(),
];
$cardDetails
[
'card'
]
=
$requestCreditCardDetails
;
$request
=
array_merge
(
$request
,
$cardDetails
);
}
// if installments is set add it into the request
if
(
$payment
->
getAdditionalInformation
(
'number_of_installments'
)
&&
$payment
->
getAdditionalInformation
(
'number_of_installments'
)
>
0
)
{
$request
[
'installments'
][
'value'
]
=
$payment
->
getAdditionalInformation
(
'number_of_installments'
);
}
}
elseif
(
$paymentMethodCode
==
\Adyen\Payment\Model\Method\Sepa
::
METHOD_CODE
)
{
// set brand to sepa
$request
[
'selectedBrand'
]
=
"sepadirectdebit"
;
// add bankDetails into request
$bankAccount
=
[
'iban'
=>
$payment
->
getAdditionalInformation
(
"iban"
),
'ownerName'
=>
$payment
->
getAdditionalInformation
(
"account_name"
),
'countryCode'
=>
$payment
->
getAdditionalInformation
(
"country"
)
];
$request
[
'bankAccount'
]
=
$bankAccount
;
}
elseif
(
$paymentMethodCode
==
\Adyen\Payment\Model\Method\Boleto
::
METHOD_CODE
)
{
if
(
$paymentMethodCode
==
\Adyen\Payment\Model\Method\Boleto
::
METHOD_CODE
)
{
$request
[
'socialSecurityNumber'
]
=
$payment
->
getAdditionalInformation
(
"social_security_number"
);
...
...
Model/Method/Cc.php
deleted
100755 → 0
View file @
482fd41f
This diff is collapsed.
Click to expand it.
Model/Method/Pos.php
View file @
aa89f491
...
...
@@ -301,7 +301,7 @@ class Pos extends \Magento\Payment\Model\Method\AbstractMethod implements Gatewa
$shopperEmail
=
$order
->
getCustomerEmail
();
$customerId
=
$order
->
getCustomerId
();
$callbackUrl
=
$this
->
_urlBuilder
->
getUrl
(
'adyen/process/resultpos'
,
[
'_secure'
=>
$this
->
_getRequest
()
->
isSecure
()]);
[
'_secure'
=>
$this
->
_getRequest
()
->
isSecure
()]);
$addReceiptOrderLines
=
$this
->
_adyenHelper
->
getAdyenPosConfigData
(
"add_receipt_order_lines"
);
$recurringContract
=
$this
->
_adyenHelper
->
getAdyenPosConfigData
(
'recurring_type'
);
$currencyCode
=
$orderCurrencyCode
;
...
...
@@ -313,7 +313,7 @@ class Pos extends \Magento\Payment\Model\Method\AbstractMethod implements Gatewa
$recurringParams
=
""
;
if
(
$order
->
getPayment
()
->
getAdditionalInformation
(
"store_cc"
)
!=
""
)
{
$recurringParams
=
"&recurringContract="
.
urlencode
(
$recurringContract
)
.
"&shopperReference="
.
urlencode
(
$shopperReference
)
.
"&shopperEmail="
.
urlencode
(
$shopperEmail
);
urlencode
(
$shopperReference
)
.
"&shopperEmail="
.
urlencode
(
$shopperEmail
);
}
$receiptOrderLines
=
""
;
...
...
@@ -331,7 +331,11 @@ class Pos extends \Magento\Payment\Model\Method\AbstractMethod implements Gatewa
"¤cy="
.
$currencyCode
.
"&merchantReference="
.
$merchantReference
.
$recurringParams
.
$receiptOrderLines
.
"&callback="
.
$callbackUrl
.
$extraParamaters
;
$this
->
_adyenLogger
->
debug
(
print_r
(
$launchlink
,
true
));
// cash not working see ticket
// https://youtrack.is.adyen.com/issue/IOS-130#comment=102-20285
// . "&transactionType=CASH";
$this
->
_adyenLogger
->
addAdyenDebug
(
print_r
(
$launchlink
,
true
));
return
$launchlink
;
}
...
...
Model/AdyenCcConfigProvider.php
→
Model/
Ui/
AdyenCcConfigProvider.php
View file @
aa89f491
...
...
@@ -21,21 +21,17 @@
* Author: Adyen <magento@adyen.com>
*/
namespace
Adyen\Payment\Model
;
namespace
Adyen\Payment\Model
\Ui
;
use
Magento\
Payment\Model\CcGenericConfigProvider
;
use
Magento\
Checkout\Model\ConfigProviderInterface
;
use
Magento\Payment\Helper\Data
as
PaymentHelper
;
use
Magento\Framework\View\Asset\Source
as
Source
;
use
\Magento\Payment\Gateway\Config\Config
as
Config
;
class
AdyenCcConfigProvider
extends
CcGenericConfigProvider
class
AdyenCcConfigProvider
implements
ConfigProviderInterface
{
/**
* @var string[]
*/
protected
$_methodCodes
=
[
\Adyen\Payment\Model\Method\Cc
::
METHOD_CODE
];
const
CODE
=
'adyen_cc'
;
/**
* @var PaymentHelper
...
...
@@ -52,24 +48,49 @@ class AdyenCcConfigProvider extends CcGenericConfigProvider
*/
protected
$_assetSource
;
/**
* Request object
*
* @var \Magento\Framework\App\RequestInterface
*/
protected
$_request
;
/**
* @var \Magento\Framework\UrlInterface
*/
protected
$_urlBuilder
;
/**
* @var \Magento\Payment\Model\CcConfig
*/
private
$ccConfig
;
/**
* AdyenCcConfigProvider constructor.
*
* @param \Magento\Payment\Model\CcConfig $ccConfig
* @param PaymentHelper $paymentHelper
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Magento\Framework\App\RequestInterface $request
* @param \Magento\Framework\UrlInterface $urlBuilder
* @param Source $assetSource
* @param \Magento\Payment\Model\CcConfig $ccConfig
* @param Config $config
*/
public
function
__construct
(
\Magento\Payment\Model\CcConfig
$ccConfig
,
PaymentHelper
$paymentHelper
,
\Adyen\Payment\Helper\Data
$adyenHelper
,
Source
$assetSource
\Magento\Framework\App\RequestInterface
$request
,
\Magento\Framework\UrlInterface
$urlBuilder
,
Source
$assetSource
,
\Magento\Payment\Model\CcConfig
$ccConfig
)
{
parent
::
__construct
(
$ccConfig
,
$paymentHelper
,
$this
->
_methodCodes
);
$this
->
_paymentHelper
=
$paymentHelper
;
$this
->
_adyenHelper
=
$adyenHelper
;
$this
->
_request
=
$request
;
$this
->
_urlBuilder
=
$urlBuilder
;
$this
->
_assetSource
=
$assetSource
;
$this
->
ccConfig
=
$ccConfig
;
}
/**
...
...
@@ -77,47 +98,65 @@ class AdyenCcConfigProvider extends CcGenericConfigProvider
*/
public
function
getConfig
()
{
$config
=
parent
::
getConfig
();
// set to active
$config
=
[
'payment'
=>
[
self
::
CODE
=>
[
'isActive'
=>
true
,
'redirectUrl'
=>
$this
->
_urlBuilder
->
getUrl
(
'adyen/process/validate3d/'
,
[
'_secure'
=>
$this
->
_getRequest
()
->
isSecure
()])
]
]
];
foreach
(
$this
->
_methodCodes
as
$code
)
{
if
(
$this
->
methods
[
$code
]
->
isAvailable
())
{
$methodCode
=
self
::
CODE
;
$demoMode
=
$this
->
_adyenHelper
->
getAdyenAbstractConfigDataFlag
(
'demo_mode'
);
$config
=
array_merge_recursive
(
$config
,
[
'payment'
=>
[
'ccform'
=>
[
'availableTypes'
=>
[
$methodCode
=>
$this
->
getCcAvailableTypes
(
$methodCode
)],
'months'
=>
[
$methodCode
=>
$this
->
getCcMonths
()],
'years'
=>
[
$methodCode
=>
$this
->
getCcYears
()],
'hasVerification'
=>
[
$methodCode
=>
$this
->
hasVerification
(
$methodCode
)],
'cvvImageUrl'
=>
[
$methodCode
=>
$this
->
getCvvImageUrl
()]
]
]
]);
if
(
$demoMode
)
{
$cseKey
=
$this
->
_adyenHelper
->
getAdyenCcConfigData
(
'cse_publickey_test'
);
}
else
{
$cseKey
=
$this
->
_adyenHelper
->
getAdyenCcConfigData
(
'cse_publickey_live'
);
}
$demoMode
=
$this
->
_adyenHelper
->
getAdyenAbstractConfigDataFlag
(
'demo_mode'
);
$cseEnabled
=
$this
->
_adyenHelper
->
getAdyenCcConfigDataFlag
(
'cse_enabled'
);
if
(
$demoMode
)
{
$cseKey
=
$this
->
_adyenHelper
->
getAdyenCcConfigData
(
'cse_publickey_test'
);
}
else
{
$cseKey
=
$this
->
_adyenHelper
->
getAdyenCcConfigData
(
'cse_publickey_live'
);
}
$recurringType
=
$this
->
_adyenHelper
->
getAdyenAbstractConfigData
(
'recurring_type'
);
$canCreateBillingAgreement
=
false
;
if
(
$recurringType
==
"ONECLICK"
||
$recurringType
==
"ONECLICK,RECURRING"
)
{
$canCreateBillingAgreement
=
true
;
}
$cseEnabled
=
$this
->
_adyenHelper
->
getAdyenCcConfigDataFlag
(
'cse_enabled'
);
$config
[
'payment'
]
[
'adyenCc'
][
'cseKey'
]
=
$cseKey
;
$config
[
'payment'
]
[
'adyenCc'
][
'cseEnabled'
]
=
$cseEnabled
;
$config
[
'payment'
]
[
'adyenCc'
][
'cseEnabled'
]
=
$cseEnabled
;
$config
[
'payment'
][
'adyenCc'
][
'generationTime'
]
=
date
(
"c"
);
$config
[
'payment'
][
'adyenCc'
][
'canCreateBillingAgreement'
]
=
$canCreateBillingAgreement
;
$config
[
'payment'
][
'adyenCc'
][
'icons'
]
=
$this
->
getIcons
();
// has installments by default false
$config
[
'payment'
][
'adyenCc'
][
'hasInstallments'
]
=
false
;
// get Installments
$installments
=
$this
->
_adyenHelper
->
getAdyenCcConfigData
(
'installments'
);
if
(
$installments
)
{
$config
[
'payment'
][
'adyenCc'
][
'installments'
]
=
unserialize
(
$installments
);
$config
[
'payment'
][
'adyenCc'
][
'hasInstallments'
]
=
true
;
}
else
{
$config
[
'payment'
][
'adyenCc'
][
'installments'
]
=
[];
}
}
$recurringType
=
$this
->
_adyenHelper
->
getAdyenAbstractConfigData
(
'recurring_type'
);
$canCreateBillingAgreement
=
false
;
if
(
$recurringType
==
"ONECLICK"
||
$recurringType
==
"ONECLICK,RECURRING"
)
{
$canCreateBillingAgreement
=
true
;
}
$config
[
'payment'
]
[
'adyenCc'
][
'cseKey'
]
=
$cseKey
;
$config
[
'payment'
]
[
'adyenCc'
][
'cseEnabled'
]
=
$cseEnabled
;
$config
[
'payment'
]
[
'adyenCc'
][
'cseEnabled'
]
=
$cseEnabled
;
$config
[
'payment'
][
'adyenCc'
][
'generationTime'
]
=
date
(
"c"
);
$config
[
'payment'
][
'adyenCc'
][
'canCreateBillingAgreement'
]
=
$canCreateBillingAgreement
;
$config
[
'payment'
][
'adyenCc'
][
'icons'
]
=
$this
->
getIcons
();
// has installments by default false
$config
[
'payment'
][
'adyenCc'
][
'hasInstallments'
]
=
false
;
// get Installments
$installments
=
$this
->
_adyenHelper
->
getAdyenCcConfigData
(
'installments'
);
if
(
$installments
)
{
$config
[
'payment'
][
'adyenCc'
][
'installments'
]
=
unserialize
(
$installments
);
$config
[
'payment'
][
'adyenCc'
][
'hasInstallments'
]
=
true
;
}
else
{
$config
[
'payment'
][
'adyenCc'
][
'installments'
]
=
[];
}
return
$config
;
...
...
@@ -133,7 +172,7 @@ class AdyenCcConfigProvider extends CcGenericConfigProvider
{
$types
=
[];
$ccTypes
=
$this
->
_adyenHelper
->
getAdyenCcTypes
();
$availableTypes
=
$this
->
methods
[
$methodCode
]
->
get
ConfigData
(
'cctypes'
);
$availableTypes
=
$this
->
_adyenHelper
->
getAdyenCc
ConfigData
(
'cctypes'
);
if
(
$availableTypes
)
{
$availableTypes
=
explode
(
','
,
$availableTypes
);
foreach
(
array_keys
(
$ccTypes
)
as
$code
)
{
...
...
@@ -171,4 +210,55 @@ class AdyenCcConfigProvider extends CcGenericConfigProvider
}
return
$icons
;
}
/**
* Retrieve credit card expire months
*
* @return array
*/
protected
function
getCcMonths
()
{
return
$this
->
ccConfig
->
getCcMonths
();
}
/**
* Retrieve credit card expire years
*
* @return array
*/
protected
function
getCcYears
()
{
return
$this
->
ccConfig
->
getCcYears
();
}
/**
* Has verification is always true
*
* @return bool
*/
protected
function
hasVerification
()
{
return
$this
->
_adyenHelper
->
getAdyenCcConfigData
(
'useccv'
);
}
/**
* Retrieve CVV tooltip image url
*
* @return string
*/
protected
function
getCvvImageUrl
()
{
return
$this
->
ccConfig
->
getCvvImageUrl
();
}
/**
* Retrieve request object
*
* @return \Magento\Framework\App\RequestInterface
*/
protected
function
_getRequest
()
{
return
$this
->
_request
;
}
}
\ No newline at end of file
Model/AdyenOneclickConfigProvider.php
→
Model/
Ui/
AdyenOneclickConfigProvider.php
View file @
aa89f491
...
...
@@ -21,40 +21,31 @@
* Author: Adyen <magento@adyen.com>
*/
namespace
Adyen\Payment\Model
;
namespace
Adyen\Payment\Model
\Ui
;
use
Magento\
Payment\Model\CcGenericConfigProvider
;
use
Magento\
Checkout\Model\ConfigProviderInterface
;
use
Magento\Payment\Helper\Data
as
PaymentHelper
;
class
AdyenOneclickConfigProvider
extends
CcGenericConfigProvider
class
AdyenOneclickConfigProvider
implements
ConfigProviderInterface
{
const
CODE
=
'adyen_oneclick'
;
/**
* @var Config
*/
protected
$config
;
/**
* @var string[]
*/
protected
$_methodCodes
=
[
\Adyen\Payment\Model\Method\Oneclick
::
METHOD_CODE
];
/**
* @var \Magento\Payment\Model\Method\AbstractMethod[]
*/
protected
$methods
=
[];
/**
* @var PaymentHelper
* @var \Adyen\Payment\Helper\Data
*/
protected
$_
payment
Helper
;
protected
$_
adyen
Helper
;
/**
* @var \
Adyen\Payment\Helper\Data
* @var \
Magento\Framework\App\RequestInterface
*/
protected
$_
adyenHelper
;
protected
$_
request
;
/**
* @var \Magento\Customer\Model\Session
...
...
@@ -67,42 +58,46 @@ class AdyenOneclickConfigProvider extends CcGenericConfigProvider
protected
$_session
;
/**
* @var \Magento\
Framework\App\Stat
e
* @var \Magento\
Store\Model\StoreManagerInterfac
e
*/
protected
$_
appState
;
protected
$_
storeManager
;
/**
* @var \Magento\
Store\Model\StoreManager
Interface
* @var \Magento\
Framework\Url
Interface
*/
protected
$_storeManager
;
protected
$_urlBuilder
;
/**
* @var \Magento\Payment\Model\CcConfig
*/
private
$ccConfig
;
/**
* AdyenOneclickConfigProvider constructor.
*
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Payment\Model\CcConfig $ccConfig
* @param PaymentHelper $paymentHelper
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Magento\Framework\App\RequestInterface $request
* @param \Magento\Customer\Model\Session $customerSession
* @param \Magento\Checkout\Model\Session $session
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Framework\UrlInterface $urlBuilder
*/
public
function
__construct
(
\Magento\Framework\Model\Context
$context
,
\Magento\Payment\Model\CcConfig
$ccConfig
,
PaymentHelper
$paymentHelper
,
\Adyen\Payment\Helper\Data
$adyenHelper
,
\Magento\Framework\App\RequestInterface
$request
,
\Magento\Customer\Model\Session
$customerSession
,
\Magento\Checkout\Model\Session
$session
,
\Magento\Store\Model\StoreManagerInterface
$storeManager
\Magento\Store\Model\StoreManagerInterface
$storeManager
,
\Magento\Framework\UrlInterface
$urlBuilder
,
\Magento\Payment\Model\CcConfig
$ccConfig
)
{
parent
::
__construct
(
$ccConfig
,
$paymentHelper
,
$this
->
_methodCodes
);
$this
->
_paymentHelper
=
$paymentHelper
;
$this
->
_adyenHelper
=
$adyenHelper
;
$this
->
_request
=
$request
;
$this
->
_customerSession
=
$customerSession
;
$this
->
_session
=
$session
;
$this
->
_appState
=
$context
->
getAppState
();
$this
->
_storeManager
=
$storeManager
;
$this
->
_urlBuilder
=
$urlBuilder
;
$this
->
ccConfig
=
$ccConfig
;
}
/**
...
...
@@ -110,7 +105,30 @@ class AdyenOneclickConfigProvider extends CcGenericConfigProvider
*/
public
function
getConfig
()
{
$config
=
parent
::
getConfig
();
// set to active
$config
=
[
'payment'
=>
[
self
::
CODE
=>
[
'isActive'
=>
true
,
'redirectUrl'
=>
$this
->
_urlBuilder
->
getUrl
(
'adyen/process/validate3d/'
,
[
'_secure'
=>
$this
->
_getRequest
()
->
isSecure
()])
]
]
];
$methodCode
=
self
::
CODE
;
$config
=
array_merge_recursive
(
$config
,
[
'payment'
=>
[
'ccform'
=>
[
'availableTypes'
=>
[
$methodCode
=>
$this
->
getCcAvailableTypes
(
$methodCode
)],
'months'
=>
[
$methodCode
=>
$this
->
getCcMonths
()],
'years'
=>
[
$methodCode
=>
$this
->
getCcYears
()],
'hasVerification'
=>
[
$methodCode
=>
$this
->
hasVerification
(
$methodCode
)],
'cvvImageUrl'
=>
[
$methodCode
=>
$this
->
getCvvImageUrl
()]
]
]
]);
$demoMode
=
$this
->
_adyenHelper
->
getAdyenAbstractConfigDataFlag
(
'demo_mode'
);
...
...
@@ -134,19 +152,15 @@ class AdyenOneclickConfigProvider extends CcGenericConfigProvider
$config
[
'payment'
][
'adyenOneclick'
][
'generationTime'
]
=
date
(
"c"
);
$config
[
'payment'
][
'adyenOneclick'
][
'canCreateBillingAgreement'
]
=
$canCreateBillingAgreement
;
foreach
(
$this
->
_methodCodes
as
$code
)
{
if
(
$this
->
methods
[
$code
]
->
isAvailable
())
{
$recurringContractType
=
$this
->
_getRecurringContractType
();
$recurringContractType
=
$this
->
_getRecurringContractType
();
$config
[
'payment'
]
[
'adyenOneclick'
][
'billingAgreements'
]
=
$this
->
getAdyenOneclickPaymentMethods
();
if
(
$recurringContractType
==
\Adyen\Payment\Model\RecurringType
::
ONECLICK
)
{
$config
[
'payment'
]
[
'adyenOneclick'
][
'hasCustomerInteraction'
]
=
true
;
}
else
{
$config
[
'payment'
]
[
'adyenOneclick'
][
'hasCustomerInteraction'
]
=
false
;
}
}
$config
[
'payment'
]
[
'adyenOneclick'
][
'billingAgreements'
]
=
$this
->
getAdyenOneclickPaymentMethods
();
if
(
$recurringContractType
==
\Adyen\Payment\Model\RecurringType
::
ONECLICK
)
{
$config
[
'payment'
]
[
'adyenOneclick'
][
'hasCustomerInteraction'
]
=
true
;
}
else
{
$config
[
'payment'
]
[
'adyenOneclick'
][
'hasCustomerInteraction'
]
=
false
;
}
return
$config
;
}
...
...
@@ -163,7 +177,12 @@ class AdyenOneclickConfigProvider extends CcGenericConfigProvider
$grandTotal
=
$this
->
_getQuote
()
->
getGrandTotal
();
$recurringType
=
$this
->
_getRecurringContractType
();
$billingAgreements
=
$this
->
_adyenHelper
->
getOneClickPaymentMethods
(
$customerId
,
$storeId
,
$grandTotal
,
$recurringType
);
$billingAgreements
=
$this
->
_adyenHelper
->
getOneClickPaymentMethods
(
$customerId
,
$storeId
,
$grandTotal
,
$recurringType
);
}
return
$billingAgreements
;
}
...
...
@@ -183,4 +202,80 @@ class AdyenOneclickConfigProvider extends CcGenericConfigProvider
{
return
$this
->
_session
->
getQuote
();
}
/**
* Retrieve availables credit card types
*
* @param string $methodCode
* @return array
*/
protected
function
getCcAvailableTypes
(
$methodCode
)
{
$types
=
[];
$ccTypes
=
$this
->
_adyenHelper
->
getAdyenCcTypes
();
$availableTypes
=
$this
->
_adyenHelper
->
getAdyenCcConfigData
(
'cctypes'
);
if
(
$availableTypes
)
{
$availableTypes
=
explode
(
','
,
$availableTypes
);
foreach
(
array_keys
(
$ccTypes
)
as
$code
)
{
if
(
in_array
(
$code
,
$availableTypes
))
{
$types
[
$code
]
=
$ccTypes
[
$code
][
'name'
];
}
}
}
return
$types
;
}
/**
* Retrieve credit card expire months
*
* @return array
*/
protected
function
getCcMonths
()
{
return
$this
->
ccConfig
->
getCcMonths
();
}
/**
* Retrieve credit card expire years
*
* @return array
*/
protected
function
getCcYears
()
{
return
$this
->
ccConfig
->
getCcYears
();
}
/**
* Has verification is always true
*
* @return bool
*/
protected
function
hasVerification
()
{
return
$this
->
_adyenHelper
->
getAdyenCcConfigData
(
'useccv'
);
}
/**
* Retrieve CVV tooltip image url
*
* @return string
*/
protected
function
getCvvImageUrl
()
{
return
$this
->
ccConfig
->
getCvvImageUrl
();
}
/**
* Retrieve request object
*
* @return \Magento\Framework\App\RequestInterface
*/
protected
function
_getRequest
()
{
return
$this
->
_request
;
}
}
\ No newline at end of file
Observer/AdyenCcDataAssignObserver.php
0 → 100644
View file @
aa89f491
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace
Adyen\Payment\Observer
;
use
Magento\Framework\Event\Observer
;
use
Magento\Payment\Observer\AbstractDataAssignObserver
;
use
Magento\Quote\Api\Data\PaymentInterface
;
/**
* Class DataAssignObserver
*/
class
AdyenCcDataAssignObserver
extends
AbstractDataAssignObserver
{
const
CC_TYPE
=
'cc_type'
;
const
ENCRYPTED_DATA
=
'encrypted_data'
;
const
NUMBER_OF_INSTALLMENTS
=
'number_of_installments'
;
const
STORE_CC
=
'store_cc'
;
/**
* @var array
*/
protected
$additionalInformationList
=
[
self
::
CC_TYPE
,
self
::
ENCRYPTED_DATA
,
self
::
NUMBER_OF_INSTALLMENTS
,
self
::
STORE_CC
];
/**
* @param Observer $observer
* @return void
*/
public
function
execute
(
Observer
$observer
)
{
$data
=
$this
->
readDataArgument
(
$observer
);
$additionalData
=
$data
->
getData
(
PaymentInterface
::
KEY_ADDITIONAL_DATA
);
if
(
!
is_array
(
$additionalData
))
{
return
;
}
$paymentInfo
=
$this
->
readPaymentModelArgument
(
$observer
);
// set ccType
$paymentInfo
->
setCcType
(
$additionalData
[
'cc_type'
]);
foreach
(
$this
->
additionalInformationList
as
$additionalInformationKey
)
{
if
(
isset
(
$additionalData
[
$additionalInformationKey
]))
{
$paymentInfo
->
setAdditionalInformation
(
$additionalInformationKey
,
$additionalData
[
$additionalInformationKey
]
);
}
}
}
}
Model/Method/Oneclick
.php
→
Observer/AdyenOneclickDataAssignObserver
.php
View file @
aa89f491
...
...
@@ -20,87 +20,95 @@
*
* Author: Adyen <magento@adyen.com>
*/
namespace
Adyen\Payment\Observer
;
namespace
Adyen\Payment\Model\Method
;
use
Magento\Framework\Webapi\Exception
;
use
Magento\Framework\Event\Observer
;
use
Magento\Payment\Observer\AbstractDataAssignObserver
;
use
Magento\Quote\Api\Data\PaymentInterface
;
/**
* Adyen CreditCard payment method
* @SuppressWarnings(PHPMD.ExcessivePublicCount)
* @SuppressWarnings(PHPMD.TooManyFields)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* Class DataAssignObserver
*/
class
Oneclick
extends
\Adyen\Payment\Model\Method\Cc
class
AdyenOneclickDataAssignObserver
extends
AbstractDataAssignObserver
{
const
METHOD_CODE
=
'adyen_oneclick'
;
const
RECURRING_DETAIL_REFERENCE
=
'recurring_detail_reference'
;
const
ENCRYPTED_DATA
=
'encrypted_data'
;
const
NUMBER_OF_INSTALLMENTS
=
'number_of_installments'
;
/**
* @var
string
* @var
array
*/
protected
$_code
=
self
::
METHOD_CODE
;
protected
$additionalInformationList
=
[
self
::
RECURRING_DETAIL_REFERENCE
,
self
::
ENCRYPTED_DATA
,
self
::
NUMBER_OF_INSTALLMENTS
];
/**
* @var
string
* @var
\Adyen\Payment\Helper\Data
*/
pr
otected
$_formBlockType
=
'Adyen\Payment\Block\Form\Oneclick'
;
pr
ivate
$adyenHelper
;
/**
* @var
string
* @var
\Magento\Framework\App\State
*/
pr
otected
$_infoBlockType
=
'Adyen\Payment\Block\Info\Oneclick'
;
pr
ivate
$appState
;
/**
* Assign data to info model instance
*
* @param \Magento\Framework\DataObject|mixed $data
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
* AdyenCcDataAssignObserver constructor.
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public
function
__construct
(
\Adyen\Payment\Helper\Data
$adyenHelper
,
\Magento\Framework\Model\Context
$context
)
{
$this
->
adyenHelper
=
$adyenHelper
;
$this
->
appState
=
$context
->
getAppState
();
}
/**
* @param Observer $observer
* @return void
*/
public
function
assignData
(
\Magento\Framework\DataObject
$data
)
public
function
execute
(
Observer
$observer
)
{
$data
=
$this
->
readDataArgument
(
$observer
);
if
(
!
$data
instanceof
\Magento\Framework\DataObject
)
{
$data
=
new
\Magento\Framework\DataObject
(
$data
);
$additionalData
=
$data
->
getData
(
PaymentInterface
::
KEY_ADDITIONAL_DATA
);
if
(
!
is_array
(
$additionalData
))
{
return
;
}
$additionalData
=
$data
->
getAdditionalData
();
$infoInstance
=
$this
->
getInfoInstance
();
$paymentInfo
=
$this
->
readPaymentModelArgument
(
$observer
);
//
get from variant magento code for creditcard type and set this in
ccType
//
set
ccType
$variant
=
$additionalData
[
'variant'
];
$ccType
=
$this
->
_adyenHelper
->
getMagentoCreditCartType
(
$variant
);
$infoInstance
->
setCcType
(
$ccType
);
// save value remember details checkbox
$infoInstance
->
setAdditionalInformation
(
'recurring_detail_reference'
,
$additionalData
[
'recurring_detail_reference'
]);
$recurringPaymentType
=
$this
->
getRecurringPaymentType
();
if
(
$recurringPaymentType
==
\Adyen\Payment\Model\RecurringType
::
ONECLICK
)
{
$customerInteraction
=
true
;
// retrieve cse key
if
(
$this
->
_adyenHelper
->
getAdyenCcConfigDataFlag
(
'cse_enabled'
))
{
if
(
isset
(
$additionalData
[
'encrypted_data'
]))
{
$infoInstance
->
setAdditionalInformation
(
'encrypted_data'
,
$additionalData
[
'encrypted_data'
]);
}
else
{
throw
new
\Magento\Framework\Exception\LocalizedException
(
__
(
'Card encryption failed'
));
}
$ccType
=
$this
->
adyenHelper
->
getMagentoCreditCartType
(
$variant
);
$paymentInfo
->
setCcType
(
$ccType
);
foreach
(
$this
->
additionalInformationList
as
$additionalInformationKey
)
{
if
(
isset
(
$additionalData
[
$additionalInformationKey
]))
{
$paymentInfo
->
setAdditionalInformation
(
$additionalInformationKey
,
$additionalData
[
$additionalInformationKey
]
);
}
}
else
{
$customerInteraction
=
false
;
}
$infoInstance
->
setAdditionalInformation
(
'customer_interaction'
,
$customerInteraction
);
// set number of installements
if
(
isset
(
$additionalData
[
'number_of_installments'
]))
{
$infoInstance
->
setAdditionalInformation
(
'number_of_installments'
,
$additionalData
[
'number_of_installments'
]
);
// set customerInteraction
$recurringContractType
=
$this
->
getRecurringPaymentType
();
if
(
$recurringContractType
==
\Adyen\Payment\Model\RecurringType
::
ONECLICK
)
{
$paymentInfo
->
setAdditionalInformation
(
'customer_interaction'
,
true
);
}
else
{
$paymentInfo
->
setAdditionalInformation
(
'customer_interaction'
,
false
);
}
return
$this
;
// set ccType
$variant
=
$additionalData
[
'variant'
];
$ccType
=
$this
->
adyenHelper
->
getMagentoCreditCartType
(
$variant
);
$paymentInfo
->
setAdditionalInformation
(
'cc_type'
,
$ccType
);
}
/**
...
...
@@ -112,33 +120,10 @@ class Oneclick extends \Adyen\Payment\Model\Method\Cc
public
function
getRecurringPaymentType
()
{
// For admin always use Recurring
if
(
$this
->
_
appState
->
getAreaCode
()
===
\Magento\Backend\App\Area\FrontNameResolver
::
AREA_CODE
)
{
if
(
$this
->
appState
->
getAreaCode
()
===
\Magento\Backend\App\Area\FrontNameResolver
::
AREA_CODE
)
{
return
\Adyen\Payment\Model\RecurringType
::
RECURRING
;
}
else
{
return
$this
->
_adyenHelper
->
getAdyenOneclickConfigData
(
'recurring_payment_type'
);
}
}
/**
* @param \Adyen\Payment\Model\Billing\Agreement $agreement
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
*/
public
function
updateBillingAgreementStatus
(
\Adyen\Payment\Model\Billing\Agreement
$agreement
)
{
$targetStatus
=
$agreement
->
getStatus
();
if
(
$targetStatus
==
\Magento\Paypal\Model\Billing\Agreement
::
STATUS_CANCELED
)
{
try
{
$this
->
_paymentRequest
->
disableRecurringContract
(
$agreement
->
getReferenceId
(),
$agreement
->
getCustomerReference
(),
$agreement
->
getStoreId
()
);
}
catch
(
Exception
$e
)
{
throw
new
\Magento\Framework\Exception\LocalizedException
(
__
(
'Failed to disable this contract'
));
}
return
$this
->
adyenHelper
->
getAdyenOneclickConfigData
(
'recurring_payment_type'
);
}
return
$this
;
}
}
\ No newline at end of file
}
etc/config.xml
View file @
aa89f491
...
...
@@ -38,7 +38,7 @@
</adyen_abstract>
<adyen_cc>
<active>
1
</active>
<model>
Adyen
\Payment\Model\Method\Cc
</model>
<model>
Adyen
PaymentCcFacade
</model>
<title>
Adyen CreditCard
</title>
<allowspecific>
0
</allowspecific>
<sort_order>
2
</sort_order>
...
...
@@ -47,17 +47,43 @@
<cse_enabled>
1
</cse_enabled>
<enable_moto>
0
</enable_moto>
<payment_action>
authorize
</payment_action>
<is_gateway>
1
</is_gateway>
<can_use_checkout>
1
</can_use_checkout>
<can_authorize>
1
</can_authorize>
<can_authorize_3d>
1
</can_authorize_3d>
<can_capture>
1
</can_capture>
<can_capture_partial>
1
</can_capture_partial>
<can_use_internal>
1
</can_use_internal>
<can_refund_partial_per_invoice>
1
</can_refund_partial_per_invoice>
<can_refund>
1
</can_refund>
<can_void>
1
</can_void>
<can_cancel>
1
</can_cancel>
<group>
adyen
</group>
</adyen_cc>
<adyen_oneclick>
<active>
1
</active>
<model>
Adyen
\Payment\Model\Method\Oneclick
</model>
<model>
Adyen
PaymentOneclickFacade
</model>
<title>
Adyen OneClick
</title>
<allowspecific>
0
</allowspecific>
<sort_order>
1
</sort_order>
<cctypes>
AE,VI,MC,DI
</cctypes>
<!-- important to show the payment method isAvailabe()-->
<recurring_payment_type>
ONECLICK
</recurring_payment_type>
<payment_action>
authorize
</payment_action>
<useccv>
1
</useccv>
<cse_enabled>
1
</cse_enabled>
<enable_moto>
0
</enable_moto>
<payment_action>
authorize
</payment_action>
<is_gateway>
1
</is_gateway>
<can_use_checkout>
1
</can_use_checkout>
<can_authorize>
1
</can_authorize>
<can_authorize_3d>
1
</can_authorize_3d>
<can_capture>
1
</can_capture>
<can_capture_partial>
1
</can_capture_partial>
<can_use_internal>
1
</can_use_internal>
<can_refund_partial_per_invoice>
1
</can_refund_partial_per_invoice>
<can_refund>
1
</can_refund>
<can_void>
1
</can_void>
<can_cancel>
1
</can_cancel>
<group>
adyen
</group>
</adyen_oneclick>
<adyen_hpp>
...
...
@@ -77,7 +103,7 @@
</adyen_hpp>
<adyen_sepa>
<active>
0
</active>
<model>
AdyenSepaFacade
</model>
<model>
Adyen
Payment
SepaFacade
</model>
<title>
Sepa Direct Debit
</title>
<allowspecific>
0
</allowspecific>
<sort_order>
4
</sort_order>
...
...
etc/di.xml
View file @
aa89f491
This diff is collapsed.
Click to expand it.
etc/events.xml
View file @
aa89f491
...
...
@@ -23,6 +23,12 @@
*/
-->
<config
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation=
"urn:magento:framework:Event/etc/events.xsd"
>
<event
name=
"payment_method_assign_data_adyen_cc"
>
<observer
name=
"adyen_cc_gateway_data_assign"
instance=
"Adyen\Payment\Observer\AdyenCcDataAssignObserver"
/>
</event>
<event
name=
"payment_method_assign_data_adyen_oneclick"
>
<observer
name=
"adyen_cc_gateway_data_assign"
instance=
"Adyen\Payment\Observer\AdyenOneclickDataAssignObserver"
/>
</event>
<event
name=
"payment_method_assign_data_adyen_sepa"
>
<observer
name=
"adyen_sepa_gateway_data_assign"
instance=
"Adyen\Payment\Observer\AdyenSepaDataAssignObserver"
/>
</event>
...
...
etc/frontend/di.xml
View file @
aa89f491
...
...
@@ -28,8 +28,8 @@
<arguments>
<argument
name=
"configProviders"
xsi:type=
"array"
>
<item
name=
"adyen_generic_config_provider"
xsi:type=
"object"
>
Adyen\Payment\Model\AdyenGenericConfigProvider
</item>
<item
name=
"adyen_cc_config_provider"
xsi:type=
"object"
>
Adyen\Payment\Model\AdyenCcConfigProvider
</item>
<item
name=
"adyen_oneclick_config_provider"
xsi:type=
"object"
>
Adyen\Payment\Model\AdyenOneclickConfigProvider
</item>
<item
name=
"adyen_cc_config_provider"
xsi:type=
"object"
>
Adyen\Payment\Model\
Ui\
AdyenCcConfigProvider
</item>
<item
name=
"adyen_oneclick_config_provider"
xsi:type=
"object"
>
Adyen\Payment\Model\
Ui\
AdyenOneclickConfigProvider
</item>
<item
name=
"adyen_hpp_config_provider"
xsi:type=
"object"
>
Adyen\Payment\Model\AdyenHppConfigProvider
</item>
<item
name=
"adyen_sepa_config_provider"
xsi:type=
"object"
>
Adyen\Payment\Model\Ui\AdyenSepaConfigProvider
</item>
<item
name=
"adyen_boleto_config_provider"
xsi:type=
"object"
>
Adyen\Payment\Model\AdyenBoletoConfigProvider
</item>
...
...
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