Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Adyen Magento2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shared Libs
Adyen Magento2
Commits
5c9e1a54
Commit
5c9e1a54
authored
Mar 15, 2019
by
attilak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[WIP]
works until identifyShopper
parent
62663210
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
598 additions
and
48 deletions
+598
-48
Api/AdyenInitiatePaymentsInterface.php
Api/AdyenInitiatePaymentsInterface.php
+37
-0
Controller/Process/Validate3d.php
Controller/Process/Validate3d.php
+0
-0
Helper/Data.php
Helper/Data.php
+53
-11
Helper/PaymentMethods.php
Helper/PaymentMethods.php
+1
-27
Helper/Payments.php
Helper/Payments.php
+42
-0
Model/AdyenInitiatePayments.php
Model/AdyenInitiatePayments.php
+42
-0
Model/Ui/AdyenHppConfigProvider.php
Model/Ui/AdyenHppConfigProvider.php
+1
-1
Observer/AdyenCcDataAssignObserver.php
Observer/AdyenCcDataAssignObserver.php
+11
-1
Plugin/PaymentInformationManagement.php
Plugin/PaymentInformationManagement.php
+354
-0
etc/di.xml
etc/di.xml
+5
-2
etc/webapi.xml
etc/webapi.xml
+7
-0
view/frontend/web/js/view/payment/method-renderer/adyen-cc-method.js
...nd/web/js/view/payment/method-renderer/adyen-cc-method.js
+45
-6
No files found.
Api/AdyenInitiatePaymentsInterface.php
0 → 100644
View file @
5c9e1a54
<?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
Controller/Process/Validate3d.php
deleted
100755 → 0
View file @
62663210
Helper/Data.php
View file @
5c9e1a54
...
...
@@ -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_'
.
$
doma
in
.
'_'
.
$storeId
;
$cacheKey
=
'Adyen_origin_key_for_'
.
$
orig
in
.
'_'
.
$storeId
;
if
(
!
$originKey
=
$this
->
cache
->
load
(
$cacheKey
))
{
if
(
$originKey
=
$this
->
getOriginKeyFor
Url
(
$doma
in
,
$storeId
))
{
if
(
$originKey
=
$this
->
getOriginKeyFor
Origin
(
$orig
in
,
$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
getOriginKeyFor
Url
(
$url
,
$storeId
=
null
)
private
function
getOriginKeyFor
Origin
(
$origin
,
$storeId
=
null
)
{
$params
=
array
(
"originDomains"
=>
array
(
...
...
Helper/PaymentMethods.php
View file @
5c9e1a54
...
...
@@ -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
*/
...
...
Helper/Payments.php
0 → 100644
View file @
5c9e1a54
<?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
;
}
}
Model/AdyenInitiatePayments.php
0 → 100644
View file @
5c9e1a54
<?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
Model/Ui/AdyenHppConfigProvider.php
View file @
5c9e1a54
...
...
@@ -134,7 +134,7 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
}
}
$config
[
'payment'
][
'adyenHpp'
][
'locale'
]
=
$this
->
adyenHelper
->
get
StoreLocale
(
$this
->
storeManager
->
getStore
()
->
getId
());
$config
[
'payment'
][
'adyenHpp'
][
'locale'
]
=
$this
->
adyenHelper
->
get
CurrentLocaleCode
(
$this
->
storeManager
->
getStore
());
// add to config
$config
[
'payment'
]
[
'adyenHpp'
][
'gender'
]
=
$gender
;
...
...
Observer/AdyenCcDataAssignObserver.php
View file @
5c9e1a54
...
...
@@ -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
];
/**
...
...
Plugin/PaymentInformationManagement.php
0 → 100644
View file @
5c9e1a54
This diff is collapsed.
Click to expand it.
etc/di.xml
View file @
5c9e1a54
...
...
@@ -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
etc/webapi.xml
View file @
5c9e1a54
...
...
@@ -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
view/frontend/web/js/view/payment/method-renderer/adyen-cc-method.js
View file @
5c9e1a54
...
...
@@ -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
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment