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 10bcbf45 authored by rikterbeek's avatar rikterbeek

implemented notificaiton handler, cronjob and Adyen CC with CSE integration

parent a0baf50a
<?php
namespace Adyen\Payment\Api\Data;
interface NotificationInterface
{
/**#@+
* Constants for keys of data array. Identical to the name of the getter in snake case.
*/
/*
* Entity ID.
*/
const ENTITY_ID = 'entity_id';
/*
* Pspreference.
*/
const PSPREFRENCE = 'pspreference';
/*
* Merchantreference
*/
const MERCHANT_REFERENCE = 'merchant_reference';
/*
* Eventcode
*/
const EVENT_CODE = 'event_code';
/*
* Success
*/
const SUCCESS = 'success';
/*
* Paymentmethod
*/
const PAYMENT_METHOD = 'payment_method';
/*
* Amount value
*/
const AMOUNT_VALUE = 'amount_value';
/*
* Amount currency
*/
const AMOUNT_CURRENCY = 'amount_currency';
/*
* reason
*/
const REASON = 'reason';
/*
* Live
*/
const LIVE = 'live';
/*
* Additional data
*/
const ADDITIONAL_DATA = 'additional_data';
/*
* Created-at timestamp.
*/
const CREATED_AT = 'created_at';
/*
* Updated-at timestamp.
*/
const UPDATED_AT = 'updated_at';
/**
* Gets the ID for the notification.
*
* @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 notification.
*
* @return int|null Pspreference.
*/
public function getPspreference();
/**
* Sets Pspreference.
*
* @param string $pspreference
* @return $this
*/
public function setPspreference($pspreference);
/**
* Gets the Merchantreference for the notification.
*
* @return int|null MerchantReference.
*/
public function getMerchantReference();
/**
* Sets MerchantReference.
*
* @param string $merchantReference
* @return $this
*/
public function setMerchantReference($merchantReference);
/**
* Gets the Eventcode for the notification.
*
* @return int|null Eventcode.
*/
public function getEventCode();
/**
* Sets EventCode.
*
* @param string $eventCode
* @return $this
*/
public function setEventCode($eventCode);
/**
* Gets the success for the notification.
*
* @return int|null Success.
*/
public function getSucess();
/**
* Sets Success.
*
* @param boolean $success
* @return $this
*/
public function setSuccess($success);
/**
* Gets the Paymentmethod for the notification.
*
* @return int|null PaymentMethod.
*/
public function getPaymentMethod();
/**
* Sets PaymentMethod.
*
* @param string $paymentMethod
* @return $this
*/
public function setPaymentMethod($paymentMethod);
/**
* Gets the AmountValue for the notification.
*
* @return int|null AmountValue.
*/
public function getAmountValue();
/**
* Sets AmountValue.
*
* @param string $amountValue
* @return $this
*/
public function setAmountValue($amountValue);
/**
* Gets the AmountValue for the notification.
*
* @return int|null AmountValue.
*/
public function getAmountCurency();
/**
* Sets AmountCurrency.
*
* @param string $amountCurrency
* @return $this
*/
public function setAmountCurrency($amountCurrency);
/**
* Gets the Reason for the notification.
*
* @return int|null Reason.
*/
public function getReason();
/**
* Sets Reason.
*
* @param string $reason
* @return $this
*/
public function setReason($reason);
/**
* Gets the AdditionalData for the notification.
*
* @return int|null AdditionalData.
*/
public function getAdditionalData();
/**
* Sets AdditionalData.
*
* @param string $additionalData
* @return $this
*/
public function setAddtionalData($additionalData);
/**
* Gets the Done for the notification.
*
* @return int|null Done.
*/
public function getDone();
/**
* Sets Done.
*
* @param string $done
* @return $this
*/
public function setDone($done);
/**
* Gets the created-at timestamp for the notification.
*
* @return string|null Created-at timestamp.
*/
public function getCreatedAt();
/**
* Sets the created-at timestamp for the notification.
*
* @param string $createdAt timestamp
* @return $this
*/
public function setCreatedAt($createdAt);
/**
* Gets the updated-at timestamp for the notification.
*
* @return string|null Updated-at timestamp.
*/
public function getUpdatedAt();
/**
* Sets the updated-at timestamp for the notification.
*
* @param string $timestamp
* @return $this
*/
public function setUpdatedAt($timestamp);
}
\ No newline at end of file
<?php
/**
* Field renderer for PayPal merchant country selector
*/
namespace Adyen\Payment\Block\Adminhtml\System\Config\Field;
class Version extends \Magento\Config\Block\System\Config\Form\Field
{
protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
{
// TODO: make dynamic
//$configVer = $this->moduleList->getOne($moduleName)['setup_version'];
return (string) "0.1.0";
}
}
\ No newline at end of file
...@@ -5,6 +5,14 @@ namespace Adyen\Payment\Controller\Index; ...@@ -5,6 +5,14 @@ namespace Adyen\Payment\Controller\Index;
class Index extends \Magento\Framework\App\Action\Action class Index extends \Magento\Framework\App\Action\Action
{ {
public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager)
{
$this->_objectManager = $objectManager;
}
public function execute() public function execute()
{ {
echo 'test';die(); echo 'test';die();
......
<?php
namespace Adyen\Payment\Controller\Process;
use Symfony\Component\Config\Definition\Exception\Exception;
/**
* Class Json
* @package Adyen\Payment\Controller\Process
*/
class Cron extends \Magento\Framework\App\Action\Action
{
/**
* @var \Magento\Framework\ObjectManagerInterface
*/
protected $_objectManager;
/**
* @var \Magento\Framework\Controller\Result\RawFactory
*/
protected $_resultFactory;
/**
* @param \Magento\Framework\App\Action\Context $context
*/
public function __construct(
\Magento\Framework\App\Action\Context $context
) {
parent::__construct($context);
$this->_objectManager = $context->getObjectManager();
$this->_resultFactory = $context->getResultFactory();
}
/**
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function execute()
{
$cron = $this->_objectManager->create('Adyen\Payment\Model\Cron');
$cron->processNotification();
die();
}
}
\ No newline at end of file
<?php
namespace Adyen\Payment\Controller\Process;
class Index extends \Magento\Framework\App\Action\Action
{
public function execute()
{
echo 'test';die();
$this->_view->loadLayout();
$this->_view->getLayout()->initMessages();
$this->_view->renderLayout();
}
}
\ No newline at end of file
<?php
namespace Adyen\Payment\Controller\Process;
use Symfony\Component\Config\Definition\Exception\Exception;
/**
* Class Json
* @package Adyen\Payment\Controller\Process
*/
class Json extends \Magento\Framework\App\Action\Action
{
/**
* @var \Magento\Framework\ObjectManagerInterface
*/
protected $_objectManager;
/**
* @var \Magento\Framework\Controller\Result\RawFactory
*/
protected $_resultFactory;
/**
* @param \Magento\Framework\App\Action\Context $context
*/
public function __construct(
\Magento\Framework\App\Action\Context $context
) {
parent::__construct($context);
$this->_objectManager = $context->getObjectManager();
$this->_resultFactory = $context->getResultFactory();
}
/**
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function execute()
{
//TODO validate the notification with authentication!!
// check duplicates
try {
// $notificationItems = json_decode(file_get_contents('php://input'), true);
$notificationItems = json_decode('{"live":"false","notificationItems":[{"NotificationRequestItem":{"additionalData":{"expiryDate":"12\/2012"," NAME1 ":"VALUE1","authCode":"1234","cardSummary":"7777","totalFraudScore":"10","hmacSignature":"yGnVWLP+UcpqjHTJbO5IUkG4ZdIk3uHCu62QAJvbbyg=","NAME2":" VALUE2 ","fraudCheck-6-ShopperIpUsage":"10"},"amount":{"currency":"EUR","value":10100},"eventCode":"AUTHORISATION","eventDate":"2015-09-11T13:53:21+02:00","merchantAccountCode":"MagentoMerchantByteShop1","merchantReference":"000000023","operations":["CANCEL","CAPTURE","REFUND"],"paymentMethod":"visa","pspReference":"test_AUTHORISATION_1","reason":"1234:7777:12\/2012","success":"true"}}]}', true);
$notificationMode = isset($notificationItems['live']) ? $notificationItems['live'] : "";
if($notificationMode != "" && $this->_validateNotificationMode($notificationMode))
{
foreach($notificationItems['notificationItems'] as $notificationItem)
{
$status = $this->_processNotification($notificationItem['NotificationRequestItem']);
if($status == "401"){
$this->_return401();
return;
}
}
$this->getResponse()
->clearHeader('Content-Type')
->setHeader('Content-Type', 'text/html')
->setBody("[accepted]");
return;
} else
{
if($notificationMode == "") {
$this->_return401();
return;
}
throw new \Magento\Framework\Exception\LocalizedException(__('Mismatch between Live/Test modes of Magento store and the Adyen platform'));
}
} catch (Exception $e) {
throw new \Magento\Framework\Exception\LocalizedException(__($e->getMessage()));
}
}
/**
* @param $notificationMode
* @return bool
*/
protected function _validateNotificationMode($notificationMode)
{
// $mode = $this->_getConfigData('demoMode');
// if ($mode=='Y' && $notificationMode == "false" || $mode=='N' && $notificationMode == 'true') {
// return true;
// }
// return false;
return true;
}
/**
* $desc save notification into the database for cronjob to execute notificaiton
* @param $response
* @throws \Magento\Framework\Exception\LocalizedException
*/
protected function _processNotification($response)
{
try {
$notification = $this->_objectManager->create('Adyen\Payment\Model\Notification');
if(isset($response['pspReference'])) {
$notification->setPspreference($response['pspReference']);
}
if(isset($response['merchantReference'])) {
$notification->setMerchantReference($response['merchantReference']);
}
if(isset($response['eventCode'])) {
$notification->setEventCode($response['eventCode']);
}
if(isset($response['success'])) {
$notification->setSuccess($response['success']);
}
if(isset($response['paymentMethod'])) {
$notification->setPaymentMethod($response['paymentMethod']);
}
if(isset($response['amount'])) {
$notification->setAmountValue($response['amount']['value']);
$notification->setAmountCurrency($response['amount']['currency']);
}
if(isset($response['reason'])) {
$notification->setReason($response['reason']);
}
if(isset($response['additionalData'])) {
$notification->setAddtionalData(serialize($response['additionalData']));
}
if(isset($response['done'])) {
$notification->setDone($response['done']);
}
$notification->save();
} catch(Exception $e) {
throw new \Magento\Framework\Exception\LocalizedException(__($e->getMessage()));
}
}
/**
*
*/
protected function _return401()
{
$this->getResponse()->setHttpResponseCode(401);
}
}
\ No newline at end of file
...@@ -36,11 +36,11 @@ class Redirect extends \Magento\Framework\App\Action\Action ...@@ -36,11 +36,11 @@ class Redirect extends \Magento\Framework\App\Action\Action
* @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Customer\Model\Session $customerSession
*/ */
public function __construct( public function __construct(
\Magento\Framework\App\Action\Context $context, \Magento\Framework\App\Action\Context $context
\Magento\Customer\Model\Session $customerSession // \Magento\Customer\Model\Session $customerSession
) { ) {
parent::__construct($context); parent::__construct($context);
$this->_customerSession = $customerSession; // $this->_customerSession = $customerSession;
} }
......
...@@ -13,6 +13,27 @@ use Magento\Framework\App\Helper\AbstractHelper; ...@@ -13,6 +13,27 @@ use Magento\Framework\App\Helper\AbstractHelper;
class Data extends AbstractHelper class Data extends AbstractHelper
{ {
/**
* Core store config
*
* @var \Magento\Framework\App\Config\ScopeConfigInterface
*/
protected $_scopeConfig;
/**
* @param Context $context
*/
public function __construct(
\Magento\Framework\App\Helper\Context $context,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
)
{
parent::__construct($context);
$this->_scopeConfig = $scopeConfig;
}
public function getRecurringTypes() { public function getRecurringTypes() {
return [ return [
...@@ -22,4 +43,153 @@ class Data extends AbstractHelper ...@@ -22,4 +43,153 @@ class Data extends AbstractHelper
]; ];
} }
public function getModes() {
return [
'1' => 'Test Mode',
'0' => 'Production Mode'
];
}
public function getCaptureModes() {
return [
'auto' => 'immediate',
'manual' => 'manual'
];
}
/**
* Return the formatted currency. Adyen accepts the currency in multiple formats.
* @param $amount
* @param $currency
* @return string
*/
public function formatAmount($amount, $currency)
{
switch($currency) {
case "JPY":
case "IDR":
case "KRW":
case "BYR":
case "VND":
case "CVE":
case "DJF":
case "GNF":
case "PYG":
case "RWF":
case "UGX":
case "VUV":
case "XAF":
case "XOF":
case "XPF":
case "GHC":
case "KMF":
$format = 0;
break;
case "MRO":
$format = 1;
break;
case "BHD":
case "JOD":
case "KWD":
case "OMR":
case "LYD":
case "TND":
$format = 3;
break;
default:
$format = 2;
break;
}
return number_format($amount, $format, '', '');
}
/**
* Street format
* @param type $address
* @return array
*/
public function getStreet($address)
{
if (empty($address)) return false;
$street = self::formatStreet($address->getStreet());
$streetName = $street['0'];
unset($street['0']);
// $streetNr = implode('',$street);
$streetNr = implode(' ',$street);
return (array('name' => $streetName, 'house_number' => $streetNr));
}
/**
* Fix this one string street + number
* @example street + number
* @param type $street
* @return type $street
*/
static public function formatStreet($street)
{
if (count($street) != 1) {
return $street;
}
preg_match('/((\s\d{0,10})|(\s\d{0,10}\w{1,3}))$/i', $street['0'], $houseNumber, PREG_OFFSET_CAPTURE);
if(!empty($houseNumber['0'])) {
$_houseNumber = trim($houseNumber['0']['0']);
$position = $houseNumber['0']['1'];
$streeName = trim(substr($street['0'], 0, $position));
$street = array($streeName,$_houseNumber);
}
return $street;
}
public function getAdyenAbstractConfigData($field, $storeId = null)
{
return $this->getConfigData($field, 'adyen_abstract', $storeId);
}
public function getAdyenAbstractConfigDataFlag($field, $storeId = null)
{
return $this->getConfigData($field, 'adyen_abstract', $storeId, true);
}
public function getAdyenCcConfigData($field, $storeId = null)
{
return $this->getConfigData($field, 'adyen_cc', $storeId);
}
public function getAdyenCcConfigDataFlag($field, $storeId = null)
{
return $this->getConfigData($field, 'adyen_cc', $storeId, true);
}
public function getAdyenHppConfigData($field, $storeId = null)
{
return $this->getConfigData($field, 'adyen_hpp', $storeId);
}
public function getAdyenHppConfigDataFlag($field, $storeId = null)
{
return $this->getConfigData($field, 'adyen_hpp', $storeId, true);
}
/**
* Retrieve information from payment configuration
*
* @param string $field
* @param int|string|null|\Magento\Store\Model\Store $storeId
*
* @return mixed
*/
public function getConfigData($field, $paymentMethodCode, $storeId, $flag = false)
{
$path = 'payment/' . $paymentMethodCode . '/' . $field;
if(!$flag) {
return $this->_scopeConfig->getValue($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
} else {
return $this->_scopeConfig->isSetFlag($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
}
} }
\ No newline at end of file
<?php
namespace Adyen\Payment\Logger;
use Monolog\Logger;
class AdyenLogger extends Logger
{
/**
* Adds a log record.
*
* @param integer $level The logging level
* @param string $message The log message
* @param array $context The log context
* @return Boolean Whether the record has been processed
*/
public function addRecord($level, $message, array $context = [])
{
$context['is_exception'] = $message instanceof \Exception;
return parent::addRecord($level, $message, $context);
}
}
\ No newline at end of file
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Adyen\Payment\Logger\Handler;
use Magento\Framework\Filesystem\DriverInterface;
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
class AdyenDebug extends StreamHandler
{
/**
* @var string
*/
protected $fileName = '/var/log/adyen/debug.log';
/**
* @var int
*/
protected $loggerType = Logger::DEBUG;
/**
* @var DriverInterface
*/
protected $filesystem;
/**
* @param DriverInterface $filesystem
* @param string $filePath
*/
public function __construct(
DriverInterface $filesystem,
$filePath = null
) {
$this->filesystem = $filesystem;
parent::__construct(
$filePath ? $filePath . $this->fileName : BP . $this->fileName,
$this->loggerType
);
$this->setFormatter(new LineFormatter(null, null, true));
}
/**
* @{inheritDoc}
*
* @param $record array
* @return void
*/
public function write(array $record)
{
$logDir = $this->filesystem->getParentDirectory($this->url);
if (!$this->filesystem->isDirectory($logDir)) {
$this->filesystem->createDirectory($logDir, 0777);
}
parent::write($record);
}
}
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Adyen\Payment\Model;
use Magento\Payment\Model\CcGenericConfigProvider;
use Magento\Payment\Helper\Data as PaymentHelper;
class AdyenCcConfigProvider extends CcGenericConfigProvider
{
/**
* @var Config
*/
protected $config;
/**
* @var string[]
*/
protected $methodCodes = [
\Adyen\Payment\Model\Method\Cc::METHOD_CODE
];
/**
* @var \Magento\Payment\Model\Method\AbstractMethod[]
*/
protected $methods = [];
/**
* @var PaymentHelper
*/
protected $paymentHelper;
protected $adyenHelper;
/**
* @param CcConfig $ccConfig
* @param PaymentHelper $paymentHelper
* @param array $methodCodes
*/
public function __construct(
\Magento\Payment\Model\CcConfig $ccConfig,
PaymentHelper $paymentHelper,
\Adyen\Payment\Helper\Data $adyenHelper
) {
parent::__construct($ccConfig, $paymentHelper, $this->methodCodes);
$this->adyenHelper = $adyenHelper;
}
public function getConfig()
{
$config = parent::getConfig();
$demoMode = $this->adyenHelper->getAdyenAbstractConfigDataFlag('demo_mode');
if($demoMode) {
$cseKey = $this->adyenHelper->getAdyenCcConfigData('cse_publickey_test');
} else {
$cseKey = $this->adyenHelper->getAdyenCcConfigData('cse_publickey_live');
}
$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");
return $config;
}
}
\ No newline at end of file
...@@ -12,17 +12,20 @@ class PaymentRequest extends \Magento\Framework\Object ...@@ -12,17 +12,20 @@ class PaymentRequest extends \Magento\Framework\Object
protected $_code; protected $_code;
protected $_logger; protected $_logger;
protected $_encryptor; protected $_encryptor;
protected $_adyenHelper;
public function __construct( public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Psr\Log\LoggerInterface $logger, \Psr\Log\LoggerInterface $logger,
\Magento\Framework\Encryption\EncryptorInterface $encryptor, \Magento\Framework\Encryption\EncryptorInterface $encryptor,
\Adyen\Payment\Helper\Data $adyenHelper,
array $data = [] array $data = []
) { ) {
$this->_scopeConfig = $scopeConfig; $this->_scopeConfig = $scopeConfig;
$this->_logger = $logger; $this->_logger = $logger;
$this->_encryptor = $encryptor; $this->_encryptor = $encryptor;
$this->_code = "adyen_cc"; $this->_code = "adyen_cc";
$this->_adyenHelper = $adyenHelper;
} }
/** /**
...@@ -33,51 +36,85 @@ class PaymentRequest extends \Magento\Framework\Object ...@@ -33,51 +36,85 @@ class PaymentRequest extends \Magento\Framework\Object
* *
* @return mixed * @return mixed
*/ */
public function getConfigData($field, $storeId = null) public function getConfigData($field, $paymentMethodCode = "adyen_abstract", $storeId = null)
{ {
if (null === $storeId) { if (null === $storeId) {
$storeId = $this->getStore(); $storeId = $this->getStore();
} }
$path = 'payment/' . $this->_code . '/' . $field;
// $this->_code to get current methodcode
$path = 'payment/' . $paymentMethodCode . '/' . $field;
return $this->_scopeConfig->getValue($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId); return $this->_scopeConfig->getValue($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
} }
public function fullApiRequest($merchantAccount, $payment) public function fullApiRequest($payment)
{ {
$order = $payment->getOrder(); $order = $payment->getOrder();
$amount = $order->getGrandTotal();
$customerEmail = $order->getCustomerEmail();
$shopperIp = $order->getRemoteIp();
$orderCurrencyCode = $order->getOrderCurrencyCode();
$merchantAccount = $this->getConfigData("merchant_account");
if($order) { $this->_logger->critical("fullApiRequest1 ");
$this->_logger->critical("TEST5!!:" . print_r($order->getIncrementId(), true));
}
$this->_logger->critical("CLASS OBJECT:" . get_class($payment));
$request = array( $request = array(
"action" => "Payment.authorise", "action" => "Payment.authorise",
"paymentRequest.merchantAccount" => $merchantAccount, "paymentRequest.merchantAccount" => $merchantAccount,
"paymentRequest.amount.currency" => "EUR", "paymentRequest.amount.currency" => $orderCurrencyCode,
"paymentRequest.amount.value" => "199", "paymentRequest.amount.value" => $this->_adyenHelper->formatAmount($amount, $orderCurrencyCode),
"paymentRequest.reference" => $order->getIncrementId(), "paymentRequest.reference" => $order->getIncrementId(),
"paymentRequest.shopperIP" => "ShopperIPAddress", "paymentRequest.shopperIP" => $shopperIp,
"paymentRequest.shopperEmail" => "TheShopperEmailAddress", "paymentRequest.shopperEmail" => $customerEmail,
"paymentRequest.shopperReference" => "YourReference", "paymentRequest.shopperReference" => $order->getIncrementId(),
"paymentRequest.fraudOffset" => "0", "paymentRequest.fraudOffset" => "0"
"paymentRequest.card.billingAddress.street" => "Simon Carmiggeltstraat",
"paymentRequest.card.billingAddress.postalCode" => "1011 DJ",
"paymentRequest.card.billingAddress.city" => "Amsterdam",
"paymentRequest.card.billingAddress.houseNumberOrName" => "6-50",
"paymentRequest.card.billingAddress.stateOrProvince" => "",
"paymentRequest.card.billingAddress.country" => "NL",
"paymentRequest.card.expiryMonth" => $payment->getCcExpMonth(),
"paymentRequest.card.expiryYear" => $payment->getCcExpYear(),
"paymentRequest.card.holderName" => $payment->getCcOwner(),
"paymentRequest.card.number" => $payment->getCcNumber(),
"paymentRequest.card.cvc" => $payment->getCcCid(),
); );
$billingAddress = $order->getBillingAddress();
if($billingAddress)
{
$addressArray = $this->_adyenHelper->getStreet($billingAddress);
$requestBilling = array("paymentRequest.card.billingAddress.street" => $addressArray['name'],
"paymentRequest.card.billingAddress.postalCode" => $billingAddress->getPostcode(),
"paymentRequest.card.billingAddress.city" => $billingAddress->getCity(),
"paymentRequest.card.billingAddress.houseNumberOrName" => $addressArray['house_number'],
"paymentRequest.card.billingAddress.stateOrProvince" => $billingAddress->getRegionCode(),
"paymentRequest.card.billingAddress.country" => $billingAddress->getCountryId()
);
$request = array_merge($request, $requestBilling);
}
$deliveryAddress = $order->getDeliveryAddress();
if($deliveryAddress)
{
$addressArray = $this->_adyenHelper->getStreet($deliveryAddress);
$requestDelivery = array("paymentRequest.card.billingAddress.street" => $addressArray['name'],
"paymentRequest.card.billingAddress.postalCode" => $deliveryAddress->getPostcode(),
"paymentRequest.card.billingAddress.city" => $deliveryAddress->getCity(),
"paymentRequest.card.billingAddress.houseNumberOrName" => $addressArray['house_number'],
"paymentRequest.card.billingAddress.stateOrProvince" => $deliveryAddress->getRegionCode(),
"paymentRequest.card.billingAddress.country" => $deliveryAddress->getCountryId()
);
$request = array_merge($request, $requestDelivery);
}
// TODO get CSE setting
$cseEnabled = true;
if($cseEnabled) {
$request['paymentRequest.additionalData.card.encrypted.json'] = $payment->getAdditionalInformation("encrypted_data");
} else {
$requestCreditCardDetails = array("paymentRequest.card.expiryMonth" => $payment->getCcExpMonth(),
"paymentRequest.card.expiryYear" => $payment->getCcExpYear(),
"paymentRequest.card.holderName" => $payment->getCcOwner(),
"paymentRequest.card.number" => $payment->getCcNumber(),
"paymentRequest.card.cvc" => $payment->getCcCid(),
);
$request = array_merge($request, $requestCreditCardDetails);
}
$this->_logger->critical("fullApiRequest"); $this->_logger->critical("fullApiRequest");
$this->_logger->critical(print_r($request, true)); $this->_logger->critical(print_r($request, true));
...@@ -87,7 +124,8 @@ class PaymentRequest extends \Magento\Framework\Object ...@@ -87,7 +124,8 @@ class PaymentRequest extends \Magento\Framework\Object
protected function _apiRequest($request) { protected function _apiRequest($request) {
$webserviceUsername = $this->getConfigData("webservice_username"); // TODO make differents between test and live
$webserviceUsername = $this->getConfigData("ws_username_test");
$webservicePassword = $this->decryptPassword($this->getConfigData("webservice_password")); // DECODE!! $webservicePassword = $this->decryptPassword($this->getConfigData("webservice_password")); // DECODE!!
$ch = curl_init(); $ch = curl_init();
......
<?php
namespace Adyen\Payment\Model\Config\Source;
/**
* Order Statuses source model
*/
class Cancelled extends \Magento\Sales\Model\Config\Source\Order\Status
{
/**
* @var string[]
*/
protected $_stateStatuses = [
\Magento\Sales\Model\Order::STATE_CANCELED
];
}
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* Order Statuses source model
*/
namespace Adyen\Payment\Model\Config\Source;
class CaptureMode implements \Magento\Framework\Option\ArrayInterface
{
/**
* @var \Magento\Sales\Model\Order\Config
*/
protected $_orderConfig;
protected $_adyenHelper;
/**
* @param \Magento\Sales\Model\Order\Config $orderConfig
*/
public function __construct(
\Magento\Sales\Model\Order\Config $orderConfig,
\Adyen\Payment\Helper\Data $adyenHelper
)
{
$this->_orderConfig = $orderConfig;
$this->_adyenHelper = $adyenHelper;
}
/**
* @return array
*/
public function toOptionArray()
{
$recurringTypes = $this->_adyenHelper->getCaptureModes();
foreach ($recurringTypes as $code => $label) {
$options[] = ['value' => $code, 'label' => $label];
}
return $options;
}
}
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* Order Statuses source model
*/
namespace Adyen\Payment\Model\Config\Source;
class DemoMode implements \Magento\Framework\Option\ArrayInterface
{
/**
* @var \Magento\Sales\Model\Order\Config
*/
protected $_orderConfig;
protected $_adyenHelper;
/**
* @param \Magento\Sales\Model\Order\Config $orderConfig
*/
public function __construct(
\Magento\Sales\Model\Order\Config $orderConfig,
\Adyen\Payment\Helper\Data $adyenHelper
)
{
$this->_orderConfig = $orderConfig;
$this->_adyenHelper = $adyenHelper;
}
/**
* @return array
*/
public function toOptionArray()
{
$recurringTypes = $this->_adyenHelper->getModes();
foreach ($recurringTypes as $code => $label) {
$options[] = ['value' => $code, 'label' => $label];
}
return $options;
}
}
This diff is collapsed.
...@@ -43,6 +43,8 @@ class Cc extends \Magento\Payment\Model\Method\Cc ...@@ -43,6 +43,8 @@ class Cc extends \Magento\Payment\Model\Method\Cc
protected $_paymentRequest; protected $_paymentRequest;
protected $_adyenLogger;
/** /**
* @param \Magento\Framework\Model\Context $context * @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry * @param \Magento\Framework\Registry $registry
...@@ -59,6 +61,7 @@ class Cc extends \Magento\Payment\Model\Method\Cc ...@@ -59,6 +61,7 @@ class Cc extends \Magento\Payment\Model\Method\Cc
*/ */
public function __construct( public function __construct(
\Adyen\Payment\Model\Api\PaymentRequest $paymentRequest, \Adyen\Payment\Model\Api\PaymentRequest $paymentRequest,
\Adyen\Payment\Logger\AdyenLogger $adyenLogger,
\Magento\Framework\Model\Context $context, \Magento\Framework\Model\Context $context,
\Magento\Framework\Registry $registry, \Magento\Framework\Registry $registry,
\Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory, \Magento\Framework\Api\ExtensionAttributesFactory $extensionFactory,
...@@ -87,6 +90,7 @@ class Cc extends \Magento\Payment\Model\Method\Cc ...@@ -87,6 +90,7 @@ class Cc extends \Magento\Payment\Model\Method\Cc
$data $data
); );
$this->_paymentRequest = $paymentRequest; $this->_paymentRequest = $paymentRequest;
$this->_adyenLogger = $adyenLogger;
} }
...@@ -98,6 +102,7 @@ class Cc extends \Magento\Payment\Model\Method\Cc ...@@ -98,6 +102,7 @@ class Cc extends \Magento\Payment\Model\Method\Cc
public function isAvailable($quote = null) public function isAvailable($quote = null)
{ {
$this->_logger->critical("CC IS AVAILABLE!! IS TRUE"); $this->_logger->critical("CC IS AVAILABLE!! IS TRUE");
// $this->_adyenLogger->critical("TESTTT");
return true; return true;
} }
...@@ -110,10 +115,25 @@ class Cc extends \Magento\Payment\Model\Method\Cc ...@@ -110,10 +115,25 @@ class Cc extends \Magento\Payment\Model\Method\Cc
*/ */
public function assignData($data) public function assignData($data)
{ {
parent::assignData($data);
$infoInstance = $this->getInfoInstance();
$this->_logger->critical("Assign data!!:" . print_r($data, true)); $this->_logger->critical("Assign data!!:" . print_r($data, true));
return parent::assignData($data);
//// print_r($data);die();
// throw new \Magento\Framework\Exception\LocalizedException(__('The authorize action is not available.' . print_r($data, true)));
//// print_r($data);die();
// $this->_logger->critical("TEST in validate FUNTION !!:"); // $this->_logger->critical("TEST in validate FUNTION !!:");
$infoInstance->setAdditionalInformation('encrypted_data', $data['encrypted_data']);
$this->_logger->critical("encrypted dat:" . $data['encrypted_data']);
return $this;
} }
public function validate() public function validate()
...@@ -125,6 +145,7 @@ class Cc extends \Magento\Payment\Model\Method\Cc ...@@ -125,6 +145,7 @@ class Cc extends \Magento\Payment\Model\Method\Cc
public function authorize(\Magento\Payment\Model\InfoInterface $payment, $amount) public function authorize(\Magento\Payment\Model\InfoInterface $payment, $amount)
{ {
$this->_logger->critical("TEST in authorize FUNTION !!:"); $this->_logger->critical("TEST in authorize FUNTION !!:");
if (!$this->canAuthorize()) { if (!$this->canAuthorize()) {
throw new \Magento\Framework\Exception\LocalizedException(__('The authorize action is not available.')); throw new \Magento\Framework\Exception\LocalizedException(__('The authorize action is not available.'));
} }
...@@ -150,16 +171,13 @@ class Cc extends \Magento\Payment\Model\Method\Cc ...@@ -150,16 +171,13 @@ class Cc extends \Magento\Payment\Model\Method\Cc
} }
protected function _processRequest(\Magento\Framework\Object $payment, $amount, $request) { protected function _processRequest(\Magento\Framework\Object $payment, $amount, $request)
{
$merchantAccount = $this->getConfigData('merchant_account');
$recurringType = $this->getConfigData('recurring_type');
$enableMoto = $this->getConfigData('enable_moto');
switch ($request) { switch ($request) {
case "authorise": case "authorise":
$response = $this->_paymentRequest->fullApiRequest($merchantAccount, $payment); $response = $this->_paymentRequest->fullApiRequest($payment);
break; break;
} }
...@@ -167,9 +185,15 @@ class Cc extends \Magento\Payment\Model\Method\Cc ...@@ -167,9 +185,15 @@ class Cc extends \Magento\Payment\Model\Method\Cc
$this->_logger->critical("HIERRR result is " . print_r($response,true)); $this->_logger->critical("HIERRR result is " . print_r($response,true));
if (!empty($response)) { if (!empty($response)) {
$this->_logger->critical("NOT EMPTY "); $this->_logger->critical("NOT EMPTY ");
$this->_processResponse($payment, $response);
// print_r($response);die(); // print_r($response);die();
// $this->_processResponse($payment, $response, $request); // $this->_processResponse($payment, $response, $request);
...@@ -181,6 +205,60 @@ class Cc extends \Magento\Payment\Model\Method\Cc ...@@ -181,6 +205,60 @@ class Cc extends \Magento\Payment\Model\Method\Cc
} }
protected function _processResponse(\Magento\Payment\Model\InfoInterface $payment, $response)
{
switch ($response['paymentResult_resultCode']) {
case "Authorised":
//$this->_addStatusHistory($payment, $responseCode, $pspReference, $this->_getConfigData('order_status'));
break;
case "Refused":
// paymentResult_refusalReason
if($response['paymentResult_refusalReason']) {
$refusalReason = $response['paymentResult_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 by Adyen.');
break;
}
} else {
$errorMsg = Mage::helper('adyen')->__('The payment is REFUSED by Adyen.');
}
if ($errorMsg) {
$this->_logger->critical($errorMsg);
throw new \Magento\Framework\Exception\LocalizedException($errorMsg);
}
break;
}
if($response['paymentResult_resultCode'] == 'Refused') {
}
// print_R($response);die();
}
// does not seem to work. // does not seem to work.
public function hasVerification() { public function hasVerification() {
return true; return true;
......
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Adyen\Payment\Model;
use Adyen\Payment\Api\Data\NotificationInterface;
use Magento\Framework\Object\IdentityInterface;
class Notification extends \Magento\Framework\Model\AbstractModel
implements NotificationInterface
{
const AUTHORISATION = 'AUTHORISATION';
const PENDING = 'PENDING';
const AUTHORISED = 'AUTHORISED';
const CANCELLED = 'CANCELLED';
const REFUSED = 'REFUSED';
const ERROR = 'ERROR';
const REFUND = 'REFUND';
const REFUND_FAILED = 'REFUND_FAILED';
const CANCEL_OR_REFUND = 'CANCEL_OR_REFUND';
const CAPTURE = 'CAPTURE';
const CAPTURE_FAILED = 'CAPTURE_FAILED';
const CANCELLATION = 'CANCELLATION';
const POSAPPROVED = 'POS_APPROVED';
const HANDLED_EXTERNALLY = 'HANDLED_EXTERNALLY';
const MANUAL_REVIEW_ACCEPT = 'MANUAL_REVIEW_ACCEPT';
const MANUAL_REVIEW_REJECT = 'MANUAL_REVIEW_REJECT ';
const RECURRING_CONTRACT = "RECURRING_CONTRACT";
const REPORT_AVAILABLE = "REPORT_AVAILABLE";
const ORDER_CLOSED = "ORDER_CLOSED";
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\Model\Resource\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = []
) {
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
}
/**
* Initialize resource model
*
* @return void
*/
protected function _construct()
{
$this->_init('Adyen\Payment\Model\Resource\Notification');
}
/**
* Gets the Pspreference for the notification.
*
* @return int|null Pspreference.
*/
public function getPspreference()
{
return $this->getData(self::PSPREFRENCE);
}
/**
* Sets Pspreference.
*
* @param string $pspreference
* @return $this
*/
public function setPspreference($pspreference)
{
return $this->setData(self::PSPREFRENCE, $pspreference);
}
/**
* Gets the Merchantreference for the notification.
*
* @return int|null MerchantReference.
*/
public function getMerchantReference()
{
return $this->getData(self::MERCHANT_REFERENCE);
}
/**
* Sets MerchantReference.
*
* @param string $merchantReference
* @return $this
*/
public function setMerchantReference($merchantReference)
{
return $this->setData(self::MERCHANT_REFERENCE, $merchantReference);
}
/**
* Gets the Eventcode for the notification.
*
* @return int|null Eventcode.
*/
public function getEventCode()
{
return $this->getData(self::EVENT_CODE);
}
/**
* Sets EventCode.
*
* @param string $eventCode
* @return $this
*/
public function setEventCode($eventCode)
{
return $this->setData(self::EVENT_CODE, $eventCode);
}
/**
* Gets the success for the notification.
*
* @return int|null Success.
*/
public function getSucess()
{
return $this->getData(self::SUCCESS);
}
/**
* Sets Success.
*
* @param boolean $success
* @return $this
*/
public function setSuccess($success)
{
return $this->setData(self::SUCCESS, $success);
}
/**
* Gets the Paymentmethod for the notification.
*
* @return int|null PaymentMethod.
*/
public function getPaymentMethod()
{
return $this->getData(self::PAYMENT_METHOD);
}
/**
* Sets PaymentMethod.
*
* @param string $paymentMethod
* @return $this
*/
public function setPaymentMethod($paymentMethod)
{
return $this->setData(self::PAYMENT_METHOD, $paymentMethod);
}
/**
* Gets the AmountValue for the notification.
*
* @return int|null AmountValue.
*/
public function getAmountValue()
{
return $this->getData(self::AMOUNT_VALUE);
}
/**
* Sets AmountValue.
*
* @param string $amountValue
* @return $this
*/
public function setAmountValue($amountValue)
{
return $this->setData(self::AMOUNT_VALUE, $amountValue);
}
/**
* Gets the AmountValue for the notification.
*
* @return int|null AmountValue.
*/
public function getAmountCurency()
{
return $this->getData(self::AMOUNT_CURRENCY);
}
/**
* Sets AmountCurrency.
*
* @param string $amountCurrency
* @return $this
*/
public function setAmountCurrency($amountCurrency)
{
return $this->setData(self::AMOUNT_CURRENCY, $amountCurrency);
}
/**
* Gets the Reason for the notification.
*
* @return int|null Reason.
*/
public function getReason()
{
return $this->getData(self::REASON);
}
/**
* Sets Reason.
*
* @param string $reason
* @return $this
*/
public function setReason($reason)
{
return $this->setData(self::REASON, $reason);
}
/**
* Gets the AdditionalData for the notification.
*
* @return int|null AdditionalData.
*/
public function getAdditionalData()
{
return $this->getData(self::ADDITIONAL_DATA);
}
/**
* Sets AdditionalData.
*
* @param string $additionalData
* @return $this
*/
public function setAddtionalData($additionalData)
{
return $this->setData(self::ADDITIONAL_DATA, $additionalData);
}
/**
* Gets the Done for the notification.
*
* @return int|null Done.
*/
public function getDone()
{
return $this->getData(self::DONE);
}
/**
* Sets Done.
*
* @param string $done
* @return $this
*/
public function setDone($done)
{
return $this->setData(self::DONE, $done);
}
/**
* Gets the created-at timestamp for the notification.
*
* @return string|null Created-at timestamp.
*/
public function getCreatedAt()
{
return $this->getData(self::CREATED_AT);
}
/**
* Sets the created-at timestamp for the notification.
*
* @param string $createdAt timestamp
* @return $this
*/
public function setCreatedAt($createdAt)
{
return $this->setData(self::CREATED_AT, $createdAt);
}
/**
* Gets the updated-at timestamp for the notification.
*
* @return string|null Updated-at timestamp.
*/
public function getUpdatedAt()
{
return $this->getData(self::UPDATED_AT);
}
/**
* Sets the updated-at timestamp for the notification.
*
* @param string $timestamp
* @return $this
*/
public function setUpdatedAt($timestamp)
{
return $this->setData(self::UPDATED_AT, $timestamp);
}
}
\ No newline at end of file
<?php
namespace Adyen\Payment\Model\Resource;
class Notification extends \Magento\Framework\Model\Resource\Db\AbstractDb
{
public function _construct()
{
$this->_init('adyen_notification', 'entity_id');
}
}
\ No newline at end of file
<?php
namespace Adyen\Payment\Model\Resource\Notification;
class Collection extends \Magento\Framework\Model\Resource\Db\Collection\AbstractCollection
{
public function _construct()
{
$this->_init('Adyen\Payment\Model\Notification', 'Adyen\Payment\Model\Resource\Notification');
}
}
\ No newline at end of file
<?php
/**
* Created by PhpStorm.
* User: rikt
* Date: 9/15/15
* Time: 10:00 AM
*/
\ No newline at end of file
<?php
namespace Adyen\Payment\Setup;
use Magento\Framework\Setup\InstallSchemaInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
use Magento\Framework\DB\Ddl\Table;
use \Magento\Framework\DB\Adapter\AdapterInterface;
class InstallSchema implements InstallSchemaInterface
{
/**
* Installs DB schema for a module
*
* @param SchemaSetupInterface $setup
* @param ModuleContextInterface $context
* @return void
*/
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
$installer = $setup;
$installer->startSetup();
$table = $installer->getConnection()
->newTable($installer->getTable('adyen_notification'))
->addColumn('entity_id', Table::TYPE_SMALLINT, null,['identity' => true, 'nullable' => false, 'primary' => true],'Entity ID')
->addColumn('pspreference', Table::TYPE_TEXT, 255, ['nullable' => true], 'Pspreference')
->addColumn('merchant_reference', Table::TYPE_TEXT, 255, ['nullable' => true], 'Merchant Reference')
->addColumn('event_code', Table::TYPE_TEXT, 255, ['nullable' => true], 'Event Code')
->addColumn('success', Table::TYPE_TEXT, 255, ['nullable' => true], 'Success')
->addColumn('payment_method', Table::TYPE_TEXT, 255, ['nullable' => true], 'Payment Method')
->addColumn('amount_value', Table::TYPE_TEXT, 255, ['nullable' => true], 'Amount value')
->addColumn('amount_currency', Table::TYPE_TEXT, 255, ['nullable' => true], 'Amount currency')
->addColumn('reason', Table::TYPE_TEXT, 255, ['nullable' => true], 'reason')
->addColumn('live', Table::TYPE_TEXT, 255, ['nullable' => true], 'Send from Live platform of adyen?')
->addColumn('additional_data', Table::TYPE_TEXT, null, ['nullable' => true], 'AdditionalData')
->addColumn('done', Table::TYPE_BOOLEAN, null, ['nullable' => false, 'default' => 0], 'done')
->addColumn('created_at', Table::TYPE_TIMESTAMP, null, ['nullable' => false, 'default' => Table::TIMESTAMP_INIT], 'Created At')
->addColumn('updated_at', Table::TYPE_TIMESTAMP, null, ['nullable' => false, 'default' => Table::TIMESTAMP_INIT_UPDATE],'Updated At')
->addIndex($installer->getIdxName('adyen_notification', ['pspreference']), ['pspreference'])
->addIndex($installer->getIdxName('adyen_notification', ['event_code']), ['event_code'])
->addIndex(
$installer->getIdxName(
'adyen_notification',
['pspreference', 'event_code'],
AdapterInterface::INDEX_TYPE_INDEX
),
['pspreference', 'event_code'],
['type' => AdapterInterface::INDEX_TYPE_INDEX]
)
->addIndex(
$installer->getIdxName(
'adyen_notification',
['merchant_reference', 'event_code'],
AdapterInterface::INDEX_TYPE_INDEX
),
['merchant_reference', 'event_code'],
['type' => AdapterInterface::INDEX_TYPE_INDEX]
)
->setComment('Adyen Notifications');
$installer->getConnection()->createTable($table);
$orderTable = $installer->getTable('sales_order');
$columns = [
'adyen_resulturl_event_code' => [
'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
'length' => 255,
'nullable' => true,
'comment' => 'Adyen resulturl event status',
],
'adyen_notification_event_code' => [
'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
'length' => 255,
'nullable' => true,
'comment' => 'Adyen notification event status',
]
];
$connection = $installer->getConnection();
foreach ($columns as $name => $definition) {
$connection->addColumn($orderTable, $name, $definition);
}
$installer->endSetup();
}
}
\ No newline at end of file
<?xml version="1.0"?> <?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Magento/Config/etc/system_file.xsd"> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Magento/Config/etc/system_file.xsd">
<system> <system>
<section id="payment" translate="label" type="text" sortOrder="400" showInDefault="1" showInWebsite="1" showInStore="1"> <section id="payment" translate="label" type="text" sortOrder="400" showInDefault="1" showInWebsite="1" showInStore="1">
<group id="adyen_cc" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Adyen</label>
<field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0"> <group id="adyen_group_all_in_one" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enabled</label> <label>Adyen All-in-One Payment Solutions</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model> <comment><![CDATA[Adyen All-in-One Payment Solutions]]></comment>
</field> <attribute type="expanded">1</attribute>
<field id="title" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1"> <fieldset_css>complex</fieldset_css>
<label>Title</label> <frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Group</frontend_model>
</field>
<field id="merchant_account" translate="label" type="text" sortOrder="15" showInDefault="1" showInWebsite="1" showInStore="0"> <include path="Adyen_Payment::system/adyen_getting_started.xml"/>
<label>Merchant Account</label> <include path="Adyen_Payment::system/adyen_required_settings.xml"/>
</field> <include path="Adyen_Payment::system/adyen_cc.xml"/>
<field id="webservice_username" translate="label" type="text" sortOrder="16" showInDefault="1" showInWebsite="1" showInStore="1"> <include path="Adyen_Payment::system/adyen_hpp.xml"/>
<label>Webservice username</label>
</field>
<field id="webservice_password" translate="label" type="obscure" sortOrder="17" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Webservice Password</label>
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
</field>
<field id="order_status" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="0">
<label>New Order Status</label>
<source_model>Magento\Sales\Model\Config\Source\Order\Status\NewStatus</source_model>
</field>
<field id="recurring_type" translate="label" type="select" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Recurring Type</label>
<source_model>Adyen\Payment\Model\Config\Source\RecurringType</source_model>
</field>
<field id="enable_moto" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Enable MOTO for backend orders</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="sort_order" translate="label" type="text" sortOrder="190" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Sort Order</label>
<frontend_class>validate-number</frontend_class>
</field>
<field id="allowspecific" translate="label" type="allowspecific" sortOrder="200" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Payment from Applicable Countries</label>
<source_model>Magento\Payment\Model\Config\Source\Allspecificcountries</source_model>
</field>
<field id="specificcountry" translate="label" type="multiselect" sortOrder="201" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Payment from Specific Countries</label>
<source_model>Magento\Directory\Model\Config\Source\Country</source_model>
<can_be_empty>1</can_be_empty>
</field>
<field id="model"></field>
</group> </group>
<group id="adyen_hpp" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Adyen</label>
<field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Enabled</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="title" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Title</label>
</field>
</group>
<group id="test" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1"> <group id="test" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Test</label> <label>Test</label>
<field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0"> <field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0">
......
<?xml version="1.0"?>
<!--
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<include xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../Magento/Config/etc/system_include.xsd">
<group id="adyen_cc" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="1">
<label><![CDATA[CreditCard API integration]]></label>
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Payment</frontend_model>
<fieldset_css>adyen-method-adyen-cc</fieldset_css>
<comment>Process creditcard payments inside your checkout.</comment>
<field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Enabled</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/adyen_cc/active</config_path>
</field>
<field id="title" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Title</label>
<config_path>payment/adyen_cc/title</config_path>
</field>
<field id="sort_order" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Sort Order</label>
<frontend_class>validate-number</frontend_class>
<config_path>payment/adyen_cc/sort_order</config_path>
</field>
<field id="cse_enabled" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enable CSE</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/adyen_cc/cse_enabled</config_path>
</field>
<field id="cse_publickey_test" translate="label" type="textarea" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enter CSE Public Key of Test Adyen Web Service User</label>
<depends><field id="cse_enabled">1</field></depends>
<config_path>payment/adyen_cc/cse_publickey_test</config_path>
</field>
<field id="cse_publickey_live" translate="label" type="textarea" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enter CSE Public Key of Live Adyen Web Service User</label>
<depends><field id="cse_enabled">1</field></depends>
<config_path>payment/adyen_cc/cse_publickey_live</config_path>
</field>
<group id="adyen_cc_country_specific" translate="label" showInDefault="1" showInWebsite="1" sortOrder="200">
<label>Country Specific Settings</label>
<frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
<field id="allowspecific" translate="label" type="allowspecific" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Payment from Applicable Countries</label>
<source_model>Magento\Payment\Model\Config\Source\Allspecificcountries</source_model>
<config_path>payment/adyen_cc/allowspecific</config_path>
</field>
<field id="specificcountry" translate="label" type="multiselect" sortOrder="200" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Payment from Specific Countries</label>
<source_model>Magento\Directory\Model\Config\Source\Country</source_model>
<can_be_empty>1</can_be_empty>
<config_path>payment/adyen_cc/specificcountry</config_path>
</field>
</group>
</group>
</include>
\ No newline at end of file
<?xml version="1.0"?>
<!--
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<include xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../Magento/Config/etc/system_include.xsd">
<group id="adyen_getting_started" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label><![CDATA[Documentation & Support]]></label>
<frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
<comment><![CDATA[
<ul>
<li><a target="_blank" href="http://vimeo.com/94005128">Instructional video on how to set up the Adyen Magento plugin</a></a>
<li><a target="_blank" href="https://www.adyen.com/dam/documentation/manuals/MagentoQuickIntegrationManual.pdf">Download the Quick Quick Integration Guide</a></li>
<li><a target="_blank" href="https://www.adyen.com/dam/documentation/manuals/AdyenMagentoExtension.pdf">Download the more advanced manual</a></li>
<li><a target="_blank" href="https://www.adyen.com/home/payment-services/plug-ins/magento#form"><strong>Sign</strong> up for a test account</a></li>
<li>The latest version of the <a target="_blank" href="https://github.com/adyenpayments/magento/releases">Adyen Magento module is also available through GitHub</a>.</li>
</ul>
<p> In the test modus you nee to use test cards. <a target="_blank" href="http://adyen.com/test-card-numbers">Test cards can be found here</a>
<p>You can find this in the Adyen back-office. The Adyen back-office can be found on <a target="_blank" href="https://ca-test.adyen.com">https://ca-test.adyen.com</a> for test or <a target="_blank" href="https://ca-live.adyen.com">https://ca-live.adyen.com</a> for live.</p>
<p>If you have any further questions, please visit the <a target="_blank" href="http://www.adyen.com">Adyen.com</a> website or email <a href="mailto:magento@adyen.com">magento@adyen.com</a>.</p>
]]></comment>
<field id="version" translate="label" type="label" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Extension version</label>
<frontend_model>\Adyen\Payment\Block\Adminhtml\System\Config\Field\Version</frontend_model>
</field>
</group>
</include>
\ No newline at end of file
<?xml version="1.0"?>
<!--
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<include xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../Magento/Config/etc/system_include.xsd">
<group id="adyen_hpp" translate="label" type="text" sortOrder="200" showInDefault="1" showInWebsite="1" showInStore="1">
<label><![CDATA[Hosted Payment Page (HPP) integration]]></label>
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Fieldset\Payment</frontend_model>
<fieldset_css>adyen-method-adyen-cc</fieldset_css>
<comment>Process alternative payments methods</comment>
<field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Enabled</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/adyen_hpp/active</config_path>
</field>
<field id="title" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Title</label>
<config_path>payment/adyen_hpp/title</config_path>
</field>
<field id="sort_order" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Sort Order</label>
<frontend_class>validate-number</frontend_class>
<config_path>payment/adyen_hpp/sort_order</config_path>
</field>
<group id="adyen_cc_country_specific" translate="label" showInDefault="1" showInWebsite="1" sortOrder="210">
<label>Country Specific Settings</label>
<frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
<field id="allowspecific" translate="label" type="allowspecific" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Payment from Applicable Countries</label>
<source_model>Magento\Payment\Model\Config\Source\Allspecificcountries</source_model>
<config_path>payment/adyen_cc/allowspecific</config_path>
</field>
<field id="specificcountry" translate="label" type="multiselect" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Payment from Specific Countries</label>
<source_model>Magento\Directory\Model\Config\Source\Country</source_model>
<can_be_empty>1</can_be_empty>
<config_path>payment/adyen_cc/specificcountry</config_path>
</field>
</group>
</group>
</include>
\ No newline at end of file
<?xml version="1.0"?>
<!--
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<include xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../Magento/Config/etc/system_include.xsd">
<group id="adyen_required_settings" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label><![CDATA[Required Settings]]></label>
<frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
<field id="merchant_account" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Merchant Account</label>
<config_path>payment/adyen_abstract/merchant_account</config_path>
</field>
<field id="demo_mode" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Test/Production Mode</label>
<source_model>Adyen\Payment\Model\Config\Source\DemoMode</source_model>
<config_path>payment/adyen_abstract/demo_mode</config_path>
<tooltip><![CDATA[ In the test mode you must use test cards. See section Documentation & Support for the link to the test cards]]></tooltip>
</field>
<field id="notification_username" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Notification User Name</label>
<config_path>payment/adyen_abstract/notification_username</config_path>
<tooltip>Set a user name of your choice here and copy it over to Adyen Customer Area => Settings => Server Communication => Standard Notification => User Name.</tooltip>
</field>
<field id="notification_password" translate="label" type="obscure" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Notification Password</label>
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
<config_path>payment/adyen_abstract/notification_password</config_path>
<tooltip>Set a password of your choice and copy it over to Adyen Customer Area => Settings => Server Communication => Standard Notification => Password.</tooltip>
</field>
<field id="ws_username_test" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Webservice username</label>
<tooltip>Find this in your Test Adyen Customer Area => Settings => Users => System. Normally this will be ws@Company.YourCompanyAccount. Copy and Paste the exact ws user name here.</tooltip>
<config_path>payment/adyen_abstract/ws_username_test</config_path>
</field>
<field id="ws_password_test" translate="label" type="obscure" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Webservice Password</label>
<tooltip>Find this in your Test Adyen Customer Area => Settings => Users => System. Click on your web service user and generate a new password. Copy and Paste the exact password here.</tooltip>
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
<config_path>payment/adyen_abstract/ws_password_test</config_path>
</field>
<field id="ws_username_live" translate="label" type="text" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Webservice username</label>
<tooltip>This is only applicable if you have a Live account. Find this in your Live Adyen Customer Area => Settings => Users => System. Normally this will be ws@Company.YourCompanyAccount. Copy and Paste the exact ws user name here.</tooltip>
<config_path>payment/adyen_abstract/ws_username_live</config_path>
</field>
<field id="ws_password_live" translate="label" type="obscure" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Webservice Password</label>
<tooltip>This is only applicable if you have a Live account. Find this in your Live Adyen Customer Area => Settings => Users => System. Click on your web service user and generate a new password. Copy and Paste the exact password here.</tooltip>
<backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
<config_path>payment/adyen_abstract/ws_password_live</config_path>
</field>
<field id="capture_mode" translate="label" type="select" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Capture Delay</label>
<tooltip>Immediate is the default. Set to manual if you want to perform the capture of funds manually later (only affects credit cards and a few alternative payment methods). You need to change this setting as well in Adyen Customer Area => Settings => Merchant Settings => Capture Delay. If you have selected a capture delay of a couple of days in Adyen keep it here on immediate</tooltip>
<source_model>Adyen\Payment\Model\Config\Source\CaptureMode</source_model>
<config_path>payment/adyen_abstract/capture_mode</config_path>
</field>
<field id="order_status" translate="label" type="select" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Order status: order creation</label>
<tooltip>Status given to newly created orders before payment result confirmation via server notifications from Adyen.</tooltip>
<source_model>Magento\Sales\Model\Config\Source\Order\Status\NewStatus</source_model>
<config_path>payment/adyen_abstract/order_status</config_path>
</field>
<field id="payment_pre_authorized" translate="label" type="select" sortOrder="110" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Order status: payment authorisation</label>
<tooltip>Status given to orders after authorisation confirmed by an AUTHORISATION notification from Adyen. Note: an authorisation status via the result URL does not yet trigger this status.</tooltip>
<source_model>Magento\Sales\Model\Config\Source\Order\Status\Newprocessing</source_model>
<config_path>payment/adyen_abstract/payment_pre_authorized</config_path>
</field>
<field id="payment_authorized" translate="label" type="select" sortOrder="120" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Order status: payment confirmed</label>
<tooltip>Status given to orders after capture result is confirmed by an AUTHORISATION notification (if capture mode = immediate) or a CAPTURE notification (if capture mode = manual capture) from Adyen.</tooltip>
<source_model>Magento\Sales\Model\Config\Source\Order\Status\Processing</source_model>
<config_path>payment/adyen_abstract/payment_authorized</config_path>
</field>
<field id="payment_cancelled" translate="label" type="select" sortOrder="130" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Order status: order cancellation</label>
<tooltip>Status given to orders after order cancellation is confirmed by a CANCEL_OR_REFUND notification from Adyen. If orders are already invoiced, they cannot be cancelled, but will be refunded instead.</tooltip>
<source_model>Adyen\Payment\Model\Config\Source\Cancelled</source_model>
<config_path>payment/adyen_abstract/payment_cancelled</config_path>
</field>
<field id="debug" translate="label" type="select" sortOrder="140" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Enable debug logging</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/adyen_abstract/debug</config_path>
</field>
</group>
</include>
\ No newline at end of file
...@@ -8,16 +8,21 @@ ...@@ -8,16 +8,21 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Magento/Store/etc/config.xsd"> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Magento/Store/etc/config.xsd">
<default> <default>
<payment> <payment>
<adyen_abstract>
<active>0</active>
<recurring_type>ONECLICK</recurring_type>
<order_status>pending</order_status>
<demo_mode>1</demo_mode>
</adyen_abstract>
<adyen_cc> <adyen_cc>
<active>1</active> <active>1</active>
<model>Adyen\Payment\Model\Method\Cc</model> <model>Adyen\Payment\Model\Method\Cc</model>
<order_status>pending</order_status> <title>Adyen CC</title>
<title>Adyen</title>
<recurring_type>ONECLICK</recurring_type>
<allowspecific>0</allowspecific> <allowspecific>0</allowspecific>
<sort_order>1</sort_order> <sort_order>1</sort_order>
<cctypes>AE,VI,MC,DI</cctypes> <cctypes>AE,VI,MC,DI</cctypes>
<useccv>1</useccv> <useccv>1</useccv>
<cse_enabled>1</cse_enabled>
<group>adyen</group> <group>adyen</group>
</adyen_cc> </adyen_cc>
<adyen_hpp> <adyen_hpp>
......
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../Magento/Cron/etc/crontab.xsd">
<group id="index">
<job name="adyen_payment_process_notification" instance="Adyen\Payment\Model\Cron" method="processNotification">
<schedule>* * * * *</schedule>
</job>
</group>
</config>
\ No newline at end of file
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
<type name="Adyen\Payment\Logger\Handler\AdyenDebug">
<arguments>
<argument name="filesystem" xsi:type="object">Magento\Framework\Filesystem\Driver\File</argument>
</arguments>
</type>
<type name="Adyen\Payment\Logger\AdyenLogger">
<arguments>
<argument name="name" xsi:type="string">AdyenLoggerTest</argument>
<argument name="handlers" xsi:type="array">
<item name="adyenDebug" xsi:type="object">Adyen\Payment\Logger\Handler\AdyenDebug</item>
</argument>
</arguments>
</type>
</config>
\ No newline at end of file
...@@ -6,17 +6,10 @@ ...@@ -6,17 +6,10 @@
*/ */
--> -->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd"> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
<virtualType name="AdyenCcConfigProvider" type="Magento\Payment\Model\CcGenericConfigProvider">
<arguments>
<argument name="methodCodes" xsi:type="array">
<item name="adyen_cc" xsi:type="const">Adyen\Payment\Model\Method\Cc::METHOD_CODE</item>
</argument>
</arguments>
</virtualType>
<type name="Magento\Checkout\Model\CompositeConfigProvider"> <type name="Magento\Checkout\Model\CompositeConfigProvider">
<arguments> <arguments>
<argument name="configProviders" xsi:type="array"> <argument name="configProviders" xsi:type="array">
<item name="adyen_cc_config_provider" xsi:type="object">AdyenCcConfigProvider</item> <item name="adyen_cc_config_provider" xsi:type="object">Adyen\Payment\Model\AdyenCcConfigProvider</item>
<item name="adyen_hpp_config_provider" xsi:type="object">Adyen\Payment\Model\AdyenHppConfigProvider</item> <item name="adyen_hpp_config_provider" xsi:type="object">Adyen\Payment\Model\AdyenHppConfigProvider</item>
</argument> </argument>
</arguments> </arguments>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
*/ */
--> -->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd"> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="Adyen_Payment" setup_version="1.0.0"> <module name="Adyen_Payment" setup_version="0.1.0">
<sequence> <sequence>
<module name="Magento_Sales"/> <module name="Magento_Sales"/>
<module name="Magento_Quote"/> <module name="Magento_Quote"/>
......
<?xml version="1.0"?>
<!--
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<head>
<css src="Adyen_Payment::styles.css"/>
</head>
</page>
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
.adyen-method-adyen-cc > .entry-edit-head > .config-heading .heading strong { padding-left:90px;background:url(images/adyen-logo.png) no-repeat 0 0; background-size: 83px 24px;line-height: 23px;}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -6,15 +6,21 @@ ...@@ -6,15 +6,21 @@
/*global define*/ /*global define*/
define( define(
[ [
'underscore',
'jquery',
'Magento_Payment/js/view/payment/cc-form', 'Magento_Payment/js/view/payment/cc-form',
'Magento_Checkout/js/action/set-payment-information', 'Magento_Checkout/js/action/set-payment-information',
'Magento_Checkout/js/action/place-order',
'mage/translate',
'Adyen_Payment/js/view/payment/adyen-encrypt'
], ],
function (Component, setPaymentInformationAction) { function (_, $, Component, setPaymentInformationAction, placeOrderAction, $t) {
'use strict'; 'use strict';
return Component.extend({ return Component.extend({
defaults: { defaults: {
template: 'Adyen_Payment/payment/cc-form', template: 'Adyen_Payment/payment/cc-form',
creditCardOwner: '' creditCardOwner: '',
encryptedData: ''
}, },
initObservable: function () { initObservable: function () {
this._super() this._super()
...@@ -27,10 +33,35 @@ define( ...@@ -27,10 +33,35 @@ define(
'creditCardSsStartMonth', 'creditCardSsStartMonth',
'creditCardSsStartYear', 'creditCardSsStartYear',
'selectedCardType', 'selectedCardType',
'creditCardOwner' 'creditCardOwner',
'encryptedData',
]); ]);
return this; return this;
}, },
initialize: function() {
var self = this;
this._super();
// when creditCarNumber change call encrypt function
this.creditCardNumber.subscribe(function(value) {
self.calculateCseKey();
});
this.creditCardOwner.subscribe(function(value) {
self.calculateCseKey();
});
//this.creditCardExpMonth.subscribe(function(value) {
// self.calculateCseKey();
//});
//this.creditCardExpYear.subscribe(function(value) {
// self.calculateCseKey();
//});
this.creditCardVerificationNumber.subscribe(function(value) {
self.calculateCseKey();
});
},
placeOrderHandler: null, placeOrderHandler: null,
validateHandler: null, validateHandler: null,
setPlaceOrderHandler: function(handler) { setPlaceOrderHandler: function(handler) {
...@@ -53,13 +84,61 @@ define( ...@@ -53,13 +84,61 @@ define(
additional_data: { additional_data: {
'cc_cid': this.creditCardVerificationNumber(), 'cc_cid': this.creditCardVerificationNumber(),
'cc_ss_start_month': this.creditCardSsStartMonth(), 'cc_ss_start_month': this.creditCardSsStartMonth(),
'cc_ss_start_year': this.creditCardSsStartYear() 'cc_ss_start_year': this.creditCardSsStartYear(),
'encrypted_data': this.encryptedData()
} }
}; };
}, },
isActive: function() { isActive: function() {
return true; return true;
}, },
placeOrder: function() {
var self = this;
//var cse_form = $("adyen-cc-form");
var cse_form = document.getElementById('adyen-cc-form');
var cse_key = this.getCSEKey();
var cse_options = {
name: 'payment[encrypted_data]',
enableValidations: true,
//submitButtonAlwaysEnabled: true
};
var cseInstance = adyen.encrypt.createEncryptedForm(cse_form, cse_key, cse_options);
// TODO needs to be done through php
var generation = new Date().toISOString();
var cardData = {
number : self.creditCardNumber,
cvc : self.creditCardVerificationNumber,
holderName : self.creditCardOwner,
expiryMonth : self.creditCardExpMonth,
expiryYear : self.creditCardExpYear,
generationtime : generation
};
var data = cseInstance.encrypt(cardData);
self.encryptedData(data);
var placeOrder = placeOrderAction(this.getData(), this.redirectAfterPlaceOrder);
$.when(placeOrder).fail(function(){
self.isPlaceOrderActionAllowed(true);
});
//return true;
//
//if (this.validateHandler()) {
// this.isPlaceOrderActionAllowed(false);
// $.when(setPaymentInformationAction()).done(function() {
// self.placeOrderHandler();
// }).fail(function() {
// self.isPlaceOrderActionAllowed(true);
// });
//}
},
getTitle: function() { getTitle: function() {
return 'Adyen cc'; return 'Adyen cc';
}, },
...@@ -72,6 +151,35 @@ define( ...@@ -72,6 +151,35 @@ define(
context: function() { context: function() {
return this; return this;
}, },
isCseEnabled: function() {
return window.checkoutConfig.payment.adyenCc.cseEnabled;
},
getCSEKey: function() {
return window.checkoutConfig.payment.adyenCc.cseKey;
},
getGenerationTime: function() {
return window.checkoutConfig.payment.adyenCc.generationTime;
},
isShowLegend: function() {
return true;
},
calculateCseKey: function() {
//
////var cse_form = $("adyen-cc-form");
//var cse_form = document.getElementById('adyen-cc-form');
//var cse_key = this.getCSEKey();
//var cse_options = {
// name: 'payment[encrypted_data]',
// enableValidations: true, // disable because month needs to be 01 isntead of 1
// //submitButtonAlwaysEnabled: true
//};
//
//var result = adyen.encrypt.createEncryptedForm(cse_form, cse_key, cse_options);
}
}); });
} }
); );
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<form class="form" id="co-transparent-form" action="#" method="post" data-bind="mageInit: { <form class="form" id="adyen-cc-form" action="#" method="post" data-bind="mageInit: {
'transparent':{ 'transparent':{
'context': context(), 'context': context(),
'controller': getControllerName(), 'controller': getControllerName(),
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
<span><!-- ko i18n: 'Credit Card Information'--><!-- /ko --></span> <span><!-- ko i18n: 'Credit Card Information'--><!-- /ko --></span>
</legend><br /> </legend><br />
<!-- /ko --> <!-- /ko -->
<div class="field type required"> <div class="field type required">
<label data-bind="attr: {for: getCode() + '_cc_type'}" class="label"> <label data-bind="attr: {for: getCode() + '_cc_type'}" class="label">
<span><!-- ko i18n: 'Credit Card Type'--><!-- /ko --></span> <span><!-- ko i18n: 'Credit Card Type'--><!-- /ko --></span>
...@@ -71,6 +72,7 @@ ...@@ -71,6 +72,7 @@
</label> </label>
<div class="control"> <div class="control">
<input type="number" name="payment[cc_number]" class="input-text" value="" <input type="number" name="payment[cc_number]" class="input-text" value=""
data-encrypted-name="number"
data-bind="attr: { data-bind="attr: {
autocomplete: off, autocomplete: off,
id: getCode() + '_cc_number', id: getCode() + '_cc_number',
...@@ -91,6 +93,7 @@ ...@@ -91,6 +93,7 @@
name="payment[cc_owner]" name="payment[cc_owner]"
class="input-text" class="input-text"
value="" value=""
data-encrypted-name="holderName"
data-bind="attr: {id: getCode() + '_cc_owner', 'data-container': getCode() + '-cc-owner'}, data-bind="attr: {id: getCode() + '_cc_owner', 'data-container': getCode() + '-cc-owner'},
enable: isActive($parents), enable: isActive($parents),
value: creditCardOwner"> value: creditCardOwner">
...@@ -106,6 +109,7 @@ ...@@ -106,6 +109,7 @@
<div class="control"> <div class="control">
<select name="payment[cc_exp_month]" <select name="payment[cc_exp_month]"
class="select select-month" class="select select-month"
data-encrypted-name="expiryMonth"
data-bind="attr: {id: getCode() + '_expiration', 'data-container': getCode() + '-cc-month', 'data-validate': JSON.stringify({required:true, 'validate-cc-exp':'#' + getCode() + '_expiration_yr'})}, data-bind="attr: {id: getCode() + '_expiration', 'data-container': getCode() + '-cc-month', 'data-validate': JSON.stringify({required:true, 'validate-cc-exp':'#' + getCode() + '_expiration_yr'})},
enable: isActive($parents), enable: isActive($parents),
options: getCcMonthsValues(), options: getCcMonthsValues(),
...@@ -120,6 +124,7 @@ ...@@ -120,6 +124,7 @@
<div class="control"> <div class="control">
<select name="payment[cc_exp_year]" <select name="payment[cc_exp_year]"
class="select select-year" class="select select-year"
data-encrypted-name="expiryYear"
data-bind="attr: {id: getCode() + '_expiration_yr', 'data-container': getCode() + '-cc-year', 'data-validate': JSON.stringify({required:true})}, data-bind="attr: {id: getCode() + '_expiration_yr', 'data-container': getCode() + '-cc-year', 'data-validate': JSON.stringify({required:true})},
enable: isActive($parents), enable: isActive($parents),
options: getCcYearsValues(), options: getCcYearsValues(),
...@@ -142,6 +147,7 @@ ...@@ -142,6 +147,7 @@
<input type="number" <input type="number"
autocomplete="off" autocomplete="off"
class="input-text cvv" class="input-text cvv"
data-encrypted-name="cvc"
name="payment[cc_cid]" name="payment[cc_cid]"
value="" value=""
data-bind="attr: {id: getCode() + '_cc_cid', data-bind="attr: {id: getCode() + '_cc_cid',
...@@ -226,6 +232,14 @@ ...@@ -226,6 +232,14 @@
</div> </div>
</div> </div>
<!-- /ko --> <!-- /ko -->
<!-- ko if: (isCseEnabled())-->
<input type="hidden" id="adyen_encrypted_form_expiry_generationtime" data-bind="value: getGenerationTime()" data-encrypted-name="generationtime" />
<!-- /ko -->
</fieldset> </fieldset>
<div class="checkout-agreements-block"> <div class="checkout-agreements-block">
...@@ -252,5 +266,3 @@ ...@@ -252,5 +266,3 @@
</div> </div>
</div> </div>
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