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
{
$payment->setAdditionalInformation('3dActive', false);
switch ($response['paymentResult_resultCode']) {
switch ($response['resultCode']) {
case "Authorised":
//$this->_addStatusHistory($payment, $responseCode, $pspReference, $this->_getConfigData('order_status'));
$this->_addStatusHistory($payment, $response['paymentResult_resultCode'], $response['paymentResult_pspReference']);
$payment->setAdditionalInformation('pspReference', $response['paymentResult_pspReference']);
$this->_addStatusHistory($payment, $response['resultCode'], $response['pspReference']);
$payment->setAdditionalInformation('pspReference', $response['pspReference']);
break;
case "RedirectShopper":
// 3d is active so set the param to true checked in Controller/Validate3d
$payment->setAdditionalInformation('3dActive', true);
$issuerUrl = $response['paymentResult_issuerUrl'];
$PaReq = $response['paymentResult_paRequest'];
$md = $response['paymentResult_md'];
$issuerUrl = $response['issuerUrl'];
$PaReq = $response['paRequest'];
$md = $response['md'];
if(!empty($PaReq) && !empty($md) && !empty($issuerUrl)) {
$payment->setAdditionalInformation('issuerUrl', $response['paymentResult_issuerUrl']);
$payment->setAdditionalInformation('paRequest', $response['paymentResult_paRequest']);
$payment->setAdditionalInformation('md', $response['paymentResult_md']);
$payment->setAdditionalInformation('issuerUrl', $response['issuerUrl']);
$payment->setAdditionalInformation('paRequest', $response['paRequest']);
$payment->setAdditionalInformation('md', $response['md']);
} else {
throw new \Magento\Framework\Exception\LocalizedException(__('3D secure is not valid'));
}
break;
case "Refused":
// paymentResult_refusalReason
if($response['paymentResult_refusalReason']) {
// refusalReason
if($response['refusalReason']) {
$refusalReason = $response['paymentResult_refusalReason'];
$refusalReason = $response['refusalReason'];
switch($refusalReason) {
case "Transaction Not Permitted":
$errorMsg = __('The transaction is not permitted.');
......@@ -279,7 +279,7 @@ class Cc extends \Magento\Payment\Model\Method\Cc
{
$response = $this->_paymentRequest->authorise3d($payment);
$responseCode = $response['paymentResult_resultCode'];
$responseCode = $response['resultCode'];
return $responseCode;
}
......
......@@ -40,4 +40,4 @@
"Adyen\\Payment\\": ""
}
}
}
}
\ No newline at end of file
......@@ -25,5 +25,10 @@
<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">
<sequence>
<module name="Magento_Sales"/>
<module name="Magento_Quote"/>
<module name="Magento_Checkout"/>
</sequence>
</module>
</config>
\ No newline at end of file
......@@ -29,9 +29,11 @@ define(
'Magento_Checkout/js/action/set-payment-information',
'Adyen_Payment/js/action/place-order',
'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';
return Component.extend({
defaults: {
......@@ -52,6 +54,7 @@ define(
'selectedCardType',
'creditCardOwner',
'encryptedData',
'generationtime'
]);
return this;
},
......@@ -101,47 +104,54 @@ define(
'cc_cid': this.creditCardVerificationNumber(),
'cc_ss_start_month': this.creditCardSsStartMonth(),
'cc_ss_start_year': this.creditCardSsStartYear(),
'encrypted_data': this.encryptedData()
'encrypted_data': this.encryptedData(),
'generationtime': this.generationtime()
}
};
},
isActive: function() {
return true;
},
/**
* @override
*/
placeOrder: function() {
var self = this;
//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 cseInstance = adyen.encrypt.createEncryptedForm(cse_form, cse_key, cse_options);
//var cse_options = {
// name: 'payment[encrypted_data]',
// enableValidations: true,
// submitButtonAlwaysEnabled: true
//};
var options = {};
// TODO genreation time needs to be set through PHP in hidden field
var generation = new Date().toISOString();
var cseInstance = adyen.encrypt.createEncryption(cse_key, options);
var generationtime = self.getGenerationTime();
var cardData = {
number : self.creditCardNumber,
cvc : self.creditCardVerificationNumber,
holderName : self.creditCardOwner,
expiryMonth : self.creditCardExpMonth,
expiryYear : self.creditCardExpYear,
generationtime : generation
number : self.creditCardNumber(),
cvc : self.creditCardVerificationNumber(),
holderName : self.creditCardOwner(),
expiryMonth : self.creditCardExpMonth(),
expiryYear : self.creditCardExpYear(),
generationtime : generationtime
};
var data = cseInstance.encrypt(cardData);
self.encryptedData(data);
// loading icon
fullScreenLoader.startLoader();
var placeOrder = placeOrderAction(this.getData(), this.redirectAfterPlaceOrder);
$.when(placeOrder).fail(function(){
self.isPlaceOrderActionAllowed(true);
fullScreenLoader.stopLoader();
});
//return true;
//
......
......@@ -246,7 +246,14 @@
<!-- 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 -->
......@@ -276,22 +283,3 @@
</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