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


PHP Payment::setMethod方法代碼示例

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


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

示例1: initPayment

 /**
  * @param $context
  */
 protected function initPayment($context)
 {
     $this->payment = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject('Magento\\Sales\\Model\\Order\\Payment', ['context' => $context, 'serviceOrderFactory' => $this->serviceOrderFactory, 'paymentData' => $this->helperMock, 'priceCurrency' => $this->priceCurrencyMock, 'transactionFactory' => $this->transactionFactory, 'transactionCollectionFactory' => $this->transactionCollectionFactory]);
     $this->payment->setMethod('any');
     $this->payment->setOrder($this->orderMock);
     $this->transactionId = 100;
 }
開發者ID:nja78,項目名稱:magento2,代碼行數:10,代碼來源:PaymentTest.php

示例2: setUp

 /**
  * @return void
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  * @SuppressWarnings(PHPMD.TooManyFields)
  */
 protected function setUp()
 {
     $this->eventManagerMock = $this->getMockBuilder('Magento\\Framework\\Event\\Manager')->disableOriginalConstructor()->getMock();
     $this->mockContext = $this->getMockBuilder('Magento\\Framework\\Model\\Context')->disableOriginalConstructor()->getMock();
     $this->mockContext->expects($this->atLeastOnce())->method('getEventDispatcher')->will($this->returnValue($this->eventManagerMock));
     $this->helperMock = $this->getMockBuilder('Magento\\Payment\\Helper\\Data')->disableOriginalConstructor()->setMethods(['getMethodInstance'])->getMock();
     $this->priceCurrencyMock = $this->getMockBuilder('Magento\\Directory\\Model\\PriceCurrency')->disableOriginalConstructor()->setMethods(['format'])->getMock();
     $this->currencyMock = $this->getMockBuilder('Magento\\Directory\\Model\\Currency')->disableOriginalConstructor()->setMethods(['formatTxt'])->getMock();
     $transaction = 'Magento\\Sales\\Model\\Order\\Payment\\Transaction\\Repository';
     $this->transactionRepositoryMock = $this->getMockBuilder($transaction)->disableOriginalConstructor()->setMethods(['get', 'getByTransactionType', 'getByTransactionId'])->getMock();
     $this->paymentProcessor = $this->getMock('Magento\\Sales\\Model\\Order\\Payment\\Processor', [], [], '', false);
     $this->orderRepository = $this->getMock('Magento\\Sales\\Model\\OrderRepository', ['get'], [], '', false);
     $this->priceCurrencyMock->expects($this->any())->method('format')->willReturnCallback(function ($value) {
         return $value;
     });
     $this->paymentMethodMock = $this->getMockBuilder('Magento\\Payment\\Model\\Method\\AbstractMethod')->disableOriginalConstructor()->setMethods(['canVoid', 'authorize', 'getConfigData', 'getConfigPaymentAction', 'validate', 'setStore', 'acceptPayment', 'denyPayment', 'fetchTransactionInfo', 'canCapture', 'canRefund', 'canOrder', 'order', 'isInitializeNeeded', 'initialize', 'refund'])->getMock();
     $this->invoiceMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Invoice')->disableOriginalConstructor()->setMethods(['getTransactionId', 'load', 'getId', 'pay', 'cancel', 'getGrandTotal', 'getBaseGrandTotal', 'getShippingAmount', 'getBaseShippingAmount', 'getBaseTotalRefunded', 'getItemsCollection', 'getOrder', 'register', 'capture'])->getMock();
     $this->helperMock->method('getMethodInstance')->will($this->returnValue($this->paymentMethodMock));
     $this->orderMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->setMethods(['getConfig', 'setState', 'setStatus', 'getStoreId', 'getBaseGrandTotal', 'getBaseCurrency', 'getBaseCurrencyCode', 'getTotalDue', 'getBaseTotalDue', 'getInvoiceCollection', 'addRelatedObject', 'getState', 'getStatus', 'addStatusHistoryComment', 'registerCancellation', 'getCustomerNote', 'prepareInvoice', 'getPaymentsCollection'])->getMock();
     $this->transactionCollectionFactory = $this->getMock('Magento\\Sales\\Model\\ResourceModel\\Order\\Payment\\Transaction\\CollectionFactory', ['create'], [], '', false);
     $this->creditmemoFactoryMock = $this->getMock('Magento\\Sales\\Model\\Order\\CreditmemoFactory', [], [], '', false);
     $this->transactionManagerMock = $this->getMock('Magento\\Sales\\Model\\Order\\Payment\\Transaction\\Manager', [], [], '', false);
     $this->transactionBuilderMock = $this->getMock('Magento\\Sales\\Model\\Order\\Payment\\Transaction\\Builder', [], [], '', false);
     $this->creditMemoMock = $this->getMock('Magento\\Sales\\Model\\Order\\Creditmemo', ['setPaymentRefundDisallowed', 'getItemsCollection', 'getItems', 'setAutomaticallyCreated', 'register', 'addComment', 'save', 'getGrandTotal', 'getBaseGrandTotal', 'getDoTransaction', 'getInvoice'], [], '', false);
     $this->payment = $this->initPayment();
     $this->payment->setMethod('any');
     $this->payment->setOrder($this->orderMock);
     $this->transactionId = self::TRANSACTION_ID;
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:34,代碼來源:PaymentTest.php

示例3: setUp

 protected function setUp()
 {
     $this->eventManagerMock = $this->getMockBuilder('Magento\\Framework\\Event\\Manager')->disableOriginalConstructor()->getMock();
     $context = $this->getMockBuilder('Magento\\Framework\\Model\\Context')->disableOriginalConstructor()->getMock();
     $context->expects($this->once())->method('getEventDispatcher')->will($this->returnValue($this->eventManagerMock));
     $this->helperMock = $this->getMockBuilder('Magento\\Payment\\Helper\\Data')->disableOriginalConstructor()->setMethods(['getMethodInstance'])->getMock();
     $this->priceCurrencyMock = $this->getMockBuilder('Magento\\Directory\\Model\\PriceCurrency')->disableOriginalConstructor()->setMethods(['format'])->getMock();
     $this->priceCurrencyMock->expects($this->any())->method('format')->willReturnCallback(function ($value) {
         return $value;
     });
     $this->paymentMethodMock = $this->getMockBuilder('Magento\\Payment\\Model\\Method\\AbstractMethod')->disableOriginalConstructor()->setMethods(['canVoid', 'authorize', 'getConfigData', 'getConfigPaymentAction', 'validate'])->getMock();
     $this->helperMock->expects($this->once())->method('getMethodInstance')->will($this->returnValue($this->paymentMethodMock));
     $this->orderMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->setMethods(['getConfig', 'setState', 'getStoreId', 'getBaseGrandTotal', 'getBaseCurrency', 'getBaseCurrencyCode', 'getTotalDue', 'getBaseTotalDue'])->getMock();
     $this->payment = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject('Magento\\Sales\\Model\\Order\\Payment', ['context' => $context, 'paymentData' => $this->helperMock, 'priceCurrency' => $this->priceCurrencyMock]);
     $this->payment->setMethod('any');
     $this->payment->setOrder($this->orderMock);
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:17,代碼來源:PaymentTest.php

示例4: setMethod

 /**
  * {@inheritdoc}
  */
 public function setMethod($method)
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'setMethod');
     if (!$pluginInfo) {
         return parent::setMethod($method);
     } else {
         return $this->___callPlugins('setMethod', func_get_args(), $pluginInfo);
     }
 }
開發者ID:CSYE6225,項目名稱:UnixSysProgramming,代碼行數:12,代碼來源:Interceptor.php


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