當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Payment::setParentTransactionId方法代碼示例

本文整理匯總了PHP中Magento\Sales\Model\Order\Payment::setParentTransactionId方法的典型用法代碼示例。如果您正苦於以下問題:PHP Payment::setParentTransactionId方法的具體用法?PHP Payment::setParentTransactionId怎麽用?PHP Payment::setParentTransactionId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Sales\Model\Order\Payment的用法示例。


在下文中一共展示了Payment::setParentTransactionId方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testRegisterRefundNotificationWrongAmount

 public function testRegisterRefundNotificationWrongAmount()
 {
     $amount = 30;
     $grandTotalCreditMemo = 50;
     $invoiceBaseGrandTotal = 50;
     $invoiceBaseTotalRefunded = 0;
     $this->invoiceMock->expects($this->any())->method('getBaseGrandTotal')->willReturn($invoiceBaseGrandTotal);
     $this->invoiceMock->expects($this->any())->method('getBaseTotalRefunded')->willReturn($invoiceBaseTotalRefunded);
     $this->creditMemoMock->expects($this->any())->method('getGrandTotal')->willReturn($grandTotalCreditMemo);
     $this->payment->setParentTransactionId($this->transactionId);
     $this->mockInvoice($this->transactionId, 1);
     $this->orderMock->expects($this->once())->method('getBaseCurrency')->willReturn($this->currencyMock);
     $parentTransaction = $this->getMock('Magento\\Sales\\Model\\Order\\Payment\\Transaction', ['setOrderId', 'setPaymentId', 'loadByTxnId', 'getId', 'getTxnId', 'getTxnType'], [], '', false);
     //generate new transaction and check if not exists
     $this->transactionRepositoryMock->expects($this->once())->method('getByTransactionId')->with($this->transactionId)->willReturn($parentTransaction);
     $newTransactionId = $this->transactionId . '-refund';
     $this->transactionManagerMock->expects($this->once())->method('isTransactionExists')->with($newTransactionId)->willReturn(false);
     $this->transactionManagerMock->expects($this->once())->method('generateTransactionId')->with($this->payment, Transaction::TYPE_REFUND, $parentTransaction)->willReturn($newTransactionId);
     $this->assertSame($this->payment, $this->payment->registerRefundNotification($amount));
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:20,代碼來源:PaymentTest.php

示例2: testRegisterRefundNotificationWrongAmount

 public function testRegisterRefundNotificationWrongAmount()
 {
     $amount = 30;
     $grandTotalCreditMemo = 50;
     $invoiceBaseGrandTotal = 50;
     $invoiceBaseTotalRefunded = 0;
     $this->invoiceMock->expects($this->any())->method('getBaseGrandTotal')->willReturn($invoiceBaseGrandTotal);
     $this->invoiceMock->expects($this->any())->method('getBaseTotalRefunded')->willReturn($invoiceBaseTotalRefunded);
     $this->creditMemoMock->expects($this->any())->method('getGrandTotal')->willReturn($grandTotalCreditMemo);
     $this->payment->setParentTransactionId($this->transactionId);
     $this->mockInvoice($this->transactionId, 1);
     $this->orderMock->expects($this->once())->method('getBaseCurrency')->willReturn($this->currencyMock);
     $parentTransaction = $this->getMock('Magento\\Sales\\Model\\Order\\Payment\\Transaction', ['setOrderPaymentObject', 'loadByTxnId', 'getId', 'getTxnId', 'getTxnType'], [], '', false);
     $parentTransaction->expects($this->atLeastOnce())->method('setOrderPaymentObject')->with($this->payment)->willReturnSelf();
     $parentTransaction->expects($this->exactly(1))->method('loadByTxnId')->with($this->transactionId)->willReturnSelf();
     $newTransaction = $this->getMock('Magento\\Sales\\Model\\Order\\Payment\\Transaction', ['getId', 'setOrderPaymentObject', 'loadByTxnId', 'setTxnId', 'setTxnType', 'isFailsafe', 'getTxnId', 'getTxnType'], [], '', false);
     $this->transactionFactory->expects($this->exactly(2))->method('create')->willReturnOnConsecutiveCalls($parentTransaction, $newTransaction);
     $newTransaction->expects($this->exactly(1))->method('loadByTxnId')->with($this->transactionId . '-' . \Magento\Sales\Model\Order\Payment\Transaction::TYPE_REFUND)->willReturnSelf();
     $newTransaction->expects($this->atLeastOnce())->method('setOrderPaymentObject')->willReturnSelf();
     $this->assertSame($this->payment, $this->payment->registerRefundNotification($amount));
 }
開發者ID:nja78,項目名稱:magento2,代碼行數:21,代碼來源:PaymentTest.php


注:本文中的Magento\Sales\Model\Order\Payment::setParentTransactionId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。