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

Merge pull request #46 from Adyen/develop

Merge branch 'develop'
parents ea6820f2 4ebc77df
<?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\Api;
/**
* Interface GuestAdyenPaymentMethodManagementInterface
* @api
* @package Adyen\Payment\Api
*/
interface AdyenPaymentMethodManagementInterface
{
/**
* Get payment information
*
* @param string $cartId
* @return \Magento\Checkout\Api\Data\PaymentDetailsInterface
*/
public function getPaymentMethods($cartId, \Magento\Quote\Api\Data\AddressInterface $shippingAddress);
}
<?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\Api;
/**
* Interface GuestAdyenPaymentMethodManagementInterface
* @api
* @package Adyen\Payment\Api
*/
interface GuestAdyenPaymentMethodManagementInterface
{
/**
* Get payment information
*
* @param string $cartId
* @return \Magento\Checkout\Api\Data\PaymentDetailsInterface
*/
public function getPaymentMethods($cartId, \Magento\Quote\Api\Data\AddressInterface $shippingAddress);
}
......@@ -229,7 +229,7 @@ class Data extends AbstractHelper
$streetName = $street['0'];
unset($street['0']);
$streetNr = implode(' ', $street);
return (['name' => $streetName, 'house_number' => $streetNr]);
return (['name' => trim($streetName), 'house_number' => $streetNr]);
}
/**
......
This diff is collapsed.
This diff is collapsed.
<?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;
class AdyenPaymentMethodManagement implements \Adyen\Payment\Api\AdyenPaymentMethodManagementInterface
{
/**
* @var \Adyen\Payment\Helper\PaymentMethods
*/
protected $_paymentMethodsHelper;
/**
* AdyenPaymentMethodManagement constructor.
*
* @param \Adyen\Payment\Helper\PaymentMethods $paymentMethodsHelper
*/
public function __construct(
\Adyen\Payment\Helper\PaymentMethods $paymentMethodsHelper
) {
$this->_paymentMethodsHelper = $paymentMethodsHelper;
}
/**
* {@inheritDoc}
*/
public function getPaymentMethods($cartId, \Magento\Quote\Api\Data\AddressInterface $shippingAddress = null)
{
// if shippingAddress is provided use this country
$country = null;
if ($shippingAddress) {
$country = $shippingAddress->getCountryId();
}
return $this->_paymentMethodsHelper->getPaymentMethods($cartId, $country);
}
}
\ No newline at end of file
......@@ -262,7 +262,7 @@ class PaymentRequest extends DataObject
if ($paymentMethodCode == \Adyen\Payment\Model\Method\Cc::METHOD_CODE ||
$paymentMethodCode == \Adyen\Payment\Model\Method\Oneclick::METHOD_CODE) {
// If cse is enabled add encrypted card date into request
if ($this->_adyenHelper->getAdyenCcConfigDataFlag('cse_enabled')) {
if ($this->_adyenHelper->getAdyenCcConfigDataFlag('cse_enabled', $storeId)) {
$request['additionalData']['card.encrypted.json'] =
$payment->getAdditionalInformation("encrypted_data");
} else {
......@@ -303,7 +303,8 @@ class PaymentRequest extends DataObject
public function authorise3d($payment)
{
$order = $payment->getOrder();
$merchantAccount = $this->_adyenHelper->getAdyenAbstractConfigData("merchant_account");
$storeId = $order->getStoreId();
$merchantAccount = $this->_adyenHelper->getAdyenAbstractConfigData("merchant_account", $storeId);
$shopperIp = $order->getRemoteIp();
$md = $payment->getAdditionalInformation('md');
......@@ -338,8 +339,9 @@ class PaymentRequest extends DataObject
*/
public function capture(\Magento\Payment\Model\InfoInterface $payment, $amount)
{
$storeId = $payment->getOrder()->getStoreId();
$pspReference = $this->_getPspReference($payment);
$merchantAccount = $this->_adyenHelper->getAdyenAbstractConfigData("merchant_account");
$merchantAccount = $this->_adyenHelper->getAdyenAbstractConfigData("merchant_account", $storeId);
$currency = $payment->getOrder()->getBaseCurrencyCode();
//format the amount to minor units
......@@ -385,8 +387,9 @@ class PaymentRequest extends DataObject
*/
public function cancelOrRefund(\Magento\Payment\Model\InfoInterface $payment)
{
$storeId = $payment->getOrder()->getStoreId();
$pspReference = $this->_getPspReference($payment);
$merchantAccount = $this->_adyenHelper->getAdyenAbstractConfigData("merchant_account");
$merchantAccount = $this->_adyenHelper->getAdyenAbstractConfigData("merchant_account", $storeId);
$request = [
"merchantAccount" => $merchantAccount,
......@@ -424,8 +427,9 @@ class PaymentRequest extends DataObject
*/
public function refund(\Magento\Payment\Model\InfoInterface $payment, $amount)
{
$storeId = $payment->getOrder()->getStoreId();
$pspReference = $this->_getPspReference($payment);
$merchantAccount = $this->_adyenHelper->getAdyenAbstractConfigData("merchant_account");
$merchantAccount = $this->_adyenHelper->getAdyenAbstractConfigData("merchant_account", $storeId);
$currency = $payment->getOrder()->getBaseCurrencyCode();
//format the amount to minor units
......@@ -536,12 +540,13 @@ class PaymentRequest extends DataObject
*
* @param $recurringDetailReference
* @param $shopperReference
* @param $storeId
* @return bool
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function disableRecurringContract($recurringDetailReference, $shopperReference)
public function disableRecurringContract($recurringDetailReference, $shopperReference, $storeId)
{
$merchantAccount = $this->_adyenHelper->getAdyenAbstractConfigData("merchant_account");
$merchantAccount = $this->_adyenHelper->getAdyenAbstractConfigData("merchant_account", $storeId);
$request = [
"merchantAccount" => $merchantAccount,
......
<?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;
class GuestAdyenPaymentMethodManagement implements \Adyen\Payment\Api\GuestAdyenPaymentMethodManagementInterface
{
/**
* @var \Magento\Quote\Model\QuoteIdMaskFactory
*/
protected $_quoteIdMaskFactory;
/**
* @var \Adyen\Payment\Helper\PaymentMethods
*/
protected $_paymentMethodsHelper;
/**
* GuestAdyenPaymentMethodManagement constructor.
*
* @param \Magento\Quote\Model\QuoteIdMaskFactory $quoteIdMaskFactory
* @param \Adyen\Payment\Helper\PaymentMethods $paymentMethodsHelper
*/
public function __construct(
\Magento\Quote\Model\QuoteIdMaskFactory $quoteIdMaskFactory,
\Adyen\Payment\Helper\PaymentMethods $paymentMethodsHelper
) {
$this->_quoteIdMaskFactory = $quoteIdMaskFactory;
$this->_paymentMethodsHelper = $paymentMethodsHelper;
}
/**
* {@inheritDoc}
*/
public function getPaymentMethods($cartId, \Magento\Quote\Api\Data\AddressInterface $shippingAddress = null)
{
$quoteIdMask = $this->_quoteIdMaskFactory->create()->load($cartId, 'masked_id');
$quoteId = $quoteIdMask->getQuoteId();
// if shippingAddress is provided use this country
$country = null;
if ($shippingAddress) {
$country = $shippingAddress->getCountryId();
}
return $this->_paymentMethodsHelper->getPaymentMethods($quoteId, $country);
}
}
\ No newline at end of file
......@@ -108,7 +108,8 @@ class Oneclick extends \Adyen\Payment\Model\Method\Cc
try {
$this->_paymentRequest->disableRecurringContract(
$agreement->getReferenceId(),
$agreement->getCustomerReference()
$agreement->getCustomerReference(),
$agreement->getStoreId()
);
} catch(Exception $e) {
throw new \Magento\Framework\Exception\LocalizedException(__('Failed to disable this contract'));
......
......@@ -87,4 +87,6 @@
<argument name="dataStorage" xsi:type="object">adyenPaymentConfigDataStorage</argument>
</arguments>
</type>
<preference for="Adyen\Payment\Api\GuestAdyenPaymentMethodManagementInterface" type="Adyen\Payment\Model\GuestAdyenPaymentMethodManagement" />
<preference for="Adyen\Payment\Api\AdyenPaymentMethodManagementInterface" type="Adyen\Payment\Model\AdyenPaymentMethodManagement" />
</config>
\ No newline at end of file
<?xml version="1.0"?>
<!--
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* 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>
*/
-->
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Webapi:etc/webapi.xsd">
<route url="/V1/guest-carts/:cartId/retrieve-adyen-payment-methods" method="POST">
<service class="Adyen\Payment\Api\GuestAdyenPaymentMethodManagementInterface" method="getPaymentMethods"/>
<resources>
<resource ref="anonymous" />
</resources>
</route>
<route url="/V1/carts/mine/retrieve-adyen-payment-methods" method="POST">
<service class="Adyen\Payment\Api\AdyenPaymentMethodManagementInterface" method="getPaymentMethods"/>
<resources>
<resource ref="self" />
</resources>
<data>
<parameter name="cartId" force="true">%cart_id%</parameter>
</data>
</route>
</routes>
\ No newline at end of file
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
define(
[
'ko'
],
function(ko) {
'use strict';
return ko.observableArray([]);
}
);
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
define(
[
'underscore',
'Magento_Checkout/js/model/quote',
'Adyen_Payment/js/model/adyen-method-list',
],
function (_, quote, methodList) {
'use strict';
return {
/**
* Populate the list of payment methods
* @param {Array} methods
*/
setPaymentMethods: function (methods) {
methodList(methods);
},
/**
* Get the list of available payment methods.
* @returns {Array}
*/
getAvailablePaymentMethods: function () {
return methodList();
}
};
}
);
......@@ -29,9 +29,10 @@ define(
'Adyen_Payment/js/action/place-order',
'mage/translate',
'Magento_Checkout/js/model/payment/additional-validators',
'Magento_Customer/js/model/customer',
'adyen/encrypt'
],
function (_, $, Component, placeOrderAction, $t, additionalValidators, adyenEncrypt) {
function (_, $, Component, placeOrderAction, $t, additionalValidators, customer, adyenEncrypt) {
'use strict';
return Component.extend({
......@@ -141,7 +142,10 @@ define(
return window.checkoutConfig.payment.adyenCc.generationTime;
},
canCreateBillingAgreement: function() {
return window.checkoutConfig.payment.adyenCc.canCreateBillingAgreement;
if(customer.isLoggedIn()) {
return window.checkoutConfig.payment.adyenCc.canCreateBillingAgreement;
}
return false;
},
isShowLegend: function() {
return true;
......
......@@ -30,9 +30,14 @@ define(
'Magento_Checkout/js/action/select-payment-method',
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/checkout-data',
'Magento_Checkout/js/model/payment/additional-validators'
'Magento_Checkout/js/model/payment/additional-validators',
'mage/storage',
'Magento_Checkout/js/model/url-builder',
'Adyen_Payment/js/model/adyen-payment-service',
'Magento_Customer/js/model/customer',
'Magento_Checkout/js/model/full-screen-loader'
],
function (ko, $, Component, setPaymentMethodAction, selectPaymentMethodAction, quote, checkoutData, additionalValidators) {
function (ko, $, Component, setPaymentMethodAction, selectPaymentMethodAction, quote, checkoutData, additionalValidators, storage, urlBuilder, adyenPaymentService, customer, fullScreenLoader) {
'use strict';
var brandCode = ko.observable(null);
var paymentMethod = ko.observable(null);
......@@ -51,14 +56,53 @@ define(
]);
return this;
},
initialize: function () {
this._super();
fullScreenLoader.startLoader();
// reset variable:
adyenPaymentService.setPaymentMethods();
// retrieve payment methods
var serviceUrl,
payload;
if(customer.isLoggedIn()) {
serviceUrl = urlBuilder.createUrl('/carts/mine/retrieve-adyen-payment-methods', {});
} else {
serviceUrl = urlBuilder.createUrl('/guest-carts/:cartId/retrieve-adyen-payment-methods', {
cartId: quote.getQuoteId()
});
}
payload = {
cartId: quote.getQuoteId(),
shippingAddress: quote.shippingAddress()
};
storage.post(
serviceUrl, JSON.stringify(payload)
).done(
function (response) {
adyenPaymentService.setPaymentMethods(response);
fullScreenLoader.stopLoader();
}
).fail(function(error) {
console.log(JSON.stringify(error));
fullScreenLoader.stopLoader();
});
},
getAdyenHppPaymentMethods: function() {
var self = this;
// convert to list so you can iterate
var paymentList = _.map(window.checkoutConfig.payment.adyenHpp.paymentMethods, function(value, key) {
if(key == "ideal") {
var paymentMethods = adyenPaymentService.getAvailablePaymentMethods();
var paymentList = _.map(paymentMethods, function(value) {
if(value.brandCode == "ideal") {
return {
'value': key,
'value': value.brandCode,
'name': value,
'method': self.item.method,
'issuerIds': value.issuers,
......@@ -72,7 +116,7 @@ define(
}
} else {
return {
'value': key,
'value': value.brandCode,
'name': value,
'method': self.item.method,
getCode: function() {
......
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