Skip to content

Fix support for returns#322

Open
ernestwisniewski wants to merge 6 commits intomainfrom
fix_support_for_returns
Open

Fix support for returns#322
ernestwisniewski wants to merge 6 commits intomainfrom
fix_support_for_returns

Conversation

@ernestwisniewski
Copy link
Contributor

This PR fixes #224

@ernestwisniewski ernestwisniewski force-pushed the fix_support_for_returns branch 2 times, most recently from b85e74e to 7bb2972 Compare September 12, 2025 16:18
use Sylius\Component\Core\Model\PaymentMethodInterface;
use Sylius\RefundPlugin\Provider\RefundPaymentMethodsProviderInterface;

final class TpayAwareRefundPaymentMethodsProvider implements RefundPaymentMethodsProviderInterface
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this class?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A 500 error occurs when a payment does not have a Tpay transaction ID in its details. For new, manually created Tpay orders, the refund works correctly. The class filters the refund options to only those that can be executed via Tpay. I asked about the expected behavior, and the Tpay refund option was supposed to be hidden.

#322

return array_values(array_filter($paymentMethods, function (PaymentMethodInterface $method): bool {
$factoryName = $method->getGatewayConfig()?->getFactoryName();

return null !== $factoryName && 'tpay_redirect' !== $factoryName;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we filter only tpay_redirect? Every Tpay payment method will cause an error here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only this one gateway is added to the parameter sylius_refund.supported_gateways

AddSupportedRefundPaymentMethodPass:

/** @var array<string, mixed> $supportedGateways */
$supportedGateways = $container->getParameter(self::SUPPORTED_GATEWAYS_PARAM_NAME);
$supportedGateways[] = 'tpay_redirect';

$container->setParameter(self::SUPPORTED_GATEWAYS_PARAM_NAME, $supportedGateways);

I modified the condition to be more generic. Alternatively, I could try to use RefundDispatchEligibilityChecker here.

@ernestwisniewski ernestwisniewski force-pushed the fix_support_for_returns branch 3 times, most recently from d2f79a3 to 52de016 Compare September 17, 2025 09:34
@jakubtobiasz jakubtobiasz force-pushed the fix_support_for_returns branch from 52de016 to fde0163 Compare September 23, 2025 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix support for returns

3 participants