public function testCompletePayment() { $amount = 2.22; $payuplOrderId = 'ABC'; $payment = $this->getMockBuilder(\Magento\Sales\Model\Order\Payment::class)->setMethods(['setParentTransactionId', 'setTransactionId', 'registerCaptureNotification', 'save'])->disableOriginalConstructor()->getMock(); $payment->expects($this->once())->method('setParentTransactionId')->with($payuplOrderId)->will($this->returnSelf()); $payment->expects($this->once())->method('setTransactionId')->with($payuplOrderId . ':C')->will($this->returnSelf()); $payment->expects($this->once())->method('registerCaptureNotification')->with($this->equalTo($amount))->will($this->returnSelf()); $payment->expects($this->once())->method('save'); $order = $this->getOrderMock(); $order->expects($this->once())->method('getPayment')->willReturn($payment); $invoice = $this->getMockBuilder(\Magento\Sales\Model\Order\Invoice::class)->disableOriginalConstructor()->getMock(); $invoice->expects($this->once())->method('save'); $order->expects($this->once())->method('getRelatedObjects')->willReturn([$invoice]); $order->expects($this->once())->method('save')->will($this->returnSelf()); $this->model->completePayment($order, $amount, $payuplOrderId); }
/** * @param string $payuplOrderId * @param string $status * @param float $amount * @throws LocalizedException */ public function processCompleted($payuplOrderId, $status, $amount) { $order = $this->loadOrderByPayuplOrderId($payuplOrderId); $this->orderHelper->completePayment($order, $amount, $payuplOrderId); $this->transactionService->updateStatus($payuplOrderId, $status, true); }