Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion Block/Adminhtml/Widget/Grid/PaypalReferenceColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function decorate($value, TransactionInterface $row): string
return '';
}

$details = json_decode($information['details'], true);
$details = $this->getDetails($information);
if (!array_key_exists('paypalReference', $details)) {
return '';
}
Expand All @@ -53,4 +53,18 @@ public function filterPaypalReference(Collection $collection, self $column)
$value = $this->getFilter()->getValue();
$collection->addFieldToFilter('sop.additional_information', ['like' => '%' . $value . '%']);
}

public function getDetails(array $information): array
{
$details = $information['details'];
if (is_array($details)) {
return $details;
}

if (!is_string($details)) {
return [];
}

return json_decode($details, true);
}
}
44 changes: 32 additions & 12 deletions Block/Info/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@

namespace Mollie\Payment\Block\Info;

use Exception;
use Magento\Framework\Pricing\PriceCurrencyInterface;
use Magento\Framework\Registry;
use Magento\Payment\Block\Info;
use Magento\Framework\View\Element\Template\Context;
use Magento\Framework\Stdlib\DateTime;
use Magento\Framework\View\Element\Template\Context;
use Magento\Payment\Block\Info;
use Magento\Sales\Api\Data\OrderInterface;
use Mollie\Payment\Config;
use Mollie\Payment\Helper\General as MollieHelper;
Expand Down Expand Up @@ -75,7 +76,7 @@ public function getCheckoutType(): ?string
{
try {
return $this->getInfo()->getAdditionalInformation('checkout_type');
} catch (\Exception $e) {
} catch (Exception $e) {
$this->mollieHelper->addTolog('error', $e->getMessage());
return null;
}
Expand All @@ -87,7 +88,7 @@ public function getExpiresAt(): ?string
if ($expiresAt = $this->getInfo()->getAdditionalInformation('expires_at')) {
return $this->timezone->date($expiresAt)->format(DateTime::DATETIME_PHP_FORMAT);
}
} catch (\Exception $e) {
} catch (Exception $e) {
$this->mollieHelper->addTolog('error', $e->getMessage());
}

