Skip to content

Commit

Permalink
New release 2.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Elavarasan Natarajan committed Sep 13, 2019
1 parent 0e57bec commit 0781673
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 41 deletions.
7 changes: 4 additions & 3 deletions Controller/ThreeDSecure/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ public function execute()
var encodedJWT = encodedHeader + "." + encodedData + "." + signature;
document.getElementById("second_jwt").value = encodedJWT;
function uuidv4() {
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
);
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, function(c){
var crypto = window.crypto || window.msCrypto;
return (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
});
}
function base64url(source) {
Expand Down
5 changes: 5 additions & 0 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,11 @@ public function getOrderByOrderId($orderId){
return $this->orderFactory->create()->load($orderId);
}

public function isWalletsEnabled()
{
return (bool) $this->_scopeConfig->getValue('worldpay/wallets_config/enabled', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
}

public function getWalletsTitle()
{
return $this->_scopeConfig->getValue('worldpay/wallets_config/title', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
Expand Down
9 changes: 1 addition & 8 deletions Model/PaymentMethods/Wallets.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function getAuthorisationService($storeId)
*/
public function isAvailable(\Magento\Quote\Api\Data\CartInterface $quote = null)
{
if ($this->worlpayhelper->isWorldPayEnable()) {
if ($this->worlpayhelper->isWorldPayEnable() && $this->worlpayhelper->isWalletsEnabled()) {
return true;
}
return false;
Expand All @@ -63,11 +63,4 @@ public function getTitle()
return $this->worlpayhelper->getWalletsTitle();
}
}



// public function getTitle()
// {
// return 'worldpay_wallets';
// }
}
43 changes: 28 additions & 15 deletions Model/WorldpayConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Magento\Framework\View\Asset\Repository;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\View\Asset\Source;
use Magento\Framework\Locale\Bundle\DataBundle;

/**
* Configuration provider for worldpayment rendering payment page.
Expand Down Expand Up @@ -53,6 +54,14 @@ class WorldpayConfigProvider implements ConfigProviderInterface
* @var \Sapient\Worldpay\Logger\WorldpayLogger
*/
protected $wplogger;

/**
* Locale model
*
* @var \Magento\Framework\Locale\ResolverInterface
*/
protected $localeResolver;


/**
* @param \Sapient\Worldpay\Logger\WorldpayLogger $wplogger
Expand All @@ -64,6 +73,7 @@ class WorldpayConfigProvider implements ConfigProviderInterface
* @param \Magento\Backend\Model\Session\Quote $adminquotesession
* @param SavedTokenFactory $savedTokenFactory
* @param \Magento\Backend\Model\Auth\Session $backendAuthSession
* @param \Magento\Framework\Locale\ResolverInterface $localeResolver
*/
public function __construct(
\Sapient\Worldpay\Logger\WorldpayLogger $wplogger,
Expand All @@ -78,7 +88,8 @@ public function __construct(
\Magento\Backend\Model\Auth\Session $backendAuthSession,
Repository $assetRepo,
RequestInterface $request,
Source $assetSource
Source $assetSource,
\Magento\Framework\Locale\ResolverInterface $localeResolver
) {

$this->wplogger = $wplogger;
Expand All @@ -96,6 +107,7 @@ public function __construct(
$this->assetRepo = $assetRepo;
$this->request = $request;
$this->assetSource = $assetSource;
$this->localeResolver = $localeResolver;
}

/**
Expand Down Expand Up @@ -233,22 +245,23 @@ public function getWalletsTypes($code)
return $this->worldpayHelper->getWalletsTypes($code);
}

/**
* Retrieve list of months translation
*
* @return array
* @api
*/
public function getMonths()
{
return array(
"01" => "01 - January",
"02" => "02 - February",
"03" => "03 - March",
"04" => "04 - April",
"05" => "05 - May",
"06" => "06 - June",
"07" => "07 - July",
"08" => "08 - August",
"09" => "09 - September",
"10"=> "10 - October",
"11"=> "11 - November",
"12"=> "12 - December"
);
$data = [];
$months = (new DataBundle())->get(
$this->localeResolver->getLocale()
)['calendar']['gregorian']['monthNames']['format']['wide'];
foreach ($months as $key => $value) {
$monthNum = ++$key < 10 ? '0' . $key : $key;
$data[$key] = $monthNum . ' - ' . $value;
}
return $data;
}

/**
Expand Down
Binary file modified Worldpay User Document.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"magento/module-quote": ">=100.0.0",
"magento/module-vault": ">=100.0.0"
},
"version": "2.1.0",
"version": "2.1.1",
"license":"proprietary",
"autoload":{
"files":[
Expand Down
4 changes: 4 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@
<!--Mobile Wallets-->
<group id="wallets_config" translate="label" type="text" sortOrder="4" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Mobile Wallets</label>
<field id="enabled" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enabled</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="title" translate="label" type="text" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Title</label>
</field>
Expand Down
9 changes: 5 additions & 4 deletions view/frontend/templates/jwtiframe.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ $environmentMode = $block->getEnvironmentMode();

document.getElementById("first_jwt").value = encodedJWT;
function uuidv4() {
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
);
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, function(c){
var crypto = window.crypto || window.msCrypto;
return (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
});
}

function base64url(source) {
// Encode in classical base64
var encodedSource = CryptoJS.enc.Base64.stringify(source);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ define(
return this;
},

filterajax: function(statusCheck = null){
filterajax: function(statusCheck){
if(!statusCheck){
return;
}
Expand Down
37 changes: 29 additions & 8 deletions view/frontend/web/js/view/payment/method-renderer/cc-method.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ define(
});
return this;
},
filtercardajax: function(statusCheck = null){
filtercardajax: function(statusCheck){
if(!statusCheck){
return;
}
Expand Down Expand Up @@ -355,15 +355,32 @@ define(
if(cc_type_selected == 'savedcard'){
bin = $("input[name='payment[token_to_use]']:checked").next().next().val();
}
if(bin) {
createJwt(bin);
}else {
alert('This card number cannot be used to place 3DS2 order now, please go and update this from My account first.');
return;
}



if(this.intigrationmode == 'direct') {

if(cc_type_selected == 'savedcard'){
if($savedCardForm.validation() && $savedCardForm.validation('isValid')) {
if(bin) {
createJwt(bin);
}else{
alert('This card number cannot be used to place 3DS2 order now, please go and update this from My account first.');
return;
}
}

}else {
if($form.validation() && $form.validation('isValid')) {
//var bin = this.creditCardNumber();
createJwt(bin);
}
}

}

}

this.dfReferenceId = null;

if(cc_type_selected == 'savedcard'){
Expand Down Expand Up @@ -428,11 +445,15 @@ define(
if(this.isClientSideEncryptionEnabled()){
require(["https://payments.worldpay.com/resources/cse/js/worldpay-cse-1.0.1.min.js"], function (worldpay) {
worldpay.setPublicKey(that.getCsePublicKey());
var expiryMonth = that.creditCardExpMonth();
if(expiryMonth < 10){
expiryMonth = '0'+expiryMonth;
}
var cseData = {
cvc: that.creditCardVerificationNumber(),
cardHolderName: $('#' + that.getCode() + '_cc_name').val(),
cardNumber: that.creditCardNumber(),
expiryMonth: that.creditCardExpMonth(),
expiryMonth: expiryMonth,
expiryYear: that.creditCardExpYear()
};
var encryptedData = worldpay.encrypt(cseData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ define(
});
return this;
},
filterwalletajax: function(statusCheck = null){
filterwalletajax: function(statusCheck){
if(!statusCheck){
return;
}
Expand Down

0 comments on commit 0781673

Please sign in to comment.