当前位置: 首页>>代码示例>>PHP>>正文


PHP Order::setStatus方法代码示例

本文整理汇总了PHP中Magento\Sales\Model\Order::setStatus方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::setStatus方法的具体用法?PHP Order::setStatus怎么用?PHP Order::setStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Sales\Model\Order的用法示例。


在下文中一共展示了Order::setStatus方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 /**
  * Receives webhook events from Roadrunner
  */
 public function execute()
 {
     $this->_logger->addDebug('paystandmagento/webhook/paystand endpoint was hit');
     $body = @file_get_contents('php://input');
     $json = json_decode($body);
     $this->_logger->addDebug(">>>>> body=" . print_r($body, TRUE));
     if (isset($json->resource->meta->source) && $json->resource->meta->source == "magento 2") {
         $quoteId = $json->resource->meta->quote;
         $this->_logger->addDebug('magento 2 webhook identified with quote id = ' . $quoteId);
         $this->_order->loadByAttribute('quote_id', $quoteId);
         if (!empty($this->_order->getIncrementId())) {
             $this->_logger->addDebug('current order increment id = ' . $this->_order->getIncrementId());
             $state = $this->_order->getState();
             $this->_logger->addDebug('current order state = ' . $state);
             $status = $this->_order->getStatus();
             $this->_logger->addDebug('current order status = ' . $status);
             $storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
             if ($this->scopeConfig->getValue(self::USE_SANDBOX, $storeScope)) {
                 $base_url = 'https://api.paystand.co/v3';
             } else {
                 $base_url = 'https://api.paystand.com/v3';
             }
             $url = $base_url . "/events/" . $json->id . "/verify";
             $auth_header = array("x-publishable-key: " . $this->scopeConfig->getValue(self::PUBLISHABLE_KEY, $storeScope));
             $curl = $this->buildCurl("POST", $url, json_encode($json), $auth_header);
             $response = $this->runCurl($curl);
             $this->_logger->addDebug("http_response_code is " . $this->http_response_code);
             if (FALSE !== $response && $this->http_response_code == 200) {
                 if ($json->resource->object = "payment") {
                     switch ($json->resource->status) {
                         case 'posted':
                             $state = 'pending';
                             $status = 'pending';
                             break;
                         case 'paid':
                             $state = 'processing';
                             $status = 'processing';
                             break;
                         case 'failed':
                             $state = 'closed';
                             $status = 'closed';
                             break;
                         case 'canceled':
                             $state = 'canceled';
                             $status = 'canceled';
                             break;
                     }
                 }
                 $this->_order->setState($state);
                 $this->_order->setStatus($status);
                 $this->_order->save();
                 $this->_logger->addDebug('new order state = ' . $state);
                 $this->_logger->addDebug('new order status = ' . $status);
             } else {
                 $this->_logger->addDebug('event verify failed');
             }
         }
     }
 }
开发者ID:steegi,项目名称:paystand-magento2,代码行数:62,代码来源:PayStand.php

示例2: _registerPaymentReversal

 /**
  * Process payment reversal and cancelled reversal notification
  *
  * @return void
  */
 protected function _registerPaymentReversal()
 {
     $reasonCode = $this->getRequestData('reason_code');
     $reasonComment = $this->_paypalInfo->explainReasonCode($reasonCode);
     $notificationAmount = $this->_order->getBaseCurrency()->formatTxt($this->getRequestData('mc_gross') + $this->getRequestData('mc_fee'));
     $paymentStatus = $this->_filterPaymentStatus($this->getRequestData('payment_status'));
     $orderStatus = $paymentStatus == Info::PAYMENTSTATUS_REVERSED ? Info::ORDER_STATUS_REVERSED : Info::ORDER_STATUS_CANCELED_REVERSAL;
     //Change order status to PayPal Reversed/PayPal Cancelled Reversal if it is possible.
     $message = __('IPN "%1". %2 Transaction amount %3. Transaction ID: "%4"', $this->getRequestData('payment_status'), $reasonComment, $notificationAmount, $this->getRequestData('txn_id'));
     $this->_order->setStatus($orderStatus);
     $this->_order->save();
     $this->_order->addStatusHistoryComment($message, $orderStatus)->setIsCustomerNotified(false)->save();
 }
开发者ID:nja78,项目名称:magento2,代码行数:18,代码来源:Ipn.php

