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
e9936fa7
Commit
e9936fa7
authored
May 29, 2020
by
attilak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move all alternative payment methods to generic component (backend)
parent
925eec72
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
101 additions
and
61 deletions
+101
-61
Gateway/Request/CheckoutDataBuilder.php
Gateway/Request/CheckoutDataBuilder.php
+0
-6
Observer/AdyenCcDataAssignObserver.php
Observer/AdyenCcDataAssignObserver.php
+3
-20
Observer/AdyenHppDataAssignObserver.php
Observer/AdyenHppDataAssignObserver.php
+50
-34
Observer/AdyenObserverTrait.php
Observer/AdyenObserverTrait.php
+47
-0
view/frontend/web/js/view/payment/method-renderer/adyen-hpp-method.js
...d/web/js/view/payment/method-renderer/adyen-hpp-method.js
+1
-1
No files found.
Gateway/Request/CheckoutDataBuilder.php
View file @
e9936fa7
...
...
@@ -76,12 +76,6 @@ class CheckoutDataBuilder implements BuilderInterface
$order
->
setCanSendNewEmailFlag
(
false
);
$componentStateData
=
$payment
->
getAdditionalInformation
(
AdyenCcDataAssignObserver
::
STATE_DATA
);
$this
->
adyenHelper
->
adyenLogger
->
addAdyenDebug
(
json_encode
(
$componentStateData
));
$requestBody
=
array_merge
(
$requestBody
,
$componentStateData
);
$this
->
adyenHelper
->
adyenLogger
->
addAdyenDebug
(
json_encode
(
$requestBody
));
/*foreach ($componentStateData as $key => $data) {
}*/
if
(
empty
(
$requestBody
[
'paymentMethod'
][
'type'
])
&&
!
empty
(
$payment
->
getAdditionalInformation
(
...
...
Observer/AdyenCcDataAssignObserver.php
View file @
e9936fa7
...
...
@@ -26,12 +26,15 @@ namespace Adyen\Payment\Observer;
use
Magento\Framework\Event\Observer
;
use
Magento\Payment\Observer\AbstractDataAssignObserver
;
use
Magento\Quote\Api\Data\PaymentInterface
;
use
Adyen\Payment\Observer\AdyenObserverTrait
;
/**
* Class DataAssignObserver
*/
class
AdyenCcDataAssignObserver
extends
AbstractDataAssignObserver
{
use
AdyenObserverTrait
;
//TODO do we need these?
const
VARIANT
=
'variant'
;
...
...
@@ -110,24 +113,4 @@ class AdyenCcDataAssignObserver extends AbstractDataAssignObserver
$paymentInfo
->
setCcType
(
$additionalData
[
self
::
CC_TYPE
]);
}
}
/**
* Returns an array with only the approved keys
*
* @param array $array
* @param array $approvedKeys
* @return array
*/
private
function
getArrayOnlyWithApprovedKeys
(
$array
,
$approvedKeys
)
{
$result
=
[];
foreach
(
$approvedKeys
as
$approvedKey
)
{
if
(
isset
(
$array
[
$approvedKey
]))
{
$result
[
$approvedKey
]
=
$array
[
$approvedKey
];
}
}
return
$result
;
}
}
Observer/AdyenHppDataAssignObserver.php
View file @
e9936fa7
...
...
@@ -31,36 +31,36 @@ use Magento\Quote\Api\Data\PaymentInterface;
*/
class
AdyenHppDataAssignObserver
extends
AbstractDataAssignObserver
{
const
BRAND_CODE
=
'brand_code'
;
const
ISSUER_ID
=
'issuer_id'
;
const
GENDER
=
'gender'
;
const
DOB
=
'dob'
;
const
TELEPHONE
=
'telephone'
;
use
AdyenObserverTrait
;
// TODO do we need these?
const
DF_VALUE
=
'df_value'
;
const
SSN
=
'ssn'
;
const
OWNER_NAME
=
'ownerName'
;
const
BANK_ACCOUNT_OWNER_NAME
=
'bankAccountOwnerName'
;
const
IBAN_NUMBER
=
'ibanNumber'
;
const
BANK_ACCOUNT_NUMBER
=
'bankAccountNumber'
;
const
BANK_LOCATIONID
=
'bankLocationId'
;
const
BRAND_CODE
=
'brand_code'
;
const
STATE_DATA
=
'state_data'
;
const
BROWSER_INFO
=
'browserInfo'
;
const
PAYMENT_METHOD
=
'paymentMethod'
;
const
RISK_DATA
=
'riskData'
;
/**
* Approved root level keys from additional data array
*
* @var array
*/
private
static
$approvedAdditionalDataKeys
=
[
self
::
STATE_DATA
,
self
::
BRAND_CODE
];
/**
* Approved root level keys from the checkout component's state data object
*
* @var array
*/
protected
$additionalInformationList
=
[
self
::
BRAND_CODE
,
self
::
ISSUER_ID
,
self
::
GENDER
,
self
::
DOB
,
self
::
TELEPHONE
,
self
::
DF_VALUE
,
self
::
SSN
,
self
::
OWNER_NAME
,
self
::
BANK_ACCOUNT_OWNER_NAME
,
self
::
IBAN_NUMBER
,
self
::
BANK_ACCOUNT_NUMBER
,
self
::
BANK_LOCATIONID
private
static
$approvedStateDataKeys
=
[
self
::
BROWSER_INFO
,
self
::
PAYMENT_METHOD
,
self
::
RISK_DATA
];
/**
...
...
@@ -69,26 +69,42 @@ class AdyenHppDataAssignObserver extends AbstractDataAssignObserver
*/
public
function
execute
(
Observer
$observer
)
{
// Get request fields
$data
=
$this
->
readDataArgument
(
$observer
);
// Get additional data array
$additionalData
=
$data
->
getData
(
PaymentInterface
::
KEY_ADDITIONAL_DATA
);
if
(
!
is_array
(
$additionalData
))
{
return
;
}
$paymentInfo
=
$this
->
readPaymentModelArgument
(
$observer
);
// Get a validated additional data array
$additionalData
=
$this
->
getArrayOnlyWithApprovedKeys
(
$additionalData
,
self
::
$approvedAdditionalDataKeys
);
if
(
isset
(
$additionalData
[
self
::
BRAND_CODE
]))
{
$paymentInfo
->
setCcType
(
$additionalData
[
self
::
BRAND_CODE
]);
// json decode state data
$stateData
=
[];
if
(
!
empty
(
$additionalData
[
self
::
STATE_DATA
]))
{
$stateData
=
json_decode
(
$additionalData
[
self
::
STATE_DATA
],
true
);
}
// Get validated state data array
if
(
!
empty
(
$stateData
))
{
$stateData
=
$this
->
getArrayOnlyWithApprovedKeys
(
$stateData
,
self
::
$approvedStateDataKeys
);
}
foreach
(
$this
->
additionalInformationList
as
$additionalInformationKey
)
{
if
(
isset
(
$additionalData
[
$additionalInformationKey
]))
{
$paymentInfo
->
setAdditionalInformation
(
$additionalInformationKey
,
$additionalData
[
$additionalInformationKey
]
);
// Replace state data with the decoded and validated state data
$additionalData
[
self
::
STATE_DATA
]
=
$stateData
;
// Set additional data in the payment
$paymentInfo
=
$this
->
readPaymentModelArgument
(
$observer
);
foreach
(
$additionalData
as
$key
=>
$data
)
{
$paymentInfo
->
setAdditionalInformation
(
$key
,
$data
);
}
// Is this the correct way of setting it???
// Set BrandCode into CCType
if
(
isset
(
$additionalData
[
self
::
BRAND_CODE
]))
{
$paymentInfo
->
setCcType
(
$additionalData
[
self
::
BRAND_CODE
]);
}
}
}
Observer/AdyenObserverTrait.php
0 → 100644
View file @
e9936fa7
<?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\Observer
;
trait
AdyenObserverTrait
{
/**
* Returns an array with only the approved keys
*
* @param array $array
* @param array $approvedKeys
* @return array
*/
private
function
getArrayOnlyWithApprovedKeys
(
$array
,
$approvedKeys
)
{
$result
=
[];
foreach
(
$approvedKeys
as
$approvedKey
)
{
if
(
isset
(
$array
[
$approvedKey
]))
{
$result
[
$approvedKey
]
=
$array
[
$approvedKey
];
}
}
return
$result
;
}
}
\ No newline at end of file
view/frontend/web/js/view/payment/method-renderer/adyen-hpp-method.js
View file @
e9936fa7
...
...
@@ -246,11 +246,11 @@ define(
if
(
this
.
validate
()
&&
additionalValidators
.
validate
())
{
var
data
=
{};
data
.
stateData
=
self
.
stateData
;
data
.
method
=
self
.
method
;
var
additionalData
=
{};
additionalData
.
brand_code
=
self
.
brandCode
;
additionalData
.
state_data
=
JSON
.
stringify
(
self
.
stateData
);
if
(
brandCode
()
==
"
ratepay
"
)
{
additionalData
.
df_value
=
this
.
getRatePayDeviceIdentToken
();
...
...
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