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 f38de7c3 authored by Rik ter Beek's avatar Rik ter Beek

Merge pull request #28 from Adyen/develop

Merge branch 'develop'
parents 7874697e 438fbc4f
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\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
......@@ -157,6 +157,48 @@ class Data extends AbstractHelper
return number_format($amount, $format, '', '');
}
public function originalAmount($amount, $currency)
{
// check the format
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 = 1;
break;
case "MRO":
$format = 10;
break;
case "BHD":
case "JOD":
case "KWD":
case "OMR":
case "LYD":
case "TND":
$format = 1000;
break;
default:
$format = 100;
break;
}
return ($amount / $format);
}
/**
* Street format
* @param type $address
......
......@@ -144,9 +144,10 @@ class AdyenOneclickConfigProvider extends CcGenericConfigProvider
foreach ($this->methodCodes as $code) {
if ($this->methods[$code]->isAvailable()) {
$config['payment'] ['adyenOneclick']['billingAgreements'] = $this->getAdyenOneclickPaymentMethods();
$recurringContractType = $this->_getRecurringContractType();
$config['payment'] ['adyenOneclick']['billingAgreements'] = $this->getAdyenOneclickPaymentMethods();
$config['payment'] ['adyenOneclick']['recurringContractType'] = $recurringContractType;
if($recurringContractType == \Adyen\Payment\Model\RecurringType::ONECLICK) {
$config['payment'] ['adyenOneclick']['hasCustomerInteraction'] = true;
......@@ -155,7 +156,6 @@ class AdyenOneclickConfigProvider extends CcGenericConfigProvider
}
}
}
return $config;
}
......@@ -188,32 +188,48 @@ class AdyenOneclickConfigProvider extends CcGenericConfigProvider
foreach ($baCollection as $billingAgreement) {
$agreementData = $billingAgreement->getAgreementData();
// check if AgreementLabel is set and if contract has an recurringType
if($billingAgreement->getAgreementLabel()) {
$data = ['reference_id' => $billingAgreement->getReferenceId(),
'agreement_label' => $billingAgreement->getAgreementLabel(),
'agreement_data' => $agreementData
];
if($this->_genericConfig->showLogos()) {
$asset = $this->_genericConfig->createAsset('Adyen_Payment::images/logos/' . $agreementData['variant'] . '.png');
$placeholder = $this->_genericConfig->findRelativeSourceFilePath($asset);
$icon = null;
if ($placeholder) {
list($width, $height) = getimagesize($asset->getSourceFile());
$icon = [
'url' => $asset->getUrl(),
'width' => $width,
'height' => $height
];
// no agreementData and contractType then ignore
if((!is_array($agreementData)) || (!isset($agreementData['contractTypes']))) {
continue;
}
// check if contractType is supporting the selected contractType for OneClick payments
$allowedContractTypes = $agreementData['contractTypes'];
if(in_array($recurringPaymentType, $allowedContractTypes)) {
// check if AgreementLabel is set and if contract has an recurringType
if($billingAgreement->getAgreementLabel()) {
$data = ['reference_id' => $billingAgreement->getReferenceId(),
'agreement_label' => $billingAgreement->getAgreementLabel(),
'agreement_data' => $agreementData
];
if($this->_genericConfig->showLogos()) {
$logoName = $agreementData['variant'];
// for Ideal use sepadirectdebit because it is
if($agreementData['variant'] == 'ideal') {
$logoName = "sepadirectdebit";
}
$asset = $this->_genericConfig->createAsset('Adyen_Payment::images/logos/' . $logoName . '.png');
$placeholder = $this->_genericConfig->findRelativeSourceFilePath($asset);
$icon = null;
if ($placeholder) {
list($width, $height) = getimagesize($asset->getSourceFile());
$icon = [
'url' => $asset->getUrl(),
'width' => $width,
'height' => $height
];
}
$data['logo'] = $icon;
}
$data['logo'] = $icon;
$billingAgreements[] = $data;
}
$billingAgreements[] = $data;
}
}
}
......
......@@ -170,11 +170,6 @@ class PaymentRequest extends DataObject
$request['recurring'] = $recurring;
}
$this->_adyenLogger->error('storeCC?:' . $payment->getAdditionalInformation("store_cc"));
$this->_adyenLogger->error('recuringtype' . $recurringType);
$this->_adyenLogger->error('recurringcontractType' . $recurringContractType);
$billingAddress = $order->getBillingAddress();
if($billingAddress)
......@@ -234,7 +229,7 @@ class PaymentRequest extends DataObject
// For recurring Ideal and Sofort needs to be converted to SEPA for this it is mandatory to set selectBrand to sepadirectdebit
if(!$payment->getAdditionalInformation('customer_interaction')) {
if($payment->getCcType() == "directEbanking" || $payment->getCcType() == "ideal") {
$this->selectedBrand = "sepadirectdebit";
$request['selectedBrand'] = "sepadirectdebit";
}
}
} else {
......@@ -333,10 +328,14 @@ class PaymentRequest extends DataObject
throw new \Magento\Framework\Exception\LocalizedException(__('The capture action failed'));
}
// save pspreference in additional Data to check for notification if refund is triggerd from inside Magento
$payment->setAdditionalInformation('capture_pspreference', $result['pspReference']);
// set pspReference as TransactionId so you can do an online refund
if(isset($result['pspReference'])) {
$payment->setTransactionId($result['pspReference'])
->setIsTransactionClosed(false);
->setIsTransactionClosed(false)
->setParentTransactionId($payment->getAdditionalInformation('pspReference'));
}
return $result;
......@@ -369,6 +368,14 @@ class PaymentRequest extends DataObject
throw new \Magento\Framework\Exception\LocalizedException(__('The refund action failed'));
}
// set pspReference as TransactionId so you can do an online refund
if(isset($result['pspReference'])) {
$payment->setTransactionId($result['pspReference'])
->setIsTransactionClosed(false)
->setParentTransactionId($payment->getAdditionalInformation('pspReference'));
}
return $result;
}
......@@ -407,6 +414,13 @@ class PaymentRequest extends DataObject
throw new \Magento\Framework\Exception\LocalizedException(__('The refund action failed'));
}
// set pspReference as TransactionId so you can do an online refund
if(isset($result['pspReference'])) {
$payment->setTransactionId($result['pspReference'])
->setIsTransactionClosed(false)
->setParentTransactionId($payment->getAdditionalInformation('pspReference'));
}
return $result;
}
......@@ -440,7 +454,9 @@ class PaymentRequest extends DataObject
}
}
} catch (\Exception $exception) {
print_r($exception);
// log exception
$this->_adyenLogger->addError($exception);
throw($exception);
}
}
return $recurringContracts;
......
......@@ -80,10 +80,10 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement
$this->setCreatedAt($creationDate);
//Billing agreement SEPA
if (isset($data['bank_iban'])) {
if (isset($data['bank']['iban'])) {
$this->setAgreementLabel(__('%1, %2',
$data['bank_iban'],
$data['bank_ownerName']
$data['bank']['iban'],
$data['bank']['ownerName']
));
}
......
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2015 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Model\Config\Source;
class SepaFlow implements \Magento\Framework\Option\ArrayInterface
{
const SEPA_FLOW_SALE = 'sale';
const SEPA_FLOW_AUTHCAP = 'authcap';
/**
* @return array
*/
public function toOptionArray()
{
return array(
array('value' => self::SEPA_FLOW_SALE, 'label' => __('Sale')),
array('value' => self::SEPA_FLOW_AUTHCAP, 'label' => __('Auth/Cap')),
);
}
}
\ No newline at end of file
......@@ -113,13 +113,6 @@ class Cron
protected $_klarnaReservationNumber;
protected $_fraudManualReview;
/**
* Collected debug information
*
* @var array
*/
protected $_debugData = array();
/**
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \Adyen\Payment\Logger\AdyenLogger $adyenLogger
......@@ -174,7 +167,7 @@ class Cron
$dateStart = new \DateTime();
$dateStart->modify('-1 day');
$dateEnd = new \DateTime();
$dateEnd->modify('-0 minute');
$dateEnd->modify('-2 minute');
$dateRange = ['from' => $dateStart, 'to' => $dateEnd, 'datetime' => true];
// create collection
......@@ -186,7 +179,7 @@ class Cron
foreach($notifications as $notification) {
// log the executed notification
$this->_debugData['notification'] = print_r($notification->debug(), 1);
$this->_adyenLogger->addAdyenNotificationCronjob(print_r($notification->debug(), 1));
// get order
$incrementId = $notification->getMerchantReference();
......@@ -215,12 +208,12 @@ class Cron
if (strcmp($this->_success, 'false') == 0 || strcmp($this->_success, '0') == 0) {
// Only cancel the order when it is in state pending, payment review or if the ORDER_CLOSED is failed (means split payment has not be successful)
if($this->_order->getState() === \Magento\Sales\Model\Order::STATE_PENDING_PAYMENT || $this->_order->getState() === \Magento\Sales\Model\Order::STATE_PAYMENT_REVIEW || $this->_eventCode == Notification::ORDER_CLOSED) {
$this->_debugData['_updateOrder info'] = 'Going to cancel the order';
$this->_adyenLogger->addAdyenNotificationCronjob('Going to cancel the order');
// if payment is API check, check if API result pspreference is the same as reference
if($this->_eventCode == NOTIFICATION::AUTHORISATION && $this->_getPaymentMethodType() == 'api') {
// don't cancel the order becasue order was successfull through api
$this->_debugData['_updateOrder warning'] = 'order is not cancelled because api result was succesfull';
$this->_adyenLogger->addAdyenNotificationCronjob('order is not cancelled because api result was succesfull');
} else {
// don't cancel the order if previous state is authorisation with success=true
// Split payments can fail if the second payment has failed the first payment is refund/cancelled as well so if it is a split payment that failed cancel the order as well
......@@ -228,11 +221,11 @@ class Cron
$this->_holdCancelOrder(false);
} else {
$this->_order->setData('adyen_notification_event_code', $previousAdyenEventCode);
$this->_debugData['_updateOrder warning'] = 'order is not cancelled because previous notification was a authorisation that succeeded';
$this->_adyenLogger->addAdyenNotificationCronjob('order is not cancelled because previous notification was a authorisation that succeeded');
}
}
} else {
$this->_debugData['_updateOrder info'] = 'Order is already processed so ignore this notification state is:' . $this->_order->getState();
$this->_adyenLogger->addAdyenNotificationCronjob('Order is already processed so ignore this notification state is:' . $this->_order->getState());
}
} else {
// Notification is successful
......@@ -241,10 +234,6 @@ class Cron
$this->_order->save();
foreach($this->_debugData as $debug) {
$this->_adyenLogger->addAdyenNotificationCronjob($debug);
}
// set done to true
$dateEnd = new \DateTime();
$notification->setDone(true);
......@@ -335,17 +324,14 @@ class Cron
$amount = $this->_value;
$orderAmount = (int) $this->_adyenHelper->formatAmount($this->_order->getGrandTotal(), $currency);
$this->_debugData['_addStatusHistoryComment amount'] = 'amount notification:'.$amount . ' amount order:'.$orderAmount;
$this->_adyenLogger->addAdyenNotificationCronjob('amount notification:'.$amount . ' amount order:'.$orderAmount);
if($amount == $orderAmount) {
// $this->_order->setAdyenEventCode($this->_eventCode . " : " . strtoupper($success_result));
$this->_order->setData('adyen_notification_event_code', $this->_eventCode . " : " . strtoupper($success_result));
} else {
// $this->_order->setAdyenEventCode("(PARTIAL) " . $this->_eventCode . " : " . strtoupper($success_result));
$this->_order->setData('adyen_notification_event_code', "(PARTIAL) " . $this->_eventCode . " : " . strtoupper($success_result));
}
} else {
// $this->_order->setAdyenEventCode($this->_eventCode . " : " . strtoupper($success_result));
$this->_order->setData('adyen_notification_event_code', $this->_eventCode . " : " . strtoupper($success_result));
}
......@@ -371,7 +357,7 @@ class Cron
$pendingStatus = $this->_getConfigData('pending_status', 'adyen_abstract', $this->_order->getStoreId());
if($pendingStatus != "") {
$this->_order->addStatusHistoryComment($comment, $pendingStatus);
$this->_debugData['_addStatusHistoryComment'] = 'Created comment history for this notification with status change to: ' . $pendingStatus;
$this->_adyenLogger->addAdyenNotificationCronjob('Created comment history for this notification with status change to: ' . $pendingStatus);
return;
}
}
......@@ -382,17 +368,17 @@ class Cron
{
$manualReviewAcceptStatus = $this->_getFraudManualReviewAcceptStatus();
$this->_order->addStatusHistoryComment($comment, $manualReviewAcceptStatus);
$this->_debugData['_addStatusHistoryComment'] = 'Created comment history for this notification with status change to: ' . $manualReviewAcceptStatus;
$this->_adyenLogger->addAdyenNotificationCronjob('Created comment history for this notification with status change to: ' . $manualReviewAcceptStatus);
return;
}
$this->_order->addStatusHistoryComment($comment);
$this->_debugData['_addStatusHistoryComment'] = 'Created comment history for this notification';
$this->_adyenLogger->addAdyenNotificationCronjob('Created comment history for this notification');
}
protected function _updateAdyenAttributes($notification)
{
$this->_debugData['_updateAdyenAttributes'] = 'Updating the Adyen attributes of the order';
$this->_adyenLogger->addAdyenNotificationCronjob('Updating the Adyen attributes of the order');
$additionalData = unserialize($notification->getAdditionalData());
$_paymentCode = $this->_paymentMethodCode();
......@@ -401,7 +387,6 @@ class Cron
|| $this->_eventCode == Notification::HANDLED_EXTERNALLY
|| ($this->_eventCode == Notification::CAPTURE && $_paymentCode == "adyen_pos"))
{
// if current notification is authorisation : false and the previous notification was authorisation : true do not update pspreference
if (strcmp($this->_success, 'false') == 0 || strcmp($this->_success, '0') == 0 || strcmp($this->_success, '') == 0) {
$previousAdyenEventCode = $this->_order->getData('adyen_notification_event_code');
......@@ -502,19 +487,19 @@ class Cron
if ($this->_order->canHold()) {
$this->_order->hold();
} else {
$this->_debugData['warning'] = 'Order can not hold or is already on Hold';
$this->_adyenLogger->addAdyenNotificationCronjob('Order can not hold or is already on Hold');
return;
}
} else {
if ($this->_order->canCancel()) {
$this->_order->cancel();
} else {
$this->_debugData['warning'] = 'Order can not be canceled';
$this->_adyenLogger->addAdyenNotificationCronjob('Order can not be canceled');
return;
}
}
} else {
$this->_debugData['warning'] = 'Order has already an invoice so cannot be canceled';
$this->_adyenLogger->addAdyenNotificationCronjob('Order has already an invoice so cannot be canceled');
}
}
......@@ -523,7 +508,7 @@ class Cron
*/
protected function _processNotification()
{
$this->_debugData['_processNotification'] = 'Processing the notification';
$this->_adyenLogger->addAdyenNotificationCronjob('Processing the notification');
$_paymentCode = $this->_paymentMethodCode();
switch ($this->_eventCode) {
......@@ -537,7 +522,7 @@ class Cron
//refund completed
$this->_setRefundAuthorized();
} else {
$this->_debugData['_processNotification info'] = 'Setting to ignore refund notification is enabled so ignore this notification';
$this->_adyenLogger->addAdyenNotificationCronjob('Setting to ignore refund notification is enabled so ignore this notification');
}
break;
case Notification::PENDING:
......@@ -545,10 +530,10 @@ class Cron
// Check if payment is banktransfer or sepa if true then send out order confirmation email
$isBankTransfer = $this->_isBankTransfer();
if($isBankTransfer || $this->_paymentMethod == 'sepadirectdebit') {
// $this->_order->sendNewOrderEmail(); // send order email
$this->_orderSender->send($this->_order);
$this->_debugData['_processNotification send email'] = 'Send orderconfirmation email to shopper';
if(!$this->_order->getEmailSent()) {
$this->_orderSender->send($this->_order);
$this->_adyenLogger->addAdyenNotificationCronjob('Send orderconfirmation email to shopper');
}
}
}
break;
......@@ -575,10 +560,6 @@ class Cron
$this->_setPaymentAuthorized(false, true);
}
} else {
// uncancel the order just to be sure that order is going trough
// $this->_uncancelOrder($this->_order);
// FOR POS authorize the payment on the CAPTURE notification
$this->_authorizePayment();
}
......@@ -599,12 +580,12 @@ class Cron
}
} else {
if ($this->_order->isCanceled() || $this->_order->getState() === \Magento\Sales\Model\Order::STATE_HOLDED) {
$this->_debugData['_processNotification info'] = 'Order is already cancelled or holded so do nothing';
$this->_adyenLogger->addAdyenNotificationCronjob('Order is already cancelled or holded so do nothing');
} else if ($this->_order->canCancel() || $this->_order->canHold()) {
$this->_debugData['_processNotification info'] = 'try to cancel the order';
$this->_adyenLogger->addAdyenNotificationCronjob('try to cancel the order');
$this->_holdCancelOrder(true);
} else {
$this->_debugData['_processNotification info'] = 'try to refund the order';
$this->_adyenLogger->addAdyenNotificationCronjob('try to refund the order');
// refund
$this->_refundOrder();
//refund completed
......@@ -636,7 +617,6 @@ class Cron
}
} else {
$this->_order->getPayment()->setBillingAgreementData(
[
'billing_agreement_id' => $recurringDetailReference,
......@@ -653,66 +633,78 @@ class Cron
$customerReference = $billingAgreement->getCustomerReference();
$storeId = $billingAgreement->getStoreId();
$listRecurringContracts = $this->_adyenPaymentRequest->getRecurringContractsForShopper($customerReference, $storeId);
// for quest checkout users we can't save this in the billing agreement because it is linked to customer
if($customerReference && $storeId) {
$contractDetail = null;
// get currenct Contract details and get list of all current ones
$recurringReferencesList = array();
foreach ($listRecurringContracts as $rc) {
$recurringReferencesList[] = $rc['recurringDetailReference'];
if (isset($rc['recurringDetailReference']) && $rc['recurringDetailReference'] == $recurringDetailReference) {
$contractDetail = $rc;
$listRecurringContracts = null;
try {
$listRecurringContracts = $this->_adyenPaymentRequest->getRecurringContractsForShopper($customerReference, $storeId);
} catch(\Exception $exception) {
$this->_adyenLogger->addAdyenNotificationCronjob($exception->getMessage());
}
}
if($contractDetail != null) {
$contractDetail = null;
// get currenct Contract details and get list of all current ones
$recurringReferencesList = array();
// update status of all the current saved agreements in magento
$billingAgreements = $this->_billingAgreementCollectionFactory->create();
$billingAgreements->addFieldToFilter('customer_id', $customerReference);
if($listRecurringContracts) {
foreach ($listRecurringContracts as $rc) {
$recurringReferencesList[] = $rc['recurringDetailReference'];
if (isset($rc['recurringDetailReference']) && $rc['recurringDetailReference'] == $recurringDetailReference) {
$contractDetail = $rc;
}
}
}
// get collection
if($contractDetail != null) {
foreach($billingAgreements as $updateBillingAgreement) {
if(!in_array($updateBillingAgreement->getReferenceId(), $recurringReferencesList)) {
$updateBillingAgreement->setStatus(\Adyen\Payment\Model\Billing\Agreement::STATUS_CANCELED);
$updateBillingAgreement->save();
} else {
$updateBillingAgreement->setStatus(\Adyen\Payment\Model\Billing\Agreement::STATUS_ACTIVE);
$updateBillingAgreement->save();
// update status of all the current saved agreements in magento
$billingAgreements = $this->_billingAgreementCollectionFactory->create();
$billingAgreements->addFieldToFilter('customer_id', $customerReference);
// get collection
foreach($billingAgreements as $updateBillingAgreement) {
if(!in_array($updateBillingAgreement->getReferenceId(), $recurringReferencesList)) {
$updateBillingAgreement->setStatus(\Adyen\Payment\Model\Billing\Agreement::STATUS_CANCELED);
$updateBillingAgreement->save();
} else {
$updateBillingAgreement->setStatus(\Adyen\Payment\Model\Billing\Agreement::STATUS_ACTIVE);
$updateBillingAgreement->save();
}
}
}
// add this billing agreement
$billingAgreement->parseRecurringContractData($contractDetail);
if ($billingAgreement->isValid()) {
$message = __('Created billing agreement #%1.', $billingAgreement->getReferenceId());
// add this billing agreement
$billingAgreement->parseRecurringContractData($contractDetail);
if ($billingAgreement->isValid()) {
$message = __('Created billing agreement #%1.', $billingAgreement->getReferenceId());
// save into sales_billing_agreement_order
$billingAgreement->addOrderRelation($this->_order);
// save into sales_billing_agreement_order
$billingAgreement->addOrderRelation($this->_order);
// add to order to save agreement
$this->_order->addRelatedObject($billingAgreement);
} else {
$message = __('Failed to create billing agreement for this order.');
}
// add to order to save agreement
$this->_order->addRelatedObject($billingAgreement);
} else {
$message = __('Failed to create billing agreement for this order.');
}
}else {
$this->_debugData['_processNotification error'] = 'Failed to create billing agreement for this order (listRecurringCall did not contain contract)';
$this->_debugData['_processNotification ref'] = printf('recurringDetailReference in notification is %1', $recurringDetailReference) ;
$this->_debugData['_processNotification customer ref'] = printf('CustomerReference is: %1 and storeId is %2', $customerReference, $storeId);
$this->_debugData['_processNotification customer result'] = $listRecurringContracts;
$message = __('Failed to create billing agreement for this order (listRecurringCall did not contain contract)');
}
}else {
$this->_adyenLogger->addAdyenNotificationCronjob('Failed to create billing agreement for this order (listRecurringCall did not contain contract)');
$this->_adyenLogger->addAdyenNotificationCronjob(printf('recurringDetailReference in notification is %1', $recurringDetailReference));
$this->_adyenLogger->addAdyenNotificationCronjob(printf('CustomerReference is: %1 and storeId is %2', $customerReference, $storeId));
$this->_adyenLogger->addAdyenNotificationCronjob( $listRecurringContracts);
$message = __('Failed to create billing agreement for this order (listRecurringCall did not contain contract)');
}
$comment = $this->_order->addStatusHistoryComment($message);
$this->_order->addRelatedObject($comment);
$comment = $this->_order->addStatusHistoryComment($message);
$this->_order->addRelatedObject($comment);
}
}
break;
default:
$this->_debugData['_processNotification info'] = sprintf('This notification event: %s is not supported so will be ignored', $this->_eventCode);
$this->_adyenLogger->addAdyenNotificationCronjob(sprintf('This notification event: %s is not supported so will be ignored', $this->_eventCode));
break;
}
}
......@@ -723,57 +715,27 @@ class Cron
*/
protected function _refundOrder()
{
$this->_debugData['_refundOrder'] = 'Refunding the order';
// // Don't create a credit memo if refund is initialize in Magento because in this case the credit memo already exits
// $result = Mage::getModel('adyen/event')
// ->getEvent($this->_pspReference, '[refund-received]');
// if (!empty($result)) {
// $this->_debugData['_refundOrder ignore'] = 'Skip refund process because credit memo is already created';
// return false;
// }
//
// $_mail = (bool) $this->_getConfigData('send_update_mail', 'adyen_abstract', $order->getStoreId());
//
// $currency = $order->getOrderCurrencyCode(); // use orderCurrency because adyen respond in the same currency as in the request
// $amount = Mage::helper('adyen')->originalAmount($this->_value, $currency);
//
// if ($order->canCreditmemo()) {
// $service = Mage::getModel('sales/service_order', $order);
// $creditmemo = $service->prepareCreditmemo();
// $creditmemo->getOrder()->setIsInProcess(true);
//
// //set refund data on the order
// $creditmemo->setGrandTotal($amount);
// $creditmemo->setBaseGrandTotal($amount);
// $creditmemo->save();
//
// try {
// Mage::getModel('core/resource_transaction')
// ->addObject($creditmemo)
// ->addObject($creditmemo->getOrder())
// ->save();
// //refund
// $creditmemo->refund();
// $transactionSave = Mage::getModel('core/resource_transaction')
// ->addObject($creditmemo)
// ->addObject($creditmemo->getOrder());
// if ($creditmemo->getInvoice()) {
// $transactionSave->addObject($creditmemo->getInvoice());
// }
// $transactionSave->save();
// if ($_mail) {
// $creditmemo->getOrder()->setCustomerNoteNotify(true);
// $creditmemo->sendEmail();
// }
// $this->_debugData['_refundOrder done'] = 'Credit memo is created';
// } catch (Exception $e) {
// $this->_debugData['_refundOrder error'] = 'Error creating credit memo error message is: ' . $e->getMessage();
// Mage::logException($e);
// }
// } else {
// $this->_debugData['_refundOrder error'] = 'Order can not be refunded';
// }
$this->_adyenLogger->addAdyenNotificationCronjob('Refunding the order');
// Don't create a credit memo if refund is initialize in Magento because in this case the credit memo already exists
$lastTransactionId = $this->_order->getPayment()->getLastTransId();
if($lastTransactionId != $this->_pspReference) {
// refund is done through adyen backoffice so create an invoice
$order = $this->_order;
if ($order->canCreditmemo()) {
// there is a bug in this function of Magento see #2656 magento\magento2 repo
// $amount = $this->_adyenHelper->originalAmount($this->_value, $currency);
// $order->getPayment()->registerRefundNotification($amount);
$this->_adyenLogger->addAdyenNotificationCronjob('Please create your credit memo inside magentos');
} else {
$this->_adyenLogger->addAdyenNotificationCronjob('Could not create a credit memo for order');
}
} else {
$this->_adyenLogger->addAdyenNotificationCronjob('Did not create a credit memo for this order becasue refund is done through Magento');
}
}
/**
......@@ -781,7 +743,7 @@ class Cron
*/
protected function _setRefundAuthorized()
{
$this->_debugData['_setRefundAuthorized'] = 'Status update to default status or refund_authorized status if this is set';
$this->_adyenLogger->addAdyenNotificationCronjob('Status update to default status or refund_authorized status if this is set');
$this->_order->addStatusHistoryComment(__('Adyen Refund Successfully completed'));
}
......@@ -790,29 +752,26 @@ class Cron
*/
protected function _authorizePayment()
{
$this->_debugData['_authorizePayment'] = 'Authorisation of the order';
// $this->_uncancelOrder($order); // not implemented in magento v2.0
$this->_adyenLogger->addAdyenNotificationCronjob('Authorisation of the order');
$fraudManualReviewStatus = $this->_getFraudManualReviewStatus();
// If manual review is active and a seperate status is used then ignore the pre authorized status
if($this->_fraudManualReview != true || $fraudManualReviewStatus == "") {
$this->_setPrePaymentAuthorized();
} else {
$this->_debugData['_authorizePayment info'] = 'Ignore the pre authorized status because the order is under manual review and use the Manual review status';
$this->_adyenLogger->addAdyenNotificationCronjob('Ignore the pre authorized status because the order is under manual review and use the Manual review status');
}
$this->_prepareInvoice();
$_paymentCode = $this->_paymentMethodCode();
// for boleto confirmation mail is send on order creation
if($this->_paymentMethod != "adyen_boleto") {
// send order confirmation mail after invoice creation so merchant can add invoicePDF to this mail
// $this->_order->sendNewOrderEmail(); // send order email
$this->_orderSender->send($this->_order);
if(!$this->_order->getEmailSent()) {
$this->_orderSender->send($this->_order);
$this->_adyenLogger->addAdyenNotificationCronjob('Send orderconfirmation email to shopper');
}
}
if(($this->_paymentMethod == "c_cash" && $this->_getConfigData('create_shipment', 'adyen_cash', $this->_order->getStoreId())) || ($this->_getConfigData('create_shipment', 'adyen_pos', $this->_order->getStoreId()) && $_paymentCode == "adyen_pos"))
......@@ -828,9 +787,9 @@ class Cron
// only do this if status in configuration is set
if(!empty($status)) {
$this->_order->addStatusHistoryComment(__('Payment is authorised waiting for capture'), $status);
$this->_debugData['_setPrePaymentAuthorized'] = 'Order status is changed to Pre-authorised status, status is ' . $status;
$this->_adyenLogger->addAdyenNotificationCronjob('Order status is changed to Pre-authorised status, status is ' . $status);
} else {
$this->_debugData['_setPrePaymentAuthorized'] = 'No pre-authorised status is used so ignore';
$this->_adyenLogger->addAdyenNotificationCronjob('No pre-authorised status is used so ignore');
}
}
......@@ -839,7 +798,7 @@ class Cron
*/
protected function _prepareInvoice()
{
$this->_debugData['_prepareInvoice'] = 'Prepare invoice for order';
$this->_adyenLogger->addAdyenNotificationCronjob('Prepare invoice for order');
$payment = $this->_order->getPayment()->getMethodInstance();
......@@ -850,7 +809,7 @@ class Cron
//capture mode
if (!$this->_isAutoCapture()) {
$this->_order->addStatusHistoryComment(__('Capture Mode set to Manual'));
$this->_debugData['_prepareInvoice capture mode'] = 'Capture mode is set to Manual';
$this->_adyenLogger->addAdyenNotificationCronjob('Capture mode is set to Manual');
// show message if order is in manual review
if($this->_fraudManualReview) {
......@@ -865,7 +824,7 @@ class Cron
$createPendingInvoice = (bool) $this->_getConfigData('create_pending_invoice', 'adyen_abstract', $this->_order->getStoreId());
if(!$createPendingInvoice) {
$this->_debugData['_prepareInvoice done'] = 'Setting pending invoice is off so don\'t create an invoice wait for the capture notification';
$this->_adyenLogger->addAdyenNotificationCronjob('Setting pending invoice is off so don\'t create an invoice wait for the capture notification');
return;
}
}
......@@ -877,13 +836,13 @@ class Cron
if($this->_isTotalAmount($orderAmount)) {
$this->_createInvoice();
} else {
$this->_debugData['_prepareInvoice partial authorisation step1'] = 'This is a partial AUTHORISATION';
$this->_adyenLogger->addAdyenNotificationCronjob('This is a partial AUTHORISATION');
// Check if this is the first partial authorisation or if there is already been an authorisation
$paymentObj = $this->_order->getPayment();
$authorisationAmount = $paymentObj->getAdyenAuthorisationAmount();
if($authorisationAmount != "") {
$this->_debugData['_prepareInvoice partial authorisation step2'] = 'There is already a partial AUTHORISATION received check if this combined with the previous amounts match the total amount of the order';
$this->_adyenLogger->addAdyenNotificationCronjob('There is already a partial AUTHORISATION received check if this combined with the previous amounts match the total amount of the order');
$authorisationAmount = (int) $authorisationAmount;
$currentValue = (int) $this->_value;
$totalAuthorisationAmount = $authorisationAmount + $currentValue;
......@@ -892,14 +851,14 @@ class Cron
$paymentObj->setAdyenAuthorisationAmount($totalAuthorisationAmount);
if($totalAuthorisationAmount == $orderAmount) {
$this->_debugData['_prepareInvoice partial authorisation step3'] = 'The full amount is paid. This is the latest AUTHORISATION notification. Create the invoice';
$this->_adyenLogger->addAdyenNotificationCronjob('The full amount is paid. This is the latest AUTHORISATION notification. Create the invoice');
$this->_createInvoice();
} else {
// this can be multiple times so use envenData as unique key
$this->_debugData['_prepareInvoice partial authorisation step3'] = 'The full amount is not reached. Wait for the next AUTHORISATION notification. The current amount that is authorized is:' . $totalAuthorisationAmount;
$this->_adyenLogger->addAdyenNotificationCronjob('The full amount is not reached. Wait for the next AUTHORISATION notification. The current amount that is authorized is:' . $totalAuthorisationAmount);
}
} else {
$this->_debugData['_prepareInvoice partial authorisation step2'] = 'This is the first partial AUTHORISATION save this into the adyen_authorisation_amount field';
$this->_adyenLogger->addAdyenNotificationCronjob('This is the first partial AUTHORISATION save this into the adyen_authorisation_amount field');
$paymentObj->setAdyenAuthorisationAmount($this->_value);
}
}
......@@ -915,44 +874,54 @@ class Cron
if($this->_manualCaptureAllowed())
{
$captureMode = trim($this->_getConfigData('capture_mode', 'adyen_abstract', $this->_order->getStoreId()));
$sepaFlow = trim($this->_getConfigData('flow', 'adyen_sepa', $this->_order->getStoreId()));
$sepaFlow = trim($this->_getConfigData('sepa_flow', 'adyen_abstract', $this->_order->getStoreId()));
$_paymentCode = $this->_paymentMethodCode();
$captureModeOpenInvoice = $this->_getConfigData('auto_capture_openinvoice', 'adyen_abstract', $this->_order->getStoreId());
$captureModePayPal = trim($this->_getConfigData('paypal_capture_mode', 'adyen_abstract', $this->_order->getStoreId()));
// if you are using authcap the payment method is manual. There will be a capture send to indicate if payment is succesfull
if($_paymentCode == "adyen_sepa" && $sepaFlow == "authcap") {
if(($_paymentCode == "adyen_sepa" || $this->_paymentMethod == "sepadirectdebit") && $sepaFlow == "authcap") {
$this->_adyenLogger->addAdyenNotificationCronjob('Manual Capture is applied for sepa because it is in authcap flow');
return false;
}
// payment method ideal, cash adyen_boleto or adyen_pos has direct capture
if ($_paymentCode == "adyen_pos" || ($_paymentCode == "adyen_sepa" && $sepaFlow != "authcap")) {
if ($_paymentCode == "adyen_pos" || (($_paymentCode == "adyen_sepa" || $this->_paymentMethod == "sepadirectdebit") && $sepaFlow != "authcap")) {
$this->_adyenLogger->addAdyenNotificationCronjob('This payment method does not allow manual capture.(2) paymentCode:' . $_paymentCode . ' paymentMethod:' . $this->_paymentMethod);
return true;
}
// if auto capture mode for openinvoice is turned on then use auto capture
if ($captureModeOpenInvoice == true && (strcmp($this->_paymentMethod, 'openinvoice') === 0 || strcmp($this->_paymentMethod, 'afterpay_default') === 0 || strcmp($this->_paymentMethod, 'klarna') === 0)) {
$this->_adyenLogger->addAdyenNotificationCronjob('This payment method is configured to be working as auto capture ');
return true;
}
// if PayPal capture modues is different from the default use this one
if(strcmp($this->_paymentMethod, 'paypal' ) === 0 && $captureModePayPal != "") {
if(strcmp($captureModePayPal, 'auto') === 0 ) {
$this->_adyenLogger->addAdyenNotificationCronjob('This payment method is paypal and configured to work as auto capture');
return true;
} elseif(strcmp($captureModePayPal, 'manual') === 0 ) {
$this->_adyenLogger->addAdyenNotificationCronjob('This payment method is paypal and configured to work as manual capture');
return false;
}
}
if (strcmp($captureMode, 'manual') === 0) {
$this->_adyenLogger->addAdyenNotificationCronjob('Capture mode for this payment is set to manual');
return false;
}
//online capture after delivery, use Magento backend to online invoice (if the option auto capture mode for openinvoice is not set)
if (strcmp($this->_paymentMethod, 'openinvoice') === 0 || strcmp($this->_paymentMethod, 'afterpay_default') === 0 || strcmp($this->_paymentMethod, 'klarna') === 0) {
$this->_adyenLogger->addAdyenNotificationCronjob('Capture mode for klarna is by default set to manual');
return false;
}
$this->_adyenLogger->addAdyenNotificationCronjob('Capture mode is set to auto capture');
return true;
} else {
// does not allow manual capture so is always immediate capture
$this->_adyenLogger->addAdyenNotificationCronjob('This payment method does not allow manual capture');
return true;
}
......@@ -1024,14 +993,14 @@ class Cron
protected function _isTotalAmount($orderAmount) {
$this->_debugData['_isTotalAmount'] = 'Validate if AUTHORISATION notification has the total amount of the order';
$this->_adyenLogger->addAdyenNotificationCronjob('Validate if AUTHORISATION notification has the total amount of the order');
$value = (int)$this->_value;
if($value == $orderAmount) {
$this->_debugData['_isTotalAmount result'] = 'AUTHORISATION has the full amount';
$this->_adyenLogger->addAdyenNotificationCronjob('AUTHORISATION has the full amount');
return true;
} else {
$this->_debugData['_isTotalAmount result'] = 'This is a partial AUTHORISATION, the amount is ' . $this->_value;
$this->_adyenLogger->addAdyenNotificationCronjob('This is a partial AUTHORISATION, the amount is ' . $this->_value);
return false;
}
......@@ -1039,7 +1008,7 @@ class Cron
protected function _createInvoice()
{
$this->_debugData['_createInvoice'] = 'Creating invoice for order';
$this->_adyenLogger->addAdyenNotificationCronjob('Creating invoice for order');
if ($this->_order->canInvoice()) {
......@@ -1053,6 +1022,7 @@ class Cron
// set transaction id so you can do a online refund from credit memo
$invoice->setTransactionId($this->_pspReference);
$autoCapture = $this->_isAutoCapture();
$createPendingInvoice = (bool) $this->_getConfigData('create_pending_invoice', 'adyen_abstract', $this->_order->getStoreId());
......@@ -1073,9 +1043,9 @@ class Cron
$invoice->save();
$this->_debugData['_createInvoice done'] = 'Created invoice';
$this->_adyenLogger->addAdyenNotificationCronjob('Created invoice');
} catch (Exception $e) {
$this->_debugData['_createInvoice error'] = 'Error saving invoice. The error message is: ' . $e->getMessage();
$this->_adyenLogger->addAdyenNotificationCronjob('Error saving invoice. The error message is: ' . $e->getMessage());
throw new Exception(sprintf('Error saving invoice. The error message is:', $e->getMessage()));
}
......@@ -1086,7 +1056,7 @@ class Cron
$invoice->sendEmail();
}
} else {
$this->_debugData['_createInvoice error'] = 'It is not possible to create invoice for this order';
$this->_adyenLogger->addAdyenNotificationCronjob('It is not possible to create invoice for this order');
}
}
......@@ -1095,7 +1065,7 @@ class Cron
*/
protected function _setPaymentAuthorized($manualReviewComment = true, $createInvoice = false)
{
$this->_debugData['_setPaymentAuthorized start'] = 'Set order to authorised';
$this->_adyenLogger->addAdyenNotificationCronjob('Set order to authorised');
// if full amount is captured create invoice
$currency = $this->_order->getOrderCurrencyCode();
......@@ -1104,7 +1074,7 @@ class Cron
// create invoice for the capture notification if you are on manual capture
if($createInvoice == true && $amount == $orderAmount) {
$this->_debugData['_setPaymentAuthorized amount'] = 'amount notification:'.$amount . ' amount order:'.$orderAmount;
$this->_adyenLogger->addAdyenNotificationCronjob('amount notification:'.$amount . ' amount order:'.$orderAmount);
$this->_createInvoice();
}
......@@ -1116,7 +1086,7 @@ class Cron
// virtual order can have different status
if($this->_order->getIsVirtual()) {
$this->_debugData['_setPaymentAuthorized virtual'] = 'Product is a virtual product';
$this->_adyenLogger->addAdyenNotificationCronjob('Product is a virtual product');
$virtual_status = $this->_getConfigData('payment_authorized_virtual');
if($virtual_status != "") {
$status = $virtual_status;
......@@ -1166,14 +1136,14 @@ class Cron
$status = (!empty($status)) ? $status : $this->_order->getStatus();
$this->_order->addStatusHistoryComment(__($comment), $status);
$this->_debugData['_setPaymentAuthorized end'] = 'Order status is changed to authorised status, status is ' . $status;
$this->_adyenLogger->addAdyenNotificationCronjob('Order status is changed to authorised status, status is ' . $status);
}
/**
*
*/
protected function _createShipment() {
$this->_debugData['_createShipment'] = 'Creating shipment for order';
$this->_adyenLogger->addAdyenNotificationCronjob('Creating shipment for order');
// create shipment for cash payment
$payment = $this->_order->getPayment()->getMethodInstance();
if($this->_order->canShip())
......@@ -1192,10 +1162,10 @@ class Cron
->addObject($shipment->getOrder())
->save();
$this->_debugData['_createShipment done'] = 'Order is shipped';
$this->_adyenLogger->addAdyenNotificationCronjob('Order is shipped');
}
} else {
$this->_debugData['_createShipment error'] = 'Order can\'t be shipped';
$this->_adyenLogger->addAdyenNotificationCronjob('Order can\'t be shipped');
}
}
......
......@@ -27,7 +27,7 @@ class RecurringType {
CONST NONE = '';
const ONECLICK = 'ONECLICK';
const ONECLICK_RECURRING = 'ONECLICK_RECURRING';
const ONECLICK_RECURRING = 'ONECLICK,RECURRING';
const RECURRING = 'RECURRING';
protected $_allowedRecurringTypesForListRecurringCall = [
......
......@@ -8,7 +8,7 @@ composer require adyen/module-payment
<a href="https://docs.adyen.com/manuals/magento/magento2-integration" target="_blank">https://docs.adyen.com/manuals/magento/magento2-integration</a>
## Setup Cron ##
Make sure that your magento cron is running every minute. We are using a cronjob to process the notifications. The cronjob will be executed every minute. It only executes the notifications that have been received at least 2 minutes ago. We have built in this 2 minutes so we are sure Magento has created the order and all save after events are executed. A handy tool to get inside into your cronjobs is AOE scheduler. You can download this tool through Magento Connect or GitHub
Make sure that your magento cron is running every minute. We are using a cronjob to process the notifications. The cronjob will be executed every minute. It only executes the notifications that have been received at least 2 minutes ago. We have built in this 2 minutes so we are sure Magento has created the order and all save after events are executed. A handy tool to get insight into your cronjobs is AOE scheduler. You can download this tool through Magento Connect or GitHub
## Support ##
You can create issues on our Magento Repository or if you have some specific problems for your account you can contact magento@adyen.com as well.
......
......@@ -2,7 +2,7 @@
"name": "adyen/module-payment",
"description": "Official Magento2 Plugin to connect to Payment Service Provider Adyen.",
"type": "magento2-module",
"version": "1.2.0",
"version": "1.2.1",
"license": [
"OSL-3.0",
"AFL-3.0"
......
......@@ -56,5 +56,11 @@
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/adyen_abstract/send_email_bank_sepa_on_pending</config_path>
</field>
<field id="sepa_flow" translate="label" type="select" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Sepa Payment flow</label>
<tooltip>If you are not sure just leave it at 'Sale’. Sale means it is always immidiate capture with auth/cap it will follow the Capture Delay. If you want to enable 'Auth/Capt' for SEPA Direct Debit, please contact support@adyen.com</tooltip>
<source_model>Adyen\Payment\Model\Config\Source\SepaFlow</source_model>
<config_path>payment/adyen_abstract/sepa_flow</config_path>
</field>
</group>
</include>
\ No newline at end of file
......@@ -32,7 +32,7 @@
<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/adyen/adyen-magento2/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> In the test modus you need 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>
......@@ -41,4 +41,4 @@
<frontend_model>\Adyen\Payment\Block\Adminhtml\System\Config\Field\Version</frontend_model>
</field>
</group>
</include>
\ No newline at end of file
</include>
......@@ -33,6 +33,7 @@
<demo_mode>0</demo_mode>
<debug>1</debug>
<title_renderer>title_image</title_renderer>
<sepa_flow>sale</sepa_flow>
<group>adyen</group>
</adyen_abstract>
<adyen_cc>
......
......@@ -24,7 +24,7 @@
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Adyen_Payment" setup_version="1.2.0">
<module name="Adyen_Payment" setup_version="1.2.1">
<sequence>
<module name="Magento_Sales"/>
<module name="Magento_Quote"/>
......
......@@ -50,8 +50,6 @@ define(
.observe([
'recurringDetailReference',
'creditCardType',
'creditCardExpYear',
'creditCardExpMonth',
'creditCardVerificationNumber',
'encryptedData'
]);
......@@ -100,8 +98,8 @@ define(
var cardData = {
cvc : self.creditCardVerificationNumber,
expiryMonth : self.creditCardExpMonth,
expiryYear : self.creditCardExpYear,
expiryMonth : self.creditCardExpMonth(),
expiryYear : self.creditCardExpYear(),
generationtime : generationtime
};
......@@ -118,7 +116,6 @@ define(
}
};
if (this.validate() && additionalValidators.validate()) {
//this.isPlaceOrderActionAllowed(false);
placeOrder = placeOrderAction(data, this.redirectAfterPlaceOrder);
......@@ -150,6 +147,11 @@ define(
// convert to list so you can iterate
var paymentList = _.map(window.checkoutConfig.payment.adyenOneclick.billingAgreements, function(value) {
var creditCardExpMonth, creditCardExpYear = false;
if(value.agreement_data.card) {
creditCardExpMonth = value.agreement_data.card.expiryMonth
creditCardExpYear = value.agreement_data.card.expiryYear;
}
return {
'expiry': ko.observable(false),
......@@ -164,8 +166,8 @@ define(
return self.item.method;
},
creditCardVerificationNumber: '',
creditCardExpMonth: value.agreement_data.card.expiryMonth,
creditCardExpYear: value.agreement_data.card.expiryYear,
creditCardExpMonth: ko.observable(creditCardExpMonth),
creditCardExpYear: ko.observable(creditCardExpYear),
getCSEKey: function() {
return window.checkoutConfig.payment.adyenCc.cseKey;
},
......@@ -183,10 +185,15 @@ define(
var validate = $(form).validation() && $(form).validation('isValid');
// add extra validation because jqeury validation will not work on non name attributes
var expiration = Boolean($(form + ' #' + codeValue + '_expiration').valid());
var expiration_yr = Boolean($(form + ' #' + codeValue + '_expiration_yr').valid());
// if oneclick or recurring is a card do validation on expiration date
if(this.agreement_data.card) {
// add extra validation because jqeury validation will not work on non name attributes
var expiration = Boolean($(form + ' #' + codeValue + '_expiration').valid());
var expiration_yr = Boolean($(form + ' #' + codeValue + '_expiration_yr').valid());
} else {
var expiration = true;
var expiration_yr = true;
}
// only check if recurring type is set to oneclick
var cid = true;
......
......@@ -67,14 +67,14 @@
<fieldset data-bind="attr: {class: 'fieldset payment items ccard ' + getCode(), id: 'payment_form_' + $parent.getCode() + '_' + value}">
<!-- ko if: agreement_data.card.number -->
<!-- ko if: agreement_data.card -->
<div class="field number">
<label class="label">
<span><!-- ko text: $t('Credit Card Number')--><!-- /ko --></span>
</label>
<div class="control">
<span data-bind="text: '**** **** ****' + agreement_data.card.number"></span>
<span data-bind="text: '**** **** **** ' + agreement_data.card.number"></span>
</div>
</div>
......@@ -163,7 +163,43 @@
</div>
</div>
<!-- /ko -->
<!--/ko-->
<!--/ko-->
<!-- ko if: agreement_data.bank -->
<div class="field number">
<label class="label">
<span><!-- ko text: $t('Bank account holder name')--><!-- /ko --></span>
</label>
<div class="control">
<span data-bind="text: agreement_data.bank.ownerName"></span>
</div>
</div>
<div class="field number">
<label class="label">
<span><!-- ko text: $t('Iban')--><!-- /ko --></span>
</label>
<div class="control">
<span data-bind="text: agreement_data.bank.iban"></span>
</div>
</div>
<div class="field number">
<label class="label">
<span><!-- ko text: $t('Country')--><!-- /ko --></span>
</label>
<div class="control">
<span data-bind="text: agreement_data.bank.countryCode"></span>
</div>
</div>
<!--/ko-->
</fieldset>
<div class="checkout-agreements-block">
<!-- ko foreach: $parents[1].getRegion('before-place-order') -->
......
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