We will be off from 27/1 (Monday) to 31/1 (Friday) (GMT +7) for our Tet Holiday (Lunar New Year) in our country

Commit d479ed1f authored by rikterbeek's avatar rikterbeek

Use API library for api payments, new cse library version used

parent 2a81bb59
File mode changed from 100644 to 100755
This diff is collapsed.
...@@ -204,32 +204,32 @@ class Cc extends \Magento\Payment\Model\Method\Cc ...@@ -204,32 +204,32 @@ class Cc extends \Magento\Payment\Model\Method\Cc
{ {
$payment->setAdditionalInformation('3dActive', false); $payment->setAdditionalInformation('3dActive', false);
switch ($response['paymentResult_resultCode']) { switch ($response['resultCode']) {
case "Authorised": case "Authorised":
//$this->_addStatusHistory($payment, $responseCode, $pspReference, $this->_getConfigData('order_status')); //$this->_addStatusHistory($payment, $responseCode, $pspReference, $this->_getConfigData('order_status'));
$this->_addStatusHistory($payment, $response['paymentResult_resultCode'], $response['paymentResult_pspReference']); $this->_addStatusHistory($payment, $response['resultCode'], $response['pspReference']);
$payment->setAdditionalInformation('pspReference', $response['paymentResult_pspReference']); $payment->setAdditionalInformation('pspReference', $response['pspReference']);
break; break;
case "RedirectShopper": case "RedirectShopper":
// 3d is active so set the param to true checked in Controller/Validate3d // 3d is active so set the param to true checked in Controller/Validate3d
$payment->setAdditionalInformation('3dActive', true); $payment->setAdditionalInformation('3dActive', true);
$issuerUrl = $response['paymentResult_issuerUrl']; $issuerUrl = $response['issuerUrl'];
$PaReq = $response['paymentResult_paRequest']; $PaReq = $response['paRequest'];
$md = $response['paymentResult_md']; $md = $response['md'];
if(!empty($PaReq) && !empty($md) && !empty($issuerUrl)) { if(!empty($PaReq) && !empty($md) && !empty($issuerUrl)) {
$payment->setAdditionalInformation('issuerUrl', $response['paymentResult_issuerUrl']); $payment->setAdditionalInformation('issuerUrl', $response['issuerUrl']);
$payment->setAdditionalInformation('paRequest', $response['paymentResult_paRequest']); $payment->setAdditionalInformation('paRequest', $response['paRequest']);
$payment->setAdditionalInformation('md', $response['paymentResult_md']); $payment->setAdditionalInformation('md', $response['md']);
} else { } else {
throw new \Magento\Framework\Exception\LocalizedException(__('3D secure is not valid')); throw new \Magento\Framework\Exception\LocalizedException(__('3D secure is not valid'));
} }
break; break;
case "Refused": case "Refused":
// paymentResult_refusalReason // refusalReason
if($response['paymentResult_refusalReason']) { if($response['refusalReason']) {
$refusalReason = $response['paymentResult_refusalReason']; $refusalReason = $response['refusalReason'];
switch($refusalReason) { switch($refusalReason) {
case "Transaction Not Permitted": case "Transaction Not Permitted":
$errorMsg = __('The transaction is not permitted.'); $errorMsg = __('The transaction is not permitted.');
...@@ -279,7 +279,7 @@ class Cc extends \Magento\Payment\Model\Method\Cc ...@@ -279,7 +279,7 @@ class Cc extends \Magento\Payment\Model\Method\Cc
{ {
$response = $this->_paymentRequest->authorise3d($payment); $response = $this->_paymentRequest->authorise3d($payment);
$responseCode = $response['paymentResult_resultCode']; $responseCode = $response['resultCode'];
return $responseCode; return $responseCode;
} }
......
...@@ -40,4 +40,4 @@ ...@@ -40,4 +40,4 @@
"Adyen\\Payment\\": "" "Adyen\\Payment\\": ""
} }
} }
} }
\ No newline at end of file
...@@ -25,5 +25,10 @@ ...@@ -25,5 +25,10 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Adyen_Payment" setup_version="1.0.0.1"> <module name="Adyen_Payment" setup_version="1.0.0.1">
<sequence>
<module name="Magento_Sales"/>
<module name="Magento_Quote"/>
<module name="Magento_Checkout"/>
</sequence>
</module> </module>
</config> </config>
\ No newline at end of file
...@@ -29,9 +29,11 @@ define( ...@@ -29,9 +29,11 @@ define(
'Magento_Checkout/js/action/set-payment-information', 'Magento_Checkout/js/action/set-payment-information',
'Adyen_Payment/js/action/place-order', 'Adyen_Payment/js/action/place-order',
'mage/translate', 'mage/translate',
'Adyen_Payment/js/view/payment/adyen-encrypt' 'Magento_Checkout/js/model/payment/additional-validators',
'Magento_Checkout/js/model/full-screen-loader',
'Adyen_Payment/js/view/payment/adyen-encrypt',
], ],
function (_, $, Component, setPaymentInformationAction, placeOrderAction, $t) { function (_, $, Component, setPaymentInformationAction, placeOrderAction, $t, additionalValidators, fullScreenLoader) {
'use strict'; 'use strict';
return Component.extend({ return Component.extend({
defaults: { defaults: {
...@@ -52,6 +54,7 @@ define( ...@@ -52,6 +54,7 @@ define(
'selectedCardType', 'selectedCardType',
'creditCardOwner', 'creditCardOwner',
'encryptedData', 'encryptedData',
'generationtime'
]); ]);
return this; return this;
}, },
...@@ -101,47 +104,54 @@ define( ...@@ -101,47 +104,54 @@ define(
'cc_cid': this.creditCardVerificationNumber(), 'cc_cid': this.creditCardVerificationNumber(),
'cc_ss_start_month': this.creditCardSsStartMonth(), 'cc_ss_start_month': this.creditCardSsStartMonth(),
'cc_ss_start_year': this.creditCardSsStartYear(), 'cc_ss_start_year': this.creditCardSsStartYear(),
'encrypted_data': this.encryptedData() 'encrypted_data': this.encryptedData(),
'generationtime': this.generationtime()
} }
}; };
}, },
isActive: function() { isActive: function() {
return true; return true;
}, },
/**
* @override
*/
placeOrder: function() { placeOrder: function() {
var self = this; var self = this;
//var cse_form = $("adyen-cc-form"); //var cse_form = $("adyen-cc-form");
var cse_form = document.getElementById('adyen-cc-form'); var cse_form = document.getElementById('adyen-cc-form');
var cse_key = this.getCSEKey(); var cse_key = this.getCSEKey();
var cse_options = { //var cse_options = {
name: 'payment[encrypted_data]', // name: 'payment[encrypted_data]',
enableValidations: true, // enableValidations: true,
//submitButtonAlwaysEnabled: true // submitButtonAlwaysEnabled: true
}; //};
var options = {};
var cseInstance = adyen.encrypt.createEncryptedForm(cse_form, cse_key, cse_options);
// TODO genreation time needs to be set through PHP in hidden field var cseInstance = adyen.encrypt.createEncryption(cse_key, options);
var generation = new Date().toISOString(); var generationtime = self.getGenerationTime();
var cardData = { var cardData = {
number : self.creditCardNumber, number : self.creditCardNumber(),
cvc : self.creditCardVerificationNumber, cvc : self.creditCardVerificationNumber(),
holderName : self.creditCardOwner, holderName : self.creditCardOwner(),
expiryMonth : self.creditCardExpMonth, expiryMonth : self.creditCardExpMonth(),
expiryYear : self.creditCardExpYear, expiryYear : self.creditCardExpYear(),
generationtime : generation generationtime : generationtime
}; };
var data = cseInstance.encrypt(cardData); var data = cseInstance.encrypt(cardData);
self.encryptedData(data); self.encryptedData(data);
// loading icon
fullScreenLoader.startLoader();
var placeOrder = placeOrderAction(this.getData(), this.redirectAfterPlaceOrder); var placeOrder = placeOrderAction(this.getData(), this.redirectAfterPlaceOrder);
$.when(placeOrder).fail(function(){ $.when(placeOrder).fail(function(){
self.isPlaceOrderActionAllowed(true); self.isPlaceOrderActionAllowed(true);
fullScreenLoader.stopLoader();
}); });
//return true; //return true;
// //
......
...@@ -246,7 +246,14 @@ ...@@ -246,7 +246,14 @@
<!-- ko if: (isCseEnabled())--> <!-- ko if: (isCseEnabled())-->
<input type="hidden" id="adyen_encrypted_form_expiry_generationtime" data-bind="value: getGenerationTime()" data-encrypted-name="generationtime" /> <input type="hidden"
name="payment[generationtime]"
class="input-text"
value=""
data-encrypted-name="generationtime"
data-bind="attr: {id: getCode() + '_generationtime', 'data-container': getCode() + '-generationtime'},
value: getGenerationTime()
">
<!-- /ko --> <!-- /ko -->
...@@ -276,22 +283,3 @@ ...@@ -276,22 +283,3 @@
</div> </div>
</div> </div>
<script type="text/javascript">
alert("DF");
</script>
<script>
require([
"jquery",
"mage/mage"
], function($){
alert("DF");
$(document).ready(function () {
'use strict';
var form = $( "#adyen-cc-form").attr('class');
alert(form);
});
});
</script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment