We will be off from 27/1 (Monday) to 31/1 (Friday) (GMT +7) for our Tet Holiday (Lunar New Year) in our country

Commit 0773826f authored by cyattilakiss's avatar cyattilakiss Committed by GitHub

Merge pull request #627 from Adyen/develop

Release 5.2.0
parents e1dc67f0 5e1db9b4
* @msilvagarcia @cyattilakiss @Aleffio @AlexandrosMor @rikterbeek * @msilvagarcia @cyattilakiss @Aleffio @AlexandrosMor @rikterbeek @acampos1916
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: Bug report
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
**Additional context**
Add any other context about the problem here.
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: Enhancement
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
# Configuration for probot-stale - https://github.com/probot/stale
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 14
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- Validating request
- Bug report
- Bug
- Enhancement
# Label to use when marking an issue as stale
staleLabel: Stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
closeComment: >
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.
only: issues
\ No newline at end of file
language: php
sudo: false
php:
- 7.1
- 7.2
- 7.3
install:
- echo "{\"http-basic\":{\"repo.magento.com\":{\"username\":\"${MAGENTO_USERNAME}\",\"password\":\"${MAGENTO_PASSWORD}\"}}}" > auth.json
- composer install --prefer-dist
script:
- php vendor/bin/phpcs
- vendor/bin/phpunit -c Test/phpunit.xml
\ No newline at end of file
...@@ -41,9 +41,9 @@ class PaymentLink extends AbstractInfo ...@@ -41,9 +41,9 @@ class PaymentLink extends AbstractInfo
\Adyen\Payment\Helper\Data $adyenHelper, \Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Model\ResourceModel\Order\Payment\CollectionFactory $adyenOrderPaymentCollectionFactory, \Adyen\Payment\Model\ResourceModel\Order\Payment\CollectionFactory $adyenOrderPaymentCollectionFactory,
Template\Context $context, Template\Context $context,
array $data = [],
\Magento\Framework\Registry $registry, \Magento\Framework\Registry $registry,
\Adyen\Payment\Gateway\Command\PayByMailCommand $payByMailCommand \Adyen\Payment\Gateway\Command\PayByMailCommand $payByMailCommand,
array $data = []
) { ) {
$this->registry = $registry; $this->registry = $registry;
$this->payByMail = $payByMailCommand; $this->payByMail = $payByMailCommand;
......
...@@ -89,14 +89,14 @@ class Redirect extends \Magento\Payment\Block\Form ...@@ -89,14 +89,14 @@ class Redirect extends \Magento\Payment\Block\Form
*/ */
public function __construct( public function __construct(
\Magento\Framework\View\Element\Template\Context $context, \Magento\Framework\View\Element\Template\Context $context,
array $data = [],
\Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Sales\Model\OrderFactory $orderFactory,
\Magento\Checkout\Model\Session $checkoutSession, \Magento\Checkout\Model\Session $checkoutSession,
\Adyen\Payment\Helper\Data $adyenHelper, \Adyen\Payment\Helper\Data $adyenHelper,
\Magento\Framework\Locale\ResolverInterface $resolver, \Magento\Framework\Locale\ResolverInterface $resolver,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger, \Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Magento\Tax\Model\Config $taxConfig, \Magento\Tax\Model\Config $taxConfig,
\Magento\Tax\Model\Calculation $taxCalculation \Magento\Tax\Model\Calculation $taxCalculation,
array $data = []
) { ) {
$this->_orderFactory = $orderFactory; $this->_orderFactory = $orderFactory;
$this->_checkoutSession = $checkoutSession; $this->_checkoutSession = $checkoutSession;
......
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at support@adyen.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
...@@ -62,8 +62,9 @@ class ThreeDS2DataBuilder implements BuilderInterface ...@@ -62,8 +62,9 @@ class ThreeDS2DataBuilder implements BuilderInterface
/** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */ /** @var \Magento\Payment\Gateway\Data\PaymentDataObject $paymentDataObject */
$paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject); $paymentDataObject = \Magento\Payment\Gateway\Helper\SubjectReader::readPayment($buildSubject);
$payment = $paymentDataObject->getPayment(); $payment = $paymentDataObject->getPayment();
$order = $paymentDataObject->getOrder();
$additionalInformation = $payment->getAdditionalInformation(); $additionalInformation = $payment->getAdditionalInformation();
$request['body'] = $this->adyenRequestsHelper->buildThreeDS2Data([], $additionalInformation); $request['body'] = $this->adyenRequestsHelper->buildThreeDS2Data([], $additionalInformation, $order->getStoreId());
return $request; return $request;
} }
} }
...@@ -40,34 +40,35 @@ class InstallmentValidator extends AbstractValidator ...@@ -40,34 +40,35 @@ class InstallmentValidator extends AbstractValidator
private $adyenHelper; private $adyenHelper;
/** /**
* @var \Magento\Checkout\Model\Session * @var \Magento\Framework\Serialize\SerializerInterface
*/ */
private $session; private $serializer;
/** /**
* @var \Magento\Framework\Serialize\SerializerInterface * @var \Magento\Quote\Model\QuoteRepository
*/ */
private $serializer; private $quoteRepository;
/** /**
* InstallmentValidator constructor. * InstallmentValidator constructor.
* @param \Magento\Payment\Gateway\Validator\ResultInterfaceFactory $resultFactory * @param \Magento\Payment\Gateway\Validator\ResultInterfaceFactory $resultFactory
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger * @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Adyen\Payment\Helper\Data $adyenHelper * @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Magento\Checkout\Model\Session $session
* @param \Magento\Framework\Serialize\SerializerInterface $serializer * @param \Magento\Framework\Serialize\SerializerInterface $serializer
* @param \Magento\Quote\Model\QuoteRepository $quoteRepository
*/ */
public function __construct( public function __construct(
\Magento\Payment\Gateway\Validator\ResultInterfaceFactory $resultFactory, \Magento\Payment\Gateway\Validator\ResultInterfaceFactory $resultFactory,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger, \Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Adyen\Payment\Helper\Data $adyenHelper, \Adyen\Payment\Helper\Data $adyenHelper,
\Magento\Checkout\Model\Session $session, \Magento\Framework\Serialize\SerializerInterface $serializer,
\Magento\Framework\Serialize\SerializerInterface $serializer \Magento\Quote\Model\QuoteRepository $quoteRepository
) { ) {
$this->adyenLogger = $adyenLogger; $this->adyenLogger = $adyenLogger;
$this->adyenHelper = $adyenHelper; $this->adyenHelper = $adyenHelper;
$this->session = $session;
$this->serializer = $serializer; $this->serializer = $serializer;
$this->quoteRepository = $quoteRepository;
parent::__construct($resultFactory); parent::__construct($resultFactory);
} }
...@@ -77,7 +78,13 @@ class InstallmentValidator extends AbstractValidator ...@@ -77,7 +78,13 @@ class InstallmentValidator extends AbstractValidator
$isValid = true; $isValid = true;
$fails = []; $fails = [];
$payment = $validationSubject['payment']; $payment = $validationSubject['payment'];
$quote = $this->session->getQuote(); $quoteId = $payment->getQuoteId();
//This validator also runs for other payments that don't necesarily have a quoteId
if ($quoteId) {
$quote = $this->quoteRepository->get($quoteId);
} else {
$quote = false;
}
$installmentsEnabled = $this->adyenHelper->getAdyenCcConfigData('enable_installments'); $installmentsEnabled = $this->adyenHelper->getAdyenCcConfigData('enable_installments');
if ($quote && $installmentsEnabled) { if ($quote && $installmentsEnabled) {
$grandTotal = $quote->getGrandTotal(); $grandTotal = $quote->getGrandTotal();
......
...@@ -298,26 +298,33 @@ class Requests extends AbstractHelper ...@@ -298,26 +298,33 @@ class Requests extends AbstractHelper
/** /**
* @param array $request * @param array $request
* @param $payment * @param $additionalData
* @param $store * @param $storeId
* @return array * @return array
*/ */
public function buildThreeDS2Data($request = [], $additionalData) public function buildThreeDS2Data($request = [], $additionalData, $storeId)
{ {
$request['additionalData']['allow3DS2'] = true; if ($this->adyenHelper->isCreditCardThreeDS2Enabled($storeId)) {
$request['origin'] = $this->adyenHelper->getOrigin(); $request['additionalData']['allow3DS2'] = true;
$request['channel'] = 'web'; $request['origin'] = $this->adyenHelper->getOrigin();
$request['browserInfo']['screenWidth'] = $additionalData[AdyenCcDataAssignObserver::SCREEN_WIDTH]; $request['channel'] = 'web';
$request['browserInfo']['screenHeight'] = $additionalData[AdyenCcDataAssignObserver::SCREEN_HEIGHT]; $request['browserInfo']['screenWidth'] = $additionalData[AdyenCcDataAssignObserver::SCREEN_WIDTH];
$request['browserInfo']['colorDepth'] = $additionalData[AdyenCcDataAssignObserver::SCREEN_COLOR_DEPTH]; $request['browserInfo']['screenHeight'] = $additionalData[AdyenCcDataAssignObserver::SCREEN_HEIGHT];
$request['browserInfo']['timeZoneOffset'] = $additionalData[AdyenCcDataAssignObserver::TIMEZONE_OFFSET]; $request['browserInfo']['colorDepth'] = $additionalData[AdyenCcDataAssignObserver::SCREEN_COLOR_DEPTH];
$request['browserInfo']['language'] = $additionalData[AdyenCcDataAssignObserver::LANGUAGE]; $request['browserInfo']['timeZoneOffset'] = $additionalData[AdyenCcDataAssignObserver::TIMEZONE_OFFSET];
$request['browserInfo']['language'] = $additionalData[AdyenCcDataAssignObserver::LANGUAGE];
if ($javaEnabled = $additionalData[AdyenCcDataAssignObserver::JAVA_ENABLED]) {
$request['browserInfo']['javaEnabled'] = $javaEnabled; if ($javaEnabled = $additionalData[AdyenCcDataAssignObserver::JAVA_ENABLED]) {
$request['browserInfo']['javaEnabled'] = $javaEnabled;
} else {
$request['browserInfo']['javaEnabled'] = false;
}
} else { } else {
$request['browserInfo']['javaEnabled'] = false; $request['additionalData']['allow3DS2'] = false;
$request['origin'] = $this->adyenHelper->getOrigin();
$request['channel'] = 'web';
} }
return $request; return $request;
} }
......
...@@ -56,23 +56,34 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface ...@@ -56,23 +56,34 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface
*/ */
protected $checkoutSession; protected $checkoutSession;
/**
* @var \Magento\Framework\App\ProductMetadataInterface
*/
protected $productMetadata;
/** /**
* AdyenInitiateTerminalApi constructor. * AdyenInitiateTerminalApi constructor.
* @param \Adyen\Payment\Helper\Data $adyenHelper * @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger * @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
* @param \Magento\Checkout\Model\Session $_checkoutSession * @param \Magento\Checkout\Model\Session $checkoutSession
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Framework\App\ProductMetadataInterface $productMetadata
* @param array $data * @param array $data
* @throws \Adyen\AdyenException
*/ */
public function __construct( public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper, \Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger, \Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Magento\Checkout\Model\Session $checkoutSession, \Magento\Checkout\Model\Session $checkoutSession,
\Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Framework\App\ProductMetadataInterface $productMetadata,
array $data = [] array $data = []
) { ) {
$this->adyenHelper = $adyenHelper; $this->adyenHelper = $adyenHelper;
$this->adyenLogger = $adyenLogger; $this->adyenLogger = $adyenLogger;
$this->checkoutSession = $checkoutSession; $this->checkoutSession = $checkoutSession;
$this->productMetadata = $productMetadata;
$this->storeId = $storeManager->getStore()->getId(); $this->storeId = $storeManager->getStore()->getId();
// initialize client // initialize client
...@@ -132,7 +143,7 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface ...@@ -132,7 +143,7 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface
'SaleID' => 'Magento2Cloud', 'SaleID' => 'Magento2Cloud',
'POIID' => $poiId, 'POIID' => $poiId,
'ProtocolVersion' => '3.0', 'ProtocolVersion' => '3.0',
'ServiceID' => $serviceID, 'ServiceID' => $serviceID
], ],
'PaymentRequest' => 'PaymentRequest' =>
[ [
...@@ -142,19 +153,19 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface ...@@ -142,19 +153,19 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface
'SaleTransactionID' => 'SaleTransactionID' =>
[ [
'TransactionID' => $reference, 'TransactionID' => $reference,
'TimeStamp' => $timeStamper, 'TimeStamp' => $timeStamper
], ]
], ],
'PaymentTransaction' => 'PaymentTransaction' =>
[ [
'AmountsReq' => 'AmountsReq' =>
[ [
'Currency' => $quote->getCurrency()->getQuoteCurrencyCode(), 'Currency' => $quote->getCurrency()->getQuoteCurrencyCode(),
'RequestedAmount' => doubleval($quote->getGrandTotal()), 'RequestedAmount' => doubleval($quote->getGrandTotal())
], ]
], ]
], ]
], ]
]; ];
if (!empty($payload['number_of_installments'])) { if (!empty($payload['number_of_installments'])) {
...@@ -179,22 +190,7 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface ...@@ -179,22 +190,7 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface
} }
$customerId = $this->getCustomerId($quote); $request = $this->addSaleToAcquirerData($request, $quote);
// If customer exists add it into the request to store request
if (!empty($customerId)) {
$shopperEmail = $quote->getCustomerEmail();
$recurringContract = $this->adyenHelper->getAdyenPosCloudConfigData('recurring_type', $this->storeId);
if (!empty($recurringContract) && !empty($shopperEmail)) {
$recurringDetails = [
'shopperEmail' => $shopperEmail,
'shopperReference' => strval($customerId),
'recurringContract' => $recurringContract
];
$request['SaleToPOIRequest']['PaymentRequest']['SaleData']['SaleToAcquirerData'] = http_build_query($recurringDetails);
}
}
$quote->getPayment()->getMethodInstance()->getInfoInstance()->setAdditionalInformation( $quote->getPayment()->getMethodInstance()->getInfoInstance()->setAdditionalInformation(
'serviceID', 'serviceID',
...@@ -231,9 +227,9 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface ...@@ -231,9 +227,9 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface
} }
/** /**
* This getter makes it possible to overwrite the customer id from other plugins * This getter makes it possible to overwrite the customer id from other plugins
* Use this function to get the customer id so we can keep using this plugin in the UCD * Use this function to get the customer id so we can keep using this plugin in the UCD
* *
* @param Quote $quote * @param Quote $quote
* @return mixed * @return mixed
*/ */
...@@ -241,4 +237,38 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface ...@@ -241,4 +237,38 @@ class AdyenInitiateTerminalApi implements AdyenInitiateTerminalApiInterface
{ {
return $quote->getCustomerId(); return $quote->getCustomerId();
} }
/**
* Add SaleToAcquirerData for storing for recurring transactions and able to track platform and version
* When upgrading to new version of library we can use the client methods
* @param $request
* @param $quote
* @return mixed
*/
public function addSaleToAcquirerData($request, $quote)
{
$customerId = $this->getCustomerId($quote);
$saleToAcquirerData = [];
// If customer exists add it into the request to store request
if (!empty($customerId)) {
$shopperEmail = $quote->getCustomerEmail();
$recurringContract = $this->adyenHelper->getAdyenPosCloudConfigData('recurring_type', $this->storeId);
if (!empty($recurringContract) && !empty($shopperEmail)) {
$saleToAcquirerData['shopperEmail'] = $shopperEmail;
$saleToAcquirerData['shopperReference'] = (string)$customerId;
$saleToAcquirerData['recurringContract'] = $recurringContract;
}
}
$saleToAcquirerData['applicationInfo']['merchantApplication']['version'] = $this->adyenHelper->getModuleVersion();
$saleToAcquirerData['applicationInfo']['merchantApplication']['name'] = $this->adyenHelper->getModuleName();
$saleToAcquirerData['applicationInfo']['externalPlatform']['version'] = $this->productMetadata->getVersion();
$saleToAcquirerData['applicationInfo']['externalPlatform']['name'] = $this->productMetadata->getName();
$saleToAcquirerDataBase64 = base64_encode(json_encode($saleToAcquirerData));
$request['SaleToPOIRequest']['PaymentRequest']['SaleData']['SaleToAcquirerData'] = $saleToAcquirerDataBase64;
return $request;
}
} }
...@@ -38,6 +38,7 @@ class Cron ...@@ -38,6 +38,7 @@ class Cron
/** /**
* Logging instance * Logging instance
*
* @var \Adyen\Payment\Logger\AdyenLogger * @var \Adyen\Payment\Logger\AdyenLogger
*/ */
protected $_logger; protected $_logger;
...@@ -296,6 +297,7 @@ class Cron ...@@ -296,6 +297,7 @@ class Cron
/** /**
* Process the notification * Process the notification
*
* @return void * @return void
*/ */
public function processNotification() public function processNotification()
...@@ -452,7 +454,8 @@ class Cron ...@@ -452,7 +454,8 @@ class Cron
} catch (\Exception $e) { } catch (\Exception $e) {
$this->_updateNotification($notification, false, false); $this->_updateNotification($notification, false, false);
$this->_adyenLogger->addAdyenNotificationCronjob( $this->_adyenLogger->addAdyenNotificationCronjob(
sprintf("Notification %s had an error: %s \n %s", $notification->getEntityId(), $e->getMessage(), $e->getTraceAsString()) sprintf("Notification %s had an error: %s \n %s", $notification->getEntityId(), $e->getMessage(),
$e->getTraceAsString())
); );
} }
} }
...@@ -780,6 +783,7 @@ class Cron ...@@ -780,6 +783,7 @@ class Cron
/** /**
* retrieve last 4 digits of card from the reason field * retrieve last 4 digits of card from the reason field
*
* @param $reason * @param $reason
* @return string * @return string
*/ */
...@@ -934,7 +938,7 @@ class Cron ...@@ -934,7 +938,7 @@ class Cron
} }
// Order is already Cancelled // Order is already Cancelled
if ($this->_order->isCanceled()){ if ($this->_order->isCanceled()) {
$this->_adyenLogger->addAdyenNotificationCronjob("Order is already cancelled, skipping OFFER_CLOSED"); $this->_adyenLogger->addAdyenNotificationCronjob("Order is already cancelled, skipping OFFER_CLOSED");
break; break;
} }
...@@ -1138,6 +1142,7 @@ class Cron ...@@ -1138,6 +1142,7 @@ class Cron
/** /**
* Not implemented * Not implemented
*
* @return bool * @return bool
*/ */
protected function _refundOrder() protected function _refundOrder()
...@@ -1287,8 +1292,8 @@ class Cron ...@@ -1287,8 +1292,8 @@ class Cron
} }
/** /**
* @throws Exception
* @return void * @return void
* @throws Exception
*/ */
protected function _prepareInvoice() protected function _prepareInvoice()
{ {
...@@ -1352,19 +1357,27 @@ class Cron ...@@ -1352,19 +1357,27 @@ class Cron
$orderCurrencyCode = $this->_order->getOrderCurrencyCode(); $orderCurrencyCode = $this->_order->getOrderCurrencyCode();
$amount = $this->_adyenHelper->originalAmount($this->_value, $orderCurrencyCode); $amount = $this->_adyenHelper->originalAmount($this->_value, $orderCurrencyCode);
// add to order payment try {
$date = new \DateTime(); // add to order payment
$this->_adyenOrderPaymentFactory->create() $date = new \DateTime();
->setPspreference($this->_pspReference) $this->_adyenOrderPaymentFactory->create()
->setMerchantReference($this->_merchantReference) ->setPspreference($this->_pspReference)
->setPaymentId($paymentObj->getId()) ->setMerchantReference($this->_merchantReference)
->setPaymentMethod($this->_paymentMethod) ->setPaymentId($paymentObj->getId())
->setAmount($amount) ->setPaymentMethod($this->_paymentMethod)
->setTotalRefunded(0) ->setAmount($amount)
->setCreatedAt($date) ->setTotalRefunded(0)
->setUpdatedAt($date) ->setCreatedAt($date)
->save(); ->setUpdatedAt($date)
->save();
} catch (\Exception $e) {
$this->_adyenLogger->addError(
'While processing a notification an exception occured. The payment has already been saved in the ' .
'adyen_order_payment table but something went wrong later. Please check your logs for potential ' .
'error messages regarding the merchant reference (order id): "' . $this->_merchantReference .
'" and PSP reference: "' . $this->_pspReference . '"'
);
}
if ($this->_isTotalAmount($paymentObj->getEntityId(), $orderCurrencyCode)) { if ($this->_isTotalAmount($paymentObj->getEntityId(), $orderCurrencyCode)) {
$this->_createInvoice(); $this->_createInvoice();
...@@ -1618,9 +1631,9 @@ class Cron ...@@ -1618,9 +1631,9 @@ class Cron
} }
/** /**
* @throws Exception
* @throws \Magento\Framework\Exception\LocalizedException
* @return void * @return void
* @throws \Magento\Framework\Exception\LocalizedException
* @throws Exception
*/ */
protected function _createInvoice() protected function _createInvoice()
{ {
......
# Reporting Security Issues
We welcome reports of possible vulnerabilities or issues as part of our responsible disclosure program. For more information go to
https://support.adyen.com/hc/en-us/articles/115001187330-How-do-I-report-a-possible-security-issue-to-Adyen-
...@@ -59,6 +59,8 @@ class DataTest extends \PHPUnit\Framework\TestCase ...@@ -59,6 +59,8 @@ class DataTest extends \PHPUnit\Framework\TestCase
$localeResolver = $this->getSimpleMock(\Magento\Framework\Locale\ResolverInterface::class); $localeResolver = $this->getSimpleMock(\Magento\Framework\Locale\ResolverInterface::class);
$config = $this->getSimpleMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); $config = $this->getSimpleMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
$helperBackend = $this->getSimpleMock(\Magento\Backend\Helper\Data::class); $helperBackend = $this->getSimpleMock(\Magento\Backend\Helper\Data::class);
$serializer = $this->getSimpleMock( \Magento\Framework\Serialize\SerializerInterface::class);
$componentRegistrar = $this->getSimpleMock(\Magento\Framework\Component\ComponentRegistrarInterface::class);
$this->dataHelper = new \Adyen\Payment\Helper\Data( $this->dataHelper = new \Adyen\Payment\Helper\Data(
$context, $context,
...@@ -80,7 +82,9 @@ class DataTest extends \PHPUnit\Framework\TestCase ...@@ -80,7 +82,9 @@ class DataTest extends \PHPUnit\Framework\TestCase
$agreementResourceModel, $agreementResourceModel,
$localeResolver, $localeResolver,
$config, $config,
$helperBackend $helperBackend,
$serializer,
$componentRegistrar
); );
} }
......
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment Module
*
* Copyright (c) 2019 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Model;
class AdyenInitiateTerminalApiTest extends \PHPUnit\Framework\TestCase
{
/**
* @var
*/
private $adyenInitiateTerminalApi;
private const MODULE_VERSION = '1.0.0';
private const MODULE_NAME = 'ModuleVersion';
private const PLATFORM_VERSION = '2.0.0';
private const PLATFORM_NAME = 'PlatformName';
private const CUSTOMER_ID = '1';
private const CUSTOMER_EMAIL = 'customer@example.com';
private const RECURRING_TYPE = 'ONECLICK,RECURRING';
private function getSimpleMock($originalClassName)
{
return $this->getMockBuilder($originalClassName)
->disableOriginalConstructor()
->getMock();
}
public function setUp()
{
$adyenHelper = $this->getSimpleMock(\Adyen\Payment\Helper\Data::class);
$adyenLogger = $this->getSimpleMock(\Adyen\Payment\Logger\AdyenLogger::class);
$checkoutSession = $this->getSimpleMock(\Magento\Checkout\Model\Session::class);
$storeManager = $this->getSimpleMock(\Magento\Store\Model\StoreManagerInterface::class);
$productMetadata = $this->getSimpleMock(\Magento\Framework\App\ProductMetadataInterface::class);
$store = $this->getSimpleMock(\Magento\Store\Api\Data\StoreInterface::class);
$storeManager->method('getStore')
->will($this->returnValue($store));
$adyenHelper->method('getModuleVersion')
->will($this->returnValue(self::MODULE_VERSION));
// Create a map of arguments to return values.
$map = [
['pos_timeout', null, ''],
['recurring_type', null, self::RECURRING_TYPE]
];
// Configure the stub.
$adyenHelper->method('getAdyenPosCloudConfigData')
->will($this->returnValueMap($map));
$adyenHelper->method('getModuleName')
->will($this->returnValue(self::MODULE_NAME));
$productMetadata->method('getVersion')
->will($this->returnValue(self::PLATFORM_VERSION));
$productMetadata->method('getName')
->will($this->returnValue(self::PLATFORM_NAME));
$this->adyenInitiateTerminalApi = new \Adyen\Payment\Model\AdyenInitiateTerminalApi(
$adyenHelper,
$adyenLogger,
$checkoutSession,
$storeManager,
$productMetadata
);
}
/** @throws \Exception */
public function testAddSaleToAcquirerData()
{
$quote = $this->getSimpleMock(\Magento\Quote\Model\Quote::class);
$request = [];
$result = $this->adyenInitiateTerminalApi->addSaleToAcquirerData($request, $quote);
$appInfo = [
'applicationInfo' => [
'merchantApplication' => [
'version' => self::MODULE_VERSION,
'name' => self::MODULE_NAME
],
'externalPlatform' => [
'version' => self::PLATFORM_VERSION,
'name' => self::PLATFORM_NAME
]
]
];
$saleToAcquirerData = base64_encode(json_encode($appInfo));
$resultArrayExpected = [
'SaleToPOIRequest' => [
'PaymentRequest' => [
'SaleData' => [
'SaleToAcquirerData' => $saleToAcquirerData
]
]
]
];
$this->assertEquals($resultArrayExpected, $result);
}
public function testAddSaleToAcquirerDataLoggedInCustomer()
{
$quoteMock = $this->getMockBuilder('Magento\Quote\Model\Quote')
->disableOriginalConstructor()
->setMethods(
[
'getId',
'getCustomerEmail',
'getCustomerId'
]
)
->getMock();
$quoteMock->expects($this->any())
->method('getCustomerId')
->willReturn(self::CUSTOMER_ID);
$quoteMock->expects($this->atLeastOnce())
->method('getCustomerEmail')
->willReturn(self::CUSTOMER_EMAIL);
$request = [];
$result = $this->adyenInitiateTerminalApi->addSaleToAcquirerData($request, $quoteMock);
$appInfo = [
'shopperEmail' => self::CUSTOMER_EMAIL,
'shopperReference' => self::CUSTOMER_ID,
'recurringContract' => self::RECURRING_TYPE,
'applicationInfo' => [
'merchantApplication' => [
'version' => self::MODULE_VERSION,
'name' => self::MODULE_NAME
],
'externalPlatform' => [
'version' => self::PLATFORM_VERSION,
'name' => self::PLATFORM_NAME
]
]
];
$saleToAcquirerData = base64_encode(json_encode($appInfo));
$resultArrayExpected = [
'SaleToPOIRequest' => [
'PaymentRequest' => [
'SaleData' => [
'SaleToAcquirerData' => $saleToAcquirerData
]
]
]
];
$this->assertEquals($resultArrayExpected, $result);
}
}
\ No newline at end of file
...@@ -23,4 +23,3 @@ ...@@ -23,4 +23,3 @@
*/ */
require __DIR__.'/../vendor/autoload.php'; require __DIR__.'/../vendor/autoload.php';
require __DIR__.'/../../../../vendor/autoload.php';
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"name": "adyen/module-payment", "name": "adyen/module-payment",
"description": "Official Magento2 Plugin to connect to Payment Service Provider Adyen.", "description": "Official Magento2 Plugin to connect to Payment Service Provider Adyen.",
"type": "magento2-module", "type": "magento2-module",
"version": "5.1.0", "version": "5.2.0",
"license": [ "license": [
"OSL-3.0", "OSL-3.0",
"AFL-3.0" "AFL-3.0"
...@@ -16,10 +16,13 @@ ...@@ -16,10 +16,13 @@
"require": { "require": {
"adyen/php-api-library": "~4.1", "adyen/php-api-library": "~4.1",
"magento/framework": ">=101.0.8 <102 || >=102.0.1", "magento/framework": ">=101.0.8 <102 || >=102.0.1",
"magento/module-vault": "101.*" "magento/module-vault": "101.*",
"magento/module-paypal": "*"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "~6.5.0" "phpunit/phpunit": "~6.5.0",
"magento/magento-coding-standard": "*",
"squizlabs/php_codesniffer": "~3.5.3"
}, },
"autoload": { "autoload": {
"files": [ "files": [
...@@ -38,6 +41,12 @@ ...@@ -38,6 +41,12 @@
"test": [ "test": [
"Composer\\Config::disableProcessTimeout", "Composer\\Config::disableProcessTimeout",
"vendor/bin/phpunit -c Test/phpunit.xml" "vendor/bin/phpunit -c Test/phpunit.xml"
],
"post-install-cmd": [
"([ $COMPOSER_DEV_MODE -eq 0 ] || vendor/bin/phpcs --config-set installed_paths ../../magento/magento-coding-standard/)"
],
"post-update-cmd": [
"([ $COMPOSER_DEV_MODE -eq 0 ] || vendor/bin/phpcs --config-set installed_paths ../../magento/magento-coding-standard/)"
] ]
} }
} }
<?xml version="1.0"?>
<!--
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2019 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
-->
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PHP_CodeSniffer"
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
<exclude-pattern type="relative">vendor/*</exclude-pattern>
<file>.</file>
<arg value="p"/>
<arg value="n"/>
<rule ref="Magento2"/>
</ruleset>
\ No newline at end of file
...@@ -100,6 +100,7 @@ define( ...@@ -100,6 +100,7 @@ define(
} }
}); });
var googlepay = self.checkoutComponent.create('paywithgoogle', { var googlepay = self.checkoutComponent.create('paywithgoogle', {
showPayButton: true,
environment: self.getCheckoutEnvironment().toUpperCase(), environment: self.getCheckoutEnvironment().toUpperCase(),
configuration: { configuration: {
......
...@@ -43,7 +43,7 @@ define( ...@@ -43,7 +43,7 @@ define(
var paymentMethod = ko.observable(null); var paymentMethod = ko.observable(null);
var messageComponents; var messageComponents;
var shippingAddressCountryCode = quote.shippingAddress().countryId; var shippingAddressCountryCode = quote.shippingAddress().countryId;
var unsupportedPaymentMethods = ['scheme', 'boleto', 'bcmc_mobile_QR', 'wechatpay']; var unsupportedPaymentMethods = ['scheme', 'boleto', 'bcmc_mobile_QR', 'wechatpay', /^bcmc$/ ];
/** /**
* Shareble adyen checkout component * Shareble adyen checkout component
* @type {AdyenCheckout} * @type {AdyenCheckout}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment