Skip to content

Commit

Permalink
Merge pull request #281 from Adyen/develop
Browse files Browse the repository at this point in the history
Merge for new release 2.3.0
  • Loading branch information
rikterbeek authored Jun 22, 2018
2 parents 787f9f5 + 4495500 commit 527ab73
Show file tree
Hide file tree
Showing 70 changed files with 1,784 additions and 734 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

**Tested scenarios**
<!-- Description of tested scenarios -->
<!-- Please verify that the unit tests are passing by running "vendor/bin/phpunit -c ." -->
<!-- Please verify that the unit tests are passing by running "vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist vendor/adyen/module-payment/Test/" -->

**Fixed issue**: <!-- #-prefixed issue number -->
155 changes: 155 additions & 0 deletions AdminMessage/VersionMessage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment Module
*
* Copyright (c) 2018 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*
* Author: Adyen <[email protected]>
*/

namespace Adyen\Payment\AdminMessage;

class VersionMessage implements \Magento\Framework\Notification\MessageInterface
{
protected $_authSession;
protected $_adyenHelper;
protected $_inboxFactory;

public function __construct(
\Magento\Backend\Model\Auth\Session $authSession,
\Adyen\Payment\Helper\Data $adyenHelper,
\Magento\AdminNotification\Model\InboxFactory $inboxFactory
) {
$this->_authSession = $authSession;
$this->_adyenHelper = $adyenHelper;
$this->_inboxFactory = $inboxFactory;
}

/**
* Message identity
*/
const MESSAGE_IDENTITY = 'Adyen Version Control message';

/**
* Retrieve unique system message identity
*
* @return string
*/
public function getIdentity()
{
return self::MESSAGE_IDENTITY;
}

/**
* Check whether the system message should be shown
*
* @return bool
*/
public function isDisplayed()
{
// Only execute the query the first time you access the Admin page
if ($this->_authSession->isFirstPageAfterLogin()) {

try {
$githubContent = $this->getDecodedContentFromGithub();
$this->setSessionData("AdyenGithubVersion", $githubContent);
$title = "Adyen extension version " . $githubContent['tag_name'] . " available!";
$versionData[] = array(
'severity' => self::SEVERITY_NOTICE,
'date_added' => $githubContent['published_at'],
'title' => $title,
'description' => $githubContent['body'],
'url' => $githubContent['html_url'],
);

/*
* The parse function checks if the $versionData message exists in the inbox,
* otherwise it will create it and add it to the inbox.
*/
$this->_inboxFactory->create()->parse(array_reverse($versionData));

/*
* This will compare the currently installed version with the latest available one.
* A message will appear after the login if the two are not matching.
*/
if ($this->_adyenHelper->getModuleVersion() != $githubContent['tag_name']) {
return true;
}
} catch (\Exception $e) {
return false;
}
}
return false;

}

/**
* Retrieve system message text
*
* @return \Magento\Framework\Phrase
*/
public function getText()
{
$githubContent = $this->getSessionData("AdyenGithubVersion");
$message = __("A new Adyen extension version is now available: ");
$message .= __("<a href= \"" . $githubContent['html_url'] . "\" target='_blank'> " . $githubContent['tag_name'] . "!</a>");
$message .= __(" You are running the " . $this->_adyenHelper->getModuleVersion() . " version. We advise to update your extension.");
return __($message);
}

/**
* Retrieve system message severity
*
* @return int
*/
public function getSeverity()
{
return self::SEVERITY_MAJOR;
}

public function getDecodedContentFromGithub()
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.github.com/repos/adyen/adyen-magento2/releases/latest');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'magento');
$content = curl_exec($ch);
curl_close($ch);
$json = json_decode($content, true);
return $json;
}

/**
* Set the current value for the backend session
*/
public function setSessionData($key, $value)
{
return $this->_authSession->setData($key, $value);
}

/**
* Retrieve the session value
*/
public function getSessionData($key, $remove = false)
{
return $this->_authSession->getData($key, $remove);
}

}

5 changes: 3 additions & 2 deletions Api/AdyenPaymentMethodManagementInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ interface AdyenPaymentMethodManagementInterface
/**
* Get payment information
*
* @param string $cartId
* @param string $cartId
* @param null|\Magento\Quote\Api\Data\AddressInterface
* @return \Magento\Checkout\Api\Data\PaymentDetailsInterface
*/
public function getPaymentMethods($cartId, \Magento\Quote\Api\Data\AddressInterface $shippingAddress);
public function getPaymentMethods($cartId, \Magento\Quote\Api\Data\AddressInterface $shippingAddress = null);

}
125 changes: 125 additions & 0 deletions Api/Data/InvoiceInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment Module
*
* Copyright (c) 2018 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*
* Author: Adyen <[email protected]>
*/

namespace Adyen\Payment\Api\Data;

interface InvoiceInterface
{
/**
* Constants for keys of data array. Identical to the name of the getter in snake case.
*/

/*
* Entity ID.
*/
const ENTITY_ID = 'entity_id';
/*
* Pspreference of the capture.
*/
const PSPREFERENCE = 'pspreference';
/*
* Original Pspreference of the payment.
*/
const ORIGINAL_REFERENCE = 'original_reference';
/*
* Acquirer reference.
*/
const ACQUIRER_REFERENCE = 'acquirer_reference';
/*
* Invoice ID.
*/
const INVOICE_ID = 'invoice_id';

/**
* Gets the ID for the invoice.
*
* @return int|null Entity ID.
*/
public function getEntityId();

/**
* Sets entity ID.
*
* @param int $entityId
* @return $this
*/
public function setEntityId($entityId);

/**
* Gets the Pspreference for the invoice(capture).
*
* @return int|null Pspreference.
*/
public function getPspreference();

/**
* Sets Pspreference.
*
* @param string $pspreference
* @return $this
*/
public function setPspreference($pspreference);

/**
* @return mixed
*/
public function getOriginalReference();

/**
* @param $originalReference
* @return mixed
*/
public function setOriginalReference($originalReference);

/**
* Gets the AcquirerReference for the invoice.
*
* @return int|null Acquirerreference.
*/
public function getAcquirerReference();

/**
* Sets AcquirerReference.
*
* @param string $acquirerReference
* @return $this
*/
public function setAcquirerReference($acquirerReference);

/**
* Gets the InvoiceID for the invoice.
*
* @return int|null Invoice ID.
*/
public function getInvoiceId();

/**
* Sets InvoiceID.
*
* @param int $invoiceId
* @return $this
*/
public function setInvoiceId($invoiceId);

}
5 changes: 3 additions & 2 deletions Api/GuestAdyenPaymentMethodManagementInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ interface GuestAdyenPaymentMethodManagementInterface
/**
* Get payment information
*
* @param string $cartId
* @param string $cartId
* @param null|\Magento\Quote\Api\Data\AddressInterface
* @return \Magento\Checkout\Api\Data\PaymentDetailsInterface
*/
public function getPaymentMethods($cartId, \Magento\Quote\Api\Data\AddressInterface $shippingAddress);
public function getPaymentMethods($cartId, \Magento\Quote\Api\Data\AddressInterface $shippingAddress = null);

}
6 changes: 3 additions & 3 deletions Block/Info/AbstractInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,21 @@ class AbstractInfo extends \Magento\Payment\Block\Info
protected $_adyenHelper;

/**
* @var \Adyen\Payment\Model\Resource\Order\Payment\CollectionFactory
* @var \Adyen\Payment\Model\ResourceModel\Order\Payment\CollectionFactory
*/
protected $_adyenOrderPaymentCollectionFactory;

/**
* AbstractInfo constructor.
*
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Adyen\Payment\Model\Resource\Order\Payment\CollectionFactory $adyenOrderPaymentCollectionFactory
* @param \Adyen\Payment\Model\ResourceModel\Order\Payment\CollectionFactory $adyenOrderPaymentCollectionFactory
* @param Template\Context $context
* @param array $data
*/
public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper,
\Adyen\Payment\Model\Resource\Order\Payment\CollectionFactory $adyenOrderPaymentCollectionFactory,
\Adyen\Payment\Model\ResourceModel\Order\Payment\CollectionFactory $adyenOrderPaymentCollectionFactory,
Template\Context $context,
array $data = []
)
Expand Down
2 changes: 1 addition & 1 deletion Block/Info/Oneclick.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ class Oneclick extends Cc
/**
* @var string
*/
protected $_template = 'Adyen_Payment::info/adyen_oneclick.phtml';
protected $_template = 'Adyen_Payment::info/adyen_cc.phtml';
}
Loading

0 comments on commit 527ab73

Please sign in to comment.