-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Display PBC fields in order grid #126
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
40f3bf0
Added payment void on order placement failure
a6522b1
Added card fields to order grid for rvvup pbc orders
2a30b6a
PHPCs fix
b3c6125
PHPCs fix
fbdd612
Fix using wrong payment method name
49f29f6
Merge branch 'main' into feature/pbc-fields
e87d002
Added images to Rvvup Card payments
851dc61
Revert "Change 'cancel payment links' behavior (#127)"
a45fc02
Revert "Added payment void on order placement failure"
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Rvvup\Payments\Ui\Component\Listing\Column; | ||
|
||
use Magento\Framework\App\CacheInterface; | ||
use Magento\Framework\App\RequestInterface; | ||
use Magento\Framework\View\Asset\Repository; | ||
use Magento\Sales\Api\OrderRepositoryInterface; | ||
use Magento\Framework\View\Element\UiComponent\ContextInterface; | ||
use Magento\Framework\View\Element\UiComponentFactory; | ||
use Magento\Ui\Component\Listing\Columns\Column; | ||
|
||
class Data extends Column | ||
{ | ||
private const RVVUP_PAYMENTS_IMAGES_GREEN_SVG = 'Rvvup_Payments::images/green.svg'; | ||
private const RVVUP_PAYMENTS_IMAGES_GREY_SVG = 'Rvvup_Payments::images/grey.svg'; | ||
private const RVVUP_PAYMENTS_IMAGES_RED_SVG = 'Rvvup_Payments::images/red.svg'; | ||
|
||
/** @var OrderRepositoryInterface */ | ||
private $orderRepository; | ||
|
||
/** @var CacheInterface */ | ||
private $cache; | ||
|
||
/** @var Repository */ | ||
private $assetRepo; | ||
|
||
/** | ||
* @var RequestInterface | ||
*/ | ||
protected $request; | ||
|
||
/** | ||
* @param ContextInterface $context | ||
* @param UiComponentFactory $uiComponentFactory | ||
* @param OrderRepositoryInterface $orderRepository | ||
* @param CacheInterface $cache | ||
* @param Repository $assetRepo | ||
* @param RequestInterface $request | ||
* @param array $components | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
ContextInterface $context, | ||
UiComponentFactory $uiComponentFactory, | ||
OrderRepositoryInterface $orderRepository, | ||
CacheInterface $cache, | ||
Repository $assetRepo, | ||
RequestInterface $request, | ||
array $components = [], | ||
array $data = [] | ||
) { | ||
$this->orderRepository = $orderRepository; | ||
$this->cache = $cache; | ||
$this->assetRepo = $assetRepo; | ||
$this->request = $request; | ||
parent::__construct($context, $uiComponentFactory, $components, $data); | ||
} | ||
|
||
public function prepareDataSource(array $dataSource): array | ||
{ | ||
if (isset($dataSource['data']['items'])) { | ||
foreach ($dataSource['data']['items'] as & $item) { | ||
if (isset($item['payment_method'])) { | ||
$field = $this->getData('name'); | ||
$id = $item["entity_id"] . '_' . $field; | ||
|
||
if ($this->cache->load($id) != null) { | ||
$value = $this->cache->load($id); | ||
$item[$field . '_src'] = $value; | ||
continue; | ||
} | ||
|
||
if (strpos($item['payment_method'], 'rvvup_CARD') === 0) { | ||
$order = $this->orderRepository->get($item["entity_id"]); | ||
$payment = $order->getPayment(); | ||
$value = $payment->getAdditionalInformation($field) ?? ''; | ||
$value = $this->getImagePath($field, $value); | ||
$item[$field . '_src'] = $value; | ||
$this->cache->save($value, $id); | ||
} else { | ||
$this->cache->save('', $id); | ||
} | ||
} | ||
} | ||
} | ||
return $dataSource; | ||
} | ||
|
||
/** | ||
* @param string $field | ||
* @param string $value | ||
* @return string | ||
*/ | ||
private function getImagePath(string $field, string $value): string | ||
{ | ||
if ($field === 'rvvup_eci') { | ||
if ($value == '05' || $value == '02') { | ||
$value = $this->getViewFileUrl(self::RVVUP_PAYMENTS_IMAGES_GREEN_SVG); | ||
} else { | ||
$value = $this->getViewFileUrl(self::RVVUP_PAYMENTS_IMAGES_GREY_SVG); | ||
} | ||
} else { | ||
switch ($value) { | ||
case 2: | ||
$value = $this->getViewFileUrl(self::RVVUP_PAYMENTS_IMAGES_GREEN_SVG); | ||
break; | ||
case 4: | ||
$value = $this->getViewFileUrl(self::RVVUP_PAYMENTS_IMAGES_RED_SVG); | ||
break; | ||
case 0: | ||
case 1: | ||
default: | ||
$value = $this->getViewFileUrl(self::RVVUP_PAYMENTS_IMAGES_GREY_SVG); | ||
} | ||
} | ||
return $value; | ||
} | ||
|
||
/** | ||
* @param string $fileId | ||
* @return string | ||
*/ | ||
public function getViewFileUrl(string $fileId): string | ||
{ | ||
$params = array_merge(['_secure' => $this->request->isSecure()], []); | ||
return $this->assetRepo->getUrlWithParams($fileId, $params); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd"> | ||
<columns name="sales_order_columns"> | ||
<column name="rvvup_cvvResponseCode" | ||
component="Magento_PageBuilder/js/grid/columns/preview-image" | ||
class="Rvvup\Payments\Ui\Component\Listing\Column\Data"> | ||
<settings> | ||
<label translate="true">Rvvup CVV</label> | ||
<hasPreview>1</hasPreview> | ||
<sortable>false</sortable> | ||
<draggable>false</draggable> | ||
</settings> | ||
</column> | ||
<column name="rvvup_avsPostCodeResponseCode" | ||
component="Magento_PageBuilder/js/grid/columns/preview-image" | ||
class="Rvvup\Payments\Ui\Component\Listing\Column\Data"> | ||
<settings> | ||
<label translate="true">Rvvup PostCode Avs</label> | ||
<hasPreview>1</hasPreview> | ||
<sortable>false</sortable> | ||
<draggable>false</draggable> | ||
</settings> | ||
</column> | ||
<column name="rvvup_avsAddressResponseCode" | ||
component="Magento_PageBuilder/js/grid/columns/preview-image" | ||
class="Rvvup\Payments\Ui\Component\Listing\Column\Data"> | ||
<settings> | ||
<label translate="true">Rvvup Address Avs</label> | ||
<hasPreview>1</hasPreview> | ||
<sortable>false</sortable> | ||
<draggable>false</draggable> | ||
</settings> | ||
</column> | ||
<column name="rvvup_eci" | ||
component="Magento_PageBuilder/js/grid/columns/preview-image" | ||
class="Rvvup\Payments\Ui\Component\Listing\Column\Data"> | ||
<settings> | ||
<label translate="true">Rvvup Eci</label> | ||
<hasPreview>1</hasPreview> | ||
<sortable>false</sortable> | ||
<draggable>false</draggable> | ||
</settings> | ||
</column> | ||
</columns> | ||
</listing> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs reverting. I think it was accidently removed.