Skip to content

Commit

Permalink
New release 2.1.1 with API KEY changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Elavarasan Natarajan committed Sep 13, 2019
1 parent 0781673 commit 3839a51
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 15 deletions.
5 changes: 5 additions & 0 deletions Block/Jwt.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public function __construct(
parent::__construct($context);
}

public function getJwtApiKey()
{
return $this->_helper->isJwtApiKey();
}

public function getJwtIssuer()
{
return $this->_helper->isJwtIssuer();
Expand Down
2 changes: 1 addition & 1 deletion Controller/ThreeDSecure/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function execute()
},
"ObjectifyPayload": true
};
var secret = "fa2daee2-1fbb-45ff-4444-52805d5cd9e0";
var secret = "'.$threeDSecureChallengeConfig["jwtApiKey"].'";
var stringifiedHeader = CryptoJS.enc.Utf8.parse(JSON.stringify(header));
var encodedHeader = base64url(stringifiedHeader);
Expand Down
7 changes: 7 additions & 0 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,13 @@ public function isDynamic3DS2Enabled()
return (bool) $this->_scopeConfig->getValue('worldpay/general_config/enable_dynamic3DS2', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
}

public function isJwtApiKey() {
if ($this->isDynamic3DS2Enabled()) {
return $this->_scopeConfig->getValue('worldpay/general_config/jwt_api_key', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
}
return (bool) false;
}

public function isJwtIssuer() {
if ($this->isDynamic3DS2Enabled()) {
return $this->_scopeConfig->getValue('worldpay/general_config/jwt_issuer', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
Expand Down
4 changes: 2 additions & 2 deletions Model/Authorisation/DirectService.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ private function _abortIfPaymentError($paymentUpdate)
// get 3ds2 params from the configuration and set to checkout session
public function get3DS2ConfigValues(){
$data = array();
$data['jwtIssuer'] = $this->worldpayHelper->isJwtIssuer();

$data['jwtApiKey'] = $this->worldpayHelper->isJwtApiKey();
$data['jwtIssuer'] = $this->worldpayHelper->isJwtIssuer();
$data['organisationalUnitId'] = $this->worldpayHelper->isOrganisationalUnitId();

$mode = $this->worldpayHelper->getEnvironmentMode();
Expand Down
4 changes: 2 additions & 2 deletions Model/Authorisation/TokenService.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ private function _abortIfPaymentError($paymentUpdate)
// get 3ds2 params from the configuration and set to checkout session
public function get3DS2ConfigValues(){
$data = array();
$data['jwtIssuer'] = $this->worldpayHelper->isJwtIssuer();

$data['jwtApiKey'] = $this->worldpayHelper->isJwtApiKey();
$data['jwtIssuer'] = $this->worldpayHelper->isJwtIssuer();
$data['organisationalUnitId'] = $this->worldpayHelper->isOrganisationalUnitId();

$mode = $this->worldpayHelper->getEnvironmentMode();
Expand Down
1 change: 1 addition & 0 deletions Model/WorldpayConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ public function getConfig()

// 3DS2 Configurations
$config['payment']['ccform']['isDynamic3DS2Enabled'] = $this->worldpayHelper->isDynamic3DS2Enabled();
$config['payment']['ccform']['isJwtApiKey'] = $this->worldpayHelper->isJwtApiKey();
$config['payment']['ccform']['isJwtIssuer'] = $this->worldpayHelper->isJwtIssuer();
$config['payment']['ccform']['isOrganisationalUnitId'] = $this->worldpayHelper->isOrganisationalUnitId();
$config['payment']['ccform']['isTestDdcUrl'] = $this->worldpayHelper->isTestDdcUrl();
Expand Down
22 changes: 13 additions & 9 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,46 +65,50 @@
<label>Enable Dynamic 3DS2 Secure Override</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="jwt_issuer" translate="label" type="text" sortOrder="22" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="jwt_api_key" translate="label" type="text" sortOrder="23" showInDefault="1" showInWebsite="1" showInStore="1">
<label>JWT Api key</label>
<depends><field id="enable_dynamic3DS2">1</field></depends>
</field>
<field id="jwt_issuer" translate="label" type="text" sortOrder="24" showInDefault="1" showInWebsite="1" showInStore="1">
<label>JWT Issuer</label>
<depends><field id="enable_dynamic3DS2">1</field></depends>
</field>
<field id="organisational_unit_id" translate="label" type="text" sortOrder="23" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="organisational_unit_id" translate="label" type="text" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Organisational Unit Id</label>
<depends><field id="enable_dynamic3DS2">1</field></depends>
</field>
<field id="test_ddc_url" translate="label" type="text" sortOrder="26" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Test DDC URL</label>
<depends><field id="enable_dynamic3DS2">1</field></depends>
</field>
<field id="production_ddc_url" translate="label" type="text" sortOrder="26" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="production_ddc_url" translate="label" type="text" sortOrder="27" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Production DDC URL</label>
<depends><field id="enable_dynamic3DS2">1</field></depends>
</field>
<field id="risk_data" translate="label" type="select" sortOrder="24" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="risk_data" translate="label" type="select" sortOrder="28" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Risk Data</label>
<depends><field id="enable_dynamic3DS2">1</field></depends>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="authentication_method" translate="label" type="select" sortOrder="25" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="authentication_method" translate="label" type="select" sortOrder="29" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Authentication Method</label>
<depends><field id="enable_dynamic3DS2">1</field></depends>
<source_model>Sapient\Worldpay\Model\Config\Source\AuthenticationMethods</source_model>
</field>
<field id="test_challenge_url" translate="label" type="text" sortOrder="26" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="test_challenge_url" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Test Challenge URL</label>
<depends><field id="enable_dynamic3DS2">1</field></depends>
</field>
<field id="production_challenge_url" translate="label" type="text" sortOrder="26" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="production_challenge_url" translate="label" type="text" sortOrder="31" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Production Challenge URL</label>
<depends><field id="enable_dynamic3DS2">1</field></depends>
</field>
<field id="challenge_preference" translate="label" type="select" sortOrder="27" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="challenge_preference" translate="label" type="select" sortOrder="32" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Challenge Preference</label>
<depends><field id="enable_dynamic3DS2">1</field></depends>
<source_model>Sapient\Worldpay\Model\Config\Source\ChallengePreference</source_model>
</field>
<field id="challenge_window_size" translate="label" type="select" sortOrder="28" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="challenge_window_size" translate="label" type="select" sortOrder="33" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Challenge Window Size</label>
<depends><field id="enable_dynamic3DS2">1</field></depends>
<source_model>Sapient\Worldpay\Model\Config\Source\ChallengeWindowSize</source_model>
Expand Down
3 changes: 2 additions & 1 deletion view/frontend/templates/jwtiframe.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ $ccNumber = '';
if($params){
$ccNumber = $params['cardNumber'];
}
$jwtApiKey = $block->getJwtApiKey();
$jwtIssuer = $block->getJwtIssuer();
$organisationalUnitId = $block->getOrganisationalUnitId();
$ddcUrl = $block->getDdcUrl();
Expand Down Expand Up @@ -35,7 +36,7 @@ $environmentMode = $block->getEnvironmentMode();
"iss": "<?php echo $jwtIssuer;?>",
"OrgUnitId": "<?php echo $organisationalUnitId;?>"
};
var secret = "fa2daee2-1fbb-45ff-4444-52805d5cd9e0";
var secret = "<?php echo $jwtApiKey;?>";

var stringifiedHeader = CryptoJS.enc.Utf8.parse(JSON.stringify(header));
var encodedHeader = base64url(stringifiedHeader);
Expand Down

0 comments on commit 3839a51

Please sign in to comment.