示例3: _processOrderCreated

 protected function _processOrderCreated($params)
 {
     $this->_order->setStatus($this->_paymentMethod->getConfigData('order_approved_status'));
     if (!$this->_order->getEmailSent()) {
         $this->orderSender->send($this->_order);
     }
     $this->_order->save();
     if ($this->_paymentMethod->getConfigData('invoice_before_fraud_review')) {
         $this->_createInvoice($params);
     }
     $comment = $this->_createNotificationComment(sprintf('ORDER CREATED: "%s"', $params['sale_id']));
     $comment->save();
 }
开发者ID:craigchristenson,项目名称:magento2-2checkout,代码行数:13,代码来源:Notification.php

示例4: _processOrder

 protected function _processOrder(\Magento\Sales\Model\Order $order, $response)
 {
     //$response = $this->getResponse();
     $payment = $order->getPayment();
     //$payment->setTransactionId($response->getPnref())->setIsTransactionClosed(0);
     //TODO: add validation for request data
     try {
         $errors = array();
         //$this->readConfig();
         //$order = Mage::getModel("sales/order")->load($this->getOrderId($answer));
         //$order = Mage::getModel("sales/order")->loadByIncrementId($this->getOrderId($answer));
         $hashArray = array($response["OutSum"], $response["InvId"], $this->getConfigData('pass_word_2'));
         $hashCurrent = strtoupper(md5(implode(":", $hashArray)));
         $correctHash = strcmp($hashCurrent, strtoupper($response['SignatureValue'])) == 0;
         if (!$correctHash) {
             $errors[] = "Incorrect HASH (need:" . $hashCurrent . ", got:" . strtoupper($response['SignatureValue']) . ") - fraud data or wrong secret Key";
             $errors[] = "Maybe success payment";
         }
         /**
          * @var $order Mage_Sales_Model_Order
          */
         // if ($this->_transferCurrency != $order->getOrderCurrencyCode()) {
         //     $outSum = round(
         //         $order->getBaseCurrency()->convert($order->getBaseGrandTotal(), $this->_transferCurrency),
         //         2
         //     );
         // } else {
         $outSum = round($order->getGrandTotal(), 2);
         // }
         if ($outSum != $response["OutSum"]) {
             $errors[] = "Incorrect Amount: " . $response["OutSum"] . " (need: " . $outSum . ")";
         }
         // if (count($errors) > 0) {
         //     return $errors;
         // }
         //return (bool)$correctHash;
         //$payment->registerCaptureNotification($payment->getBaseAmountAuthorized());
         if (!$correctHash) {
             $payment->setTransactionId($response["InvId"])->setIsTransactionClosed(0);
             $order->setStatus(Order::STATE_PAYMENT_REVIEW);
             $order->save();
             return "Ok" . $response["InvId"];
         }
         //
     } catch (Exception $e) {
         return array("Internal error:" . $e->getMessage());
     }
 }
开发者ID:MagePsycho,项目名称:magento2-module-payment-tmrobokassa,代码行数:48,代码来源:TMRobokassa.php