Expand Down Expand Up @@ -116,7 +117,7 @@ public function getCheckoutUrl(): ?string
{
try {
return $this->getInfo()->getAdditionalInformation('checkout_url');
} catch (\Exception $e) {
} catch (Exception $e) {
$this->mollieHelper->addTolog('error', $e->getMessage());
return null;
}
Expand All @@ -126,7 +127,7 @@ public function getPaymentStatus(): ?string
{
try {
return $this->getInfo()->getAdditionalInformation('payment_status');
} catch (\Exception $e) {
} catch (Exception $e) {
$this->mollieHelper->addTolog('error', $e->getMessage());
return null;
}
Expand All @@ -136,7 +137,26 @@ public function getDashboardUrl(): ?string
{
try {
return $this->getInfo()->getAdditionalInformation('dashboard_url');
} catch (\Exception $e) {
} catch (Exception $e) {
$this->mollieHelper->addTolog('error', $e->getMessage());
return null;
}
}

public function getPayPalReference(): ?string
{
try {
$details = $this->getInfo()->getAdditionalInformation('details');
if (is_string($details)) {
$details = json_decode($details, true);
}

if (!is_array($details) || !array_key_exists('paypalReference', $details)) {
return null;
}

return $details['paypalReference'];
} catch (Exception $e) {
$this->mollieHelper->addTolog('error', $e->getMessage());
return null;
}
Expand All @@ -146,7 +166,7 @@ public function getChangePaymentStatusUrl(): ?string
{
try {
return (string)$this->getInfo()->getAdditionalInformation('mollie_change_payment_state_url');
} catch (\Exception $exception) {
} catch (Exception $exception) {
return null;
}
}
Expand All @@ -155,7 +175,7 @@ public function getMollieId(): ?string
{
try {
return $this->getInfo()->getAdditionalInformation('mollie_id');
} catch (\Exception $e) {
} catch (Exception $e) {
$this->mollieHelper->addTolog('error', $e->getMessage());
return null;
}
Expand All @@ -181,7 +201,7 @@ public function isBuyNowPayLaterMethod(): bool
if (in_array($code, $methods)) {
return true;
}
} catch (\Exception $e) {
} catch (Exception $e) {
$this->mollieHelper->addTolog('error', $e->getMessage());
}

Expand All @@ -205,7 +225,7 @@ public function getOrderId(): ?string
{
try {
return $this->getInfo()->getParentId();
} catch (\Exception $e) {
} catch (Exception $e) {
$this->mollieHelper->addTolog('error', $e->getMessage());
return null;
}
Expand All @@ -224,7 +244,7 @@ public function getRemainderAmount()
{
try {
return $this->getInfo()->getAdditionalInformation('remainder_amount');
} catch (\Exception $e) {
} catch (Exception $e) {
$this->mollieHelper->addTolog('error', $e->getMessage());
}

Expand Down
9 changes: 9 additions & 0 deletions Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class Config
const PAYMENT_PAYMENTLINK_NEW_STATUS = 'payment/mollie_methods_paymentlink/order_status_new';
const PAYMENT_PAYMENTLINK_ADD_MESSAGE = 'payment/mollie_methods_paymentlink/add_message';
const PAYMENT_PAYMENTLINK_MESSAGE = 'payment/mollie_methods_paymentlink/message';
const PAYMENT_PAYPAL_SHOW_REFERENCE_IN_TRANSACTIONS_GRID = 'payment/mollie_methods_paypal/show_reference_in_transactions_grid';
const PAYMENT_USE_CUSTOM_PAYMENTLINK_URL = 'payment/mollie_general/use_custom_paymentlink_url';
const PAYMENT_CUSTOM_PAYMENTLINK_URL = 'payment/mollie_general/custom_paymentlink_url';
const PAYMENT_POINTOFSALE_ALLOWED_CUSTOMER_GROUPS = 'payment/mollie_methods_pointofsale/allowed_customer_groups';
Expand Down Expand Up @@ -549,6 +550,14 @@ public function paymentLinkMessage($storeId = null): string
);
}

public function showPaypalReferenceInTransactionsGrid(?int $storeId = null): bool
{
return (string)$this->isSetFlag(
static::PAYMENT_PAYPAL_SHOW_REFERENCE_IN_TRANSACTIONS_GRID,
$storeId
);
}

public function useCustomPaymentLinkUrl($storeId = null): bool
{
return $this->isSetFlag(static::PAYMENT_USE_CUSTOM_PAYMENTLINK_URL, $storeId);
Expand Down
8 changes: 8 additions & 0 deletions etc/adminhtml/methods/paypal.xml
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,13 @@
<field id="active">1</field>
</depends>
</field>
<field id="show_reference_in_transactions_grid" translate="label" type="select" sortOrder="160"
showInDefault="1"
showInWebsite="1"
showInStore="1">
<label>Add reference column to transactions grid</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<config_path>payment/mollie_methods_paypal/show_reference_in_transactions_grid</config_path>
</field>
</group>
</include>
1 change: 1 addition & 0 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@
<can_authorize>0</can_authorize>
<can_authorize_vault>0</can_authorize_vault>
<can_edit>1</can_edit>
<show_reference_in_transactions_grid>1</show_reference_in_transactions_grid>
</mollie_methods_paypal>
<mollie_methods_paysafecard>
<active>1</active>
Expand Down
4 changes: 3 additions & 1 deletion view/adminhtml/layout/sales_transactions_grid_block.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="sales.transactions.grid.columnSet">
<block class="Mollie\Payment\Block\Adminhtml\Widget\Grid\PaypalReferenceColumn" name="mollie_paypal_reference">
<block class="Mollie\Payment\Block\Adminhtml\Widget\Grid\PaypalReferenceColumn"
name="mollie_paypal_reference"
ifconfig="payment/mollie_methods_paypal/show_reference_in_transactions_grid">
<arguments>
<argument name="header" xsi:type="string" translate="true">Mollie PayPal ID</argument>
<argument name="type" xsi:type="string">additional_information_renderer</argument>
Expand Down
9 changes: 9 additions & 0 deletions view/adminhtml/templates/info/mollie_base.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @var \Mollie\Payment\Block\Info\Base $block
* @var \Magento\Framework\Escaper $escaper
*/

use Mollie\Payment\Model\Methods\Voucher;

// Magento 2.3 compatibility
Expand Down Expand Up @@ -87,6 +88,14 @@ $status = $block->getPaymentStatus();
</td>
</tr>
<?php endif; ?>
<?php if ($paypalReference = $block->getPayPalReference()): ?>
<tr>
<th><?= $escaper->escapeHtml(__('PayPal Reference')); ?></th>
<td>
<?= $escaper->escapeHtml($paypalReference); ?>
</td>
</tr>
<?php endif; ?>
<tr>
<th><?= $escaper->escapeHtml(__('Update Payment Status')); ?></th>
<td>
Expand Down
Loading