diff --git a/Block/Adminhtml/Form/Field/AdminLabels.php b/Block/Adminhtml/Form/Field/AdminLabels.php index 90d49d2..3b19a97 100644 --- a/Block/Adminhtml/Form/Field/AdminLabels.php +++ b/Block/Adminhtml/Form/Field/AdminLabels.php @@ -2,7 +2,6 @@ namespace Sapient\AccessWorldpay\Block\Adminhtml\Form\Field; - class AdminLabels extends \Sapient\AccessWorldpay\Block\Form\Field\FieldArray\CustomLabelsArray { @@ -30,5 +29,5 @@ protected function _prepareToRender() $this->_addAfter = false; $this->_addButtonLabel = __('Add'); - } + } } diff --git a/Block/Adminhtml/Form/Field/MyAccountLabels.php b/Block/Adminhtml/Form/Field/MyAccountLabels.php index 66a9ed9..90966d2 100644 --- a/Block/Adminhtml/Form/Field/MyAccountLabels.php +++ b/Block/Adminhtml/Form/Field/MyAccountLabels.php @@ -3,7 +3,6 @@ namespace Sapient\AccessWorldpay\Block\Adminhtml\Form\Field; - class MyAccountLabels extends \Sapient\AccessWorldpay\Block\Form\Field\FieldArray\CustomLabelsArray { /** diff --git a/Block/Edit.php b/Block/Edit.php index c6cac87..bf1efa9 100644 --- a/Block/Edit.php +++ b/Block/Edit.php @@ -3,7 +3,9 @@ * @copyright 2017 Sapient */ namespace Sapient\AccessWorldpay\Block; + use Magento\Framework\Serialize\SerializerInterface; + class Edit extends \Magento\Framework\View\Element\Template { /** @@ -11,8 +13,8 @@ class Edit extends \Magento\Framework\View\Element\Template */ protected $_savecard; /** - * @var SerializerInterface - */ + * @var SerializerInterface + */ private $serializer; /** * @var \Magento\Customer\Model\Session @@ -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; diff --git a/Block/Form/Field/FieldArray/CustomLabelsFieldArray.php b/Block/Form/Field/FieldArray/CustomLabelsFieldArray.php index a1aa4f5..73b436d 100644 --- a/Block/Form/Field/FieldArray/CustomLabelsFieldArray.php +++ b/Block/Form/Field/FieldArray/CustomLabelsFieldArray.php @@ -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'; /** diff --git a/Controller/Adminhtml/Syncstatus/Index.php b/Controller/Adminhtml/Syncstatus/Index.php index 7116ff8..f30dfaa 100644 --- a/Controller/Adminhtml/Syncstatus/Index.php +++ b/Controller/Adminhtml/Syncstatus/Index.php @@ -118,6 +118,6 @@ private function _redirectBackToOrderView() private function _updateOrderStatus() { - $this->paymentoperations->updateOrderStatus($this->_order); + $this->paymentoperations->updateOrderStatus($this->_order); } } diff --git a/Controller/Notification/Index.php b/Controller/Notification/Index.php index 7adf395..ab6aff0 100644 --- a/Controller/Notification/Index.php +++ b/Controller/Notification/Index.php @@ -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)); @@ -186,6 +186,6 @@ private function updateNotification($xml) private function _updateOrderStatus() { - $this->paymentoperations->updateOrderStatus($this->_order); + $this->paymentoperations->updateOrderStatus($this->_order); } } diff --git a/Controller/Savedcard/Edit.php b/Controller/Savedcard/Edit.php index 97b5f4b..2dfdc63 100644 --- a/Controller/Savedcard/Edit.php +++ b/Controller/Savedcard/Edit.php @@ -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, diff --git a/Controller/Savedcard/Index.php b/Controller/Savedcard/Index.php index 578dd89..567fd0d 100644 --- a/Controller/Savedcard/Index.php +++ b/Controller/Savedcard/Index.php @@ -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; } /** diff --git a/Cron/OrderSyncStatus.php b/Cron/OrderSyncStatus.php index bcf7516..d3b1cee 100644 --- a/Cron/OrderSyncStatus.php +++ b/Cron/OrderSyncStatus.php @@ -10,7 +10,8 @@ /** * Model for order sync status based on configuration set by admin */ -class OrderSyncStatus { +class OrderSyncStatus +{ /** * * @var \Sapient\AccessWorldpay\Logger\AccessWorldpayLogger @@ -27,7 +28,7 @@ class OrderSyncStatus { /** * Constructor - * + * * @param JsonFactory $resultJsonFactory * @param \Sapient\AccessWorldpay\Logger\AccessWorldpayLogger $wplogger * @param \Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory @@ -158,6 +159,6 @@ private function _applyPaymentUpdate() private function _updateOrderStatus() { - $this->paymentoperations->updateOrderStatus($this->_order); + $this->paymentoperations->updateOrderStatus($this->_order); } } diff --git a/Helper/AdminLabels.php b/Helper/AdminLabels.php index 23cbe5e..53ad346 100644 --- a/Helper/AdminLabels.php +++ b/Helper/AdminLabels.php @@ -6,7 +6,7 @@ use Magento\Store\Model\Store; use Magento\Framework\Serialize\SerializerInterface; -class AdminLabels +class AdminLabels { /** * Core store config @@ -212,5 +212,4 @@ public function getConfigValue($wplabelcode, $store = null) } } } - } diff --git a/Helper/CheckoutLabels.php b/Helper/CheckoutLabels.php index 26007d0..657b87b 100644 --- a/Helper/CheckoutLabels.php +++ b/Helper/CheckoutLabels.php @@ -5,7 +5,7 @@ use Magento\Store\Model\Store; use Magento\Framework\Serialize\SerializerInterface; -class CheckoutLabels +class CheckoutLabels { /** diff --git a/Helper/Data.php b/Helper/Data.php index 6ccfd79..3fbe96f 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -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() { @@ -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 @@ -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 @@ -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 diff --git a/Helper/MyAccountLabels.php b/Helper/MyAccountLabels.php index ff54292..885444f 100644 --- a/Helper/MyAccountLabels.php +++ b/Helper/MyAccountLabels.php @@ -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; /** diff --git a/Model/Authorisation/DirectService.php b/Model/Authorisation/DirectService.php index f1cfccd..150cafc 100644 --- a/Model/Authorisation/DirectService.php +++ b/Model/Authorisation/DirectService.php @@ -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 = []; @@ -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']))) { @@ -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); @@ -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']; diff --git a/Model/Authorisation/WebSdkService.php b/Model/Authorisation/WebSdkService.php index 116c941..346c717 100644 --- a/Model/Authorisation/WebSdkService.php +++ b/Model/Authorisation/WebSdkService.php @@ -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() @@ -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']; diff --git a/Model/Mapping/Service.php b/Model/Mapping/Service.php index 72cee51..af9e654 100644 --- a/Model/Mapping/Service.php +++ b/Model/Mapping/Service.php @@ -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" ] ; @@ -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']:''; } diff --git a/Model/Payment/Service.php b/Model/Payment/Service.php index 4ee8e59..3d56c39 100644 --- a/Model/Payment/Service.php +++ b/Model/Payment/Service.php @@ -35,7 +35,7 @@ public function __construct( public function createPaymentUpdateFromWorldPayXml($xml) { - if(isset($xml->errorName) && $xml->errorName=='entityIsNotConfigured' ) { + if (isset($xml->errorName) && $xml->errorName=='entityIsNotConfigured') { throw new \Magento\Framework\Exception\LocalizedException(__($xml->message)); } return $this->_getPaymentUpdateFactory() diff --git a/Model/Payment/StateJson.php b/Model/Payment/StateJson.php index 0e7768a..ca210f3 100644 --- a/Model/Payment/StateJson.php +++ b/Model/Payment/StateJson.php @@ -27,8 +27,8 @@ public function getOrderCode() { if (isset($this->_xml->orderCode)) { return (string) $this->_xml->orderCode; - }else if (isset($this->_xml->eventDetails->transactionReference)) { - return (string) $this->_xml->eventDetails->transactionReference; + } elseif (isset($this->_xml->eventDetails->transactionReference)) { + return (string) $this->_xml->eventDetails->transactionReference; } } @@ -51,9 +51,9 @@ private function _getStatusNode() { if (isset($this->_xml->outcome)) { return strtoupper($this->_xml->outcome); - }else if (isset($this->_xml->lastEvent)) { + } elseif (isset($this->_xml->lastEvent)) { return strtoupper($this->_xml->lastEvent); - }else if (isset($this->_xml->eventDetails->type)) { + } elseif (isset($this->_xml->eventDetails->type)) { return strtoupper($this->_xml->eventDetails->type); } @@ -70,7 +70,7 @@ public function getJournalReference($state) $statusNode = $this->_getStatusNode(); if (isset($this->_xml->reference)) { $reference = $this->_xml->reference; - }else if (isset($this->_xml->eventDetails->reference)) { + } elseif (isset($this->_xml->eventDetails->reference)) { $reference = $this->_xml->eventDetails->reference; return $reference->__toString(); } @@ -102,20 +102,20 @@ public function getOmsUrls($link) return $link->href; } - public function formattedStatusFromEvents($statusNode) + public function formattedStatusFromEvents($statusNode) { - switch($statusNode){ - case "SENTFORAUTHORIZATION": - return "SENT_FOR_AUTHORIZATION"; - case "SENTFORSETTLEMENT": - return "SENT_FOR_SETTLEMENT"; - case "SENTFORREFUND": - return "SENT_FOR_REFUND"; - case "REFUNDFAILED": - return "REFUND_FAILED"; - default: - return $statusNode; - } + switch ($statusNode) { + case "SENTFORAUTHORIZATION": + return "SENT_FOR_AUTHORIZATION"; + case "SENTFORSETTLEMENT": + return "SENT_FOR_SETTLEMENT"; + case "SENTFORREFUND": + return "SENT_FOR_REFUND"; + case "REFUNDFAILED": + return "REFUND_FAILED"; + default: + return $statusNode; + } } /** diff --git a/Model/Payment/Update/Authorised.php b/Model/Payment/Update/Authorised.php index 5c46966..8c7a174 100644 --- a/Model/Payment/Update/Authorised.php +++ b/Model/Payment/Update/Authorised.php @@ -67,17 +67,18 @@ private function _applyUpdate($payment, $order = null) * @return array */ private function _getAllowedPaymentStatuses(\Sapient\AccessWorldpay\Model\Order $order) - { if(!empty($order) && $order->hasWorldPayPayment()) { - if ($this->_isDirectIntegrationMode($order)) { - return [ + { + if (!empty($order) && $order->hasWorldPayPayment()) { + if ($this->_isDirectIntegrationMode($order)) { + return [ \Sapient\AccessWorldpay\Model\Payment\State::STATUS_SENT_FOR_AUTHORISATION, \Sapient\AccessWorldpay\Model\Payment\State::STATUS_AUTHORISED - ]; + ]; + } + return [\Sapient\AccessWorldpay\Model\Payment\State::STATUS_SENT_FOR_AUTHORISATION]; + } else { + throw new \Magento\Framework\Exception\LocalizedException(__('No Payment')); } - return [\Sapient\AccessWorldpay\Model\Payment\State::STATUS_SENT_FOR_AUTHORISATION]; - }else { - throw new \Magento\Framework\Exception\LocalizedException(__('No Payment')); - } } /** diff --git a/Model/Payment/Update/Factory.php b/Model/Payment/Update/Factory.php index 224fefa..a15d022 100644 --- a/Model/Payment/Update/Factory.php +++ b/Model/Payment/Update/Factory.php @@ -26,7 +26,7 @@ public function __construct( * @return object */ public function create(\Sapient\AccessWorldpay\Model\Payment\State $paymentState) - { + { switch ($paymentState->getPaymentStatus()) { case \Sapient\AccessWorldpay\Model\Payment\State::STATUS_AUTHORISED: return new \Sapient\AccessWorldpay\Model\Payment\Update\Authorised( @@ -44,12 +44,12 @@ public function create(\Sapient\AccessWorldpay\Model\Payment\State $paymentState case \Sapient\AccessWorldpay\Model\Payment\State::STATUS_SENT_FOR_SETTLEMENT: $state = \Sapient\AccessWorldpay\Model\Payment\State::STATUS_SENT_FOR_SETTLEMENT; $reference = $paymentState->getJournalReference($state); - if(isset($reference) && strtoupper($reference) == 'PARTIAL CAPTURE') { - return new \Sapient\AccessWorldpay\Model\Payment\Update\PartialCaptured( - $paymentState, - $this->worldpaymentmodel, - $this->_configHelper - ); + if (isset($reference) && strtoupper($reference) == 'PARTIAL CAPTURE') { + return new \Sapient\AccessWorldpay\Model\Payment\Update\PartialCaptured( + $paymentState, + $this->worldpaymentmodel, + $this->_configHelper + ); } return new \Sapient\AccessWorldpay\Model\Payment\Update\Captured( $paymentState, diff --git a/Model/Payment/Update/PartialRefunded.php b/Model/Payment/Update/PartialRefunded.php index 924c184..ff8cd88 100644 --- a/Model/Payment/Update/PartialRefunded.php +++ b/Model/Payment/Update/PartialRefunded.php @@ -33,9 +33,9 @@ public function apply($payment, $order = null) $reference = $this->_paymentState->getJournalReference( \Sapient\AccessWorldpay\Model\Payment\State::STATUS_PARTIAL_REFUNDED ); - if(isset($reference) && !empty($order)) { - $message = self::REFUND_COMMENT . ' Reference: ' . $reference; - $order->refund($reference, $message); + if (isset($reference) && !empty($order)) { + $message = self::REFUND_COMMENT . ' Reference: ' . $reference; + $order->refund($reference, $message); } $this->_worldPayPayment->updateAccessWorldpayPayment($this->_paymentState); } diff --git a/Model/Payment/Update/Refunded.php b/Model/Payment/Update/Refunded.php index 422e9be..aa088fc 100644 --- a/Model/Payment/Update/Refunded.php +++ b/Model/Payment/Update/Refunded.php @@ -33,9 +33,9 @@ public function apply($payment, $order = null) $reference = $this->_paymentState->getJournalReference( \Sapient\AccessWorldpay\Model\Payment\State::STATUS_REFUNDED ); - if(isset($reference) && !empty($order)) { - $message = self::REFUND_COMMENT . ' Reference: ' . $reference; - $order->refund($reference, $message); + if (isset($reference) && !empty($order)) { + $message = self::REFUND_COMMENT . ' Reference: ' . $reference; + $order->refund($reference, $message); } $this->_worldPayPayment->updateAccessWorldpayPayment($this->_paymentState); } diff --git a/Model/Payment/WorldPayPayment.php b/Model/Payment/WorldPayPayment.php index e995b6c..1313146 100644 --- a/Model/Payment/WorldPayPayment.php +++ b/Model/Payment/WorldPayPayment.php @@ -39,9 +39,9 @@ public function updateAccessWorldpayPayment(\Sapient\AccessWorldpay\Model\Paymen $wpp = $this->worldpaypayment->create(); $wpp = $wpp->loadByAccessWorldpayOrderId($paymentState->getOrderCode()); - if(strtoupper($paymentState->getPaymentStatus()) !== "UNKNOWN") { + if (strtoupper($paymentState->getPaymentStatus()) !== "UNKNOWN") { $wpp->setData('payment_status', $paymentState->getPaymentStatus()); - } + } // $wpp->setData('card_number', $paymentState->getCardNumber()); // $wpp->setData('avs_result', $paymentState->getAvsResultCode()); // $wpp->setData('cvc_result', $paymentState->getCvcResultCode()); diff --git a/Model/PaymentMethods/AbstractMethod.php b/Model/PaymentMethods/AbstractMethod.php index 402973a..7f8a4c1 100644 --- a/Model/PaymentMethods/AbstractMethod.php +++ b/Model/PaymentMethods/AbstractMethod.php @@ -576,8 +576,8 @@ public function getTokenUrl($additionalInformation) if (isset($additionalInformation['token']) && !empty($additionalInformation['token'])) { $token = $savedToken->loadByTokenCode($additionalInformation['token']); return $token ['token']; - }elseif(isset($additionalInformation['tokenUrl']) && !empty($additionalInformation['tokenUrl'])) { - return $additionalInformation['tokenUrl']; + } elseif (isset($additionalInformation['tokenUrl']) && !empty($additionalInformation['tokenUrl'])) { + return $additionalInformation['tokenUrl']; } return ''; } @@ -617,20 +617,19 @@ public function getGraphQlCCType($payment) { $additional_data = $payment->getAdditionalInformation(); $cc_type = 'CARD-SSL'; - if ($payment->getMethod()=='worldpay_cc'){ - if(!empty($additional_data['cc_number'])) { - $cc_type = $this->worlpayhelper->getCardType($additional_data['cc_number']); - } - elseif(!empty($additional_data['token']) || !empty($additional_data['tokenId'])){ + if ($payment->getMethod()=='worldpay_cc') { + if (!empty($additional_data['cc_number'])) { + $cc_type = $this->worlpayhelper->getCardType($additional_data['cc_number']); + } elseif (!empty($additional_data['token']) || !empty($additional_data['tokenId'])) { $tokenId = !empty($additional_data['token']) ? $additional_data['token'] : $additional_data['tokenId']; $tokenData = $this->worlpayhelper->getSelectedSavedCardTokenData($tokenId); $cc_type = $tokenData[0]['card_brand'].'-SSL'; - }elseif(!empty($additional_data['tokenUrl'])) { + } elseif (!empty($additional_data['tokenUrl'])) { $getTokenBrandDetails = $this->paymentservicerequest->getDetailedTokenForBrand( - $additional_data['tokenUrl'], - $this->worlpayhelper->getXmlUsername(), - $this->worlpayhelper->getXmlPassword() - ); + $additional_data['tokenUrl'], + $this->worlpayhelper->getXmlUsername(), + $this->worlpayhelper->getXmlPassword() + ); $brandResponse = json_decode($getTokenBrandDetails, true); $cc_type = $brandResponse['paymentInstrument']['brand'].'-SSL'; } @@ -641,8 +640,8 @@ public function getGraphQlCCType($payment) public function checkIfStoredSavedCard($additionalInformation) { - if(!empty($additionalInformation['tokenId'])) { - return true; + if (!empty($additionalInformation['tokenId'])) { + return true; } return false; } diff --git a/Model/PaymentMethods/PaymentOperations.php b/Model/PaymentMethods/PaymentOperations.php index 9d69ac4..9c9e529 100644 --- a/Model/PaymentMethods/PaymentOperations.php +++ b/Model/PaymentMethods/PaymentOperations.php @@ -2,10 +2,10 @@ namespace Sapient\AccessWorldpay\Model\PaymentMethods; -class PaymentOperations extends \Sapient\AccessWorldpay\Model\PaymentMethods\AbstractMethod +class PaymentOperations extends \Sapient\AccessWorldpay\Model\PaymentMethods\AbstractMethod { - public function updateOrderStatus($order) + public function updateOrderStatus($order) { if (!empty($order)) { $payment = $order->getPayment(); @@ -26,7 +26,7 @@ public function updateOrderStatus($order) } } - public function updateOrder($paymentStatus, $mageOrder) + public function updateOrder($paymentStatus, $mageOrder) { switch ($paymentStatus) { case 'SENT_FOR_SETTLEMENT': @@ -63,5 +63,4 @@ public function updateOrder($paymentStatus, $mageOrder) break; } } - } diff --git a/Model/Request.php b/Model/Request.php index b4d523e..efcc26e 100644 --- a/Model/Request.php +++ b/Model/Request.php @@ -196,6 +196,7 @@ public function sendApplePayRequest($orderCode, $username, $password, $url, $quo * */ + // @codingStandardsIgnoreStart $request = $this->_getRequest(); $logger = $this->_wplogger; if (!$url) { @@ -264,7 +265,7 @@ public function sendApplePayRequest($orderCode, $username, $password, $url, $quo '########### END OF REQUEST - FAILURE WHILST TRYING TO SEND REQUEST ###########' ); throw new \Magento\Framework\Exception\LocalizedException( - __( 'AccessWorldpay api service not available') + __('AccessWorldpay api service not available') ); } $request->close(); @@ -295,6 +296,7 @@ public function sendApplePayRequest($orderCode, $username, $password, $url, $quo ); } return $xml; + // @codingStandardsIgnoreEnd } public function sendDdcRequest($orderCode, $username, $password, $url, $quote = null) @@ -348,7 +350,7 @@ public function sendDdcRequest($orderCode, $username, $password, $url, $quote = '########### END OF REQUEST - FAILURE WHILST TRYING TO SEND REQUEST ###########' ); throw new \Magento\Framework\Exception\LocalizedException( - __( 'AccessWorldpay api service not available') + __('AccessWorldpay api service not available') ); } $request->close(); @@ -512,6 +514,7 @@ public function getSessionHrefForDirect($url, $params, $username, $password) //get detailed verified token public function getDetailedVerifiedToken($verifiedToken, $username, $password) { + // @codingStandardsIgnoreStart $logger = $this->_wplogger; $curl = curl_init(); @@ -537,18 +540,20 @@ public function getDetailedVerifiedToken($verifiedToken, $username, $password) '########### END OF REQUEST - FAILURE WHILST TRYING TO SEND REQUEST ###########' ); throw new \Magento\Framework\Exception\LocalizedException( - __( 'AccessWorldpay api service not available') + __('AccessWorldpay api service not available') ); } $logger->info('Request successfully sent for Detailed Verified Tokenisation ..........'); $logger->info($response); return $response; + // @codingStandardsIgnoreEnd } //get token details for brand public function getDetailedTokenForBrand($verifiedToken, $username, $password) { + // @codingStandardsIgnoreStart $logger = $this->_wplogger; $curl = curl_init(); @@ -574,18 +579,20 @@ public function getDetailedTokenForBrand($verifiedToken, $username, $password) '########### END OF REQUEST - FAILURE WHILST TRYING TO SEND REQUEST ###########' ); throw new \Magento\Framework\Exception\LocalizedException( - __( 'AccessWorldpay api service not available') + __('AccessWorldpay api service not available') ); } $logger->info('Request successfully sent for Detailed Token ........................'); $logger->info($response); return $response; + // @codingStandardsIgnoreEnd } //get detailed verified token public function getTokenInquiry($verifiedToken, $username, $password) { + // @codingStandardsIgnoreStart $logger = $this->_wplogger; $curl = curl_init(); curl_setopt_array($curl, [ @@ -612,17 +619,19 @@ public function getTokenInquiry($verifiedToken, $username, $password) '########### END OF REQUEST - FAILURE WHILST TRYING TO SEND REQUEST ###########' ); throw new \Magento\Framework\Exception\LocalizedException( - __( 'AccessWorldpay api service not available') + __('AccessWorldpay api service not available') ); } $logger->info('Request successfully sent for getTokenInquiry from My Account................'); $logger->info($response); return $response; + // @codingStandardsIgnoreEnd } public function getTokenDelete($deleteTokenUrl, $username, $password) { + // @codingStandardsIgnoreStart $logger = $this->_wplogger; $logger->info($deleteTokenUrl); $ch = curl_init(); @@ -643,6 +652,7 @@ public function getTokenDelete($deleteTokenUrl, $username, $password) $logger->info('Request successfully sent for delete token ........................'); curl_close($ch); return $httpcode; + // @codingStandardsIgnoreEnd } /** * Censors sensitive data before outputting to the log file @@ -688,6 +698,7 @@ private function _getRequest() */ public function putRequest($username, $password, $url, $quote = null) { + // @codingStandardsIgnoreStart $logger = $this->_wplogger; $logger->info('Setting destination URL: ' . $url); $logger->info('Initialising request'); @@ -738,7 +749,7 @@ public function putRequest($username, $password, $url, $quote = null) '########### END OF REQUEST - FAILURE WHILST TRYING TO PUT REQUEST ###########' ); throw new \Magento\Framework\Exception\LocalizedException( - __( 'AccessWorldpay api service not available for put request') + __('AccessWorldpay api service not available for put request') ); } $request->close(); @@ -761,6 +772,7 @@ public function putRequest($username, $password, $url, $quote = null) $jsonData = json_decode($body, true); $xml = $this->_array2xml($jsonData, false); return $xml; + // @codingStandardsIgnoreEnd } public function _array2xml($array, $xml = false, $orderCode = null) @@ -825,6 +837,7 @@ public function resolveConflict($username, $password, $url) */ public function getConflictDetails($username, $password, $url) { + // @codingStandardsIgnoreStart $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET"); @@ -847,6 +860,7 @@ public function getConflictDetails($username, $password, $url) $verifiedTokenResponseToArray['response_code']=$httpCode; $body = json_encode($verifiedTokenResponseToArray, true); return $body; + // @codingStandardsIgnoreEnd } /** @@ -854,6 +868,7 @@ public function getConflictDetails($username, $password, $url) */ public function resolveConflictData($username, $password, $url, $data) { + // @codingStandardsIgnoreStart $this->_wplogger->info('Conflict Data'.$data); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); @@ -872,6 +887,7 @@ public function resolveConflictData($username, $password, $url, $data) $result = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); return $httpCode; + // @codingStandardsIgnoreEnd } public function sendSavedCardCardOnFileVerificationRequest( @@ -881,6 +897,7 @@ public function sendSavedCardCardOnFileVerificationRequest( $url, $quote = null ) { + // @codingStandardsIgnoreStart $request = $this->_getRequest(); $logger = $this->_wplogger; if (!$url) { @@ -923,7 +940,7 @@ public function sendSavedCardCardOnFileVerificationRequest( '########### END OF REQUEST - FAILURE WHILST TRYING TO SEND REQUEST ###########' ); throw new \Magento\Framework\Exception\LocalizedException( - __( 'AccessWorldpay api service not available') + __('AccessWorldpay api service not available') ); } $request->close(); @@ -943,6 +960,7 @@ public function sendSavedCardCardOnFileVerificationRequest( $this->helper->setAccessWorldpayAuthCookie($match[1]); } return $body; + // @codingStandardsIgnoreEnd } /** @@ -956,6 +974,7 @@ public function sendSavedCardCardOnFileVerificationRequest( */ public function savedCardSendRequest($orderCode, $username, $password, $url, $quote = null) { + // @codingStandardsIgnoreStart $request = $this->_getRequest(); $logger = $this->_wplogger; if (!$url) { @@ -1027,11 +1046,12 @@ public function savedCardSendRequest($orderCode, $username, $password, $url, $qu $jsonData = json_decode($body, true); return $jsonData; + // @codingStandardsIgnoreEnd } public function sendGooglePayRequest($orderCode, $username, $password, $url, $quote = null) { - + // @codingStandardsIgnoreStart $request = $this->_getRequest(); $logger = $this->_wplogger; if (!$url) { @@ -1098,7 +1118,7 @@ public function sendGooglePayRequest($orderCode, $username, $password, $url, $qu '########### END OF REQUEST - FAILURE WHILST TRYING TO SEND REQUEST ###########' ); throw new \Magento\Framework\Exception\LocalizedException( - __( 'AccessWorldpay api service not available') + __('AccessWorldpay api service not available') ); } $request->close(); @@ -1129,20 +1149,21 @@ public function sendGooglePayRequest($orderCode, $username, $password, $url, $qu ); } return $xml; + // @codingStandardsIgnoreEnd } /** - * Process the request - * - * @param $quote - * @param $username - * @param $password - * @return SimpleXMLElement body - * @throws Exception - */ + * Process the request + * + * @param $quote + * @param $username + * @param $password + * @return SimpleXMLElement body + * @throws Exception + */ public function sendEventRequest($orderCode, $username, $password, $url, $quote = null) { - + // @codingStandardsIgnoreStart $logger = $this->_wplogger; $logger->info('Setting destination URL: ' . $url); $logger->info('Initialising request'); @@ -1172,7 +1193,7 @@ public function sendEventRequest($orderCode, $username, $password, $url, $quote $logger->info( '########### END OF REQUEST - FAILURE WHILST TRYING TO SEND REQUEST ###########' ); - throw new \Magento\Framework\Exception\LocalizedException ( + throw new \Magento\Framework\Exception\LocalizedException( __('AccessWorldpay api service not available') ); } @@ -1203,6 +1224,6 @@ public function sendEventRequest($orderCode, $username, $password, $url, $quote ); } return $xml; + // @codingStandardsIgnoreEnd } - } diff --git a/Model/Request/PaymentServiceRequest.php b/Model/Request/PaymentServiceRequest.php index 3e539da..531f693 100644 --- a/Model/Request/PaymentServiceRequest.php +++ b/Model/Request/PaymentServiceRequest.php @@ -261,8 +261,8 @@ public function sendWebsdkTokenOrder($directOrderParams) $directOrderParams['orderCode'] ); //add check for Graphql - if(!isset($directOrderParams['is_graphql'])) { - $this->customerSession->setUsedSavedCard(true); + if (!isset($directOrderParams['is_graphql'])) { + $this->customerSession->setUsedSavedCard(true); } return $xml; } else { @@ -282,12 +282,12 @@ public function websdkorder($directOrderParams) 'threeDSecureConfig' => $directOrderParams['threeDSecureConfig'] ]; //checkGraphQl, !empty(token_url),!used_savedcard - if(isset($directOrderParams['paymentDetails']['is_graphql']) + if (isset($directOrderParams['paymentDetails']['is_graphql']) && !empty($directOrderParams['paymentDetails']['token_url'] && !$this->worldpayhelper->is3DSecureEnabled()) ) { $directOrderParams['paymentDetails']['verifiedToken']= $directOrderParams['paymentDetails']['token_url']; return $this->sendWebsdkTokenOrder($directOrderParams); - }elseif (isset($directOrderParams['paymentDetails']['tokenId'])) { + } elseif (isset($directOrderParams['paymentDetails']['tokenId'])) { if (isset($directOrderParams['paymentDetails']['cvcHref']) && !empty($directOrderParams['paymentDetails']['cvcHref'])) { return $this->_sendWebSdkSavedCardRequest($directOrderParams, $customerId); @@ -1599,17 +1599,17 @@ protected function _sendGoogleRequest($orderCode, $username, $password, $url, $x public function eventInquiry($orderid) { - if ($this->worldpayhelper->isWorldPayEnable()) { - $collectionData = $this->omsCollectionFactory->create() + if ($this->worldpayhelper->isWorldPayEnable()) { + $collectionData = $this->omsCollectionFactory->create() ->addFieldToSelect(['awp_order_code','awp_events_param']) ->addFieldToFilter('order_increment_id', ['eq' => $orderid ]); $collectionData = $collectionData->getData(); if ($collectionData) { $eventUrl = $collectionData[0]['awp_events_param']; - }else { + } else { throw new \Magento\Framework\Exception\LocalizedException( - __('No available event link found to synchronize the status') - ); + __('No available event link found to synchronize the status') + ); } $orderCode = $collectionData[0]['awp_order_code']; @@ -1619,12 +1619,17 @@ public function eventInquiry($orderid) . $orderCode . ' ##########' ); - $xml = $this->_request->sendEventRequest($orderCode,$this->worldpayhelper->getXmlUsername(), - $this->worldpayhelper->getXmlPassword(),$eventUrl,null); + $xml = $this->_request->sendEventRequest( + $orderCode, + $this->worldpayhelper->getXmlUsername(), + $this->worldpayhelper->getXmlPassword(), + $eventUrl, + null + ); - return $xml; - } - throw new \Magento\Framework\Exception\LocalizedException( + return $xml; + } + throw new \Magento\Framework\Exception\LocalizedException( __('Access Worldpay Service Not Available') ); } diff --git a/Model/WorldpayDataProvider.php b/Model/WorldpayDataProvider.php index 21eeab5..4dd7b48 100644 --- a/Model/WorldpayDataProvider.php +++ b/Model/WorldpayDataProvider.php @@ -58,14 +58,14 @@ public function getData(array $data): array __($this->worldpayHelper->getCreditCardSpecificexception('GCCAM0')) ); } - if($this->worldpayHelper->getCcIntegrationMode() =='web_sdk' - && !empty($data[self::PATH_ADDITIONAL_DATA]['cc_number'])) { + if ($this->worldpayHelper->getCcIntegrationMode() =='web_sdk' + && !empty($data[self::PATH_ADDITIONAL_DATA]['cc_number'])) { $exceptionMessage = $this->worldpayHelper->getCreditCardSpecificexception('GCCAM10')? $this->worldpayHelper->getCreditCardSpecificexception('GCCAM10'): 'Invalid Data passed for AccessCheckout(WebSDK) integration. Please refer user guide for configuration for WebSDK'; - throw new GraphQlInputException( + throw new GraphQlInputException( __($exceptionMessage) - ); + ); } if ($this->getIsCardValidationRequired($data) && isset($data[self::PATH_ADDITIONAL_DATA]['cc_name']) diff --git a/Setup/UpgradeData.php b/Setup/UpgradeData.php index c244e7f..3dc12ee 100644 --- a/Setup/UpgradeData.php +++ b/Setup/UpgradeData.php @@ -580,18 +580,17 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $configModel = $this->configFactory->create(['data' => $configData]); $configModel->save(); } - } public function convertArrayToString($exceptionValues) { - $resultArray = []; - foreach ($exceptionValues as $row) { - $payment_type = $row['exception_code']; - $rs['exception_messages'] = $row['exception_messages']; - $rs['exception_module_messages'] = $row['exception_module_messages']; - $resultArray[$payment_type] = $rs; - } + $resultArray = []; + foreach ($exceptionValues as $row) { + $payment_type = $row['exception_code']; + $rs['exception_messages'] = $row['exception_messages']; + $rs['exception_module_messages'] = $row['exception_module_messages']; + $resultArray[$payment_type] = $rs; + } return $this->serializer->serialize($resultArray); } @@ -606,5 +605,4 @@ public function convertArrayToStringForLabels($exceptionValues) } return $this->serializer->serialize($resultArray); } - } diff --git a/composer.json b/composer.json index 33b6ec7..02038de 100644 --- a/composer.json +++ b/composer.json @@ -3,8 +3,6 @@ "description":"Accesss WorldPay Payment Module", "type":"magento2-module", "require":{ - "php":"~5.5.0|~5.6.0|~7.0.0", - "magento/magento-composer-installer": "*", "magento/module-sales": ">=100.0.0", "magento/module-payment": ">=100.0.0", "magento/module-quote": ">=100.0.0", diff --git a/docs/Magento2AccessWorldpayGraphQL-API-Guide.pdf b/docs/Access Worldpay Magento 2 GraphQL API Guide.pdf similarity index 100% rename from docs/Magento2AccessWorldpayGraphQL-API-Guide.pdf rename to docs/Access Worldpay Magento 2 GraphQL API Guide.pdf diff --git a/docs/Worldpay Magento 2 plugin installation guide.pdf b/docs/Access Worldpay Magento 2 plugin installation guide.pdf similarity index 64% rename from docs/Worldpay Magento 2 plugin installation guide.pdf rename to docs/Access Worldpay Magento 2 plugin installation guide.pdf index 7aeaeb5..20c311d 100644 Binary files a/docs/Worldpay Magento 2 plugin installation guide.pdf and b/docs/Access Worldpay Magento 2 plugin installation guide.pdf differ diff --git a/docs/Access Worldpay plugin for Magento 2 user guide.pdf b/docs/Access Worldpay plugin for Magento 2 user guide.pdf new file mode 100644 index 0000000..e54d47a Binary files /dev/null and b/docs/Access Worldpay plugin for Magento 2 user guide.pdf differ diff --git a/view/frontend/templates/addnewcard.phtml b/view/frontend/templates/addnewcard.phtml index 82ed5ad..f2345f2 100644 --- a/view/frontend/templates/addnewcard.phtml +++ b/view/frontend/templates/addnewcard.phtml @@ -24,7 +24,7 @@ $storeCode = $block->getStoreCode(); control-select-new-card"> getStoreCode();
getAccountLabelbyCode('AC3') : 'Card Number' ?>" class="input-text required validate-cc-number worldpay-cardnumber-valid">
@@ -54,12 +54,12 @@ $storeCode = $block->getStoreCode();
getAccountLabelbyCode('AC1') : 'Card Holder Name' ?>" class="input-text required cardholder_name worldpay-cardholdername-length">
@@ -102,7 +102,7 @@ $storeCode = $block->getStoreCode();
getStoreCode();