diff --git a/src/PaymentProcessing/RefundPaymentProcessor.php b/src/PaymentProcessing/RefundPaymentProcessor.php index 54fe0d51..b6d74a0f 100644 --- a/src/PaymentProcessing/RefundPaymentProcessor.php +++ b/src/PaymentProcessing/RefundPaymentProcessor.php @@ -13,6 +13,7 @@ use PayPlug\SyliusPayPlugPlugin\Gateway\BancontactGatewayFactory; use PayPlug\SyliusPayPlugPlugin\Gateway\OneyGatewayFactory; use PayPlug\SyliusPayPlugPlugin\Gateway\PayPlugGatewayFactory; +use PayPlug\SyliusPayPlugPlugin\Gateway\ScalapayGatewayFactory; use PayPlug\SyliusPayPlugPlugin\Repository\RefundHistoryRepositoryInterface; use Psr\Log\LoggerInterface; use Sylius\Component\Core\Model\PaymentInterface; @@ -124,6 +125,7 @@ private function prepare(PaymentInterface $payment): void BancontactGatewayFactory::FACTORY_NAME, ApplePayGatewayFactory::FACTORY_NAME, AmericanExpressGatewayFactory::FACTORY_NAME, + ScalapayGatewayFactory::FACTORY_NAME, ], true) ) { return; diff --git a/tests/PHPUnit/PaymentProcessing/RefundPaymentProcessorTest.php b/tests/PHPUnit/PaymentProcessing/RefundPaymentProcessorTest.php index 456a0e19..d4ba9812 100644 --- a/tests/PHPUnit/PaymentProcessing/RefundPaymentProcessorTest.php +++ b/tests/PHPUnit/PaymentProcessing/RefundPaymentProcessorTest.php @@ -10,6 +10,7 @@ use PayPlug\SyliusPayPlugPlugin\ApiClient\PayPlugApiClientInterface; use PayPlug\SyliusPayPlugPlugin\Entity\RefundHistory; use PayPlug\SyliusPayPlugPlugin\Gateway\PayPlugGatewayFactory; +use PayPlug\SyliusPayPlugPlugin\Gateway\ScalapayGatewayFactory; use PayPlug\SyliusPayPlugPlugin\PaymentProcessing\RefundPaymentProcessor; use PayPlug\SyliusPayPlugPlugin\Repository\RefundHistoryRepositoryInterface; use PHPUnit\Framework\MockObject\MockObject; @@ -81,6 +82,24 @@ public function testProcess_fullRefundSuccess_callsApiRefund(): void $this->processor->process($payment); } + // ------------------------------------------------------------------------- + // process() — Scalapay gateway → refund is processed + // ------------------------------------------------------------------------- + + /** + * Calls process() with a Scalapay payment; verifies the API client factory is invoked + * and refundPayment() is called, confirming Scalapay is included in the supported gateway list. + */ + public function testProcess_scalapayGateway_callsApiRefund(): void + { + $payment = $this->buildPayment(ScalapayGatewayFactory::FACTORY_NAME, ['payment_id' => 'pay_scalapay']); + + $this->apiClientFactory->expects(self::once())->method('createForPaymentMethod'); + $this->apiClient->expects(self::once())->method('refundPayment')->with('pay_scalapay'); + + $this->processor->process($payment); + } + // ------------------------------------------------------------------------- // process() — API exception → UpdateHandlingException // -------------------------------------------------------------------------