Skip to content

Commit

Permalink
Merge pull request #2 from Worldpay/release-v2.4.2-rc0821
Browse files Browse the repository at this point in the history
Release v2.4.2 rc0821
  • Loading branch information
chandan-PS authored Aug 2, 2021
2 parents 52c283e + 97b1b0d commit 07f017b
Show file tree
Hide file tree
Showing 34 changed files with 219 additions and 190 deletions.
3 changes: 1 addition & 2 deletions Block/Adminhtml/Form/Field/AdminLabels.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Sapient\AccessWorldpay\Block\Adminhtml\Form\Field;


class AdminLabels extends \Sapient\AccessWorldpay\Block\Form\Field\FieldArray\CustomLabelsArray
{

Expand Down Expand Up @@ -30,5 +29,5 @@ protected function _prepareToRender()

$this->_addAfter = false;
$this->_addButtonLabel = __('Add');
}
}
}
1 change: 0 additions & 1 deletion Block/Adminhtml/Form/Field/MyAccountLabels.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

namespace Sapient\AccessWorldpay\Block\Adminhtml\Form\Field;


class MyAccountLabels extends \Sapient\AccessWorldpay\Block\Form\Field\FieldArray\CustomLabelsArray
{
/**
Expand Down
8 changes: 5 additions & 3 deletions Block/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@
* @copyright 2017 Sapient
*/
namespace Sapient\AccessWorldpay\Block;

use Magento\Framework\Serialize\SerializerInterface;

class Edit extends \Magento\Framework\View\Element\Template
{
/**
* @var \Sapient\AccessWorldpay\Model\SavedTokenFactory
*/
protected $_savecard;
/**
* @var SerializerInterface
*/
* @var SerializerInterface
*/
private $serializer;
/**
* @var \Magento\Customer\Model\Session
Expand Down Expand Up @@ -41,7 +43,7 @@ public function __construct(
\Sapient\AccessWorldpay\Model\SavedTokenFactory $savecard,
\Magento\Customer\Model\Session $customerSession,
\Sapient\AccessWorldpay\Helper\Data $worldpayHelper,
SerializerInterface $serializer,
SerializerInterface $serializer,
array $data = []
) {
$this->_savecard = $savecard;
Expand Down
4 changes: 2 additions & 2 deletions Block/Form/Field/FieldArray/CustomLabelsFieldArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
class CustomLabelsFieldArray extends \Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray
{
/**
* @var string
*/
* @var string
*/
protected $_template = 'Sapient_AccessWorldpay::form/field/customlabelarray.phtml';

/**
Expand Down
2 changes: 1 addition & 1 deletion Controller/Adminhtml/Syncstatus/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,6 @@ private function _redirectBackToOrderView()

private function _updateOrderStatus()
{
$this->paymentoperations->updateOrderStatus($this->_order);
$this->paymentoperations->updateOrderStatus($this->_order);
}
}
4 changes: 2 additions & 2 deletions Controller/Notification/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function _getRawBody()
}
$this->wplogger->info("inside Notification-->getRawBody");
$jsonData = json_decode($this->_rawBody, true);
$xml = $this->request->_array2xml($jsonData,false);
$xml = $this->request->_array2xml($jsonData, false);
// $response = $this->directResponse->setResponse($xml);
// $response->getXml();
// $this->wplogger->info(print_r($response->getXml(),true));
Expand Down Expand Up @@ -186,6 +186,6 @@ private function updateNotification($xml)

private function _updateOrderStatus()
{
$this->paymentoperations->updateOrderStatus($this->_order);
$this->paymentoperations->updateOrderStatus($this->_order);
}
}
2 changes: 1 addition & 1 deletion Controller/Savedcard/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Edit extends \Magento\Framework\App\Action\Action
* @param PageFactory $resultPageFactory
* @param SavedTokenFactory $savecard
* @param \Sapient\AccessWorldpay\Helper\Data $worldpayHelper
* @param Session $customerSession
* @param Session $customerSession
*/
public function __construct(
Context $context,
Expand Down
16 changes: 8 additions & 8 deletions Controller/Savedcard/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ class Index extends \Magento\Framework\App\Action\Action
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
* @param \Magento\Customer\Model\Session $customerSession
* @param \Sapient\AccessWorldpay\Helper\Data $worldpayHelper
*/
public function __construct(
Context $context,
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
\Magento\Customer\Model\Session $customerSession,
\Sapient\AccessWorldpay\Helper\Data $worldpayHelper
) {
*/
public function __construct(
Context $context,
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
\Magento\Customer\Model\Session $customerSession,
\Sapient\AccessWorldpay\Helper\Data $worldpayHelper
) {
parent::__construct($context);
$this->_resultPageFactory = $resultPageFactory;
$this->customerSession = $customerSession;
$this->worldpayHelper = $worldpayHelper;
$this->worldpayHelper = $worldpayHelper;
}

/**
Expand Down
7 changes: 4 additions & 3 deletions Cron/OrderSyncStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
/**
* Model for order sync status based on configuration set by admin
*/
class OrderSyncStatus {
class OrderSyncStatus
{
/**
*
* @var \Sapient\AccessWorldpay\Logger\AccessWorldpayLogger
Expand All @@ -27,7 +28,7 @@ class OrderSyncStatus {

/**
* Constructor
*
*
* @param JsonFactory $resultJsonFactory
* @param \Sapient\AccessWorldpay\Logger\AccessWorldpayLogger $wplogger
* @param \Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory
Expand Down Expand Up @@ -158,6 +159,6 @@ private function _applyPaymentUpdate()

private function _updateOrderStatus()
{
$this->paymentoperations->updateOrderStatus($this->_order);
$this->paymentoperations->updateOrderStatus($this->_order);
}
}
3 changes: 1 addition & 2 deletions Helper/AdminLabels.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use Magento\Store\Model\Store;
use Magento\Framework\Serialize\SerializerInterface;

class AdminLabels
class AdminLabels
{
/**
* Core store config
Expand Down Expand Up @@ -212,5 +212,4 @@ public function getConfigValue($wplabelcode, $store = null)
}
}
}

}
2 changes: 1 addition & 1 deletion Helper/CheckoutLabels.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Magento\Store\Model\Store;
use Magento\Framework\Serialize\SerializerInterface;

class CheckoutLabels
class CheckoutLabels
{

/**
Expand Down
10 changes: 5 additions & 5 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ public function getXmlPassword()
}
public function getMerchantEntityReference()
{
return $this->_scopeConfig->getValue(
return $this->_scopeConfig->getValue(
'worldpay/general_config/merchant_entity',
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
);
}
public function isMacEnabled()
{
Expand Down Expand Up @@ -540,7 +540,7 @@ public function getTokenFromVault($hash, $customerId)
}

public function getMyAccountLabels()
{
{
return $this->_scopeConfig->getValue(
'worldpay_custom_labels/my_account_labels/my_account_label',
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
Expand All @@ -561,7 +561,7 @@ public function getAccountLabelbyCode($labelCode)
}

public function getCheckoutLabels()
{
{
return $this->_scopeConfig->getValue(
'worldpay_custom_labels/checkout_labels/checkout_label',
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
Expand All @@ -582,7 +582,7 @@ public function getCheckoutLabelbyCode($labelCode)
}

public function getAdminLabels()
{
{
return $this->_scopeConfig->getValue(
'worldpay_custom_labels/admin_labels/admin_label',
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
Expand Down
10 changes: 5 additions & 5 deletions Helper/MyAccountLabels.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
use Magento\Store\Model\Store;
use Magento\Framework\Serialize\SerializerInterface;

class MyAccountLabels
class MyAccountLabels
{
/**
* Core store config
*
* @var \Magento\Framework\App\Config\ScopeConfigInterface
*/
* Core store config
*
* @var \Magento\Framework\App\Config\ScopeConfigInterface
*/
protected $scopeConfig;

/**
Expand Down
40 changes: 22 additions & 18 deletions Model/Authorisation/DirectService.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function authorizePayment(
$paymentDetails,
$payment
) {
if (isset($paymentDetails['additional_data']['is_graphql'])
if (isset($paymentDetails['additional_data']['is_graphql'])
&& (empty($paymentDetails['additional_data']['tokenId'])
&& empty($paymentDetails['token_url']))) {
$orderParams = [];
Expand Down Expand Up @@ -99,7 +99,7 @@ public function authorizePayment(
/*Added Condition : If token available need not to save the card details */
if ($customerId && !(isset($paymentdetails['additional_data']['token'])
&& !empty($paymentdetails['additional_data']['token']) )) {
$this->saveToken($customerId, $payment,$paymentDetails);
$this->saveToken($customerId, $payment, $paymentDetails);
} elseif (!empty($this->customerSession->getVerifiedDetailedToken())
|| (isset($paymentDetails['additional_data']['is_graphql'])
&& !empty($paymentDetails['token_url']))) {
Expand Down Expand Up @@ -198,30 +198,30 @@ public function partialRefundPayment(
$this->_applyPaymentUpdate($directResponse, $payment);
}

public function saveToken($customerId, $payment,$paymentDetails)
public function saveToken($customerId, $payment, $paymentDetails)
{
if (isset($paymentDetails['additional_data']['is_graphql'])) {
if ($paymentDetails['additional_data']['save_card'] !=='1' && !empty($paymentDetails['token_url'])) {
if (!isset($paymentDetails['additional_data']['use_savedcard'])
if (!isset($paymentDetails['additional_data']['use_savedcard'])
&& $this->worldpayHelper->checkIfTokenExists($paymentDetails['token_url'])) {
$this->wplogger->info(" User already has this card saved....");
}else {
$this->wplogger->info(
" Inititating Delete Token for Registered customer with customerID="
.$customerId." ...."
);
$this->paymentservicerequest->getTokenDelete($paymentDetails['token_url']);
}
}else if (($paymentDetails['additional_data']['save_card'] =='1' && !empty($paymentDetails['token_url']))
$this->wplogger->info(" User already has this card saved....");
} else {
$this->wplogger->info(
" Inititating Delete Token for Registered customer with customerID="
.$customerId." ...."
);
$this->paymentservicerequest->getTokenDelete($paymentDetails['token_url']);
}
} elseif (($paymentDetails['additional_data']['save_card'] =='1' && !empty($paymentDetails['token_url']))
|| ($this->customerSession->getIsSavedCardRequested())) {
$tokenFromcard = !empty($this->customerSession->getDetailedToken())?$this->customerSession->getDetailedToken():'';
$token = !empty($paymentDetails['token_url'])?$paymentDetails['token_url'] :$tokenFromcard['_links']['tokens:token']['href'] ;
$this->customerSession->unsIsSavedCardRequested();
$this->customerSession->unsDetailedToken();
$this->saveTokenForGraphQl($token,$customerId,$payment);
$this->saveTokenForGraphQl($token, $customerId, $payment);
}

}elseif ($this->customerSession->getIsSavedCardRequested()) {
} elseif ($this->customerSession->getIsSavedCardRequested()) {
$tokenDetailResponseToArray = $this->customerSession->getDetailedToken();
$this->updateWorldPayPayment->create()->
saveVerifiedToken($tokenDetailResponseToArray, $payment);
Expand All @@ -248,16 +248,20 @@ public function saveToken($customerId, $payment,$paymentDetails)
}
}

public function saveTokenForGraphQl ($token_url,$customerId,$payment)
public function saveTokenForGraphQl($token_url, $customerId, $payment)
{
$getTokenDetails = $this->paymentservicerequest->_getDetailedVerifiedToken(
$token_url, $this->worldpayHelper->getXmlUsername(), $this->worldpayHelper->getXmlPassword()
$token_url,
$this->worldpayHelper->getXmlUsername(),
$this->worldpayHelper->getXmlPassword()
);

$tokenDetailResponseToArray = json_decode($getTokenDetails, true);
//make a call to getBrand Details,content-type is different
$getTokenBrandDetails = $this->paymentservicerequest->getDetailedTokenForBrand(
$token_url, $this->worldpayHelper->getXmlUsername(), $this->worldpayHelper->getXmlPassword()
$token_url,
$this->worldpayHelper->getXmlUsername(),
$this->worldpayHelper->getXmlPassword()
);
$brandResponse = json_decode($getTokenBrandDetails, true);
$tokenDetailResponseToArray['card_brand'] = $brandResponse['paymentInstrument']['brand'];
Expand Down
34 changes: 19 additions & 15 deletions Model/Authorisation/WebSdkService.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,21 +186,21 @@ public function saveToken($customerId, $payment, $paymentDetails)
{
if (isset($paymentDetails['additional_data']['is_graphql'])) {
if ($paymentDetails['additional_data']['save_card'] !=='1' && !empty($paymentDetails['token_url'])) {
if (!isset($paymentDetails['additional_data']['use_savedcard'])
if (!isset($paymentDetails['additional_data']['use_savedcard'])
&& $this->worldpayHelper->checkIfTokenExists($paymentDetails['token_url'])) {
$this->wplogger->info(" User already has this card saved....");
}else {
$this->wplogger->info(
" Inititating Delete Token for Registered customer with customerID="
.$customerId." ...."
);
$this->paymentservicerequest->getTokenDelete($paymentDetails['token_url']);
}
}else if ($paymentDetails['additional_data']['save_card'] =='1' && !empty($paymentDetails['token_url'])) {
$this->saveTokenForGraphQl($paymentDetails['token_url'],$customerId,$payment);
$this->wplogger->info(" User already has this card saved....");
} else {
$this->wplogger->info(
" Inititating Delete Token for Registered customer with customerID="
.$customerId." ...."
);
$this->paymentservicerequest->getTokenDelete($paymentDetails['token_url']);
}
} elseif ($paymentDetails['additional_data']['save_card'] =='1' && !empty($paymentDetails['token_url'])) {
$this->saveTokenForGraphQl($paymentDetails['token_url'], $customerId, $payment);
}

}elseif ($this->customerSession->getIsSavedCardRequested()
} elseif ($this->customerSession->getIsSavedCardRequested()
&& empty($paymentDetails['additional_data']['tokenId'])) {
$tokenDetailResponseToArray = $this->customerSession->getDetailedToken();
$this->updateWorldPayPayment->create()
Expand Down Expand Up @@ -228,16 +228,20 @@ public function saveToken($customerId, $payment, $paymentDetails)
}
}

public function saveTokenForGraphQl ($token_url,$customerId,$payment)
public function saveTokenForGraphQl($token_url, $customerId, $payment)
{
$getTokenDetails = $this->paymentservicerequest->_getDetailedVerifiedToken(
$token_url, $this->worldpayHelper->getXmlUsername(), $this->worldpayHelper->getXmlPassword()
$token_url,
$this->worldpayHelper->getXmlUsername(),
$this->worldpayHelper->getXmlPassword()
);

$tokenDetailResponseToArray = json_decode($getTokenDetails, true);
//make a call to getBrand Details,content-type is different
$getTokenBrandDetails = $this->paymentservicerequest->getDetailedTokenForBrand(
$token_url, $this->worldpayHelper->getXmlUsername(), $this->worldpayHelper->getXmlPassword()
$token_url,
$this->worldpayHelper->getXmlUsername(),
$this->worldpayHelper->getXmlPassword()
);
$brandResponse = json_decode($getTokenBrandDetails, true);
$tokenDetailResponseToArray['card_brand'] = $brandResponse['paymentInstrument']['brand'];
Expand Down
6 changes: 3 additions & 3 deletions Model/Mapping/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,8 @@ public function getRiskDataForAuthentication($quote)
"email" => $quote->getCustomerEmail(),
"createdAt" => substr($createdAt, 0, 10),
"modifiedAt" =>substr($modifiedAt, 0, 10),
"firstName" => substr(preg_replace('/\s+/', '', $address['firstName']),0,22),
"lastName" => substr(preg_replace('/\s+/', '', $address['lastName']),0,22),
"firstName" => substr(preg_replace('/\s+/', '', $address['firstName']), 0, 22),
"lastName" => substr(preg_replace('/\s+/', '', $address['lastName']), 0, 22),
"nameMatchesAccountName" => $address['firstName'] == $shippingAddress['firstName']?
"true":"false"
] ;
Expand Down Expand Up @@ -651,7 +651,7 @@ private function _getWebSdkPaymentDetails($paymentDetails)
);
}
}
if(isset($paymentDetails['additional_data']['is_graphql'])) {
if (isset($paymentDetails['additional_data']['is_graphql'])) {
$details['is_graphql'] =1;
$details['token_url'] = !empty($paymentDetails['additional_data']['tokenUrl'])?$paymentDetails['additional_data']['tokenUrl']:'';
}
Expand Down
Loading

0 comments on commit 07f017b

Please sign in to comment.