Всем привет. Поставили на сайт Яндекс Кассу. Все ок. Заказы оплачиваются - все проходит. Но после оплаты не меняется статус заказа. Писали в поддержку - ответили, что при переходе по адресу для уведомлений - сайт отвечает ошибкой 400.
Адрес: https://test.ru/index.php?route=extension/payment/yandex_money/capture
Может кто-то сталкивался с подобным? Модуль качали с https://kassa.yandex.ru/integration/opencart1-5-yookassa/
Y.CMS 2.0
Код public capture:
public function capture()
{
$this->load->language($this->getPrefix().'payment/'.self::MODULE_NAME);
if (!$this->getModel()->getKassaModel()->isEnabled()) {
header('HTTP/1.1 403 Module disabled');
return;
}
$source = file_get_contents('php://input');
if (empty($source)) {
header('HTTP/1.1 400 Empty request body');
return;
}
$json = json_decode($source, true);
if (empty($json)) {
if (json_last_error() === JSON_ERROR_NONE) {
$message = 'empty object in body';
} else {
$message = 'invalid object in body: '.$source;
}
$this->getModel()->log('warning', 'Invalid parameters in capture notification controller - '.$message);
header('HTTP/1.1 400 Invalid json object in body');
return;
}
$this->getModel()->log('info', 'Notification: '.$source);
try {
$notification = ($json['event'] === YandexCheckout\Model\NotificationEventType::PAYMENT_SUCCEEDED)
? new NotificationSucceeded($json)
: new NotificationWaitingForCapture($json);
} catch (\Exception $e) {
$this->getModel()->log('error', 'Invalid notification object - '.$e->getMessage());
header('HTTP/1.1 400 Invalid object in body');
return;
}
$orderId = $this->getModel()->findOrderIdByPayment($notification->getObject());
$this->getModel()->log('info',
sprintf($this->language->get('text_capture_init'), $notification->getObject()->getId(), $orderId));
if ($orderId <= 0) {
$this->getModel()->log('error', 'Order not exists for payment '.$notification->getObject()->getId());
header('HTTP/1.1 404 Order not exists');
return;
}
$this->load->model('checkout/order');
$orderInfo = $this->model_checkout_order->getOrder($orderId);
if (empty($orderInfo)) {
$this->getModel()->log('warning', 'Empty order#'.$orderId.' in notification');
header('HTTP/1.1 405 Invalid order payment method');
exit();
} elseif ($orderInfo['order_status_id'] <= 0) {
$this->getModel()->confirmOrder($orderId, $notification->getObject());
}
$result = null;
if ($notification instanceof NotificationWaitingForCapture) {
$payment = $this->getModel()->updatePaymentInfo($notification->getObject()->getId());
if ($payment === null) {
header('HTTP/1.1 400 Payment capture error');
$this->getModel()->log('error', 'Payment not captured: capture result is null');
} elseif ($payment->getStatus() !== PaymentStatus::WAITING_FOR_CAPTURE) {
header('HTTP/1.1 400 Invalid payment status');
$this->getModel()->log('error',
'Payment not captured: invalid payment status "'.$payment->getStatus().'"');
} else {
$payment = $notification->getObject();
if ($payment->getPaymentMethod()->getType() == PaymentMethodType::BANK_CARD) {
$this->getModel()->confirmOrder($orderId);
$kassa = $this->getModel()->getKassaModel();
$this->model_checkout_order->addOrderHistory(
$orderId,
$kassa->getHoldOrderStatusId(),
$this->language->get('text_payment_on_hold')
);
} else {
try {
$this->getModel()->capturePayment($payment);
} catch (\YandexCheckout\Common\Exceptions\ApiException $e) {
$this->getModel()->log('error', 'Payment not captured: Code: "'.$e->getCode().'"');
}
}
}
} elseif ($notification instanceof NotificationSucceeded) {
$result = $this->getModel()->fetchPaymentInfo($notification->getObject()->getId());
if ($result === null) {
header('HTTP/1.1 400 Payment capture error');
$this->getModel()->log('error', 'Payment not captured: capture result is null');
} elseif ($result->getStatus() !== PaymentStatus::SUCCEEDED) {
header('HTTP/1.1 400 Invalid payment status');
$this->getModel()->log('error',
'Payment not captured: invalid payment status "'.$result->getStatus().'"');
} else {
$this->getModel()->confirmOrderPayment(
$orderId, $result, $this->getModel()->getKassaModel()->getSuccessOrderStatusId()
);
}
}
echo json_encode(array('success' => $result));
}