cancel the order and paypal go to refund automatically (hardcoded solution)

Solution:

modules/paypal/paypal.php

comment out

Line 1667-1734

// if ($params['newOrderStatus']->id == $osCanceled) {
// if ($this->context->controller instanceof PaypalIpnModuleFrontController) {
// return true;
// }

// if (in_array($orderPayPal->method, array("MB", "PPP")) || $orderPayPal->payment_status == "refunded" || $orderPayPal->payment_status == "voided") {
// return;
// }

// $paypalCapture = PaypalCapture::loadByOrderPayPalId($orderPayPal->id);

// /** @var $response \PaypalAddons\classes\API\Response\ResponseAuthorizationVoid*/
// if ($orderPayPal->method == 'EC' && Validate::isLoadedObject($paypalCapture) == false) {
// $response = $method->refund($orderPayPal);
// } elseif ($orderPayPal->method == 'EC' &&
// Validate::isLoadedObject($paypalCapture) &&
// $paypalCapture->id_capture) {
// $response = $method->refund($orderPayPal);
// } elseif ($orderPayPal->method == 'EC' &&
// Validate::isLoadedObject($paypalCapture) &&
// $paypalCapture->id_capture == false) {
// $response = $method->void($orderPayPal);
// }

// if ($response->isSuccess()) {
// if (Validate::isLoadedObject($paypalCapture)) {
// $paypalCapture->result = 'voided';
// $paypalCapture->save();
// }

// $orderPayPal->payment_status = 'voided';
// $orderPayPal->save();

// ProcessLoggerHandler::openLogger();
// ProcessLoggerHandler::logInfo(
// $response->getMessage(),
// $response->getIdTransaction(),
// $orderPayPal->id_order,
// $orderPayPal->id_cart,
// $this->context->shop->id,
// $orderPayPal->payment_tool,
// $orderPayPal->sandbox,
// $response->getDateTransaction()
// );
// ProcessLoggerHandler::closeLogger();
// } else {
// if ($response->isAlreadyRefunded()) {
// if (session_status() == PHP_SESSION_NONE) {
// session_start();
// }

// $_SESSION['paypal_transaction_already_refunded'] = true;
// } else {
// ProcessLoggerHandler::openLogger();
// ProcessLoggerHandler::logError(
// $response->getError()->getMessage(),
// null,
// $orderPayPal->id_order,
// $orderPayPal->id_cart,
// $this->context->shop->id,
// $orderPayPal->payment_tool,
// $orderPayPal->sandbox
// );
// ProcessLoggerHandler::closeLogger();
// Tools::redirect($_SERVER['HTTP_REFERER'] . '&cancel_failed=1');
// }
// }
// }

 

 

Article Details

Article ID:
35
Rating :