Skip to content
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Version 9.1.0 - WIP

* FC#0132520 - add option to disable refunds completely

## Version 9.0.0 - Released on 2026-04-13

* FC#0132520 - add config options to change capture trigger, disable automatic refunds
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ratepay/shopware6-module",
"description": "Ratepay payment methods for Shopware 6",
"version": "9.0.0",
"version": "9.1.0",
"license": "MIT",
"authors": [
{
Expand Down
27 changes: 18 additions & 9 deletions src/Components/OrderManagement/Controller/ProductPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Ratepay\RpayPayments\Core\Entity\Extension\OrderLineItemExtension;
use Ratepay\RpayPayments\Core\Entity\RatepayOrderDataEntity;
use Ratepay\RpayPayments\Core\Entity\RatepayOrderLineItemDataEntity;
use Ratepay\RpayPayments\Core\PluginConfigService;
use Ratepay\RpayPayments\Core\Util\LineItemUtil;
use Ratepay\RpayPayments\Util\CriteriaHelper;
use RuntimeException;
Expand Down Expand Up @@ -64,7 +65,8 @@ public function __construct(
PaymentCancelService $paymentCancelService,
private readonly PaymentCreditService $creditService,
private readonly LineItemFactory $lineItemFactory,
private readonly DataValidator $dataValidator
private readonly DataValidator $dataValidator,
private readonly PluginConfigService $pluginConfigService,
) {
$this->requestServicesByOperation = [
OrderOperationData::OPERATION_DELIVER => $paymentDeliverService,
Expand Down Expand Up @@ -218,15 +220,22 @@ protected function processModify(Request $request, Context $context, string $ope
], 400); // todo is this status OK ?
}

$response = $this->requestServicesByOperation[$operation]->doRequest(
new OrderOperationData($context, $order, $operation, $items, (bool) $request->request->get('updateStock'))
);
$performOperation = true;
if ($operation === OrderOperationData::OPERATION_CANCEL || $operation === OrderOperationData::OPERATION_RETURN) {
$performOperation = $this->pluginConfigService->getPerformTransactionRefunds() !== 'never';
}

if (!$response->getResponse()->isSuccessful()) {
return $this->json([
'success' => false,
'message' => $response->getResponse()->getReasonMessage(),
], 500);
if ($performOperation) {
$response = $this->requestServicesByOperation[$operation]->doRequest(
new OrderOperationData($context, $order, $operation, $items, (bool)$request->request->get('updateStock'))
);

if (!$response->getResponse()->isSuccessful()) {
return $this->json([
'success' => false,
'message' => $response->getResponse()->getReasonMessage(),
], 500);
}
}

return new Response(null, Response::HTTP_NO_CONTENT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,15 @@ protected function onDeliveryStatusTransition(StateMachineTransitionEvent $event
$service = $this->paymentDeliverService;
break;
case OrderDeliveryStates::STATE_CANCELLED:
if (!$this->configService->isTransactionRefundsOnDeliveryStatusChange()) {
if ($this->configService->getPerformTransactionRefunds() !== 'automatic') {
// do nothing
return;
}
$operation = OrderOperationData::OPERATION_CANCEL;
$service = $this->paymentCancelService;
break;
case OrderDeliveryStates::STATE_RETURNED:
if (!$this->configService->isTransactionRefundsOnDeliveryStatusChange()) {
if ($this->configService->getPerformTransactionRefunds() !== 'automatic') {
// do nothing
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Core/PluginConfigService.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ public function getCaptureTrigger(): string
return $config['captureTrigger'] ?? 'deliver';
}

public function isTransactionRefundsOnDeliveryStatusChange(): bool
public function getPerformTransactionRefunds(): string
{
$config = $this->getPluginConfiguration();

return (bool) ($config['automaticTransactionRefunds'] ?? true);
return $config['performTransactionRefunds'] ?? 'automatic';
}

protected function getContext(): Context
Expand Down

Large diffs are not rendered by default.

27 changes: 22 additions & 5 deletions src/Resources/config/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,28 @@
<label lang="de-DE">Auslöser Zahlungseinzug</label>
</input-field>

<input-field type="bool">
<name>automaticTransactionRefunds</name>
<label>Refund transactions automatically when order delivery status changes to "Cancelled" or "Returned".</label>
<label lang="de-DE">Transaktionen automatisch erstatten, wenn sich der Lieferstatus auf "Abgebrochen" oder "Retour" ändert.</label>
<defaultValue>true</defaultValue>
<input-field type="single-select">
<name>performTransactionRefunds</name>
<options>
<option>
<id>automatic</id>
<name>Refund transactions automatically when order delivery status changes to "Cancelled" or "Returned" or when performing a manual cancel or refund in the order admin.</name>
<name lang="de-DE">Transaktionen automatisch erstatten, wenn sich der Lieferstatus auf "Abgebrochen" oder "Retour" ändert oder wenn manuelle Stornierungen und Erstattungen im Bestell-Admin durchgeführt werden.</name>
</option>
<option>
<id>manual</id>
<name>Only refund transactions when performing a manual cancel or refund in the order admin.</name>
<name lang="de-DE">Transaktionen nur erstatten, wenn manuelle Stornierungen oder Erstattungen im Bestell-Admin durchgeführt werden.</name>
</option>
<option>
<id>never</id>
<name>Never refund transactions.</name>
<name lang="de-DE">Transaktionen niemals erstatten.</name>
</option>
</options>
<label>Transaction refunds</label>
<label lang="de-DE">Transaktionen erstatten</label>
<defaultValue>automatic</defaultValue>
</input-field>

<input-field type="textarea">
Expand Down
25 changes: 25 additions & 0 deletions src/Resources/public/administration/.vite/entrypoints.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"base": "/bundles/rpaypayments/administration/",
"entryPoints": {
"rpay-payments": {
"css": [
"/bundles/rpaypayments/administration/assets/rpay-payments-DQrD5tLS.css"
],
"dynamic": [],
"js": [
"/bundles/rpaypayments/administration/assets/rpay-payments-CzvWDQ2q.js"
],
"legacy": false,
"preload": []
}
},
"legacy": false,
"metadatas": {},
"version": [
"7.1.0",
7,
1,
0
],
"viteServer": null
}
11 changes: 11 additions & 0 deletions src/Resources/public/administration/.vite/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"main.js": {
"file": "assets/rpay-payments-CzvWDQ2q.js",
"name": "rpay-payments",
"src": "main.js",
"isEntry": true,
"css": [
"assets/rpay-payments-DQrD5tLS.css"
]
}
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion src/Resources/public/administration/js/rpay-payments.js

This file was deleted.

Loading