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,8 +188,16 @@ class AdyenOneclickConfigProvider extends CcGenericConfigProvider
foreach ($baCollection as $billingAgreement) {
$agreementData = $billingAgreement->getAgreementData();
// check if AgreementLabel is set and if contract has an recurringType
// 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(),
......@@ -197,7 +205,14 @@ class AdyenOneclickConfigProvider extends CcGenericConfigProvider
];
if($this->_genericConfig->showLogos()) {
$asset = $this->_genericConfig->createAsset('Adyen_Payment::images/logos/' . $agreementData['variant'] . '.png');
$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;
......@@ -217,6 +232,7 @@ class AdyenOneclickConfigProvider extends CcGenericConfigProvider
}
}
}
}
return $billingAgreements;
}
......
......@@ -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.
......@@ -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>
......
......@@ -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');
// 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>
......@@ -164,6 +164,42 @@
</div>
<!-- /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