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 5c9e1a54 authored by attilak's avatar attilak

[WIP]

works until identifyShopper
parent 62663210
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment Module
*
* Copyright (c) 2019 Adyen B.V.
* This file is open source and available under the MIT license.
* See the LICENSE file for more info.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Api;
interface AdyenInitiatePaymentsInterface
{
/**
* Returns string
*
* @api
* @param string $payload
* @return string
*/
public function initiate($payload);
}
\ No newline at end of file
......@@ -118,6 +118,8 @@ class Data extends AbstractHelper
*/
private $agreementResourceModel;
private $localeResolver;
/**
* Data constructor.
* @param \Magento\Framework\App\Helper\Context $context
......@@ -155,7 +157,8 @@ class Data extends AbstractHelper
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Framework\App\CacheInterface $cache,
\Adyen\Payment\Model\Billing\AgreementFactory $billingAgreementFactory,
\Adyen\Payment\Model\ResourceModel\Billing\Agreement $agreementResourceModel
\Adyen\Payment\Model\ResourceModel\Billing\Agreement $agreementResourceModel,
\Magento\Framework\Locale\ResolverInterface $localeResolver
) {
parent::__construct($context);
$this->_encryptor = $encryptor;
......@@ -174,6 +177,7 @@ class Data extends AbstractHelper
$this->cache = $cache;
$this->billingAgreementFactory = $billingAgreementFactory;
$this->agreementResourceModel = $agreementResourceModel;
$this->localeResolver = $localeResolver;
}
/**
......@@ -1096,6 +1100,32 @@ class Data extends AbstractHelper
return $this->scopeConfig->getValue($path, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
/**
* @param $store
* @return mixed|string
*/
public function getCurrentLocaleCode($store)
{
$localeCode = $this->getAdyenAbstractConfigData('shopper_locale', $store->getId());
if ($localeCode != "") {
return $localeCode;
}
$locale = $this->localeResolver->getLocale();
if ($locale) {
return $locale;
}
// should have the value if not fall back to default
$localeCode = $this->scopeConfig->getValue(
\Magento\Directory\Helper\Data::XML_PATH_DEFAULT_LOCALE,
\Magento\Store\Model\ScopeInterface::SCOPE_STORES,
$store->getCode()
);
return $localeCode;
}
public function getApplePayShippingTypes()
{
return [
......@@ -1334,11 +1364,15 @@ class Data extends AbstractHelper
* return the merchant account name defined in required settings.
*
* @param $paymentMethod
* @param int $storeId
* @param int|null $storeId
* @return string
*/
public function getAdyenMerchantAccount($paymentMethod, $storeId)
public function getAdyenMerchantAccount($paymentMethod, $storeId = null)
{
if (!$storeId) {
$storeId = $this->storeManager->getStore()->getId();
}
$merchantAccount = $this->getAdyenAbstractConfigData("merchant_account", $storeId);
$merchantAccountPos = $this->getAdyenPosCloudConfigData('pos_merchant_account', $storeId);
......@@ -1438,6 +1472,16 @@ class Data extends AbstractHelper
return new \Adyen\Client();
}
/**
* @return string
*/
public function getOrigin() {
$baseUrl = $this->storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB);
$parsed = parse_url($baseUrl);
$origin = $parsed['scheme'] . "://" . $parsed['host'];
return $origin;
}
/**
* Retrieve origin keys for platform's base url
*
......@@ -1446,14 +1490,12 @@ class Data extends AbstractHelper
*/
public function getOriginKeyForBaseUrl()
{
$baseUrl = $this->storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB);
$parsed = parse_url($baseUrl);
$domain = $parsed['scheme'] . "://" . $parsed['host'];
$origin = $this->getOrigin();
$storeId = $this->storeManager->getStore()->getId();
$cacheKey = 'Adyen_origin_key_for_' . $domain . '_' . $storeId;
$cacheKey = 'Adyen_origin_key_for_' . $origin . '_' . $storeId;
if (!$originKey = $this->cache->load($cacheKey)) {
if ($originKey = $this->getOriginKeyForUrl($domain, $storeId)) {
if ($originKey = $this->getOriginKeyForOrigin($origin, $storeId)) {
$this->cache->save($originKey, $cacheKey, array(), 60 * 60 * 24);
}
}
......@@ -1462,14 +1504,14 @@ class Data extends AbstractHelper
}
/**
* Get origin key for a specific url using the adyen api library client
* Get origin key for a specific origin using the adyen api library client
*
* @param $url
* @param $origin
* @param int|null $storeId
* @return string
* @throws \Adyen\AdyenException
*/
private function getOriginKeyForUrl($url, $storeId = null)
private function getOriginKeyForOrigin($origin, $storeId = null)
{
$params = array(
"originDomains" => array(
......
......@@ -198,7 +198,7 @@ class PaymentMethods extends AbstractHelper
),
],
"shopperReference" => $this->getCurrentShopperReference(),
"shopperLocale" => $this->getCurrentLocaleCode($store)
"shopperLocale" => $this->adyenHelper->getCurrentLocaleCode($store)
];
$billingAddress = $this->getQuote()->getBillingAddress();
......@@ -325,32 +325,6 @@ class PaymentMethods extends AbstractHelper
return "";
}
/**
* @param $store
* @return mixed|string
*/
protected function getCurrentLocaleCode($store)
{
$localeCode = $this->adyenHelper->getAdyenAbstractConfigData('shopper_locale', $store->getId());
if ($localeCode != "") {
return $localeCode;
}
$locale = $this->localeResolver->getLocale();
if ($locale) {
return $locale;
}
// should have the value if not fall back to default
$localeCode = $this->config->getValue(
\Magento\Directory\Helper\Data::XML_PATH_DEFAULT_LOCALE,
\Magento\Store\Model\ScopeInterface::SCOPE_STORES,
$store->getCode()
);
return $localeCode;
}
/**
* @var array
*/
......
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2019 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Helper;
use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Framework\App\Helper\Context;
class Payments extends AbstractHelper
{
/**
* @var \Adyen\Payment\Helper\Data
*/
private $adyenHelper;
public function __construct(
\Adyen\Payment\Helper\Data $adyenHelper
)
{
$this->adyenHelper = $adyenHelper;
}
}
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2019 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Model;
use Adyen\Payment\Api\AdyenInitiatePaymentsInterface;
class AdyenInitiatePayments implements AdyenInitiatePaymentsInterface
{
public function __construct()
{
}
public function initiate($payload)
{
$payload = json_decode($payload);
$paymentMethod = $payload;
return $payload;
}
}
\ No newline at end of file
......@@ -134,7 +134,7 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
}
}
$config['payment']['adyenHpp']['locale'] = $this->adyenHelper->getStoreLocale($this->storeManager->getStore()->getId());
$config['payment']['adyenHpp']['locale'] = $this->adyenHelper->getCurrentLocaleCode($this->storeManager->getStore());
// add to config
$config['payment'] ['adyenHpp']['gender'] = $gender;
......
......@@ -40,6 +40,11 @@ class AdyenCcDataAssignObserver extends AbstractDataAssignObserver
const ENCRYPTED_EXPIRY_YEAR = 'expiryYear';
const HOLDER_NAME = 'holderName';
const VARIANT = 'variant';
const JAVA_ENABLED = 'java_enabled';
const SCREEN_COLOR_DEPTH = 'screen_color_depth';
const SCREEN_WIDTH = 'screen_width';
const SCREEN_HEIGHT = 'screen_hegiht';
const TIMEZONE_OFFSET = 'timezone_offset';
/**
* @var array
......@@ -53,7 +58,12 @@ class AdyenCcDataAssignObserver extends AbstractDataAssignObserver
self::ENCRYPTED_EXPIRY_MONTH,
self::ENCRYPTED_EXPIRY_YEAR,
self::HOLDER_NAME,
self::VARIANT
self::VARIANT,
self::JAVA_ENABLED,
self::SCREEN_COLOR_DEPTH,
self::SCREEN_WIDTH,
self::SCREEN_HEIGHT,
self::TIMEZONE_OFFSET
];
/**
......
<?php
/**
* ######
* ######
* ############ ####( ###### #####. ###### ############ ############
* ############# #####( ###### #####. ###### ############# #############
* ###### #####( ###### #####. ###### ##### ###### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ##### ######
* ###### ###### #####( ###### #####. ###### ##### ##### ######
* ############# ############# ############# ############# ##### ######
* ############ ############ ############# ############ ##### ######
* ######
* #############
* ############
*
* Adyen Payment module (https://www.adyen.com/)
*
* Copyright (c) 2019 Adyen BV (https://www.adyen.com/)
* See LICENSE.txt for license details.
*
* Author: Adyen <magento@adyen.com>
*/
namespace Adyen\Payment\Plugin;
use Adyen\Payment\Observer\AdyenHppDataAssignObserver;
use Adyen\Payment\Observer\AdyenCcDataAssignObserver;
use Magento\Vault\Model\Ui\VaultConfigProvider;
class PaymentInformationManagement
{
private $checkoutSession;
private $adyenHelper;
private $context;
private $transferFactory;
private $transactionPayment;
private $checkoutResponseValidator;
public function __construct(
\Magento\Checkout\Model\Session $checkoutSession,
\Adyen\Payment\Helper\Data $adyenHelper,
\Magento\Framework\Model\Context $context,
\Adyen\Payment\Gateway\Http\TransferFactory $transferFactory,
\Adyen\Payment\Gateway\Http\Client\TransactionPayment $transactionPayment,
\Adyen\Payment\Gateway\Validator\CheckoutResponseValidator $checkoutResponseValidator
)
{
$this->checkoutSession = $checkoutSession;
$this->adyenHelper = $adyenHelper;
$this->context = $context;
$this->transferFactory = $transferFactory;
$this->transactionPayment = $transactionPayment;
$this->checkoutResponseValidator = $checkoutResponseValidator;
}
/**
* @param \Magento\Checkout\Model\PaymentInformationManagement $subject
* @param $response
*/
public function afterSavePaymentInformation(
\Magento\Checkout\Model\PaymentInformationManagement $subject,
$response
)
{
$quote = $this->checkoutSession->getQuote();
$payment = $quote->getPayment();
// Build request for first payments call
$request = [];
// Merchant account data builder
$merchantAccount = $this->adyenHelper->getAdyenMerchantAccount($payment->getMethod(), $quote->getStoreId());
$request["merchantAccount"] = $merchantAccount;
// Customer data builder
$customerId = $quote->getCustomerId();
if ($customerId > 0) {
$request['shopperReference'] = $customerId;
}
$billingAddress = $quote->getBillingAddress();
if (!empty($billingAddress)) {
if ($this->adyenHelper->isPaymentMethodOpenInvoiceMethod(
$payment->getAdditionalInformation(AdyenHppDataAssignObserver::BRAND_CODE)
) && !$this->adyenHelper->isPaymentMethodAfterpayTouchMethod(
$payment->getAdditionalInformation(AdyenHppDataAssignObserver::BRAND_CODE)
)) {
if ($customerEmail = $billingAddress->getEmail()) {
$request['paymentMethod']['personalDetails']['shopperEmail'] = $customerEmail;
}
if ($customerTelephone = trim($billingAddress->getTelephone())) {
$request['paymentMethod']['personalDetails']['telephoneNumber'] = $customerTelephone;
}
if ($firstName = $billingAddress->getFirstname()) {
$request['paymentMethod']['personalDetails']['firstName'] = $firstName;
}
if ($lastName = $billingAddress->getLastname()) {
$request['paymentMethod']['personalDetails']['lastName'] = $lastName;
}
} else {
if ($customerEmail = $billingAddress->getEmail()) {
$request['shopperEmail'] = $customerEmail;
}
if ($customerTelephone = trim($billingAddress->getTelephone())) {
$request['telephoneNumber'] = $customerTelephone;
}
if ($firstName = $billingAddress->getFirstname()) {
$request['shopperName']['firstName'] = $firstName;
}
if ($lastName = $billingAddress->getLastname()) {
$request['shopperName']['lastName'] = $lastName;
}
}
if ($countryId = $billingAddress->getCountryId()) {
$request['countryCode'] = $countryId;
}
}
// Customer Ip data builder
$request['shopperIP'] = $quote->getRemoteIp();
// AddressDataBuilder
if ($billingAddress) {
$requestBilling = [
"street" => "N/A",
"postalCode" => '',
"city" => "N/A",
"houseNumberOrName" => '',
"stateOrProvince" => '',
"country" => "ZZ"
];
$address = $this->adyenHelper->getStreetFromString($billingAddress->getStreetFull());
if ($address["name"]) {
$requestBilling["street"] = $address["name"];
}
if ($address["house_number"]) {
$requestBilling["houseNumberOrName"] = $address["house_number"];
}
if ($billingAddress->getPostcode()) {
$requestBilling["postalCode"] = $billingAddress->getPostcode();
}
if ($billingAddress->getCity()) {
$requestBilling["city"] = $billingAddress->getCity();
}
if ($billingAddress->getRegionCode()) {
$requestBilling["stateOrProvince"] = $billingAddress->getRegionCode();
}
if ($billingAddress->getCountryId()) {
$requestBilling["country"] = $billingAddress->getCountryId();
}
$request['billingAddress'] = $requestBilling;
}
$shippingAddress = $quote->getShippingAddress();
if ($shippingAddress) {
$requestDeliveryDefaults = [
"street" => "N/A",
"postalCode" => '',
"city" => "N/A",
"houseNumberOrName" => '',
"stateOrProvince" => '',
"country" => "ZZ"
];
$requestDelivery = $requestDeliveryDefaults;
$address = $this->adyenHelper->getStreetFromString($shippingAddress->getStreetFull());
if ($address['name']) {
$requestDelivery["street"] = $address["name"];
}
if ($address["house_number"]) {
$requestDelivery["houseNumberOrName"] = $address["house_number"];
}
if ($shippingAddress->getPostcode()) {
$requestDelivery["postalCode"] = $shippingAddress->getPostcode();
}
if ($shippingAddress->getCity()) {
$requestDelivery["city"] = $shippingAddress->getCity();
}
if ($shippingAddress->getRegionCode()) {
$requestDelivery["stateOrProvince"] = $shippingAddress->getRegionCode();
}
if ($shippingAddress->getCountryId()) {
$requestDelivery["country"] = $shippingAddress->getCountryId();
}
// If nothing is changed which means delivery address is not filled
if ($requestDelivery !== $requestDeliveryDefaults) {
$request['deliveryAddress'] = $requestDelivery;
}
}
// PaymentDataBuilder
$currencyCode = $quote->getQuoteCurrencyCode();
$amount = $quote->getGrandTotal();
$amount = ['currency' => $currencyCode,
'value' => $this->adyenHelper->formatAmount($amount, $currencyCode)];
$request["amount"] = $amount;
$request["reference"] = $quote->getId();
$request["fraudOffset"] = "0";
// Browser data builder
$request['browserInfo'] = [
'userAgent' => $_SERVER['HTTP_USER_AGENT'],
'acceptHeader' => $_SERVER['HTTP_ACCEPT']
];
// 3DS2.0 data builder
//TODO PW-1106
$is3DS2Enabled = true;
if ($is3DS2Enabled) {
$request['origin'] = $this->adyenHelper->getOrigin();
$request['additionalData']['allow3DS2'] = true;
$request['channel'] = 'web';
$request['browserInfo'] = [
'screenWidth' => $payment->getAdditionalInformation(AdyenCcDataAssignObserver::SCREEN_WIDTH),
'screenHeight' => $payment->getAdditionalInformation(AdyenCcDataAssignObserver::SCREEN_HEIGHT),
'colorDepth' => $payment->getAdditionalInformation(AdyenCcDataAssignObserver::SCREEN_COLOR_DEPTH),
'timeZoneOffset' => $payment->getAdditionalInformation(AdyenCcDataAssignObserver::TIMEZONE_OFFSET),
'language' => $this->adyenHelper->getCurrentLocaleCode($quote->getStore()),
'javaEnabled' => $payment->getAdditionalInformation(AdyenCcDataAssignObserver::JAVA_ENABLED)
];
}
// RecurringDataBuilder
// If the vault feature is on this logic is handled in the VaultDataBuilder
if (!$this->adyenHelper->isCreditCardVaultEnabled()) {
$storeId = null;
if ($this->context->getAppState()->getAreaCode() === \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) {
$storeId = $quote->getStoreId();
}
$enableOneclick = $this->adyenHelper->getAdyenAbstractConfigData('enable_oneclick', $storeId);
$enableRecurring = $this->adyenHelper->getAdyenAbstractConfigData('enable_recurring', $storeId);
if ($enableOneclick) {
$request['enableOneClick'] = true;
} else {
$request['enableOneClick'] = false;
}
if ($enableRecurring) {
$request['enableRecurring'] = true;
} else {
$request['enableRecurring'] = false;
}
if ($payment->getAdditionalInformation('store_cc') === '1') {
$request['paymentMethod']['storeDetails'] = true;
}
}
// CcAuthorizationDataBuilder
// If ccType is set use this. For bcmc you need bcmc otherwise it will fail
$request['paymentMethod']['type'] = "scheme";
if ($cardNumber = $payment->getAdditionalInformation(AdyenCcDataAssignObserver::ENCRYPTED_CREDIT_CARD_NUMBER)) {
$request['paymentMethod']['encryptedCardNumber'] = $cardNumber;
}
if ($expiryMonth = $payment->getAdditionalInformation(AdyenCcDataAssignObserver::ENCRYPTED_EXPIRY_MONTH)) {
$request['paymentMethod']['encryptedExpiryMonth'] = $expiryMonth;
}
if ($expiryYear = $payment->getAdditionalInformation(AdyenCcDataAssignObserver::ENCRYPTED_EXPIRY_YEAR)) {
$request['paymentMethod']['encryptedExpiryYear'] = $expiryYear;
}
if ($holderName = $payment->getAdditionalInformation(AdyenCcDataAssignObserver::HOLDER_NAME)) {
$request['paymentMethod']['holderName'] = $holderName;
}
if ($securityCode = $payment->getAdditionalInformation(AdyenCcDataAssignObserver::ENCRYPTED_SECURITY_CODE)) {
$request['paymentMethod']['encryptedSecurityCode'] = $securityCode;
}
// Remove from additional data
$payment->unsAdditionalInformation(AdyenCcDataAssignObserver::ENCRYPTED_CREDIT_CARD_NUMBER);
$payment->unsAdditionalInformation(AdyenCcDataAssignObserver::ENCRYPTED_EXPIRY_MONTH);
$payment->unsAdditionalInformation(AdyenCcDataAssignObserver::ENCRYPTED_EXPIRY_YEAR);
$payment->unsAdditionalInformation(AdyenCcDataAssignObserver::ENCRYPTED_SECURITY_CODE);
$payment->unsAdditionalInformation(AdyenCcDataAssignObserver::HOLDER_NAME);
/**
* if MOTO for backend is enabled use MOTO as shopper interaction type
*/
$enableMoto = $this->adyenHelper->getAdyenCcConfigDataFlag('enable_moto', $storeId);
if ($this->context->getAppState()->getAreaCode() === \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE &&
$enableMoto
) {
$request['shopperInteraction'] = "Moto";
}
// if installments is set add it into the request
if ($payment->getAdditionalInformation(AdyenCcDataAssignObserver::NUMBER_OF_INSTALLMENTS) &&
$payment->getAdditionalInformation(AdyenCcDataAssignObserver::NUMBER_OF_INSTALLMENTS) > 0
) {
$request['installments']['value'] = $payment->getAdditionalInformation(AdyenCcDataAssignObserver::NUMBER_OF_INSTALLMENTS);
}
// Valut data builder
$data = $payment->getAdditionalInformation();
if (!empty($data[VaultConfigProvider::IS_ACTIVE_CODE]) &&
$data[VaultConfigProvider::IS_ACTIVE_CODE] === true
) {
// store it only as oneclick otherwise we store oneclick tokens (maestro+bcmc) that will fail
$request['enableRecurring'] = true;
} else {
// explicity turn this off as merchants have recurring on by default
$request['enableRecurring'] = false;
}
$transferObject = $this->transferFactory->create($request);
$response_a = $this->transactionPayment->placeRequest($transferObject);
$this->checkoutResponseValidator->validate($response_a);
return json_encode(array("test" => $response, "addData" => $response_a));
}
}
......@@ -396,8 +396,6 @@
<!-- Authorization command -->
<virtualType name="AdyenPaymentCcAuthorizeCommand" type="Magento\Payment\Gateway\Command\GatewayCommand">
<arguments>
<argument name="requestBuilder" xsi:type="object">AdyenPaymentCcAuthorizeRequest</argument>
<argument name="transferFactory" xsi:type="object">Adyen\Payment\Gateway\Http\TransferFactory</argument>
<argument name="client" xsi:type="object">Adyen\Payment\Gateway\Http\Client\TransactionPayment</argument>
<argument name="validator" xsi:type="object">CheckoutResponseValidator</argument>
<argument name="handler" xsi:type="object">AdyenPaymentCcResponseHandlerComposite</argument>
......@@ -885,9 +883,14 @@
type="Adyen\Payment\Model\AdyenRequestMerchantSession"/>
<preference for="Adyen\Payment\Api\AdyenInitiateTerminalApiInterface"
type="Adyen\Payment\Model\AdyenInitiateTerminalApi"/>
<preference for="Adyen\Payment\Api\AdyenInitiatePaymentsInterface"
type="Adyen\Payment\Model\AdyenInitiatePayments"/>
<preference for="Magento\Checkout\Api\PaymentInformationManagementInterface"
type="Adyen\Payment\Model\AdyenPaymentInformationManagement"/>
<type name="Magento\Vault\Api\PaymentTokenRepositoryInterface">
<plugin name="AdyenPaymentVaultDeleteToken" type="Adyen\Payment\Plugin\PaymentVaultDeleteToken" sortOrder="10"/>
</type>
<type name="\Magento\Checkout\Model\PaymentInformationManagement">
<plugin name="AdyenPaymentInformationManagement" type="Adyen\Payment\Plugin\PaymentInformationManagement" sortOrder="20" disabled="false"/>
</type>
</config>
\ No newline at end of file
......@@ -57,4 +57,11 @@
<resource ref="anonymous"/>
</resources>
</route>
<route url="/V1/adyen/payments" method="POST">
<service class="Adyen\Payment\Api\AdyenInitiatePaymentsInterface" method="initiate"/>
<resources>
<resource ref="anonymous"/>
</resources>
</route>
</routes>
\ No newline at end of file
......@@ -30,9 +30,13 @@ define(
'Magento_Checkout/js/model/quote',
'Adyen_Payment/js/model/installments',
'mage/url',
'Magento_Vault/js/view/payment/vault-enabler'
'Magento_Vault/js/view/payment/vault-enabler',
'Magento_Checkout/js/model/url-builder',
'mage/storage',
'Magento_Checkout/js/model/full-screen-loader',
'Magento_Paypal/js/action/set-payment-method',
],
function ($, ko, Component, customer, creditCardData, additionalValidators, quote, installments, url, VaultEnabler) {
function ($, ko, Component, customer, creditCardData, additionalValidators, quote, installments, url, VaultEnabler, urlBuilder, storage, fullScreenLoader, setPaymentMethodAction) {
'use strict';
......@@ -194,7 +198,12 @@ define(
'expiryYear': this.expiryYear(),
'holderName': this.creditCardOwner(),
'store_cc': this.setStoreCc(),
'number_of_installments': this.installment()
'number_of_installments': this.installment(),
'java_enabled': navigator.javaEnabled(),
'screen_color_depth': screen.colorDepth,
'screen_width': screen.width,
'screen_hegiht': screen.height,
'timezone_offset': new Date().getTimezoneOffset()
}
};
this.vaultEnabler.visitAdditionalData(data);
......@@ -224,9 +233,39 @@ define(
}
if (this.validate() && additionalValidators.validate()) {
this.isPlaceOrderActionAllowed(false);
//this.isPlaceOrderActionAllowed(false);
this.getPlaceOrderDeferredObject()
fullScreenLoader.startLoader();
var serviceUrl = urlBuilder.createUrl('/adyen/payments', {});
var payload = {
"payload": JSON.stringify(self.getData()),
};
//update payment method information if additional data was changed
self.selectPaymentMethod();
setPaymentMethodAction(this.messageContainer).done(
function (response) {
console.log(response);
fullScreenLoader.stopLoader();
}
);
return false;
/*storage.post(
serviceUrl,
JSON.stringify(payload),
true
).done(function(response) {
console.log(response);
fullScreenLoader.stopLoader();
//this.isPlaceOrderActionAllowed(true);
});*/
/*this.getPlaceOrderDeferredObject()
.fail(
function () {
self.isPlaceOrderActionAllowed(true);
......@@ -240,7 +279,7 @@ define(
window.location.replace(url.build(window.checkoutConfig.payment[quote.paymentMethod().method].redirectUrl));
}
}
);
);*/
return true;
}
......
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