Skip to content

Commit bdf55ca

Browse files
committed
Add partial refund
1 parent 90f2703 commit bdf55ca

33 files changed

+150
-37
lines changed

Command/TreatOrderMultiPaymentCommand.php

100644100755
File mode changed.

Config/config.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<forms>
1414
<form name="payplugmodule_configuration_form" class="PayPlugModule\Form\ConfigurationForm" />
1515
<form name="payplugmodule_order_action_form" class="PayPlugModule\Form\OrderActionForm" />
16+
<form name="payplugmodule_order_action_form_refund" class="PayPlugModule\Form\OrderRefundForm" />
1617
</forms>
1718

1819
<commands>
@@ -53,6 +54,7 @@
5354
<hooks>
5455
<hook id="payplugmodule_back_hook" class="PayPlugModule\Hook\BackHookManager">
5556
<tag name="hook.event_listener" event="order-edit.payment-module-bottom" type="back" method="onOrderEditPaymentModuleBottom"/>
57+
<tag name="hook.event_listener" event="order.edit-js " type="back" templates="js:PayPlugModule/order_pay_plug.js"/>
5658
</hook>
5759
<hook id="payplugmodule_front_hook" class="PayPlugModule\Hook\FrontHookManager">
5860
<argument type="service" id="thelia.taxengine"/>

Config/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<language>en_US</language>
1818
<language>fr_FR</language>
1919
</languages>
20-
<version>1.0.0</version>
20+
<version>1.0.2</version>
2121
<authors>
2222
<author>
2323
<name>Vincent Lopes-Vicente</name>

Config/schema.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<column name="payment_method" type="VARCHAR" size="255" />
3838
<column name="payment_id" type="VARCHAR" size="255" />
3939
<column name="paid_at" type="TIMESTAMP" />
40-
<column name="refunded_at" type="TIMESTAMP" />
40+
<column name="amount_refunded" scale="6" size="16" type="DECIMAL" default="0"/>
4141

4242
<foreign-key foreignTable="order" onDelete="CASCADE" onUpdate="CASCADE">
4343
<reference local="order_id" foreign="id" />

Config/sqldb.map

100644100755
File mode changed.

Config/thelia.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ CREATE TABLE `order_pay_plug_multi_payment`
6363
`payment_method` VARCHAR(255),
6464
`payment_id` VARCHAR(255),
6565
`paid_at` DATETIME,
66-
`refunded_at` DATETIME,
66+
`amount_refunded` DECIMAL(16,6) DEFAULT 0,
6767
PRIMARY KEY (`id`,`order_id`),
6868
INDEX `order_pay_plug_multi_payment_fi_75704f` (`order_id`),
6969
CONSTRAINT `order_pay_plug_multi_payment_fk_75704f`

Config/update/1.0.2.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# This is a fix for InnoDB in MySQL >= 4.1.x
2+
# It "suspends judgement" for fkey relationships until are tables are set.
3+
SET FOREIGN_KEY_CHECKS = 0;
4+
5+
ALTER TABLE `order_pay_plug_multi_payment` ADD COLUMN `amount_refunded` DECIMAL(16,6) DEFAULT 0;
6+
ALTER TABLE `order_pay_plug_multi_payment` DROP COLUMN `refunded_at`;
7+
8+
# This restores the fkey checks, after having unset them earlier
9+
SET FOREIGN_KEY_CHECKS = 1;

Controller/Admin/OrderController.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,18 @@ public function refundAction()
1818
return $response;
1919
}
2020

21-
$form = $this->createForm('payplugmodule_order_action_form');
21+
$form = $this->createForm('payplugmodule_order_action_form_refund');
2222

2323
try {
2424
$data = $this->validateForm($form)->getData();
2525
$order = OrderQuery::create()
2626
->findOneById($data['order_id']);
2727

28+
$amountToRefund = (int)($data['refund_amount'] * 100);
29+
2830
/** @var PaymentService $paymentService */
2931
$paymentService = $this->container->get('payplugmodule_payment_service');
30-
$paymentService->doOrderRefund($order);
32+
$paymentService->doOrderRefund($order, $amountToRefund);
3133
} catch (\Exception $e) {
3234
$this->setupFormErrorContext(
3335
Translator::getInstance()->trans(

Controller/CardController.php

100644100755
File mode changed.

EventListener/ConfirmationEmailListener.php

100644100755
File mode changed.

0 commit comments

Comments
 (0)