We will work on Apr 26th (Saturday) and will be off from Apr 30th (Wednesday) until May 2nd (Friday) for public holiday in our country

Commit 64aacc5e authored by rikterbeek's avatar rikterbeek

#561 OneCLick fix for alternative payment methods and guest checkout and...

#561 OneCLick fix for alternative payment methods and guest checkout and option to set the sepa flow default is sale
parent 33e400e0
<?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
...@@ -144,9 +144,10 @@ class AdyenOneclickConfigProvider extends CcGenericConfigProvider ...@@ -144,9 +144,10 @@ class AdyenOneclickConfigProvider extends CcGenericConfigProvider
foreach ($this->methodCodes as $code) { foreach ($this->methodCodes as $code) {
if ($this->methods[$code]->isAvailable()) { if ($this->methods[$code]->isAvailable()) {
$config['payment'] ['adyenOneclick']['billingAgreements'] = $this->getAdyenOneclickPaymentMethods();
$recurringContractType = $this->_getRecurringContractType(); $recurringContractType = $this->_getRecurringContractType();
$config['payment'] ['adyenOneclick']['billingAgreements'] = $this->getAdyenOneclickPaymentMethods();
$config['payment'] ['adyenOneclick']['recurringContractType'] = $recurringContractType; $config['payment'] ['adyenOneclick']['recurringContractType'] = $recurringContractType;
if($recurringContractType == \Adyen\Payment\Model\RecurringType::ONECLICK) { if($recurringContractType == \Adyen\Payment\Model\RecurringType::ONECLICK) {
$config['payment'] ['adyenOneclick']['hasCustomerInteraction'] = true; $config['payment'] ['adyenOneclick']['hasCustomerInteraction'] = true;
...@@ -155,7 +156,6 @@ class AdyenOneclickConfigProvider extends CcGenericConfigProvider ...@@ -155,7 +156,6 @@ class AdyenOneclickConfigProvider extends CcGenericConfigProvider
} }
} }
} }
return $config; return $config;
} }
...@@ -188,32 +188,48 @@ class AdyenOneclickConfigProvider extends CcGenericConfigProvider ...@@ -188,32 +188,48 @@ class AdyenOneclickConfigProvider extends CcGenericConfigProvider
foreach ($baCollection as $billingAgreement) { foreach ($baCollection as $billingAgreement) {
$agreementData = $billingAgreement->getAgreementData(); $agreementData = $billingAgreement->getAgreementData();
// check if AgreementLabel is set and if contract has an recurringType
// no agreementData and contractType then ignore
if($billingAgreement->getAgreementLabel()) { if((!is_array($agreementData)) || (!isset($agreementData['contractTypes']))) {
$data = ['reference_id' => $billingAgreement->getReferenceId(), continue;
'agreement_label' => $billingAgreement->getAgreementLabel(), }
'agreement_data' => $agreementData
]; // check if contractType is supporting the selected contractType for OneClick payments
$allowedContractTypes = $agreementData['contractTypes'];
if($this->_genericConfig->showLogos()) { if(in_array($recurringPaymentType, $allowedContractTypes)) {
$asset = $this->_genericConfig->createAsset('Adyen_Payment::images/logos/' . $agreementData['variant'] . '.png'); // check if AgreementLabel is set and if contract has an recurringType
$placeholder = $this->_genericConfig->findRelativeSourceFilePath($asset); if($billingAgreement->getAgreementLabel()) {
$data = ['reference_id' => $billingAgreement->getReferenceId(),
$icon = null; 'agreement_label' => $billingAgreement->getAgreementLabel(),
if ($placeholder) { 'agreement_data' => $agreementData
list($width, $height) = getimagesize($asset->getSourceFile()); ];
$icon = [
'url' => $asset->getUrl(), if($this->_genericConfig->showLogos()) {
'width' => $width,
'height' => $height $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 ...@@ -170,11 +170,6 @@ class PaymentRequest extends DataObject
$request['recurring'] = $recurring; $request['recurring'] = $recurring;
} }
$this->_adyenLogger->error('storeCC?:' . $payment->getAdditionalInformation("store_cc"));
$this->_adyenLogger->error('recuringtype' . $recurringType);
$this->_adyenLogger->error('recurringcontractType' . $recurringContractType);
$billingAddress = $order->getBillingAddress(); $billingAddress = $order->getBillingAddress();
if($billingAddress) if($billingAddress)
...@@ -234,7 +229,7 @@ class PaymentRequest extends DataObject ...@@ -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 // 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->getAdditionalInformation('customer_interaction')) {
if($payment->getCcType() == "directEbanking" || $payment->getCcType() == "ideal") { if($payment->getCcType() == "directEbanking" || $payment->getCcType() == "ideal") {
$this->selectedBrand = "sepadirectdebit"; $request['selectedBrand'] = "sepadirectdebit";
} }
} }
} else { } else {
...@@ -333,10 +328,14 @@ class PaymentRequest extends DataObject ...@@ -333,10 +328,14 @@ class PaymentRequest extends DataObject
throw new \Magento\Framework\Exception\LocalizedException(__('The capture action failed')); 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 // set pspReference as TransactionId so you can do an online refund
if(isset($result['pspReference'])) { if(isset($result['pspReference'])) {
$payment->setTransactionId($result['pspReference']) $payment->setTransactionId($result['pspReference'])
->setIsTransactionClosed(false); ->setIsTransactionClosed(false)
->setParentTransactionId($payment->getAdditionalInformation('pspReference'));
} }
return $result; return $result;
...@@ -369,6 +368,14 @@ class PaymentRequest extends DataObject ...@@ -369,6 +368,14 @@ class PaymentRequest extends DataObject
throw new \Magento\Framework\Exception\LocalizedException(__('The refund action failed')); 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; return $result;
} }
...@@ -407,6 +414,13 @@ class PaymentRequest extends DataObject ...@@ -407,6 +414,13 @@ class PaymentRequest extends DataObject
throw new \Magento\Framework\Exception\LocalizedException(__('The refund action failed')); 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; return $result;
} }
...@@ -440,7 +454,9 @@ class PaymentRequest extends DataObject ...@@ -440,7 +454,9 @@ class PaymentRequest extends DataObject
} }
} }
} catch (\Exception $exception) { } catch (\Exception $exception) {
print_r($exception); // log exception
$this->_adyenLogger->addError($exception);
throw($exception);
} }
} }
return $recurringContracts; return $recurringContracts;
......
...@@ -80,10 +80,10 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement ...@@ -80,10 +80,10 @@ class Agreement extends \Magento\Paypal\Model\Billing\Agreement
$this->setCreatedAt($creationDate); $this->setCreatedAt($creationDate);
//Billing agreement SEPA //Billing agreement SEPA
if (isset($data['bank_iban'])) { if (isset($data['bank']['iban'])) {
$this->setAgreementLabel(__('%1, %2', $this->setAgreementLabel(__('%1, %2',
$data['bank_iban'], $data['bank']['iban'],
$data['bank_ownerName'] $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
This diff is collapsed.
...@@ -56,5 +56,11 @@ ...@@ -56,5 +56,11 @@
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model> <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/adyen_abstract/send_email_bank_sepa_on_pending</config_path> <config_path>payment/adyen_abstract/send_email_bank_sepa_on_pending</config_path>
</field> </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> </group>
</include> </include>
\ No newline at end of file
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
<demo_mode>0</demo_mode> <demo_mode>0</demo_mode>
<debug>1</debug> <debug>1</debug>
<title_renderer>title_image</title_renderer> <title_renderer>title_image</title_renderer>
<sepa_flow>sale</sepa_flow>
<group>adyen</group> <group>adyen</group>
</adyen_abstract> </adyen_abstract>
<adyen_cc> <adyen_cc>
......
...@@ -50,8 +50,6 @@ define( ...@@ -50,8 +50,6 @@ define(
.observe([ .observe([
'recurringDetailReference', 'recurringDetailReference',
'creditCardType', 'creditCardType',
'creditCardExpYear',
'creditCardExpMonth',
'creditCardVerificationNumber', 'creditCardVerificationNumber',
'encryptedData' 'encryptedData'
]); ]);
...@@ -100,8 +98,8 @@ define( ...@@ -100,8 +98,8 @@ define(
var cardData = { var cardData = {
cvc : self.creditCardVerificationNumber, cvc : self.creditCardVerificationNumber,
expiryMonth : self.creditCardExpMonth, expiryMonth : self.creditCardExpMonth(),
expiryYear : self.creditCardExpYear, expiryYear : self.creditCardExpYear(),
generationtime : generationtime generationtime : generationtime
}; };
...@@ -118,7 +116,6 @@ define( ...@@ -118,7 +116,6 @@ define(
} }
}; };
if (this.validate() && additionalValidators.validate()) { if (this.validate() && additionalValidators.validate()) {
//this.isPlaceOrderActionAllowed(false); //this.isPlaceOrderActionAllowed(false);
placeOrder = placeOrderAction(data, this.redirectAfterPlaceOrder); placeOrder = placeOrderAction(data, this.redirectAfterPlaceOrder);
...@@ -150,6 +147,11 @@ define( ...@@ -150,6 +147,11 @@ define(
// convert to list so you can iterate // convert to list so you can iterate
var paymentList = _.map(window.checkoutConfig.payment.adyenOneclick.billingAgreements, function(value) { 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 { return {
'expiry': ko.observable(false), 'expiry': ko.observable(false),
...@@ -164,8 +166,8 @@ define( ...@@ -164,8 +166,8 @@ define(
return self.item.method; return self.item.method;
}, },
creditCardVerificationNumber: '', creditCardVerificationNumber: '',
creditCardExpMonth: value.agreement_data.card.expiryMonth, creditCardExpMonth: ko.observable(creditCardExpMonth),
creditCardExpYear: value.agreement_data.card.expiryYear, creditCardExpYear: ko.observable(creditCardExpYear),
getCSEKey: function() { getCSEKey: function() {
return window.checkoutConfig.payment.adyenCc.cseKey; return window.checkoutConfig.payment.adyenCc.cseKey;
}, },
...@@ -183,10 +185,15 @@ define( ...@@ -183,10 +185,15 @@ define(
var validate = $(form).validation() && $(form).validation('isValid'); var validate = $(form).validation() && $(form).validation('isValid');
// add extra validation because jqeury validation will not work on non name attributes // if oneclick or recurring is a card do validation on expiration date
var expiration = Boolean($(form + ' #' + codeValue + '_expiration').valid()); if(this.agreement_data.card) {
var expiration_yr = Boolean($(form + ' #' + codeValue + '_expiration_yr').valid()); // 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 // only check if recurring type is set to oneclick
var cid = true; var cid = true;
......
...@@ -67,14 +67,14 @@ ...@@ -67,14 +67,14 @@
<fieldset data-bind="attr: {class: 'fieldset payment items ccard ' + getCode(), id: 'payment_form_' + $parent.getCode() + '_' + value}"> <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"> <div class="field number">
<label class="label"> <label class="label">
<span><!-- ko text: $t('Credit Card Number')--><!-- /ko --></span> <span><!-- ko text: $t('Credit Card Number')--><!-- /ko --></span>
</label> </label>
<div class="control"> <div class="control">
<span data-bind="text: '**** **** ****' + agreement_data.card.number"></span> <span data-bind="text: '**** **** **** ' + agreement_data.card.number"></span>
</div> </div>
</div> </div>
...@@ -163,7 +163,43 @@ ...@@ -163,7 +163,43 @@
</div> </div>
</div> </div>
<!-- /ko --> <!-- /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> </fieldset>
<div class="checkout-agreements-block"> <div class="checkout-agreements-block">
<!-- ko foreach: $parents[1].getRegion('before-place-order') --> <!-- 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