示例5: confirmOrder

 /**
  * Confirm the payment of an order
  *
  * @param \Magento\Sales\Model\Order $order
  * @param \WirecardCEE_Stdlib_Return_ReturnAbstract $return
  * @param bool $fraudDetected
  *
  * @return Order
  *
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function confirmOrder($order, $return, $fraudDetected)
 {
     /** @var \Magento\Sales\Model\Order\Payment $payment */
     $payment = $order->getPayment();
     /** @var \Wirecard\CheckoutPage\Model\AbstractPayment $paymentInstance */
     $paymentInstance = $payment->getMethodInstance();
     $additionalInformation = array();
     foreach ($return->getReturned() as $fieldName => $fieldValue) {
         $additionalInformation[htmlentities($fieldName)] = htmlentities($fieldValue);
     }
     $payment->setAdditionalInformation($additionalInformation);
     if ($fraudDetected) {
         $order->setStatus(\Magento\Sales\Model\Order::STATUS_FRAUD);
         $message = $this->_dataHelper->__('fraud attemmpt detected, cart has been modified during checkout!');
         $this->_logger->debug(__METHOD__ . ':' . $message);
         $order->addStatusHistoryComment($message);
     }
     $doCapture = false;
     if (!$this->isOrderProcessed($order)) {
         if ($return->getPaymentState() == \WirecardCEE_QPay_ReturnFactory::STATE_PENDING) {
             /** @var \WirecardCEE_QPay_Return_Pending $return */
             $order->setState(\Magento\Sales\Model\Order::STATE_PENDING_PAYMENT);
             $message = $this->_dataHelper->__('The payment authorization is pending.');
         } else {
             /** @var \WirecardCEE_QPay_Return_Success $return */
             $order->setState(\Magento\Sales\Model\Order::STATE_PROCESSING);
             $order->setStatus(\Magento\Sales\Model\Order::STATE_PROCESSING);
             $message = $this->_dataHelper->__('The payment has been successfully completed.');
             // invoice payment
             if ($order->canInvoice()) {
                 $invoice = $order->prepareInvoice();
                 $invoice->register();
                 /* capture invoice if toolkit is not availble */
                 if (!$this->_dataHelper->isBackendAvailable()) {
                     $doCapture = true;
                 } else {
                     $hasBackedOps = false;
                     $orderDetails = $paymentInstance->getOrderDetails($payment->getAdditionalInformation('orderNumber'));
                     foreach ($orderDetails->getOrder()->getPayments() as $wdPayment) {
                         /** @var \WirecardCEE_QPay_Response_Toolkit_Order_Payment $wdPayment */
                         $this->_logger->debug(__METHOD__ . ':payment-state:' . $wdPayment->getState() . ' allowed operations:' . implode(',', $wdPayment->getOperationsAllowed()));
                         if (count($wdPayment->getOperationsAllowed())) {
                             $hasBackedOps = true;
                             break;
                         }
                     }
                     if (count($orderDetails->getOrder()->getOperationsAllowed())) {
                         $this->_logger->debug(__METHOD__ . ':order allowed operations: ' . implode(',', $orderDetails->getOrder()->getOperationsAllowed()));
                         $hasBackedOps = true;
                     }
                     /* no backend ops allowed anymore, assume final state of payment, capture invoice */
                     if (!$hasBackedOps) {
                         $doCapture = true;
                     }
                 }
                 if ($doCapture && !$fraudDetected) {
                     $invoice->capture();
                 }
                 $order->addRelatedObject($invoice);
             }
             $this->_orderSender->send($order);
         }
         $type = $doCapture ? Transaction::TYPE_CAPTURE : Transaction::TYPE_AUTH;
         $this->saveTransaction($type, $message, $order, $return);
     }
     $order->save();
     return $order;
 }
开发者ID:wirecard,项目名称:magento2-wcp,代码行数:79,代码来源:OrderManagement.php

示例6: _captureOrder

 /**
  * Capture order's payment using AIM.
  *
  * @param \Magento\Sales\Model\Order $order
  * @return void
  */
 protected function _captureOrder(\Magento\Sales\Model\Order $order)
 {
     $payment = $order->getPayment();
     if ($payment->getAdditionalInformation('payment_type') == self::ACTION_AUTHORIZE_CAPTURE) {
         try {
             $payment->setTransactionId(null)->setParentTransactionId($this->getResponse()->getXTransId())->capture(null);
             // set status from config for AUTH_AND_CAPTURE orders.
             if ($order->getState() == \Magento\Sales\Model\Order::STATE_PROCESSING) {
                 $orderStatus = $this->getConfigData('order_status');
                 if (!$orderStatus || $order->getIsVirtual()) {
                     $orderStatus = $order->getConfig()->getStateDefaultStatus(\Magento\Sales\Model\Order::STATE_PROCESSING);
                 }
                 if ($orderStatus) {
                     $order->setStatus($orderStatus);
                 }
             }
             $order->save();
         } catch (\Exception $e) {
             //if we couldn't capture order, just leave it as NEW order.
             $this->_logger->logException($e);
         }
     }
 }
开发者ID:aiesh,项目名称:magento2,代码行数:29,代码来源:Directpost.php

示例7: postProcessing

 public function postProcessing(\Magento\Sales\Model\Order $order, \Magento\Framework\DataObject $payment, $response)
 {
     // Update payment details
     $payment->setTransactionId($response['invoice_id']);
     $payment->setIsTransactionClosed(0);
     $payment->setTransactionAdditionalInfo('tco_order_number', $response['order_number']);
     $payment->setAdditionalInformation('tco_order_number', $response['order_number']);
     $payment->setAdditionalInformation('tco_order_status', 'approved');
     $payment->place();
     // Update order status
     $order->setStatus($this->getOrderStatus());
     $order->setExtOrderId($response['order_number']);
     $order->save();
     // Send email confirmation
     $this->orderSender->send($order);
 }
开发者ID:craigchristenson,项目名称:magento2-2checkout,代码行数:16,代码来源:Checkout.php


注:本文中的Magento\Sales\Model\Order::setStatus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。