/** * @param bool $manualReviewComment * @param bool $createInvoice * @throws Exception */ protected function _setPaymentAuthorized($manualReviewComment = true, $createInvoice = false) { $this->_adyenLogger->addAdyenNotificationCronjob('Set order to authorised'); // if full amount is captured create invoice $currency = $this->_order->getOrderCurrencyCode(); $amount = $this->_value; $orderAmount = (int) $this->_adyenHelper->formatAmount($this->_order->getGrandTotal(), $currency); // create invoice for the capture notification if you are on manual capture if ($createInvoice == true && $amount == $orderAmount) { $this->_adyenLogger->addAdyenNotificationCronjob('amount notification:' . $amount . ' amount order:' . $orderAmount); $this->_createInvoice(); } // if you have capture on shipment enabled don't set update the status of the payment $captureOnShipment = $this->_getConfigData('capture_on_shipment', 'adyen_abstract', $this->_order->getStoreId()); if (!$captureOnShipment) { $status = $this->_getConfigData('payment_authorized', 'adyen_abstract', $this->_order->getStoreId()); } // virtual order can have different status if ($this->_order->getIsVirtual()) { $this->_adyenLogger->addAdyenNotificationCronjob('Product is a virtual product'); $virtualStatus = $this->_getConfigData('payment_authorized_virtual'); if ($virtualStatus != "") { $status = $virtualStatus; } } // check for boleto if payment is totally paid if ($this->_paymentMethodCode() == "adyen_boleto") { // check if paid amount is the same as orginal amount $orginalAmount = $this->_boletoOriginalAmount; $paidAmount = $this->_boletoPaidAmount; if ($orginalAmount != $paidAmount) { // not the full amount is paid. Check if it is underpaid or overpaid // strip the BRL of the string $orginalAmount = str_replace("BRL", "", $orginalAmount); $orginalAmount = floatval(trim($orginalAmount)); $paidAmount = str_replace("BRL", "", $paidAmount); $paidAmount = floatval(trim($paidAmount)); if ($paidAmount > $orginalAmount) { $overpaidStatus = $this->_getConfigData('order_overpaid_status', 'adyen_boleto'); // check if there is selected a status if not fall back to the default $status = !empty($overpaidStatus) ? $overpaidStatus : $status; } else { $underpaidStatus = $this->_getConfigData('order_underpaid_status', 'adyen_boleto'); // check if there is selected a status if not fall back to the default $status = !empty($underpaidStatus) ? $underpaidStatus : $status; } } } $comment = "Adyen Payment Successfully completed"; // if manual review is true use the manual review status if this is set if ($manualReviewComment == true && $this->_fraudManualReview) { // check if different status is selected $fraudManualReviewStatus = $this->_getFraudManualReviewStatus(); if ($fraudManualReviewStatus != "") { $status = $fraudManualReviewStatus; $comment = "Adyen Payment is in Manual Review check the Adyen platform"; } } $status = !empty($status) ? $status : $this->_order->getStatus(); $this->_order->addStatusHistoryComment(__($comment), $status); $this->_adyenLogger->addAdyenNotificationCronjob('Order status is changed to authorised status, status is ' . $status); }
/** * Capture order's payment using AIM. * * @param \Magento\Sales\Model\Order $order * @return void */ protected function _captureOrder(\Magento\Sales\Model\Order $order) { $payment = $order->getPayment(); if ($payment->getAdditionalInformation('payment_type') == self::ACTION_AUTHORIZE_CAPTURE) { try { $payment->setTransactionId(null)->setParentTransactionId($this->getResponse()->getXTransId())->capture(null); // set status from config for AUTH_AND_CAPTURE orders. if ($order->getState() == \Magento\Sales\Model\Order::STATE_PROCESSING) { $orderStatus = $this->getConfigData('order_status'); if (!$orderStatus || $order->getIsVirtual()) { $orderStatus = $order->getConfig()->getStateDefaultStatus(\Magento\Sales\Model\Order::STATE_PROCESSING); } if ($orderStatus) { $order->setStatus($orderStatus); } } $order->save(); } catch (\Exception $e) { //if we couldn't capture order, just leave it as NEW order. $this->_logger->logException($e); } } }
/** * @param Order $order * @return string|null */ protected function getFormattedShippingAddress($order) { return $order->getIsVirtual() ? null : $this->addressRenderer->format($order->getShippingAddress(), 'html'); }