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
1bd1e08e
Commit
1bd1e08e
authored
Jan 04, 2016
by
rikterbeek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix validation for creditcard, added directory lookup to HPP payment method
parent
d479ed1f
Changes
17
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
697 additions
and
194 deletions
+697
-194
Block/Info/AbstractInfo.php
Block/Info/AbstractInfo.php
+2
-2
Block/Redirect.php
Block/Redirect.php
+1
-0
Model/AdyenHppConfigProvider.php
Model/AdyenHppConfigProvider.php
+306
-10
Model/Method/AdyenAbstract.php
Model/Method/AdyenAbstract.php
+0
-1
Model/Method/Cc.php
Model/Method/Cc.php
+7
-1
Model/Method/Hpp.php
Model/Method/Hpp.php
+34
-14
etc/adminhtml/system/adyen_cc.xml
etc/adminhtml/system/adyen_cc.xml
+1
-1
etc/adminhtml/system/adyen_hpp.xml
etc/adminhtml/system/adyen_hpp.xml
+2
-2
view/adminhtml/templates/info/adyen_cc.phtml
view/adminhtml/templates/info/adyen_cc.phtml
+10
-8
view/adminhtml/templates/info/adyen_hpp.phtml
view/adminhtml/templates/info/adyen_hpp.phtml
+15
-3
view/frontend/requirejs-config.js
view/frontend/requirejs-config.js
+15
-0
view/frontend/web/js/action/place-order.js
view/frontend/web/js/action/place-order.js
+8
-2
view/frontend/web/js/action/set-payment-method.js
view/frontend/web/js/action/set-payment-method.js
+26
-40
view/frontend/web/js/view/payment/method-renderer/adyen-cc-method.js
...nd/web/js/view/payment/method-renderer/adyen-cc-method.js
+36
-66
view/frontend/web/js/view/payment/method-renderer/adyen-hpp-method.js
...d/web/js/view/payment/method-renderer/adyen-hpp-method.js
+117
-3
view/frontend/web/template/payment/cc-form.html
view/frontend/web/template/payment/cc-form.html
+20
-10
view/frontend/web/template/payment/hpp-form.html
view/frontend/web/template/payment/hpp-form.html
+97
-31
No files found.
Block/Info/AbstractInfo.php
View file @
1bd1e08e
...
...
@@ -52,12 +52,12 @@ class AbstractInfo extends \Magento\Payment\Block\Info
public
function
getAdyenPspReference
()
{
return
$this
->
get
Method
()
->
getInfoInstance
()
->
getAdyenPspReference
();
return
$this
->
get
Info
()
->
getAdyenPspReference
();
}
public
function
isDemoMode
()
{
$storeId
=
$this
->
get
Method
()
->
getInfoInstance
()
->
getOrder
()
->
getStoreId
();
$storeId
=
$this
->
get
Info
()
->
getOrder
()
->
getStoreId
();
return
$this
->
_adyenHelper
->
getAdyenAbstractConfigDataFlag
(
'demo_mode'
,
$storeId
);
}
...
...
Block/Redirect.php
View file @
1bd1e08e
...
...
@@ -75,6 +75,7 @@ class Redirect extends \Magento\Payment\Block\Form
}
}
catch
(
Exception
$e
)
{
// do nothing for now
throw
(
$e
);
}
return
$result
;
...
...
Model/AdyenHppConfigProvider.php
View file @
1bd1e08e
This diff is collapsed.
Click to expand it.
Model/Method/AdyenAbstract.php
View file @
1bd1e08e
...
...
@@ -27,7 +27,6 @@ use Magento\Framework\DataObject;
use
Magento\Payment\Model\Method\ConfigInterface
;
use
Magento\Payment\Model\Method\Online\GatewayInterface
;
/**
* @method \Magento\Quote\Api\Data\PaymentMethodExtensionInterface getExtensionAttributes()
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class
AdyenAbstract
extends
\Magento\Payment\Model\Method\AbstractMethod
implements
GatewayInterface
...
...
Model/Method/Cc.php
View file @
1bd1e08e
...
...
@@ -23,6 +23,12 @@
namespace
Adyen\Payment\Model\Method
;
/**
* Adyen CreditCard payment method
* @SuppressWarnings(PHPMD.ExcessivePublicCount)
* @SuppressWarnings(PHPMD.TooManyFields)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class
Cc
extends
\Magento\Payment\Model\Method\Cc
{
...
...
@@ -256,7 +262,7 @@ class Cc extends \Magento\Payment\Model\Method\Cc
if
(
$errorMsg
)
{
$this
->
_logger
->
critical
(
$errorMsg
);
throw
new
\Magento\Framework\Exception\LocalizedException
(
$errorMsg
);
throw
new
\Magento\Framework\Exception\LocalizedException
(
__
(
$errorMsg
)
);
}
break
;
}
...
...
Model/Method/Hpp.php
View file @
1bd1e08e
...
...
@@ -28,7 +28,8 @@ use Magento\Payment\Model\Method\ConfigInterface;
use
Magento\Payment\Model\Method\Online\GatewayInterface
;
/**
* @method \Magento\Quote\Api\Data\PaymentMethodExtensionInterface getExtensionAttributes()
* @SuppressWarnings(PHPMD.ExcessivePublicCount)
* @SuppressWarnings(PHPMD.TooManyFields)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class
Hpp
extends
\Magento\Payment\Model\Method\AbstractMethod
implements
GatewayInterface
...
...
@@ -159,6 +160,31 @@ class Hpp extends \Magento\Payment\Model\Method\AbstractMethod implements Gatewa
$stateObject
->
setStatus
(
$this
->
_adyenHelper
->
getAdyenAbstractConfigData
(
'order_status'
));
}
/**
* Assign data to info model instance
*
* @param \Magento\Framework\DataObject|mixed $data
* @return $this
* @throws \Magento\Framework\Exception\LocalizedException
*/
public
function
assignData
(
\Magento\Framework\DataObject
$data
)
{
parent
::
assignData
(
$data
);
$infoInstance
=
$this
->
getInfoInstance
();
if
(
isset
(
$data
[
'brand_code'
]))
{
$infoInstance
->
setAdditionalInformation
(
'brand_code'
,
$data
[
'brand_code'
]);
}
if
(
isset
(
$data
[
'issuer_id'
]))
{
$infoInstance
->
setAdditionalInformation
(
'issuer_id'
,
$data
[
'issuer_id'
]);
}
$this
->
_adyenLogger
->
info
(
print_r
(
$data
,
1
));
return
$this
;
}
/**
* Checkout redirect URL getter for onepage checkout (hardcode)
*
...
...
@@ -190,11 +216,9 @@ class Hpp extends \Magento\Payment\Model\Method\AbstractMethod implements Gatewa
/**
* @desc Get url of Adyen payment
* @return string
* @todo add brandCode here
*/
public
function
getFormUrl
()
{
// $brandCode = $this->getInfoInstance()->getCcType();
$paymentRoutine
=
$this
->
getConfigData
(
'payment_routine'
);
switch
(
$this
->
_adyenHelper
->
isDemoMode
())
{
...
...
@@ -217,15 +241,7 @@ class Hpp extends \Magento\Payment\Model\Method\AbstractMethod implements Gatewa
}
break
;
}
//IDEAL
// $idealBankUrl = false;
// $bankData = $this->getInfoInstance()->getPoNumber();
// if ($brandCode == 'ideal' && !empty($bankData)) {
// $idealBankUrl = ($isConfigDemoMode == true)
// ? 'https://test.adyen.com/hpp/redirectIdeal.shtml'
// : 'https://live.adyen.com/hpp/redirectIdeal.shtml';
// }
// return (!empty($idealBankUrl)) ? $idealBankUrl : $url;
return
$url
;
}
...
...
@@ -257,7 +273,6 @@ class Hpp extends \Magento\Payment\Model\Method\AbstractMethod implements Gatewa
}
}
$formFields
=
array
();
$formFields
[
'merchantAccount'
]
=
$merchantAccount
;
...
...
@@ -291,11 +306,16 @@ class Hpp extends \Magento\Payment\Model\Method\AbstractMethod implements Gatewa
$hmacKey
=
$this
->
_adyenHelper
->
getHmac
();
$brandCode
=
$this
->
getInfoInstance
()
->
getCcType
(
);
$brandCode
=
$order
->
getPayment
()
->
getAdditionalInformation
(
"brand_code"
);
if
(
$brandCode
)
{
$formFields
[
'brandCode'
]
=
$brandCode
;
}
$issuerId
=
$order
->
getPayment
()
->
getAdditionalInformation
(
"issuer_id"
);
if
(
$issuerId
)
{
$formFields
[
'issuerId'
]
=
$issuerId
;
}
// Sort the array by key using SORT_STRING order
ksort
(
$formFields
,
SORT_STRING
);
...
...
etc/adminhtml/system/adyen_cc.xml
View file @
1bd1e08e
...
...
@@ -32,7 +32,7 @@
<fieldset_css>
adyen-method-adyen-cc
</fieldset_css>
<comment>
Process creditcard payments inside your checkout.
</comment>
<field
id=
"active"
translate=
"label"
type=
"select"
sortOrder=
"10"
showInDefault=
"1"
showInWebsite=
"1"
showInStore=
"
0
"
>
<field
id=
"active"
translate=
"label"
type=
"select"
sortOrder=
"10"
showInDefault=
"1"
showInWebsite=
"1"
showInStore=
"
1
"
>
<label>
Enabled
</label>
<source_model>
Magento\Config\Model\Config\Source\Yesno
</source_model>
<config_path>
payment/adyen_cc/active
</config_path>
...
...
etc/adminhtml/system/adyen_hpp.xml
View file @
1bd1e08e
...
...
@@ -32,7 +32,7 @@
<fieldset_css>
adyen-method-adyen-cc
</fieldset_css>
<comment>
Process alternative payments methods
</comment>
<field
id=
"active"
translate=
"label"
type=
"select"
sortOrder=
"10"
showInDefault=
"1"
showInWebsite=
"1"
showInStore=
"
0
"
>
<field
id=
"active"
translate=
"label"
type=
"select"
sortOrder=
"10"
showInDefault=
"1"
showInWebsite=
"1"
showInStore=
"
1
"
>
<label>
Enabled
</label>
<source_model>
Magento\Config\Model\Config\Source\Yesno
</source_model>
<config_path>
payment/adyen_hpp/active
</config_path>
...
...
@@ -68,7 +68,7 @@
<label>
Advanced Settings
</label>
<frontend_model>
Magento\Config\Block\System\Config\Form\Fieldset
</frontend_model>
<field
id=
"payment_selection_on_adyen"
translate=
"label"
type=
"select"
sortOrder=
"70"
showInDefault=
"1"
showInWebsite=
"1"
showInStore=
"0"
>
<label>
Payment method selection
in Adyen
</label>
<label>
Payment method selection
on Adyen Hosted Payment Page (HPP)
</label>
<tooltip>
If you set this to 'Yes', payment methods in the checkout won't be displayed and you will be redirected to the Adyen HPP to make the selection.
</tooltip>
<source_model>
Magento\Config\Model\Config\Source\Yesno
</source_model>
<config_path>
payment/adyen_hpp/payment_selection_on_adyen
</config_path>
...
...
view/adminhtml/templates/info/adyen_cc.phtml
View file @
1bd1e08e
...
...
@@ -32,15 +32,17 @@
<?php
echo
$block
->
escapeHtml
(
$block
->
getMethod
()
->
getTitle
())
?>
<?php
$isDemoMode
=
$block
->
isDemoMode
();
$_info
=
$this
->
getInfo
();
$_isDemoMode
=
$block
->
isDemoMode
();
?>
<?php
if
(
$block
->
getAdyenPspReference
())
:
?>
<?php
if
(
$isDemoMode
)
:
?>
<div>
<?php
echo
__
(
"Adyen PSP Reference: <a href=
\"
https://ca-test.adyen.com/ca/ca/accounts/showTx.shtml?pspReference=%1&txType=Payment
\"
target=
\"
__blank
\"
>%1</a>"
,
$block
->
escapeHtml
(
$block
->
getAdyenPspReference
()));
?>
<?php
else
:
?>
<div>
<?php
echo
__
(
'Adyen PSP Reference: <a href="https://ca-live.adyen.com/ca/ca/accounts/showTx.shtml?pspReference=%1&txType=Payment" target="__blank">%1</a>'
,
$block
->
escapeHtml
(
$block
->
getAdyenPspReference
()));
?>
<?php
endif
;
?>
</div>
<?php
if
(
$_pspReference
=
$_info
->
getAdditionalInformation
(
'pspReference'
))
:
?>
<div>
<?php
if
(
$_isDemoMode
)
:
?>
<?php
echo
__
(
'Adyen PSP Reference: <a href="https://ca-test.adyen.com/ca/ca/accounts/showTx.shtml?pspReference=%1&txType=Payment" target="__blank">%1</a>'
,
$block
->
escapeHtml
(
$_pspReference
),
$block
->
escapeHtml
(
$_pspReference
))
?>
<?php
else
:
?>
<?php
echo
__
(
'Adyen PSP Reference: <a href="https://ca-live.adyen.com/ca/ca/accounts/showTx.shtml?pspReference=%1&txType=Payment" target="__blank">%1</a>'
,
$block
->
escapeHtml
(
$_pspReference
),
$block
->
escapeHtml
(
$_pspReference
))
?>
<?php
endif
;
?>
</div>
<?php
endif
;
?>
<?php
if
(
$_specificInfo
=
$block
->
getSpecificInformation
())
:
?>
...
...
view/adminhtml/templates/info/adyen_hpp.phtml
View file @
1bd1e08e
...
...
@@ -31,12 +31,24 @@
?>
<?php
echo
$block
->
escapeHtml
(
$block
->
getMethod
()
->
getTitle
())
?>
<?php
$_info
=
$this
->
getInfo
();
?>
<?php
if
(
$_pspReference
=
$block
->
getPspReference
())
:
?>
<div>
<?php
echo
__
(
'Adyen PSP Reference: <a href="https://ca-test.adyen.com/ca/ca/accounts/showTx.shtml?pspReference=%1&txType=Payment" target="__blank">%1</a>'
,
$block
->
escapeHtml
(
$_info
->
getAdditionalInformation
(
'pspReference'
)),
$block
->
escapeHtml
(
$_info
->
getAdditionalInformation
(
'pspReference'
)))
?>
<?php
$_info
=
$this
->
getInfo
();
$_isDemoMode
=
$block
->
isDemoMode
();
?>
<?php
if
(
$_pspReference
=
$_info
->
getAdditionalInformation
(
'pspReference'
))
:
?>
<div>
<?php
if
(
$_isDemoMode
)
:
?>
<?php
echo
__
(
'Adyen PSP Reference: <a href="https://ca-test.adyen.com/ca/ca/accounts/showTx.shtml?pspReference=%1&txType=Payment" target="__blank">%1</a>'
,
$block
->
escapeHtml
(
$_pspReference
),
$block
->
escapeHtml
(
$_pspReference
))
?>
<?php
else
:
?>
<?php
echo
__
(
'Adyen PSP Reference: <a href="https://ca-live.adyen.com/ca/ca/accounts/showTx.shtml?pspReference=%1&txType=Payment" target="__blank">%1</a>'
,
$block
->
escapeHtml
(
$_pspReference
),
$block
->
escapeHtml
(
$_pspReference
))
?>
<?php
endif
;
?>
</div>
<?php
endif
;
?>
<?php
if
(
$_brandCode
=
$_info
->
getAdditionalInformation
(
'brand_code'
))
:
?>
<div>
<?php
echo
__
(
'Payment Method: %1'
,
$_brandCode
);
?>
</div>
<?php
endif
;
?>
<?php
if
(
$_specificInfo
=
$block
->
getSpecificInformation
())
:
?>
<table
class=
"data-table admin__table-secondary"
>
...
...
view/frontend/requirejs-config.js
0 → 100755
View file @
1bd1e08e
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
/*jshint browser:true jquery:true*/
/*global alert*/
var
config
=
{
config
:
{
mixins
:
{
'
Adyen_Payment/js/action/place-order
'
:
{
'
Magento_CheckoutAgreements/js/model/place-order-mixin
'
:
true
}
}
}
};
view/frontend/web/js/action/place-order.js
View file @
1bd1e08e
...
...
@@ -26,15 +26,17 @@ define(
'
mage/storage
'
,
'
mage/url
'
,
'
Magento_Checkout/js/model/error-processor
'
,
'
Magento_Customer/js/model/customer
'
'
Magento_Customer/js/model/customer
'
,
'
Magento_Checkout/js/model/full-screen-loader
'
],
function
(
quote
,
urlBuilder
,
storage
,
url
,
errorProcessor
,
customer
)
{
function
(
quote
,
urlBuilder
,
storage
,
url
,
errorProcessor
,
customer
,
fullScreenLoader
)
{
'
use strict
'
;
return
function
(
paymentData
,
redirectOnSuccess
)
{
var
serviceUrl
,
payload
;
//redirectOnSuccess = redirectOnSuccess !== false;
redirectOnSuccess
=
redirectOnSuccess
===
false
?
false
:
true
;
/** Checkout for guest and registered customer. */
...
...
@@ -56,6 +58,9 @@ define(
billingAddress
:
quote
.
billingAddress
()
};
}
fullScreenLoader
.
startLoader
();
return
storage
.
post
(
serviceUrl
,
JSON
.
stringify
(
payload
)
).
done
(
...
...
@@ -67,6 +72,7 @@ define(
).
fail
(
function
(
response
)
{
errorProcessor
.
process
(
response
);
fullScreenLoader
.
stopLoader
();
}
);
};
...
...
view/frontend/web/js/action/set-payment-method.js
View file @
1bd1e08e
...
...
@@ -26,52 +26,33 @@ define(
'
Magento_Checkout/js/model/url-builder
'
,
'
mage/storage
'
,
'
Magento_Checkout/js/model/error-processor
'
,
'
Magento_Customer/js/model/customer
'
'
Magento_Customer/js/model/customer
'
,
'
Magento_Checkout/js/model/full-screen-loader
'
],
function
(
$
,
quote
,
urlBuilder
,
storage
,
errorProcessor
,
customer
)
{
function
(
$
,
quote
,
urlBuilder
,
storage
,
errorProcessor
,
customer
,
fullScreenLoader
)
{
'
use strict
'
;
//return function () {
// var serviceUrl,
// payload,
// paymentData = quote.paymentMethod();
//
// /**
// * Checkout for guest and registered customer.
// */
// if (!customer.isLoggedIn()) {
// serviceUrl = urlBuilder.createUrl('/guest-carts/:cartId/selected-payment-method', {
// cartId: quote.getQuoteId()
// });
// payload = {
// cartId: quote.getQuoteId(),
// method: paymentData
// };
// } else {
// serviceUrl = urlBuilder.createUrl('/carts/mine/selected-payment-method', {});
// payload = {
// cartId: quote.getQuoteId(),
// method: paymentData
// };
// }
// return storage.put(
// serviceUrl, JSON.stringify(payload)
// ).done(
// function () {
// $.mage.redirect(window.checkoutConfig.payment.adyenHpp.redirectUrl[quote.paymentMethod().method]);
// }
// ).fail(
// function (response) {
// errorProcessor.process(response);
// }
// );
//};
var
agreementsConfig
=
window
.
checkoutConfig
.
checkoutAgreements
;
return
function
()
{
var
serviceUrl
,
payload
,
paymentData
=
quote
.
paymentMethod
();
payload
,
paymentData
=
quote
.
paymentMethod
();
// check if agreement is enabled if so add it to payload
if
(
agreementsConfig
.
isEnabled
)
{
var
agreementForm
=
$
(
'
.payment-method._active form[data-role=checkout-agreements]
'
),
agreementData
=
agreementForm
.
serializeArray
(),
agreementIds
=
[];
agreementData
.
forEach
(
function
(
item
)
{
agreementIds
.
push
(
item
.
value
);
});
paymentData
.
extension_attributes
=
{
agreement_ids
:
agreementIds
};
}
/** Checkout for guest and registered customer. */
if
(
!
customer
.
isLoggedIn
())
{
...
...
@@ -92,6 +73,10 @@ define(
billingAddress
:
quote
.
billingAddress
()
};
}
fullScreenLoader
.
startLoader
();
return
storage
.
post
(
serviceUrl
,
JSON
.
stringify
(
payload
)
).
done
(
...
...
@@ -101,6 +86,7 @@ define(
).
fail
(
function
(
response
)
{
errorProcessor
.
process
(
response
);
fullScreenLoader
.
stopLoader
();
}
);
};
...
...
view/frontend/web/js/view/payment/method-renderer/adyen-cc-method.js
View file @
1bd1e08e
...
...
@@ -26,15 +26,18 @@ define(
'
underscore
'
,
'
jquery
'
,
'
Magento_Payment/js/view/payment/cc-form
'
,
'
Magento_Checkout/js/action/set-payment-information
'
,
'
Adyen_Payment/js/action/place-order
'
,
'
mage/translate
'
,
'
Magento_Checkout/js/model/payment/additional-validators
'
,
'
Magento_Checkout/js/model/full-screen-loader
'
,
'
Adyen_Payment/js/view/payment/adyen-encrypt
'
,
'
Adyen_Payment/js/view/payment/adyen-encrypt
'
],
function
(
_
,
$
,
Component
,
setPaymentInformationAction
,
placeOrderAction
,
$t
,
additionalValidators
,
fullScreenLoader
)
{
function
(
_
,
$
,
Component
,
placeOrderAction
,
$t
,
additionalValidators
)
{
'
use strict
'
;
$
.
validator
.
addMethod
(
'
validate-custom-required
'
,
function
(
value
)
{
return
(
value
===
'
test
'
);
// Validation logic here
},
$
.
mage
.
__
(
'
Enter This is a required field custom.
'
)
);
return
Component
.
extend
({
defaults
:
{
template
:
'
Adyen_Payment/payment/cc-form
'
,
...
...
@@ -58,29 +61,6 @@ define(
]);
return
this
;
},
initialize
:
function
()
{
var
self
=
this
;
this
.
_super
();
// when creditCarNumber change call encrypt function
this
.
creditCardNumber
.
subscribe
(
function
(
value
)
{
self
.
calculateCseKey
();
});
this
.
creditCardOwner
.
subscribe
(
function
(
value
)
{
self
.
calculateCseKey
();
});
//this.creditCardExpMonth.subscribe(function(value) {
// self.calculateCseKey();
//});
//this.creditCardExpYear.subscribe(function(value) {
// self.calculateCseKey();
//});
this
.
creditCardVerificationNumber
.
subscribe
(
function
(
value
)
{
self
.
calculateCseKey
();
});
},
placeOrderHandler
:
null
,
validateHandler
:
null
,
setPlaceOrderHandler
:
function
(
handler
)
{
...
...
@@ -115,17 +95,17 @@ define(
/**
* @override
*/
placeOrder
:
function
()
{
var
self
=
this
;
placeOrder
:
function
(
data
,
event
)
{
var
self
=
this
,
placeOrder
;
if
(
event
)
{
event
.
preventDefault
();
}
//var cse_form = $("adyen-cc-form");
var
cse_form
=
document
.
getElementById
(
'
adyen-cc-form
'
);
var
cse_key
=
this
.
getCSEKey
();
//var cse_options = {
// name: 'payment[encrypted_data]',
// enableValidations: true,
// submitButtonAlwaysEnabled: true
//};
var
options
=
{};
var
cseInstance
=
adyen
.
encrypt
.
createEncryption
(
cse_key
,
options
);
...
...
@@ -143,26 +123,16 @@ define(
var
data
=
cseInstance
.
encrypt
(
cardData
);
self
.
encryptedData
(
data
);
// loading icon
fullScreenLoader
.
startLoader
();
if
(
this
.
validate
()
&&
additionalValidators
.
validate
())
{
this
.
isPlaceOrderActionAllowed
(
false
);
placeOrder
=
placeOrderAction
(
this
.
getData
(),
this
.
redirectAfterPlaceOrder
);
var
placeOrder
=
placeOrderAction
(
this
.
getData
(),
this
.
redirectAfterPlaceOrder
);
$
.
when
(
placeOrder
).
fail
(
function
(){
self
.
isPlaceOrderActionAllowed
(
true
);
fullScreenLoader
.
stopLoader
();
});
//return true;
//
//if (this.validateHandler()) {
// this.isPlaceOrderActionAllowed(false);
// $.when(setPaymentInformationAction()).done(function() {
// self.placeOrderHandler();
// }).fail(function() {
// self.isPlaceOrderActionAllowed(true);
// });
//}
$
.
when
(
placeOrder
).
fail
(
function
(
response
)
{
self
.
isPlaceOrderActionAllowed
(
true
);
});
return
true
;
}
return
false
;
},
getControllerName
:
function
()
{
return
window
.
checkoutConfig
.
payment
.
iframe
.
controllerName
[
this
.
getCode
()];
...
...
@@ -185,22 +155,22 @@ define(
isShowLegend
:
function
()
{
return
true
;
},
calculateCseKey
:
function
()
{
//
////var cse_form = $("adyen-cc-form");
//var cse_form = document.getElementById('adyen-cc-form');
//var cse_key = this.getCSEKey();
//var cse_options = {
// name: 'payment[encrypted_data]',
// enableValidations: true, // disable because month needs to be 01 isntead of 1
// //submitButtonAlwaysEnabled: true
//};
//
//var result = adyen.encrypt.createEncryptedForm(cse_form, cse_key, cse_options);
validate
:
function
()
{
var
form
=
'
form[data-role=adyen-cc-form]
'
;
var
validate
=
$
(
form
).
validation
()
&&
$
(
form
).
validation
(
'
isValid
'
);
// add extra validation because jqeury validation will not work on non name attributes
var
ccNumber
=
Boolean
(
$
(
form
+
'
#adyen_cc_cc_number
'
).
valid
());
var
owner
=
Boolean
(
$
(
form
+
'
#adyen_cc_cc_owner
'
).
valid
());
var
expiration
=
Boolean
(
$
(
form
+
'
#adyen_cc_expiration
'
).
valid
());
var
expiration_yr
=
Boolean
(
$
(
form
+
'
#adyen_cc_expiration_yr
'
).
valid
());
var
$cid
=
Boolean
(
$
(
form
+
'
#adyen_cc_cc_cid
'
).
valid
());
if
(
!
validate
||
!
ccNumber
||
!
owner
||
!
expiration
||
!
expiration_yr
||
!
$cid
)
{
return
false
;
}
return
true
;
}
});
}
...
...
view/frontend/web/js/view/payment/method-renderer/adyen-hpp-method.js
View file @
1bd1e08e
...
...
@@ -23,15 +23,33 @@
/*global define*/
define
(
[
'
ko
'
,
'
jquery
'
,
'
Magento_Checkout/js/view/payment/default
'
,
'
Adyen_Payment/js/action/set-payment-method
'
'
Adyen_Payment/js/action/set-payment-method
'
,
'
Magento_Checkout/js/action/select-payment-method
'
,
'
Magento_Checkout/js/model/quote
'
,
'
Magento_Checkout/js/checkout-data
'
,
'
Magento_Checkout/js/model/full-screen-loader
'
,
],
function
(
$
,
Component
,
setPaymentMethodAction
)
{
function
(
ko
,
$
,
Component
,
setPaymentMethodAction
,
selectPaymentMethodAction
,
quote
,
checkoutData
,
fullScreenLoader
)
{
'
use strict
'
;
var
brandCode
=
ko
.
observable
(
null
);
var
paymentMethod
=
ko
.
observable
(
null
);
return
Component
.
extend
({
self
:
this
,
defaults
:
{
template
:
'
Adyen_Payment/payment/hpp-form
'
template
:
'
Adyen_Payment/payment/hpp-form
'
,
brandCode
:
''
},
initObservable
:
function
()
{
this
.
_super
()
.
observe
([
'
brandCode
'
,
'
issuerId
'
]);
return
this
;
},
/** Redirect to adyen */
continueToAdyen
:
function
()
{
...
...
@@ -39,6 +57,102 @@ define(
this
.
selectPaymentMethod
();
setPaymentMethodAction
();
return
false
;
},
continueToAdyenBrandCode
:
function
()
{
// set payment method to adyen_hpp
var
self
=
this
;
// for ideal add brand_code in request
if
(
brandCode
()
==
"
ideal
"
)
{
var
data
=
{
"
method
"
:
self
.
method
,
"
po_number
"
:
null
,
"
additional_data
"
:
{
issuer_id
:
this
.
issuerId
(),
brand_code
:
self
.
value
}
};
}
else
{
var
data
=
{
"
method
"
:
self
.
method
,
"
po_number
"
:
null
,
"
additional_data
"
:
{
brand_code
:
self
.
value
}
};
}
selectPaymentMethodAction
(
data
);
setPaymentMethodAction
();
return
false
;
},
getAdyenHppPaymentMethods
:
function
()
{
var
self
=
this
;
// convert to list so you can iterate
var
paymentList
=
_
.
map
(
window
.
checkoutConfig
.
payment
.
adyenHpp
.
paymentMethods
,
function
(
value
,
key
)
{
if
(
key
==
"
ideal
"
)
{
return
{
'
value
'
:
key
,
'
name
'
:
value
,
'
method
'
:
self
.
item
.
method
,
'
issuerIds
'
:
value
.
issuers
,
'
issuerId
'
:
ko
.
observable
(
null
),
getCode
:
function
()
{
return
self
.
item
.
method
;
}
}
}
else
{
return
{
'
value
'
:
key
,
'
name
'
:
value
,
'
method
'
:
self
.
item
.
method
,
getCode
:
function
()
{
return
self
.
item
.
method
;
}
}
}
}
);
return
paymentList
;
},
selectPaymentMethodBrandCode
:
function
()
{
var
self
=
this
;
// set payment method to adyen_hpp
var
data
=
{
"
method
"
:
self
.
method
,
"
po_number
"
:
null
,
"
additional_data
"
:
{
//brand_code: this.brandCode()
brand_code
:
self
.
value
,
}
};
// set the brandCode
brandCode
(
self
.
value
);
// set payment method
paymentMethod
(
self
.
method
);
selectPaymentMethodAction
(
data
);
checkoutData
.
setSelectedPaymentMethod
(
self
.
method
);
return
true
;
},
isBrandCodeChecked
:
ko
.
computed
(
function
()
{
if
(
!
quote
.
paymentMethod
())
{
return
null
;
}
if
(
quote
.
paymentMethod
().
method
==
paymentMethod
())
{
return
brandCode
();
}
return
null
;
}),
isPaymentMethodSelectionOnAdyen
:
function
()
{
return
window
.
checkoutConfig
.
payment
.
adyenHpp
.
isPaymentMethodSelectionOnAdyen
;
}
});
}
...
...
view/frontend/web/template/payment/cc-form.html
View file @
1bd1e08e
...
...
@@ -39,7 +39,7 @@
<form
class=
"form"
id=
"adyen-cc-form"
action=
"#"
method=
"post"
data-bind=
"mageInit: {
<form
class=
"form"
id=
"adyen-cc-form"
data-role=
"adyen-cc-form"
action=
"#"
method=
"post"
data-bind=
"mageInit: {
'transparent':{
'context': context(),
'controller': getControllerName(),
...
...
@@ -94,7 +94,7 @@
id: getCode() + '_cc_number',
title: $t('Credit Card Number'),
'data-container': getCode() + '-cc-number',
'data-validate': JSON.stringify({'required-number':true, 'validate-card-number':'#' + getCode() + '_cc_type', 'validate-cc-type':'#' + getCode() + '_cc_type'})},
'data-validate': JSON.stringify({'required-number':true, 'validate-card-
type':getCcAvailableTypesValues(), 'validate-card-
number':'#' + getCode() + '_cc_type', 'validate-cc-type':'#' + getCode() + '_cc_type'})},
enable: isActive($parents),
value: creditCardNumber,
valueUpdate: 'keyup' "
/>
...
...
@@ -106,12 +106,19 @@
</label>
<div
class=
"control"
>
<input
type=
"text"
class=
"input-text"
value=
""
class=
"input-text required-entry"
data-encrypted-name=
"holderName"
data-bind=
"attr: {id: getCode() + '_cc_owner', 'data-container': getCode() + '-cc-owner'},
enable: isActive($parents),
value: creditCardOwner"
>
value=
""
data-bind=
"attr: {
id: getCode() + '_cc_owner',
title: $t('Credit Card Owner'),
'data-container': getCode() + '-cc-owner'
},
enable: isActive($parents),
value: creditCardOwner,
valueUpdate: 'keyup' "
data-validate=
"{required:true}"
/>
</div>
</div>
<div
class=
"field date required"
data-bind=
"attr: {id: getCode() + '_cc_type_exp_div'}"
>
...
...
@@ -130,7 +137,8 @@
optionsValue: 'value',
optionsText: 'month',
optionsCaption: $t('Month'),
value: creditCardExpMonth"
>
value: creditCardExpMonth"
data-validate=
"{required:true}"
>
</select>
</div>
</div>
...
...
@@ -144,7 +152,8 @@
optionsValue: 'value',
optionsText: 'year',
optionsCaption: $t('Year'),
value: creditCardExpYear"
>
value: creditCardExpYear"
data-validate=
"{required:true}"
>
</select>
</div>
</div>
...
...
@@ -167,7 +176,8 @@
'data-container': getCode() + '-cc-cvv',
'data-validate': JSON.stringify({'required-number':true, 'validate-card-cvv':'#' + getCode() + '_cc_type'})},
enable: isActive($parents),
value: creditCardVerificationNumber"
/>
value: creditCardVerificationNumber"
data-validate=
"{required:true}"
/>
<div
class=
"field-tooltip toggle"
>
<span
class=
"field-tooltip-action action-cvv"
tabindex=
"0"
...
...
view/frontend/web/template/payment/hpp-form.html
View file @
1bd1e08e
...
...
@@ -21,39 +21,105 @@
* Author: Adyen <magento@adyen.com>
*/
-->
<div
class=
"payment-method"
data-bind=
"css: {'_active': (getCode() == isChecked())}"
>
<div
class=
"payment-method-title field choice"
>
<input
type=
"radio"
name=
"payment[method]"
class=
"radio"
data-bind=
"attr: {'id': getCode()}, value: getCode(), checked: isChecked, click: selectPaymentMethod, visible: isRadioButtonVisible()"
/>
<label
data-bind=
"attr: {'for': getCode()}"
class=
"label"
><span
data-bind=
"text: getTitle()"
></span></label>
</div>
<div
class=
"payment-method-content"
>
<div
class=
"payment-method-billing-address"
>
<!-- ko foreach: $parent.getRegion(getBillingAddressFormName()) -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
</div>
<fieldset
class=
"fieldset"
data-bind=
'attr: {id: "payment_form_" + getCode()}'
>
<div
class=
"payment-method-note"
>
<!-- ko text: $t('You will be redirected to the Adyen website.') --><!-- /ko -->
<!-- ko ifnot: (isPaymentMethodSelectionOnAdyen())-->
<!-- ko foreach: getAdyenHppPaymentMethods() -->
<div
class=
"payment-method"
data-bind=
"css: {'_active': (value == $parent.isBrandCodeChecked())}"
>
<div
class=
"payment-method-title field choice"
>
<input
type=
"radio"
name=
"payment[method]"
class=
"radio"
data-bind=
"attr: {'id': value}, value: value, checked: $parent.isBrandCodeChecked, click: $parent.selectPaymentMethodBrandCode"
/>
<label
data-bind=
"attr: {'for': value}"
class=
"label"
><span
data-bind=
"text: name.title"
></span></label>
</div>
<div
class=
"payment-method-content"
>
<div
class=
"payment-method-billing-address"
>
<!-- ko foreach: $parents[1].getRegion($parent.getBillingAddressFormName()) -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
</div>
<fieldset
class=
"fieldset"
data-bind=
'attr: {id: "payment_form_" + $parent.getCode() + "_" + value}'
>
<div
class=
"payment-method-note"
>
<!-- ko if: value == 'ideal' -->
<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-->
</div>
</fieldset>
<div
class=
"checkout-agreements-block"
>
<!-- ko foreach: $parents[1].getRegion('before-place-order') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
</div>
<div
class=
"actions-toolbar"
>
<div
class=
"primary"
>
<button
class=
"action primary checkout"
type=
"submit"
data-bind=
"click: $parent.continueToAdyenBrandCode, enable: (value == $parent.isBrandCodeChecked())"
disabled
>
<span
data-bind=
"text: $t('Place order')"
></span>
</button>
</div>
</div>
</div>
</fieldset>
<div
class=
"checkout-agreements-block"
>
<!-- ko foreach: $parent.getRegion('before-place-order') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
</div>
<div
class=
"actions-toolbar"
>
<div
class=
"primary"
>
<button
class=
"action primary checkout"
type=
"submit"
data-bind=
"click: continueToAdyen, enable: (getCode() == isChecked())"
disabled
>
<span
data-bind=
"text: $t('Continue to Adyen')"
></span>
</button>
<!--/ko-->
<!--/ko-->
<!-- ko if: (isPaymentMethodSelectionOnAdyen()) -->
<div
class=
"payment-method"
data-bind=
"css: {'_active': (getCode() == isChecked())}"
>
<div
class=
"payment-method-title field choice"
>
<input
type=
"radio"
name=
"payment[method]"
class=
"radio"
data-bind=
"attr: {'id': getCode()}, value: getCode(), checked: isChecked, click: selectPaymentMethod, visible: isRadioButtonVisible()"
/>
<label
data-bind=
"attr: {'for': getCode()}"
class=
"label"
><span
data-bind=
"text: getTitle()"
></span></label>
</div>
<div
class=
"payment-method-content"
>
<div
class=
"payment-method-billing-address"
>
<!-- ko foreach: $parent.getRegion(getBillingAddressFormName()) -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
</div>
<fieldset
class=
"fieldset"
data-bind=
'attr: {id: "payment_form_" + getCode()}'
>
<div
class=
"payment-method-note"
>
<!-- ko text: $t('You will be redirected to the Adyen website.') --><!-- /ko -->
</div>
</fieldset>
<div
class=
"checkout-agreements-block"
>
<!-- ko foreach: $parent.getRegion('before-place-order') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!--/ko-->
</div>
<div
class=
"actions-toolbar"
>
<div
class=
"primary"
>
<button
class=
"action primary checkout"
type=
"submit"
data-bind=
"click: continueToAdyen, enable: (getCode() == isChecked())"
disabled
>
<span
data-bind=
"text: $t('Continue to Adyen')"
></span>
</button>
</div>
</div>
</div>
</div>
<
/div
>
<
!--/ko--
>
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