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


PHP Order::canCancel方法代碼示例

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


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

示例1: testCanCancelActionFlag

    /**
     * @param bool $cancelActionFlag
     * @dataProvider dataProviderActionFlag
     */
    public function testCanCancelActionFlag($cancelActionFlag)
    {
        $paymentMock = $this->getMockBuilder('Magento\Sales\Model\ResourceModel\Order\Payment')
            ->disableOriginalConstructor()
            ->setMethods(['isDeleted', 'canReviewPayment', 'canFetchTransactionInfo', '__wakeUp'])
            ->getMock();
        $paymentMock->expects($this->any())
            ->method('canReviewPayment')
            ->will($this->returnValue(false));
        $paymentMock->expects($this->any())
            ->method('canFetchTransactionInfo')
            ->will($this->returnValue(false));

        $this->preparePaymentMock($paymentMock);

        $this->prepareItemMock(1);

        $actionFlags = [
            \Magento\Sales\Model\Order::ACTION_FLAG_UNHOLD => false,
            \Magento\Sales\Model\Order::ACTION_FLAG_CANCEL => $cancelActionFlag,
        ];
        foreach ($actionFlags as $action => $flag) {
            $this->order->setActionFlag($action, $flag);
        }
        $this->order->setData('state', \Magento\Sales\Model\Order::STATE_NEW);

        $this->item->expects($this->any())
            ->method('isDeleted')
            ->willReturn(false);
        $this->item->expects($this->any())
            ->method('getQtyToInvoice')
            ->willReturn(42);

        $this->assertEquals($cancelActionFlag, $this->order->canCancel());
    }
開發者ID:nblair,項目名稱:magescotch,代碼行數:39,代碼來源:OrderTest.php

