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
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
This diff is collapsed.
......@@ -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
......@@ -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>
......
......@@ -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