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
cd6ecf87
Commit
cd6ecf87
authored
Jun 29, 2016
by
Rik ter Beek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #60 added oneclick as backend payment option
parent
ab470b0d
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
312 additions
and
144 deletions
+312
-144
Block/Form/Oneclick.php
Block/Form/Oneclick.php
+52
-0
Helper/Data.php
Helper/Data.php
+160
-2
Model/AdyenCcConfigProvider.php
Model/AdyenCcConfigProvider.php
+3
-11
Model/AdyenGenericConfigProvider.php
Model/AdyenGenericConfigProvider.php
+6
-6
Model/AdyenOneclickConfigProvider.php
Model/AdyenOneclickConfigProvider.php
+6
-111
Model/Method/Oneclick.php
Model/Method/Oneclick.php
+30
-11
view/adminhtml/templates/form/oneclick.phtml
view/adminhtml/templates/form/oneclick.phtml
+55
-0
view/frontend/web/js/view/payment/method-renderer/adyen-oneclick-method.js
.../js/view/payment/method-renderer/adyen-oneclick-method.js
+0
-3
No files found.
Block/Form/Oneclick.php
View file @
cd6ecf87
...
...
@@ -29,4 +29,56 @@ class Oneclick extends \Adyen\Payment\Block\Form\Cc
* @var string
*/
protected
$_template
=
'Adyen_Payment::form/oneclick.phtml'
;
/**
* @var \Adyen\Payment\Model\AdyenOneclickConfigProvider
*/
protected
$_oneclickConfig
;
/**
* @var \Magento\Backend\Model\Session\Quote
*/
protected
$_sessionQuote
;
/**
* Cc constructor.
*
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Payment\Model\Config $paymentConfig
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param \Magento\Checkout\Model\Session $checkoutSession
* @param array $data
*/
public
function
__construct
(
\Magento\Framework\View\Element\Template\Context
$context
,
\Magento\Payment\Model\Config
$paymentConfig
,
\Adyen\Payment\Helper\Data
$adyenHelper
,
\Magento\Checkout\Model\Session
$checkoutSession
,
\Adyen\Payment\Model\AdyenOneclickConfigProvider
$oneclickConfigProvider
,
\Magento\Backend\Model\Session\Quote
$sessionQuote
,
array
$data
=
[]
)
{
parent
::
__construct
(
$context
,
$paymentConfig
,
$adyenHelper
,
$checkoutSession
,
$data
);
$this
->
_oneclickConfig
=
$oneclickConfigProvider
;
$this
->
_sessionQuote
=
$sessionQuote
;
}
/**
* @return array
*/
public
function
getOneClickCards
()
{
$customerId
=
$this
->
_sessionQuote
->
getCustomerId
();
$storeId
=
$this
->
_sessionQuote
->
getStoreId
();
$grandTotal
=
$this
->
_sessionQuote
->
getQuote
()
->
getGrandTotal
();
// For backend only allow recurring payments
$recurringType
=
\Adyen\Payment\Model\RecurringType
::
RECURRING
;
$cards
=
$this
->
_adyenHelper
->
getOneClickPaymentMethods
(
$customerId
,
$storeId
,
$grandTotal
,
$recurringType
);
return
$cards
;
}
}
\ No newline at end of file
Helper/Data.php
View file @
cd6ecf87
...
...
@@ -51,25 +51,51 @@ class Data extends AbstractHelper
*/
protected
$_moduleList
;
/**
* @var \Adyen\Payment\Model\Resource\Billing\Agreement\CollectionFactory
*/
protected
$_billingAgreementCollectionFactory
;
/**
* @var Repository
*/
protected
$_assetRepo
;
/**
* @var \Magento\Framework\View\Asset\Source
*/
protected
$_assetSource
;
/**
* Data constructor.
*
*
* @param \Magento\Framework\App\Helper\Context $context
* @param \Magento\Framework\Encryption\EncryptorInterface $encryptor
* @param \Magento\Framework\Config\DataInterface $dataStorage
* @param \Magento\Directory\Model\Config\Source\Country $country
* @param \Magento\Framework\Module\ModuleListInterface $moduleList
* @param \Adyen\Payment\Model\Resource\Billing\Agreement\CollectionFactory $billingAgreementCollectionFactory
* @param \Magento\Framework\View\Asset\Repository $assetRepo
* @param \Magento\Framework\View\Asset\Source $assetSource
*/
public
function
__construct
(
\Magento\Framework\App\Helper\Context
$context
,
\Magento\Framework\Encryption\EncryptorInterface
$encryptor
,
\Magento\Framework\Config\DataInterface
$dataStorage
,
\Magento\Directory\Model\Config\Source\Country
$country
,
\Magento\Framework\Module\ModuleListInterface
$moduleList
\Magento\Framework\Module\ModuleListInterface
$moduleList
,
\Adyen\Payment\Model\Resource\Billing\Agreement\CollectionFactory
$billingAgreementCollectionFactory
,
\Magento\Framework\View\Asset\Repository
$assetRepo
,
\Magento\Framework\View\Asset\Source
$assetSource
)
{
parent
::
__construct
(
$context
);
$this
->
_encryptor
=
$encryptor
;
$this
->
_dataStorage
=
$dataStorage
;
$this
->
_country
=
$country
;
$this
->
_moduleList
=
$moduleList
;
$this
->
_billingAgreementCollectionFactory
=
$billingAgreementCollectionFactory
;
$this
->
_assetRepo
=
$assetRepo
;
$this
->
_assetSource
=
$assetSource
;
}
/**
...
...
@@ -633,4 +659,136 @@ class Data extends AbstractHelper
],
];
}
/**
* @param $customerId
* @param $storeId
* @param $grandTotal
* @param $recurringType
* @return array
*/
public
function
getOneClickPaymentMethods
(
$customerId
,
$storeId
,
$grandTotal
,
$recurringType
)
{
$billingAgreements
=
[];
$baCollection
=
$this
->
_billingAgreementCollectionFactory
->
create
();
$baCollection
->
addFieldToFilter
(
'customer_id'
,
$customerId
);
$baCollection
->
addFieldToFilter
(
'store_id'
,
$storeId
);
$baCollection
->
addFieldToFilter
(
'method_code'
,
'adyen_oneclick'
);
$baCollection
->
addActiveFilter
();
foreach
(
$baCollection
as
$billingAgreement
)
{
$agreementData
=
$billingAgreement
->
getAgreementData
();
// 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
(
$recurringType
,
$allowedContractTypes
))
{
// check if AgreementLabel is set and if contract has an recurringType
if
(
$billingAgreement
->
getAgreementLabel
())
{
// for Ideal use sepadirectdebit because it is
if
(
$agreementData
[
'variant'
]
==
'ideal'
)
{
$agreementData
[
'variant'
]
=
'sepadirectdebit'
;
}
$data
=
[
'reference_id'
=>
$billingAgreement
->
getReferenceId
(),
'agreement_label'
=>
$billingAgreement
->
getAgreementLabel
(),
'agreement_data'
=>
$agreementData
];
if
(
$this
->
showLogos
())
{
$logoName
=
$agreementData
[
'variant'
];
$asset
=
$this
->
createAsset
(
'Adyen_Payment::images/logos/'
.
$logoName
.
'.png'
);
$placeholder
=
$this
->
findRelativeSourceFilePath
(
$asset
);
$icon
=
null
;
if
(
$placeholder
)
{
list
(
$width
,
$height
)
=
getimagesize
(
$asset
->
getSourceFile
());
$icon
=
[
'url'
=>
$asset
->
getUrl
(),
'width'
=>
$width
,
'height'
=>
$height
];
}
$data
[
'logo'
]
=
$icon
;
}
/**
* Check if there are installments for this creditcard type defined
*/
$data
[
'number_of_installments'
]
=
0
;
$ccType
=
$this
->
getMagentoCreditCartType
(
$agreementData
[
'variant'
]);
$installments
=
null
;
$installmentsValue
=
$this
->
getAdyenCcConfigData
(
'installments'
);
if
(
$installmentsValue
)
{
$installments
=
unserialize
(
$installmentsValue
);
}
if
(
$installments
)
{
$numberOfInstallments
=
null
;
foreach
(
$installments
as
$ccTypeInstallment
=>
$installment
)
{
if
(
$ccTypeInstallment
==
$ccType
)
{
foreach
(
$installment
as
$amount
=>
$installments
)
{
if
(
$grandTotal
<=
$amount
)
{
$numberOfInstallments
=
$installments
;
}
}
}
}
if
(
$numberOfInstallments
)
{
$data
[
'number_of_installments'
]
=
$numberOfInstallments
;
}
}
$billingAgreements
[]
=
$data
;
}
}
}
return
$billingAgreements
;
}
/**
* @return bool
*/
public
function
showLogos
()
{
$showLogos
=
$this
->
getAdyenAbstractConfigData
(
'title_renderer'
);
if
(
$showLogos
==
\Adyen\Payment\Model\Config\Source\RenderMode
::
MODE_TITLE_IMAGE
)
{
return
true
;
}
return
false
;
}
/**
* Create a file asset that's subject of fallback system
*
* @param string $fileId
* @param array $params
* @return \Magento\Framework\View\Asset\File
*/
public
function
createAsset
(
$fileId
,
array
$params
=
[])
{
$params
=
array_merge
([
'_secure'
=>
$this
->
_request
->
isSecure
()],
$params
);
return
$this
->
_assetRepo
->
createAsset
(
$fileId
,
$params
);
}
/**
* @param $asset
* @return bool|string
*/
public
function
findRelativeSourceFilePath
(
$asset
)
{
return
$this
->
_assetSource
->
findRelativeSourceFilePath
(
$asset
);
}
}
\ No newline at end of file
Model/AdyenCcConfigProvider.php
View file @
cd6ecf87
...
...
@@ -47,11 +47,6 @@ class AdyenCcConfigProvider extends CcGenericConfigProvider
*/
protected
$_adyenHelper
;
/**
* @var AdyenGenericConfig
*/
protected
$_genericConfig
;
/**
* @var Source
*/
...
...
@@ -63,20 +58,17 @@ class AdyenCcConfigProvider extends CcGenericConfigProvider
* @param \Magento\Payment\Model\CcConfig $ccConfig
* @param PaymentHelper $paymentHelper
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param AdyenGenericConfig $genericConfig
* @param Source $assetSource
*/
public
function
__construct
(
\Magento\Payment\Model\CcConfig
$ccConfig
,
PaymentHelper
$paymentHelper
,
\Adyen\Payment\Helper\Data
$adyenHelper
,
\Adyen\Payment\Model\AdyenGenericConfig
$genericConfig
,
Source
$assetSource
)
{
parent
::
__construct
(
$ccConfig
,
$paymentHelper
,
$this
->
_methodCodes
);
$this
->
_paymentHelper
=
$paymentHelper
;
$this
->
_adyenHelper
=
$adyenHelper
;
$this
->
_genericConfig
=
$genericConfig
;
$this
->
_assetSource
=
$assetSource
;
}
...
...
@@ -113,7 +105,7 @@ class AdyenCcConfigProvider extends CcGenericConfigProvider
$config
[
'payment'
][
'adyenCc'
][
'canCreateBillingAgreement'
]
=
$canCreateBillingAgreement
;
// show logos turned on by default
if
(
$this
->
_
genericConfig
->
showLogos
())
{
if
(
$this
->
_
adyenHelper
->
showLogos
())
{
$config
[
'payment'
][
'adyenCc'
][
'creditCardPaymentMethodIcon'
]
=
$this
->
_getCreditCardPaymentMethodIcon
();
}
...
...
@@ -142,8 +134,8 @@ class AdyenCcConfigProvider extends CcGenericConfigProvider
*/
protected
function
_getCreditCardPaymentMethodIcon
()
{
$asset
=
$this
->
_
genericConfig
->
createAsset
(
'Adyen_Payment::images/logos/img_trans.gif'
);
$placeholder
=
$this
->
_
genericConfig
->
findRelativeSourceFilePath
(
$asset
);
$asset
=
$this
->
_
adyenHelper
->
createAsset
(
'Adyen_Payment::images/logos/img_trans.gif'
);
$placeholder
=
$this
->
_
adyenHelper
->
findRelativeSourceFilePath
(
$asset
);
$icon
=
null
;
if
(
$placeholder
)
{
...
...
Model/AdyenGenericConfigProvider.php
View file @
cd6ecf87
...
...
@@ -39,9 +39,9 @@ class AdyenGenericConfigProvider implements ConfigProviderInterface
protected
$_paymentHelper
;
/**
* @var
AdyenGenericConfig
* @var
\Adyen\Payment\Helper\Data
*/
protected
$_
genericConfig
;
protected
$_
adyenHelper
;
/**
* @var string[]
...
...
@@ -59,14 +59,14 @@ class AdyenGenericConfigProvider implements ConfigProviderInterface
* AdyenGenericConfigProvider constructor.
*
* @param PaymentHelper $paymentHelper
* @param
AdyenGenericConfig $genericConfig
* @param
\Adyen\Payment\Helper\Data $adyenHelper
*/
public
function
__construct
(
PaymentHelper
$paymentHelper
,
\Adyen\Payment\
Model\AdyenGenericConfig
$genericConfig
\Adyen\Payment\
Helper\Data
$adyenHelper
)
{
$this
->
_paymentHelper
=
$paymentHelper
;
$this
->
_
genericConfig
=
$genericConfig
;
$this
->
_
adyenHelper
=
$adyenHelper
;
foreach
(
$this
->
_methodCodes
as
$code
)
{
$this
->
_methods
[
$code
]
=
$this
->
_paymentHelper
->
getMethodInstance
(
$code
);
...
...
@@ -94,7 +94,7 @@ class AdyenGenericConfigProvider implements ConfigProviderInterface
}
// show logos turned on by default
if
(
$this
->
_
genericConfig
->
showLogos
())
{
if
(
$this
->
_
adyenHelper
->
showLogos
())
{
$config
[
'payment'
][
'adyen'
][
'showLogo'
]
=
true
;
}
else
{
$config
[
'payment'
][
'adyen'
][
'showLogo'
]
=
false
;
...
...
Model/AdyenOneclickConfigProvider.php
View file @
cd6ecf87
...
...
@@ -56,11 +56,6 @@ class AdyenOneclickConfigProvider extends CcGenericConfigProvider
*/
protected
$_adyenHelper
;
/**
* @var Resource\Billing\Agreement\CollectionFactory
*/
protected
$_billingAgreementCollectionFactory
;
/**
* @var \Magento\Customer\Model\Session
*/
...
...
@@ -81,44 +76,33 @@ class AdyenOneclickConfigProvider extends CcGenericConfigProvider
*/
protected
$_storeManager
;
/**
* @var AdyenGenericConfig
*/
protected
$_genericConfig
;
/**
* AdyenOneclickConfigProvider constructor.
*
*
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Payment\Model\CcConfig $ccConfig
* @param PaymentHelper $paymentHelper
* @param \Adyen\Payment\Helper\Data $adyenHelper
* @param Resource\Billing\Agreement\CollectionFactory $billingAgreementCollectionFactory
* @param \Magento\Customer\Model\Session $customerSession
* @param \Magento\Checkout\Model\Session $session
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param AdyenGenericConfig $genericConfig
*/
public
function
__construct
(
\Magento\Framework\Model\Context
$context
,
\Magento\Payment\Model\CcConfig
$ccConfig
,
PaymentHelper
$paymentHelper
,
\Adyen\Payment\Helper\Data
$adyenHelper
,
\Adyen\Payment\Model\Resource\Billing\Agreement\CollectionFactory
$billingAgreementCollectionFactory
,
\Magento\Customer\Model\Session
$customerSession
,
\Magento\Checkout\Model\Session
$session
,
\Magento\Store\Model\StoreManagerInterface
$storeManager
,
\Adyen\Payment\Model\AdyenGenericConfig
$genericConfig
\Magento\Store\Model\StoreManagerInterface
$storeManager
)
{
parent
::
__construct
(
$ccConfig
,
$paymentHelper
,
$this
->
_methodCodes
);
$this
->
_paymentHelper
=
$paymentHelper
;
$this
->
_adyenHelper
=
$adyenHelper
;
$this
->
_billingAgreementCollectionFactory
=
$billingAgreementCollectionFactory
;
$this
->
_customerSession
=
$customerSession
;
$this
->
_session
=
$session
;
$this
->
_appState
=
$context
->
getAppState
();
$this
->
_storeManager
=
$storeManager
;
$this
->
_genericConfig
=
$genericConfig
;
}
/**
...
...
@@ -156,7 +140,6 @@ class AdyenOneclickConfigProvider extends CcGenericConfigProvider
$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
;
}
else
{
...
...
@@ -176,99 +159,11 @@ class AdyenOneclickConfigProvider extends CcGenericConfigProvider
$billingAgreements
=
[];
if
(
$this
->
_customerSession
->
isLoggedIn
())
{
$customerId
=
$this
->
_customerSession
->
getCustomerId
();
// is admin?
if
(
$this
->
_appState
->
getAreaCode
()
===
\Magento\Backend\App\Area\FrontNameResolver
::
AREA_CODE
)
{
//retrieve storeId from quote
$store
=
$this
->
_getQuote
()
->
getStore
();
}
else
{
$store
=
$this
->
_storeManager
->
getStore
();
}
$baCollection
=
$this
->
_billingAgreementCollectionFactory
->
create
();
$baCollection
->
addFieldToFilter
(
'customer_id'
,
$customerId
);
$baCollection
->
addFieldToFilter
(
'store_id'
,
$store
->
getId
());
$baCollection
->
addFieldToFilter
(
'method_code'
,
'adyen_oneclick'
);
$baCollection
->
addActiveFilter
();
$recurringPaymentType
=
$this
->
_getRecurringContractType
();
$storeId
=
$this
->
_storeManager
->
getStore
()
->
getId
();
$grandTotal
=
$this
->
_getQuote
()
->
getGrandTotal
();
$recurringType
=
$this
->
_getRecurringContractType
();
foreach
(
$baCollection
as
$billingAgreement
)
{
$agreementData
=
$billingAgreement
->
getAgreementData
();
// 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
())
{
// for Ideal use sepadirectdebit because it is
if
(
$agreementData
[
'variant'
]
==
'ideal'
)
{
$agreementData
[
'variant'
]
=
'sepadirectdebit'
;
}
$data
=
[
'reference_id'
=>
$billingAgreement
->
getReferenceId
(),
'agreement_label'
=>
$billingAgreement
->
getAgreementLabel
(),
'agreement_data'
=>
$agreementData
];
if
(
$this
->
_genericConfig
->
showLogos
())
{
$logoName
=
$agreementData
[
'variant'
];
$asset
=
$this
->
_genericConfig
->
createAsset
(
'Adyen_Payment::images/logos/'
.
$logoName
.
'.png'
);
$placeholder
=
$this
->
_genericConfig
->
findRelativeSourceFilePath
(
$asset
);
$icon
=
null
;
if
(
$placeholder
)
{
list
(
$width
,
$height
)
=
getimagesize
(
$asset
->
getSourceFile
());
$icon
=
[
'url'
=>
$asset
->
getUrl
(),
'width'
=>
$width
,
'height'
=>
$height
];
}
$data
[
'logo'
]
=
$icon
;
}
/**
* Check if there are installments for this creditcard type defined
*/
$data
[
'number_of_installments'
]
=
0
;
$ccType
=
$this
->
_adyenHelper
->
getMagentoCreditCartType
(
$agreementData
[
'variant'
]);
$installments
=
null
;
$installmentsValue
=
$this
->
_adyenHelper
->
getAdyenCcConfigData
(
'installments'
);
if
(
$installmentsValue
)
{
$installments
=
unserialize
(
$installmentsValue
);
}
if
(
$installments
)
{
$numberOfInstallments
=
null
;
$grandTotal
=
$this
->
_getQuote
()
->
getGrandTotal
();
foreach
(
$installments
as
$ccTypeInstallment
=>
$installment
)
{
if
(
$ccTypeInstallment
==
$ccType
)
{
foreach
(
$installment
as
$amount
=>
$installments
)
{
if
(
$grandTotal
<=
$amount
)
{
$numberOfInstallments
=
$installments
;
}
}
}
}
if
(
$numberOfInstallments
)
{
$data
[
'number_of_installments'
]
=
$numberOfInstallments
;
}
}
$billingAgreements
[]
=
$data
;
}
}
}
$billingAgreements
=
$this
->
_adyenHelper
->
getOneClickPaymentMethods
(
$customerId
,
$storeId
,
$grandTotal
,
$recurringType
);
}
return
$billingAgreements
;
}
...
...
Model/Method/Oneclick.php
View file @
cd6ecf87
...
...
@@ -48,14 +48,7 @@ class Oneclick extends \Adyen\Payment\Model\Method\Cc
* @var string
*/
protected
$_infoBlockType
=
'Adyen\Payment\Block\Info\Oneclick'
;
/**
* Payment Method not ready for internal use
*
* @var bool
*/
protected
$_canUseInternal
=
false
;
/**
* Assign data to info model instance
*
...
...
@@ -65,7 +58,6 @@ class Oneclick extends \Adyen\Payment\Model\Method\Cc
*/
public
function
assignData
(
\Magento\Framework\DataObject
$data
)
{
parent
::
assignData
(
$data
);
if
(
!
$data
instanceof
\Magento\Framework\DataObject
)
{
$data
=
new
\Magento\Framework\DataObject
(
$data
);
...
...
@@ -74,6 +66,7 @@ class Oneclick extends \Adyen\Payment\Model\Method\Cc
$additionalData
=
$data
->
getAdditionalData
();
$infoInstance
=
$this
->
getInfoInstance
();
// get from variant magento code for creditcard type and set this in ccType
$variant
=
$additionalData
[
'variant'
];
$ccType
=
$this
->
_adyenHelper
->
getMagentoCreditCartType
(
$variant
);
...
...
@@ -83,9 +76,18 @@ class Oneclick extends \Adyen\Payment\Model\Method\Cc
$infoInstance
->
setAdditionalInformation
(
'recurring_detail_reference'
,
$additionalData
[
'recurring_detail_reference'
]);
$recurringPaymentType
=
$this
->
_adyenHelper
->
getAdyenOneclickConfigData
(
'recurring_payment_type'
);
$recurringPaymentType
=
$this
->
getRecurringPaymentType
(
);
if
(
$recurringPaymentType
==
\Adyen\Payment\Model\RecurringType
::
ONECLICK
)
{
$customerInteraction
=
true
;
// retrieve cse key
if
(
$this
->
_adyenHelper
->
getAdyenCcConfigDataFlag
(
'cse_enabled'
))
{
if
(
isset
(
$additionalData
[
'encrypted_data'
]))
{
$infoInstance
->
setAdditionalInformation
(
'encrypted_data'
,
$additionalData
[
'encrypted_data'
]);
}
else
{
throw
new
\Magento\Framework\Exception\LocalizedException
(
__
(
'Card encryption failed'
));
}
}
}
else
{
$customerInteraction
=
false
;
}
...
...
@@ -94,12 +96,29 @@ class Oneclick extends \Adyen\Payment\Model\Method\Cc
// set number of installements
if
(
isset
(
$additionalData
[
'number_of_installments'
]))
{
$infoInstance
->
setAdditionalInformation
(
'number_of_installments'
,
$additionalData
[
'number_of_installments'
]);
$infoInstance
->
setAdditionalInformation
(
'number_of_installments'
,
$additionalData
[
'number_of_installments'
]);
}
return
$this
;
}
/**
* For admin use RECURRING contract for front-end get it from configuration
*
* @return mixed|string
* @throws \Magento\Framework\Exception\LocalizedException
*/
public
function
getRecurringPaymentType
()
{
// For admin always use Recurring
if
(
$this
->
_appState
->
getAreaCode
()
===
\Magento\Backend\App\Area\FrontNameResolver
::
AREA_CODE
)
{
return
\Adyen\Payment\Model\RecurringType
::
RECURRING
;
}
else
{
return
$this
->
_adyenHelper
->
getAdyenOneclickConfigData
(
'recurring_payment_type'
);
}
}
/**
* @param \Adyen\Payment\Model\Billing\Agreement $agreement
* @return $this
...
...
Model/AdyenGenericConfig.php
→
view/adminhtml/templates/form/oneclick.phtml
View file @
cd6ecf87
...
...
@@ -20,88 +20,36 @@
*
* Author: Adyen <magento@adyen.com>
*/
namespace
Adyen\Payment\Model
;
use
Magento\Framework\App\RequestInterface
;
use
Magento\Framework\UrlInterface
;
use
Magento\Framework\View\Asset\Repository
;
use
Psr\Log\LoggerInterface
;
use
Magento\Payment\Model\Config
as
PaymentConfig
;
use
Magento\Framework\View\Asset\Source
;
class
AdyenGenericConfig
{
/**
* @var Repository
*/
protected
$_assetRepo
;
// @codingStandardsIgnoreFile
/**
* @var \Magento\Payment\Block\Adminhtml\Transparent\Form $block
*/
$code
=
$block
->
escapeHtml
(
$block
->
getMethodCode
());
$currentCountry
=
$block
->
getInfoData
(
'country'
);
?>
/**
* @var RequestInterface
*/
protected
$_request
;
<fieldset
class=
"admin__fieldset payment-method"
id=
"payment_form_
<?php
/* @noEscape */
echo
$code
;
?>
"
style=
"display:none"
>
/**
* @var \Magento\Framework\View\Asset\Source
*/
protected
$_assetSource
;
/**
* @var \Adyen\Payment\Helper\Data
*/
protected
$_adyenHelper
;
<input
type=
"hidden"
id=
"adyen_oneclick_variant"
name=
"payment[variant]"
value=
""
/>
/**
* AdyenGenericConfig constructor.
*
* @param Repository $assetRepo
* @param RequestInterface $request
* @param Source $assetSource
* @param \Adyen\Payment\Helper\Data $adyenHelper
*/
public
function
__construct
(
Repository
$assetRepo
,
RequestInterface
$request
,
Source
$assetSource
,
\Adyen\Payment\Helper\Data
$adyenHelper
)
{
$this
->
_assetRepo
=
$assetRepo
;
$this
->
_request
=
$request
;
$this
->
_assetSource
=
$assetSource
;
$this
->
_adyenHelper
=
$adyenHelper
;
}
<dl
style=
"margin: 0 0 10px 10px;"
>
<?php
if
(
!
empty
(
$block
->
getOneClickCards
()))
:
?>
<?php
foreach
(
$block
->
getOneClickCards
()
as
$card
)
:
?>
<?php
if
(
$card
[
'agreement_label'
]
!=
""
)
:
?>
<dt
class=
"admin__field-option"
>
<input
id=
"p_method_adyen_oneclick_
<?php
echo
$card
[
'reference_id'
]
?>
"
value=
"
<?php
echo
$card
[
'reference_id'
];
?>
"
type=
"radio"
name=
"payment[recurring_detail_reference]"
title=
"Adyen OneClick"
onclick=
"document.getElementById('adyen_oneclick_variant').value = '
<?php
echo
$card
[
'agreement_data'
][
'variant'
];
?>
';"
class=
"admin__control-radio"
>
<label
class=
"admin__field-label"
for=
"p_method_adyen_oneclick_
<?php
echo
$card
[
'reference_id'
]
?>
"
>
<?php
echo
$card
[
'agreement_label'
];
?>
</label>
</dt>
<?php
endif
;
?>
<?php
endforeach
;
?>
<?php
else
:
?>
<dt>
<?php
echo
$block
->
escapeHtml
(
__
(
'Customer has no saved recurring cards'
));
?>
</dt>
<?php
endif
;
?>
</dl>
/**
* Create a file asset that's subject of fallback system
*
* @param string $fileId
* @param array $params
* @return \Magento\Framework\View\Asset\File
*/
public
function
createAsset
(
$fileId
,
array
$params
=
[])
{
$params
=
array_merge
([
'_secure'
=>
$this
->
_request
->
isSecure
()],
$params
);
return
$this
->
_assetRepo
->
createAsset
(
$fileId
,
$params
);
}
/**
* @param $asset
* @return bool|string
*/
public
function
findRelativeSourceFilePath
(
$asset
)
{
return
$this
->
_assetSource
->
findRelativeSourceFilePath
(
$asset
);
}
/**
* @return bool
*/
public
function
showLogos
()
{
$showLogos
=
$this
->
_adyenHelper
->
getAdyenAbstractConfigData
(
'title_renderer'
);
if
(
$showLogos
==
\Adyen\Payment\Model\Config\Source\RenderMode
::
MODE_TITLE_IMAGE
)
{
return
true
;
}
return
false
;
}
}
\ No newline at end of file
</fieldset>
view/frontend/web/js/view/payment/method-renderer/adyen-oneclick-method.js
View file @
cd6ecf87
...
...
@@ -253,9 +253,6 @@ define(
}
return
null
;
}),
getRecurringContractType
:
function
()
{
return
window
.
checkoutConfig
.
payment
.
adyenOneClick
.
recurringContractType
;
},
hasVerification
:
function
()
{
return
window
.
checkoutConfig
.
payment
.
adyenOneclick
.
hasCustomerInteraction
;
},
...
...
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