Skip to content

Commit

Permalink
Cancel payment if cancel triggered from Mollie dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
inpsyde-maticluznar committed Nov 22, 2023
1 parent 141374e commit 8348ba1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/MerchantCapture/MerchantCaptureModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public function run(ContainerInterface $container): bool
add_action(
$pluginId . '_after_webhook_action',
static function (Payment $payment, WC_Order $order) use ($container) {

if ($payment->isAuthorized()) {
if (!$payment->getAmountCaptured() == 0.0) {
return;
Expand All @@ -156,6 +157,17 @@ static function (Payment $payment, WC_Order $order) use ($container) {
ManualCaptureStatus::STATUS_CAPTURED
);
$order->save();
} elseif (
$payment->isCanceled() && (
($container->get('merchant.manual_capture.is_waiting'))($order) ||
($container->get('merchant.manual_capture.is_authorized'))($order)
)
) {
$order->update_meta_data(
self::ORDER_PAYMENT_STATUS_META_KEY,
ManualCaptureStatus::STATUS_VOIDED
);
$order->save();
}
},
10,
Expand Down

0 comments on commit 8348ba1

Please sign in to comment.