示例2: _processNotification

 /**
  * Process the Notification
  */
 protected function _processNotification()
 {
     $this->_adyenLogger->addAdyenNotificationCronjob('Processing the notification');
     $_paymentCode = $this->_paymentMethodCode();
     switch ($this->_eventCode) {
         case Notification::REFUND_FAILED:
             // do nothing only inform the merchant with order comment history
             break;
         case Notification::REFUND:
             $ignoreRefundNotification = $this->_getConfigData('ignore_refund_notification', 'adyen_abstract', $this->_order->getStoreId());
             if ($ignoreRefundNotification != true) {
                 $this->_refundOrder();
                 //refund completed
                 $this->_setRefundAuthorized();
             } else {
                 $this->_adyenLogger->addAdyenNotificationCronjob('Setting to ignore refund notification is enabled so ignore this notification');
             }
             break;
         case Notification::PENDING:
             if ($this->_getConfigData('send_email_bank_sepa_on_pending', 'adyen_abstract', $this->_order->getStoreId())) {
                 // Check if payment is banktransfer or sepa if true then send out order confirmation email
                 $isBankTransfer = $this->_isBankTransfer();
                 if ($isBankTransfer || $this->_paymentMethod == 'sepadirectdebit') {
                     if (!$this->_order->getEmailSent()) {
                         $this->_orderSender->send($this->_order);
                         $this->_adyenLogger->addAdyenNotificationCronjob('Send orderconfirmation email to shopper');
                     }
                 }
             }
             break;
         case Notification::HANDLED_EXTERNALLY:
         case Notification::AUTHORISATION:
             // for POS don't do anything on the AUTHORIZATION
             if ($_paymentCode != "adyen_pos") {
                 $this->_authorizePayment();
             }
             break;
         case Notification::MANUAL_REVIEW_REJECT:
             // don't do anything it will send a CANCEL_OR_REFUND notification when this payment is captured
             break;
         case Notification::MANUAL_REVIEW_ACCEPT:
             /*
              * only process this if you are on auto capture.
              * On manual capture you will always get Capture or CancelOrRefund notification
              */
             if ($this->_isAutoCapture()) {
                 $this->_setPaymentAuthorized(false);
             }
             break;
         case Notification::CAPTURE:
             if ($_paymentCode != "adyen_pos") {
                 /*
                  * ignore capture if you are on auto capture
                  * this could be called if manual review is enabled and you have a capture delay
                  */
                 if (!$this->_isAutoCapture()) {
                     $this->_setPaymentAuthorized(false, true);
                 }
             } else {
                 // FOR POS authorize the payment on the CAPTURE notification
                 $this->_authorizePayment();
             }
             break;
         case Notification::CAPTURE_FAILED:
         case Notification::CANCELLATION:
         case Notification::CANCELLED:
             $this->_holdCancelOrder(true);
             break;
         case Notification::CANCEL_OR_REFUND:
             if (isset($this->_modificationResult) && $this->_modificationResult != "") {
                 if ($this->_modificationResult == "cancel") {
                     $this->_holdCancelOrder(true);
                 } elseif ($this->_modificationResult == "refund") {
                     $this->_refundOrder();
                     //refund completed
                     $this->_setRefundAuthorized();
                 }
             } else {
                 if ($this->_order->isCanceled() || $this->_order->getState() === \Magento\Sales\Model\Order::STATE_HOLDED) {
                     $this->_adyenLogger->addAdyenNotificationCronjob('Order is already cancelled or holded so do nothing');
                 } else {
                     if ($this->_order->canCancel() || $this->_order->canHold()) {
                         $this->_adyenLogger->addAdyenNotificationCronjob('try to cancel the order');
                         $this->_holdCancelOrder(true);
                     } else {
                         $this->_adyenLogger->addAdyenNotificationCronjob('try to refund the order');
                         // refund
                         $this->_refundOrder();
                         //refund completed
                         $this->_setRefundAuthorized();
                     }
                 }
             }
             break;
         case Notification::RECURRING_CONTRACT:
             // storedReferenceCode
             $recurringDetailReference = $this->_pspReference;
//.........這裏部分代碼省略.........
開發者ID:Adyen,項目名稱:adyen-magento2,代碼行數:101,代碼來源:Cron.php

示例3: _processNotification

 /**
  * @param $params
  */
 protected function _processNotification()
 {
     $this->_debugData['_processNotification'] = 'Processing the notification';
     $_paymentCode = $this->_paymentMethodCode();
     switch ($this->_eventCode) {
         case Notification::REFUND_FAILED:
             // do nothing only inform the merchant with order comment history
             break;
         case Notification::REFUND:
             $ignoreRefundNotification = $this->_getConfigData('ignore_refund_notification', 'adyen_abstract', $this->_order->getStoreId());
             if ($ignoreRefundNotification != true) {
                 $this->_refundOrder();
                 //refund completed
                 $this->_setRefundAuthorized();
             } else {
                 $this->_debugData['_processNotification info'] = 'Setting to ignore refund notification is enabled so ignore this notification';
             }
             break;
         case Notification::PENDING:
             if ($this->_getConfigData('send_email_bank_sepa_on_pending', 'adyen_abstract', $this->_order->getStoreId())) {
                 // Check if payment is banktransfer or sepa if true then send out order confirmation email
                 $isBankTransfer = $this->_isBankTransfer($this->_paymentMethod);
                 if ($isBankTransfer || $this->_paymentMethod == 'sepadirectdebit') {
                     //                        $this->_order->sendNewOrderEmail(); // send order email
                     $this->_orderSender->send($this->_order);
                     $this->_debugData['_processNotification send email'] = 'Send orderconfirmation email to shopper';
                 }
             }
             break;
         case Notification::HANDLED_EXTERNALLY:
         case Notification::AUTHORISATION:
             // for POS don't do anything on the AUTHORIZATION
             if ($_paymentCode != "adyen_pos") {
                 $this->_authorizePayment();
             }
             break;
         case Notification::MANUAL_REVIEW_REJECT:
             // don't do anything it will send a CANCEL_OR_REFUND notification when this payment is captured
             break;
         case Notification::MANUAL_REVIEW_ACCEPT:
             // only process this if you are on auto capture. On manual capture you will always get Capture or CancelOrRefund notification
             if ($this->_isAutoCapture()) {
                 $this->_setPaymentAuthorized(false);
             }
             break;
         case Notification::CAPTURE:
             if ($_paymentCode != "adyen_pos") {
                 // ignore capture if you are on auto capture (this could be called if manual review is enabled and you have a capture delay)
                 if (!$this->_isAutoCapture()) {
                     $this->_setPaymentAuthorized(false, true);
                 }
             } else {
                 // uncancel the order just to be sure that order is going trough
                 //                    $this->_uncancelOrder($this->_order);
                 // FOR POS authorize the payment on the CAPTURE notification
                 $this->_authorizePayment($this->_order, $this->_paymentMethod);
             }
             break;
         case Notification::CAPTURE_FAILED:
         case Notification::CANCELLATION:
         case Notification::CANCELLED:
             $this->_holdCancelOrder(true);
             break;
         case Notification::CANCEL_OR_REFUND:
             if (isset($this->_modificationResult) && $this->_modificationResult != "") {
                 if ($this->_modificationResult == "cancel") {
                     $this->_holdCancelOrder(true);
                 } elseif ($this->_modificationResult == "refund") {
                     $this->_refundOrder();
                     //refund completed
                     $this->_setRefundAuthorized();
                 }
             } else {
                 if ($this->_order->isCanceled() || $this->_order->getState() === \Magento\Sales\Model\Order::STATE_HOLDED) {
                     $this->_debugData['_processNotification info'] = 'Order is already cancelled or holded so do nothing';
                 } else {
                     if ($this->_order->canCancel() || $this->_order->canHold()) {
                         $this->_debugData['_processNotification info'] = 'try to cancel the order';
                         $this->_holdCancelOrder($this->_order, true);
                     } else {
                         $this->_debugData['_processNotification info'] = 'try to refund the order';
                         // refund
                         $this->_refundOrder();
                         //refund completed
                         $this->_setRefundAuthorized();
                     }
                 }
             }
             break;
         default:
             $this->_order->getPayment()->getMethodInstance()->writeLog('notification event not supported!');
             break;
     }
 }
開發者ID:adragus-inviqa,項目名稱:adyen-magento2,代碼行數:97,代碼來源:Cron.php


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