本文整理匯總了PHP中Magento\Sales\Model\Order\Payment::getData方法的典型用法代碼示例。如果您正苦於以下問題:PHP Payment::getData方法的具體用法?PHP Payment::getData怎麽用?PHP Payment::getData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Sales\Model\Order\Payment
的用法示例。
在下文中一共展示了Payment::getData方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testRefund
/**
* @covers \Magento\Sales\Model\Order\Payment::refund()
*/
public function testRefund()
{
$amount = 204.04;
$this->creditMemoMock->expects(static::once())->method('getBaseGrandTotal')->willReturn($amount);
$this->creditMemoMock->expects(static::once())->method('getGrandTotal')->willReturn($amount);
$this->creditMemoMock->expects(static::once())->method('getDoTransaction')->willReturn(true);
$this->paymentMethodMock->expects(static::once())->method('canRefund')->willReturn(true);
$this->mockInvoice(self::TRANSACTION_ID, 0);
$this->creditMemoMock->expects(static::once())->method('getInvoice')->willReturn($this->invoiceMock);
$captureTranId = self::TRANSACTION_ID . '-' . Transaction::TYPE_CAPTURE;
$captureTransaction = $this->getMockBuilder(Transaction::class)->disableOriginalConstructor()->setMethods(['getTxnId'])->getMock();
$refundTranId = $captureTranId . '-' . Transaction::TYPE_REFUND;
$this->transactionManagerMock->expects(static::once())->method('generateTransactionId')->willReturn($refundTranId);
$captureTransaction->expects(static::once())->method('getTxnId')->willReturn($captureTranId);
$this->transactionRepositoryMock->expects(static::once())->method('getByTransactionId')->willReturn($captureTransaction);
$this->paymentMethodMock->expects(static::once())->method('refund')->with($this->payment, $amount);
$isOnline = true;
$this->getTransactionBuilderMock([], $isOnline, Transaction::TYPE_REFUND, $refundTranId);
$this->currencyMock->expects(static::once())->method('formatTxt')->willReturn($amount);
$this->orderMock->expects(static::once())->method('getBaseCurrency')->willReturn($this->currencyMock);
$status = 'status';
$message = 'We refunded ' . $amount . ' online. Transaction ID: "' . $refundTranId . '"';
$this->mockGetDefaultStatus(Order::STATE_PROCESSING, $status);
$this->assertOrderUpdated(Order::STATE_PROCESSING, $status, $message);
static::assertSame($this->payment, $this->payment->refund($this->creditMemoMock));
static::assertEquals($amount, $this->payment->getData('amount_refunded'));
static::assertEquals($amount, $this->payment->getData('base_amount_refunded_online'));
static::assertEquals($amount, $this->payment->getData('base_amount_refunded'));
}
示例2: testRegisterRefundNotification
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function testRegisterRefundNotification()
{
$message = 'Registered notification about refunded amount of . Transaction ID: "100-refund"';
$amount = 50;
$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->creditmemoFactoryMock->expects($this->once())->method('createByInvoice')->with($this->invoiceMock, ['adjustment_negative' => $invoiceBaseGrandTotal - $amount])->willReturn($this->creditMemoMock);
$this->creditMemoMock->expects($this->once())->method('setPaymentRefundDisallowed')->willReturnSelf();
$this->creditMemoMock->expects($this->once())->method('setAutomaticallyCreated')->willReturnSelf();
$this->creditMemoMock->expects($this->once())->method('register')->willReturnSelf();
$this->creditMemoMock->expects($this->once())->method('addComment')->willReturnSelf();
$this->creditMemoMock->expects($this->once())->method('save')->willReturnSelf();
$this->orderMock->expects($this->once())->method('getBaseCurrency')->willReturn($this->currencyMock);
$parentTransaction = $this->getMock('Magento\\Sales\\Model\\Order\\Payment\\Transaction', ['setOrderId', 'setPaymentId', 'loadByTxnId', 'getId', 'getTxnId', 'setTxnId', 'getTxnType'], [], '', false);
$newTransactionId = $this->transactionId . '-' . Transaction::TYPE_REFUND;
$this->transactionRepositoryMock->expects($this->once())->method('getByTransactionId')->with($this->transactionId)->willReturn($parentTransaction);
$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);
$status = 'status';
$this->mockGetDefaultStatus(Order::STATE_PROCESSING, $status);
$this->assertOrderUpdated(Order::STATE_PROCESSING, $status, $message);
$additionalInformation = [];
$failSafe = false;
$transactionType = Transaction::TYPE_REFUND;
$this->getTransactionBuilderMock($additionalInformation, $failSafe, $transactionType, $this->transactionId . '-' . Transaction::TYPE_REFUND);
$this->assertSame($this->payment, $this->payment->registerRefundNotification($amount));
$this->assertSame($this->creditMemoMock, $this->payment->getData('created_creditmemo'));
$this->assertEquals($grandTotalCreditMemo, $this->payment->getData('amount_refunded'));
}
示例3: testRegisterRefundNotification
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function testRegisterRefundNotification()
{
$message = 'Registered notification about refunded amount of . Transaction ID: "100-refund"';
$amount = 50;
$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->serviceOrderFactory->expects($this->once())->method('create')->with(['order' => $this->orderMock])->willReturn($this->serviceOrder);
$this->serviceOrder->expects($this->once())->method('prepareInvoiceCreditmemo')->with($this->invoiceMock, ['adjustment_negative' => $invoiceBaseGrandTotal - $amount])->willReturn($this->creditMemoMock);
$this->creditMemoMock->expects($this->once())->method('setPaymentRefundDisallowed')->willReturnSelf();
$this->creditMemoMock->expects($this->once())->method('setAutomaticallyCreated')->willReturnSelf();
$this->creditMemoMock->expects($this->once())->method('register')->willReturnSelf();
$this->creditMemoMock->expects($this->once())->method('addComment')->willReturnSelf();
$this->creditMemoMock->expects($this->once())->method('save')->willReturnSelf();
$this->orderMock->expects($this->once())->method('getBaseCurrency')->willReturn($this->currencyMock);
$newTransaction = $this->getMock('Magento\\Sales\\Model\\Order\\Payment\\Transaction', ['getId', 'setOrderPaymentObject', 'loadByTxnId', 'setTxnId', 'setTxnType', 'isFailsafe', 'getTxnId', 'getHtmlTxnId', 'getTxnType'], [], '', false);
$parentTransaction = $this->getMock('Magento\\Sales\\Model\\Order\\Payment\\Transaction', ['setOrderPaymentObject', 'loadByTxnId', 'getId', 'getTxnId', 'getTxnType'], [], '', false);
$this->transactionFactory->expects($this->exactly(3))->method('create')->willReturnOnConsecutiveCalls($parentTransaction, $newTransaction, $newTransaction, $newTransaction);
$parentTransaction->expects($this->atLeastOnce())->method('setOrderPaymentObject')->with($this->payment)->willReturnSelf();
$parentTransaction->expects($this->exactly(1))->method('loadByTxnId')->with($this->transactionId)->willReturnSelf();
$newTransaction->expects($this->exactly(1))->method('loadByTxnId')->with($this->transactionId . '-' . \Magento\Sales\Model\Order\Payment\Transaction::TYPE_REFUND)->willReturnSelf();
$parentTransaction->expects($this->atLeastOnce())->method('getId')->willReturnOnConsecutiveCalls($this->transactionId, $this->transactionId . '-' . \Magento\Sales\Model\Order\Payment\Transaction::TYPE_REFUND)->willReturnOnConsecutiveCalls($this->transactionId, $this->transactionId . '-' . \Magento\Sales\Model\Order\Payment\Transaction::TYPE_REFUND);
$newTransaction->expects($this->once())->method('setTxnId')->with($this->transactionId . '-' . \Magento\Sales\Model\Order\Payment\Transaction::TYPE_REFUND)->willReturn($newTransaction);
$newTransaction->expects($this->atLeastOnce())->method('getHtmlTxnId')->willReturn($this->transactionId . '-' . \Magento\Sales\Model\Order\Payment\Transaction::TYPE_REFUND);
$newTransaction->expects($this->atLeastOnce())->method('getTxnId')->willReturn($this->transactionId . '-' . \Magento\Sales\Model\Order\Payment\Transaction::TYPE_REFUND);
$newTransaction->expects($this->atLeastOnce())->method('setOrderPaymentObject')->willReturnSelf();
$newTransaction->expects($this->once())->method('setTxnType')->with(\Magento\Sales\Model\Order\Payment\Transaction::TYPE_REFUND)->willReturn($newTransaction);
$newTransaction->expects($this->once())->method('isFailsafe')->with(false)->willReturn($newTransaction);
$this->orderMock->expects($this->atLeastOnce())->method('addRelatedObject');
$status = 'status';
$this->mockGetDefaultStatus(Order::STATE_PROCESSING, $status);
$this->assertOrderUpdated(Order::STATE_PROCESSING, $status, $message);
$this->assertSame($this->payment, $this->payment->registerRefundNotification($amount));
$this->assertSame($this->creditMemoMock, $this->payment->getData('created_creditmemo'));
$this->assertEquals($grandTotalCreditMemo, $this->payment->getData('amount_refunded'));
}
示例4: getData
/**
* {@inheritdoc}
*/
public function getData($key = '', $index = null)
{
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'getData');
if (!$pluginInfo) {
return parent::getData($key, $index);
} else {
return $this->___callPlugins('getData', func_get_args(), $pluginInfo);
}
}