コード例 #1
0
 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);
 }
コード例 #2
0
ファイル: Processor.php プロジェクト: ORBA/magento2_payupl
 /**
  * @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);
 }