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
504033c2
Commit
504033c2
authored
Jan 11, 2019
by
cyattilakiss
Committed by
GitHub
Jan 11, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #373 from Adyen/PW-706
PW-706 Handle iDeal payments using Checkout component
parents
3185f2bf
ff4343d8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
109 additions
and
37 deletions
+109
-37
Model/Ui/AdyenHppConfigProvider.php
Model/Ui/AdyenHppConfigProvider.php
+35
-26
view/frontend/web/js/view/payment/method-renderer/adyen-hpp-method.js
...d/web/js/view/payment/method-renderer/adyen-hpp-method.js
+58
-0
view/frontend/web/template/payment/hpp-form.html
view/frontend/web/template/payment/hpp-form.html
+16
-11
No files found.
Model/Ui/AdyenHppConfigProvider.php
View file @
504033c2
...
...
@@ -35,34 +35,39 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
/**
* @var PaymentHelper
*/
protected
$
_
paymentHelper
;
protected
$paymentHelper
;
/**
* @var \Adyen\Payment\Helper\Data
*/
protected
$
_
adyenHelper
;
protected
$adyenHelper
;
/**
* Request object
*
* @var \Magento\Framework\App\RequestInterface
*/
protected
$
_
request
;
protected
$request
;
/**
* @var \Magento\Framework\UrlInterface
*/
protected
$
_
urlBuilder
;
protected
$urlBuilder
;
/**
* @var \Magento\Customer\Model\Session
*/
protected
$
_
customerSession
;
protected
$customerSession
;
/**
* @var \Magento\Checkout\Model\Session
*/
protected
$_session
;
protected
$session
;
/**
* @var \Magento\Store\Model\StoreManagerInterface
*/
protected
$storeManager
;
/**
* AdyenHppConfigProvider constructor.
...
...
@@ -80,14 +85,16 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
\Magento\Framework\App\RequestInterface
$request
,
\Magento\Framework\UrlInterface
$urlBuilder
,
\Magento\Customer\Model\Session
$customerSession
,
\Magento\Checkout\Model\Session
$session
\Magento\Checkout\Model\Session
$session
,
\Magento\Store\Model\StoreManagerInterface
$storeManager
)
{
$this
->
_paymentHelper
=
$paymentHelper
;
$this
->
_adyenHelper
=
$adyenHelper
;
$this
->
_request
=
$request
;
$this
->
_urlBuilder
=
$urlBuilder
;
$this
->
_customerSession
=
$customerSession
;
$this
->
_session
=
$session
;
$this
->
paymentHelper
=
$paymentHelper
;
$this
->
adyenHelper
=
$adyenHelper
;
$this
->
request
=
$request
;
$this
->
urlBuilder
=
$urlBuilder
;
$this
->
customerSession
=
$customerSession
;
$this
->
session
=
$session
;
$this
->
storeManager
=
$storeManager
;
}
/**
...
...
@@ -102,9 +109,9 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
'payment'
=>
[
self
::
CODE
=>
[
'isActive'
=>
true
,
'redirectUrl'
=>
$this
->
_
urlBuilder
->
getUrl
(
'redirectUrl'
=>
$this
->
urlBuilder
->
getUrl
(
'adyen/process/redirect'
,
[
'_secure'
=>
$this
->
_
getRequest
()
->
isSecure
()]
[
'_secure'
=>
$this
->
getRequest
()
->
isSecure
()]
)
]
]
...
...
@@ -114,19 +121,21 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
$dob
=
""
;
// get customer
if
(
$this
->
_
customerSession
->
isLoggedIn
())
{
if
(
$this
->
customerSession
->
isLoggedIn
())
{
$gender
=
\Adyen\Payment\Model\Gender
::
getAdyenGenderFromMagentoGender
(
$this
->
_
customerSession
->
getCustomerData
()
->
getGender
()
$this
->
customerSession
->
getCustomerData
()
->
getGender
()
);
// format to calendar date
$dob
=
$this
->
_
customerSession
->
getCustomerData
()
->
getDob
();
$dob
=
$this
->
customerSession
->
getCustomerData
()
->
getDob
();
if
(
$dob
)
{
$dob
=
strtotime
(
$dob
);
$dob
=
date
(
'm/d/Y'
,
$dob
);
}
}
$config
[
'payment'
][
'adyenHpp'
][
'locale'
]
=
$this
->
adyenHelper
->
getStoreLocale
(
$this
->
storeManager
->
getStore
()
->
getId
());
// add to config
$config
[
'payment'
]
[
'adyenHpp'
][
'gender'
]
=
$gender
;
$config
[
'payment'
]
[
'adyenHpp'
][
'dob'
]
=
$dob
;
...
...
@@ -135,16 +144,16 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
$config
[
'payment'
]
[
'adyenHpp'
][
'genderTypes'
]
=
\Adyen\Payment\Model\Gender
::
getGenderTypes
();
$paymentMethodSelectionOnAdyen
=
$this
->
_
adyenHelper
->
getAdyenHppConfigDataFlag
(
'payment_selection_on_adyen'
);
$this
->
adyenHelper
->
getAdyenHppConfigDataFlag
(
'payment_selection_on_adyen'
);
$config
[
'payment'
]
[
'adyenHpp'
][
'isPaymentMethodSelectionOnAdyen'
]
=
$paymentMethodSelectionOnAdyen
;
$config
[
'payment'
]
[
'adyenHpp'
][
'showGender'
]
=
$this
->
_
adyenHelper
->
getAdyenHppConfigDataFlag
(
'show_gender'
);
$config
[
'payment'
]
[
'adyenHpp'
][
'showDob'
]
=
$this
->
_
adyenHelper
->
getAdyenHppConfigDataFlag
(
'show_dob'
);
$config
[
'payment'
]
[
'adyenHpp'
][
'showTelephone'
]
=
$this
->
_
adyenHelper
->
getAdyenHppConfigDataFlag
(
$config
[
'payment'
]
[
'adyenHpp'
][
'showGender'
]
=
$this
->
adyenHelper
->
getAdyenHppConfigDataFlag
(
'show_gender'
);
$config
[
'payment'
]
[
'adyenHpp'
][
'showDob'
]
=
$this
->
adyenHelper
->
getAdyenHppConfigDataFlag
(
'show_dob'
);
$config
[
'payment'
]
[
'adyenHpp'
][
'showTelephone'
]
=
$this
->
adyenHelper
->
getAdyenHppConfigDataFlag
(
'show_telephone'
);
$config
[
'payment'
]
[
'adyenHpp'
][
'ratePayId'
]
=
$this
->
_
adyenHelper
->
getRatePayId
();
$config
[
'payment'
]
[
'adyenHpp'
][
'deviceIdentToken'
]
=
md5
(
$this
->
_
session
->
getQuoteId
()
.
date
(
'c'
));
$config
[
'payment'
]
[
'adyenHpp'
][
'ratePayId'
]
=
$this
->
adyenHelper
->
getRatePayId
();
$config
[
'payment'
]
[
'adyenHpp'
][
'deviceIdentToken'
]
=
md5
(
$this
->
session
->
getQuoteId
()
.
date
(
'c'
));
$config
[
'payment'
]
[
'adyenHpp'
][
'nordicCountries'
]
=
[
'SE'
,
'NO'
,
'DK'
,
'FI'
];
return
$config
;
...
...
@@ -155,8 +164,8 @@ class AdyenHppConfigProvider implements ConfigProviderInterface
*
* @return \Magento\Framework\App\RequestInterface
*/
protected
function
_
getRequest
()
protected
function
getRequest
()
{
return
$this
->
_
request
;
return
$this
->
request
;
}
}
view/frontend/web/js/view/payment/method-renderer/adyen-hpp-method.js
View file @
504033c2
...
...
@@ -199,6 +199,61 @@ define(
return
false
;
};
// Can be removed after checkout api feature branch goes live since the issuerId key is changed to
// id there and just use the value.issuers in the component
result
.
getIssuerListForComponent
=
function
()
{
if
(
result
.
isIssuerListAvailable
())
{
return
_
.
map
(
value
.
issuers
,
function
(
issuer
,
key
)
{
return
{
"
id
"
:
issuer
.
issuerId
,
"
name
"
:
issuer
.
name
};
});
}
return
[];
};
result
.
isIdeal
=
function
()
{
if
(
value
.
brandCode
.
indexOf
(
"
ideal
"
)
>=
0
)
{
return
true
;
}
return
false
;
};
/**
* Renders the secure fields,
* creates the ideal component,
* sets up the callbacks for ideal components and
*/
result
.
renderIdealComponent
=
function
()
{
self
.
isPlaceOrderActionAllowed
(
false
);
var
secureFieldsNode
=
document
.
getElementById
(
'
iDealContainer
'
);
var
checkout
=
new
AdyenCheckout
({
locale
:
self
.
getLocale
()
});
var
ideal
=
checkout
.
create
(
'
ideal
'
,
{
items
:
result
.
getIssuerListForComponent
(),
onChange
:
function
(
state
)
{
// isValid is not present on start
if
(
typeof
state
.
isValid
!==
'
undefined
'
&&
state
.
isValid
===
false
)
{
self
.
isPlaceOrderActionAllowed
(
false
);
}
},
onValid
:
function
(
state
)
{
result
.
issuerId
(
state
.
data
.
issuer
);
self
.
isPlaceOrderActionAllowed
(
true
);
},
onError
:
function
(
state
)
{
self
.
isPlaceOrderActionAllowed
(
false
);
}
});
ideal
.
mount
(
secureFieldsNode
);
};
if
(
value
.
hasOwnProperty
(
"
issuers
"
))
{
if
(
value
.
issuers
.
length
==
0
)
{
...
...
@@ -370,6 +425,9 @@ define(
},
getRatePayDeviceIdentToken
:
function
()
{
return
window
.
checkoutConfig
.
payment
.
adyenHpp
.
deviceIdentToken
;
},
getLocale
:
function
()
{
return
window
.
checkoutConfig
.
payment
.
adyenHpp
.
locale
;
}
});
}
...
...
view/frontend/web/template/payment/hpp-form.html
View file @
504033c2
...
...
@@ -55,17 +55,22 @@
<form
class=
"form"
data-role=
"adyen-hpp-form"
action=
"#"
method=
"post"
data-bind=
"mageInit: { 'validation':[]}, attr: {id: 'payment_form_' + $parent.getCode() + '_' + value}"
>
<fieldset
class=
"fieldset"
data-bind=
'attr: {id: "payment_fieldset_" + $parent.getCode() + "_" + value}'
>
<!-- ko if: isIssuerListAvailable() -->
<label
data-bind=
"attr: {'for': 'issuerId'}"
class=
"label"
>
<span>
<!-- ko text: $t('Select Your Bank') --><!-- /ko -->
</span>
</label>
<select
name=
"payment[issuer_id]"
data-bind=
"
options: name.issuers,
optionsText: 'name',
optionsValue: 'issuerId',
value: issuerId,
optionsCaption: $t('Choose Your Bank')"
>
</select>
<!-- ko if: isIdeal() -->
<div
afterRender=
"renderIdealComponent()"
data-bind=
"attr: { id: 'iDealContainer'}"
></div>
<!--/ko-->
<!-- ko ifnot: isIdeal() -->
<label
data-bind=
"attr: {'for': 'issuerId'}"
class=
"label"
>
<span>
<!-- ko text: $t('Select Your Bank') --><!-- /ko -->
</span>
</label>
<select
name=
"payment[issuer_id]"
data-bind=
"
options: name.issuers,
optionsText: 'name',
optionsValue: 'issuerId',
value: issuerId,
optionsCaption: $t('Choose Your Bank')"
>
</select>
<!--/ko-->
<!--/ko-->
<!-- ko if: isPaymentMethodOpenInvoiceMethod() -->
...
...
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