本文整理汇总了PHP中Mage_Sales_Model_Order::setState方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Order::setState方法的具体用法?PHP Mage_Sales_Model_Order::setState怎么用?PHP Mage_Sales_Model_Order::setState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Order
的用法示例。
在下文中一共展示了Mage_Sales_Model_Order::setState方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cancelaPedido
public function cancelaPedido(Mage_Sales_Model_Order $order)
{
$paymentMethod = $order->getPayment()->getMethodInstance()->getCode();
$listPaymentMethodsIdeasa = Mage::helper('base')->listPaymentMethods();
$this->logger->info('Processando cancelamento do pedido ' . $order->getRealOrderId() . ', do modulo: ' . $paymentMethod);
try {
if ($order->getState() != Mage_Sales_Model_Order::STATE_CANCELED) {
$order->cancel();
//força o cancelamento
if ($order->getStatus() != Mage_Sales_Model_Order::STATE_CANCELED) {
$order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true, Mage::helper('base')->__('Pedido cancelado'), $notified = false);
} else {
$order->addStatusToHistory($order->getStatus(), Mage::helper('base')->__('Pedido cancelado.'));
}
if ($order->hasInvoices() != '') {
$order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true, Mage::helper('base')->__('O pagamento e o pedido foram cancelados, mas não foi possível retornar os produtos ao estoque pois já havia uma fatura gerada para este pedido.'), $notified = false);
}
$order->save();
}
if (Mage::helper('base')->isIdeasaPaymentMethod($paymentMethod) && Mage::helper('base/module')->isPagSeguroDiretoExists() && $paymentMethod == $listPaymentMethodsIdeasa[0]) {
Mage::getModel('pagsegurodireto/notification')->sendEmail($order);
}
} catch (Exception $e) {
$this->logger->error("Erro ao cancelar pedido {$orderId} \n {$e->__toString}()");
}
$this->logger->info('Cancelamento do pedido foi concluido ' . $order->getRealOrderId() . ', do modulo: ' . $paymentMethod);
return;
}
示例2: updateByTransactionStatus
/**
* @param Mage_Sales_Model_Order $order
* @param Payone_Core_Model_Domain_Protocol_TransactionStatus $transactionStatus
* @return void
*/
public function updateByTransactionStatus(Mage_Sales_Model_Order $order, Payone_Core_Model_Domain_Protocol_TransactionStatus $transactionStatus)
{
// Update Status of Transaction
$order->setPayoneTransactionStatus($transactionStatus->getTxaction());
// Update dunning status
if ($transactionStatus->getReminderlevel()) {
$order->setPayoneDunningStatus($transactionStatus->getReminderlevel());
}
// Status mapping of Order by Transaction Status
$statusMapping = $this->getConfigStore()->getGeneral()->getStatusMapping();
$txAction = $transactionStatus->getTxaction();
/**
* @var $paymentMethod Payone_Core_Model_Payment_Method_Abstract
*/
$paymentMethod = $order->getPayment()->getMethodInstance();
$type = $paymentMethod->getMethodType();
// Mapping
$mapping = $statusMapping->getByType($type);
if (!is_array($mapping) or !array_key_exists($txAction, $mapping)) {
return;
}
// Check for valid Mapping
$mappingOrderState = $mapping[$txAction];
if (!is_array($mappingOrderState) or !array_key_exists('status', $mappingOrderState) or !array_key_exists('state', $mappingOrderState)) {
return;
}
// Get State / Status and set to Order
$newOrderState = $mappingOrderState['state'];
$newOrderStatus = $mappingOrderState['status'];
if ($newOrderState != '') {
$order->setState($newOrderState, $newOrderStatus);
} else {
$order->setStatus($newOrderStatus);
}
}
示例3: setState
/**
* Order state setter.
* If status is specified, will add order status history with specified comment
* the setData() cannot be overriden because of compatibility issues with resource model
*
* @param string $state
* @param string|bool $status
* @param string $comment
* @param bool $isCustomerNotified
* @return Mage_Sales_Model_Order
*/
public function setState($state, $status = false, $comment = '', $isCustomerNotified = null, $shouldProtectState = true)
{
if ((int) Mage::helper('extensions')->getMagentoVersion() < 140) {
return parent::setState($state, $status, $comment, $isCustomerNotified);
}
return $this->_setState($state, $status, $comment, $isCustomerNotified, $shouldProtectState);
}
示例4: _prepareOrder
/**
* Set the order state and status to "new" and "unsubmitted" to start.
*
* @return self
*/
protected function _prepareOrder()
{
$state = self::STATE_NEW;
$status = self::STATUS_NEW;
$this->_order->setState($state, $status);
return $this;
}
示例5: _cancelOrder
/**
* Cancel the order if is in the current Magento store, otherwise, simply
* set the state of the order to a state of canceled.
*
* @return self
*/
protected function _cancelOrder()
{
if ($this->_order->getId()) {
// Only save order that's in this magento store
$this->_order->cancel()->save();
} else {
// The order is not in this magento store, simply set state of this empty order to cancel
$this->_order->setState(Mage_Sales_Model_Order::STATE_CANCELED);
}
return $this;
}
示例6: _processSale
/**
* Processes payment confirmation, creates invoice if necessary, updates order status,
* sends order confirmation to customer
*
* @param string $status
* @param string $msg Order history message
*/
protected function _processSale($status, $msg)
{
switch ($status) {
case self::MONEYBOOKERS_STATUS_SUCCESS:
$this->_createInvoice();
$this->_order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, $msg);
// save transaction ID
$this->_order->getPayment()->setLastTransId($this->getEventData('mb_transaction_id'));
// send new order email
$this->_order->queueNewOrderEmail();
$this->_order->setEmailSent(true);
break;
case self::MONEYBOOKERS_STATUS_PENDING:
$this->_order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true, $msg);
// save transaction ID
$this->_order->getPayment()->setLastTransId($this->getEventData('mb_transaction_id'));
break;
}
$this->_order->save();
}
示例7: _getPostResponseActionUrl
private function _getPostResponseActionUrl(Mage_Sales_Model_Order $order)
{
$token = $_GET['token'];
$server = Mage::getSingleton('customer/session')->getServerMode();
$url = getStatusUrl($server, $token);
$resultJson = checkStatusPayment($url);
$theResult = $resultJson['transaction']['processing']['result'];
$returnCode = $resultJson['transaction']['processing']['return']['code'];
$returnMessage = $resultJson['transaction']['processing']['return']['message'];
$currency = $resultJson['transaction']['payment']['clearing']['currency'];
$payment_type = substr($resultJson['transaction']['payment']['code'], -2);
$refId = $resultJson['transaction']['identification']['uniqueId'];
$pageName = '';
$params = array();
if ($theResult == 'ACK') {
$order->getPayment()->setAdditionalInformation('IDENTIFICATION_REFERENCEID', $refId);
$order->getPayment()->setAdditionalInformation('CURRENCY', $currency);
$order->getPayment()->setAdditionalInformation('hyperpay_transaction_code', $payment_type);
$order->save();
$order->sendNewOrderEmail();
if ($payment_type == 'PA') {
$order->setState(Mage_Sales_Model_Order::STATE_NEW, true)->save();
} else {
Mage::helper('hyperpay')->invoice($order);
}
Mage::getModel('sales/quote')->load($order->getQuoteId())->setIsActive(false)->save();
$pageName = 'checkout/onepage/success/';
} else {
Mage::getSingleton('core/session')->setPiHyperpayPaymentError($returnCode);
$returnMessage .= " ( transaction id : " . $order->getIncrementId() . " )";
$order->cancel()->save();
$pageName = 'hyperpay/response/addErrorAndRedirect/';
// if (trim($this->getRequest()->getPost('FRONTEND_REQUEST_CANCELLED')) == 'false' && $this->getRequest()->getPost('PROCESSING_RETURN') != 'Cancelled by user') {
$params = array('message' => $returnMessage);
// }
}
$params['_secure'] = true;
//return Mage::getUrl($pageName, $params);
$this->_redirect($pageName, $params);
}
示例8: _processConfirmState
protected function _processConfirmState($state, $data)
{
switch ($state) {
case 'SUCCESS':
case 'PENDING':
$this->_confirmOrder($data);
break;
case 'CANCEL':
$this->_cancelOrder();
break;
case 'FAILURE':
$msg = !empty($data['message']) ? $data['message'] : '';
if (!$this->_succeeded($this->order)) {
$this->order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true, Mage::helper('wirecard_checkout_page')->__('An error occured during the payment process:') . ' ' . $msg)->save();
$this->order->cancel();
$payment = $this->order->getPayment();
$payment->setAdditionalInformation('consumerMessage', $data['consumerMessage']);
}
break;
default:
throw new Exception('Unhandled Wirecard Checkout Page action "' . $data['paymentState'] . '".');
}
}
示例9: updatePaymentStatusError
/**
* Update payment status to error
*
* @param $payment
*/
public function updatePaymentStatusError($payment)
{
$payment->setTransactionId($this->_transactionId);
$payment->setPreparedMessage("PayU - " . Mage::helper('payu_account')->__('The transaction is incorrect.'))->setParentTransactionId($this->_transactionId);
$this->_order->setState(Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW, true, "PayU - " . Mage::helper('payu_account')->__('The transaction is incorrect.'))->sendOrderUpdateEmail(true, "PayU - " . Mage::helper('payu_account')->__('The transaction is incorrect.'))->save();
}
示例10: completeOrder
/**
* Complete Magento order processing
*
* @param MageOrde $order Order
*/
protected function completeOrder(MageOrder $order)
{
$order->setState(MageOrder::STATE_PROCESSING, true)->sendOrderUpdateEmail()->setIsNotified(true)->save();
}
示例11: _processAuthorize
/**
* Process Configured Payment Actions: Authorized, Default operation
* just place order
*
* @param Mage_Sales_Model_Order $order Order
* @param array $params Request params
*/
protected function _processAuthorize($order, $params)
{
$status = $params['STATUS'];
if ($status == PostFinance_Payment_Model_Payment_Abstract::POSTFINANCE_AWAIT_CUSTOMER_PAYMENT) {
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage::helper('postfinance')->__('Waiting for payment. PostFinance status: %s.', Mage::helper('postfinance')->getStatusText($status)));
} elseif ($status == PostFinance_Payment_Model_Payment_Abstract::POSTFINANCE_AUTHORIZED_WAITING) {
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage::helper('postfinance')->__('Authorization uncertain. PostFinance status: %s.', Mage::helper('postfinance')->getStatusText($status)));
} else {
if ($this->isRedirectPaymentMethod($order) === true && $order->getEmailSent() !== '1') {
$order->sendNewOrderEmail();
}
$payId = $params['PAYID'];
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PROCESSING, Mage::helper('postfinance')->__('Processed by PostFinance. Payment ID: %s. PostFinance status: %s.', $payId, Mage::helper('postfinance')->getStatusText($status)));
}
$order->save();
}
示例12: orderStatusManager
/**
* Depends on Shopgate paymentInfos() to be passed
* into the TransactionAdditionalInfo of $order.
*
* @param $paymentStatus String
* @param $order Mage_Sales_Model_Order
* @return Mage_Sales_Model_Order
*/
public function orderStatusManager(Mage_Sales_Model_Order $order, $paymentStatus = null)
{
if (!$paymentStatus) {
$rawData = $order->getPayment()->getTransactionAdditionalInfo(self::RAW_DETAILS);
$paymentStatus = strtolower($rawData['payment_status']);
}
$formattedPrice = $order->getBaseCurrency()->formatTxt($order->getGrandTotal());
$state = $status = Mage_Sales_Model_Order::STATE_PROCESSING;
$action = $this->getActionByStatus($paymentStatus);
if ($order->getPayment()->getIsTransactionPending()) {
$message = Mage::helper('paypal')->__('%sing amount of %s is pending approval on gateway.', $action, $formattedPrice);
$state = $status = Mage::helper('shopgate')->getStateForStatus(self::STATE_PAYMENT_REVIEW);
} else {
$message = Mage::helper('paypal')->__('%sed amount of %s online.', $action, $formattedPrice);
}
//test for fraud
if ($order->getPayment()->getIsFraudDetected()) {
$state = Mage::helper('shopgate')->getStateForStatus(self::STATE_PAYMENT_REVIEW);
$status = Mage::helper('shopgate')->getStatusFromState($state);
}
return $order->setState($state, $status, $message);
}
示例13: syncOrderStatus
/**
* Poll Amazon API to receive order status and update Magento order.
*/
public function syncOrderStatus(Mage_Sales_Model_Order $order, $isManualSync = false)
{
$_api = $this->_getApi($order->getStoreId());
$message = '';
try {
$amazonOrderReference = $order->getPayment()->getAdditionalInformation('order_reference');
$orderReferenceDetails = $_api->getOrderReferenceDetails($amazonOrderReference);
if ($orderReferenceDetails) {
// Retrieve Amazon Authorization Details
// Last transaction ID is Amazon Authorize Reference ID
$lastAmazonReference = $order->getPayment()->getLastTransId();
$resultAuthorize = $this->_getApi($order->getStoreId())->getAuthorizationDetails($lastAmazonReference);
$amazonAuthorizationState = $resultAuthorize->getAuthorizationStatus()->getState();
$reasonCode = $resultAuthorize->getAuthorizationStatus()->getReasonCode();
// Re-authorize if holded, an Open order reference, and manual sync
if ($order->getState() == Mage_Sales_Model_Order::STATE_HOLDED && $orderReferenceDetails->getOrderReferenceStatus()->getState() == 'Open' && $isManualSync) {
$payment = $order->getPayment();
$amount = $payment->getAmountOrdered();
$method = $payment->getMethodInstance();
// Re-authorize
$payment->setTransactionId($amazonOrderReference);
$payment->setAdditionalInformation('sandbox', null);
// Remove decline and other test simulations
$method->setForceSync(true);
switch ($method->getConfigData('payment_action')) {
case $method::ACTION_AUTHORIZE:
$resultAuthorize = $method->authorize($payment, $amount, false);
break;
case $method::ACTION_AUTHORIZE_CAPTURE:
$resultAuthorize = $method->authorize($payment, $amount, true);
break;
default:
break;
}
// Resync
$order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true);
$order->save();
$this->syncOrderStatus($order);
return;
}
$message = Mage::helper('payment')->__('Sync with Amazon: Authorization state is %s.', $amazonAuthorizationState);
switch ($amazonAuthorizationState) {
// Pending (All Authorization objects are in the Pending state for 30 seconds after Authorize request)
case Amazon_Payments_Model_Api::AUTH_STATUS_PENDING:
$message .= ' (Payment is currently authorizing. Please try again momentarily.)';
break;
// Declined
// Declined
case Amazon_Payments_Model_Api::AUTH_STATUS_DECLINED:
if ($order->getState() != Mage_Sales_Model_Order::STATE_HOLDED) {
$order->setState(Mage_Sales_Model_Order::STATE_HOLDED, true);
}
if ($reasonCode == 'InvalidPaymentMethod') {
$this->_sendPaymentDeclineEmail($order, 'soft');
$message .= " Order placed on hold due to {$reasonCode}. Email sent to customer with link to order details page and instructions to update their payment method.";
} else {
$this->_sendPaymentDeclineEmail($order, 'hard');
$message .= " Order placed on hold due to {$reasonCode}. Email sent to customer with instructions to contact seller.";
}
break;
// Open (Authorize Only)
// Open (Authorize Only)
case Amazon_Payments_Model_Api::AUTH_STATUS_OPEN:
$order->setState(Mage_Sales_Model_Order::STATE_NEW);
$order->setStatus($_api->getConfig()->getNewOrderStatus($order->getStoreId()));
break;
// Closed (Authorize and Capture)
// Closed (Authorize and Capture)
case Amazon_Payments_Model_Api::AUTH_STATUS_CLOSED:
// Payment captured; create invoice
if ($reasonCode == 'MaxCapturesProcessed') {
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING);
$order->setStatus($_api->getConfig()->getNewOrderStatus($order->getStoreId()));
if ($this->_createInvoice($order, $resultAuthorize->getIdList()->getmember())) {
$message .= ' ' . Mage::helper('payment')->__('Invoice created.');
}
} else {
$order->setState(Mage_Sales_Model_Order::STATE_HOLDED, true);
$message .= ' Unable to create invoice due to Authorization Reason Code: ' . $reasonCode;
}
break;
}
// Update order
if ($amazonAuthorizationState != Amazon_Payments_Model_Api::AUTH_STATUS_PENDING) {
$order->addStatusToHistory($order->getStatus(), $message, false);
$order->save();
}
Mage::getSingleton('adminhtml/session')->addSuccess($message);
}
} catch (Exception $e) {
// Change order to "On Hold"
if ($order->getState() != Mage_Sales_Model_Order::STATE_HOLDED) {
$message = 'Error exception during sync. Please check exception.log';
$order->setState(Mage_Sales_Model_Order::STATE_HOLDED, true);
$order->addStatusToHistory($order->getStatus(), $message, false);
$order->save();
}
//.........这里部分代码省略.........
示例14: _transactionUnconfirmed
/**
* unconfirmed transaction
*
* @param SofortLib_TransactionData $transData
* @param Mage_Sales_Model_Order $order
* @param boolean $forceUpdate = false to gerate update
* @return void
*/
private function _transactionUnconfirmed($transData, $order, $forceUpdate = false)
{
$payment = $order->getPayment();
$transaction = $transData->getTransaction();
$statusReason = $transData->getStatusReason();
// rechnung
if ($transData->isSofortrechnung() && ($statusReason == 'confirm_invoice' || $forceUpdate)) {
$order->setState('sofort');
//customer may have changed the address during payment process
$address = $transData->getInvoiceAddress();
$order->getBillingAddress()->setStreet($address['street'] . ' ' . $address['street_number'])->setFirstname($address['firstname'])->setLastname($address['lastname'])->setCompany($address['company'])->setPostcode($address['zipcode'])->setCity($address['city'])->setCountryId($address['country_code']);
$address = $transData->getShippingAddress();
$order->getShippingAddress()->setStreet($address['street'] . ' ' . $address['street_number'])->setFirstname($address['firstname'])->setLastname($address['lastname'])->setCompany($address['company'])->setPostcode($address['zipcode'])->setCity($address['city'])->setCountryId($address['country_code']);
$order->save();
$waitingStatus = Mage::getStoreConfig('payment/sofort/sofortrechnung_order_status_waiting');
if ($waitingStatus == 'unchanged') {
$order->addStatusHistoryComment(Mage::helper('pnsofortueberweisung')->__('Payment successfull. Invoice needs to be confirmed.', $transaction))->setIsCustomerNotified(true);
} else {
$order->addStatusHistoryComment(Mage::helper('pnsofortueberweisung')->__('Payment successfull. Invoice needs to be confirmed.', $transaction), $waitingStatus)->setIsCustomerNotified(true);
}
$order->setIsVisibleOnFront(true);
if (!$order->getEmailSent()) {
$order->setEmailSent(true);
$order->save();
$order->sendNewOrderEmail();
}
} else {
// mark for notify
$order->setState('sofort');
}
$order->save();
}
示例15: setOrderState
/**
* Set an order status based on transaction status
*
* @param Mage_Sales_Model_Order $order
* @param string $status
* @param string $message
*/
public function setOrderState($order, $status, $message = '')
{
$this->initLibrary();
switch ($status) {
case \Genesis\API\Constants\Transaction\States::APPROVED:
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PROCESSING, $message, false)->save();
break;
case \Genesis\API\Constants\Transaction\States::PENDING:
case \Genesis\API\Constants\Transaction\States::PENDING_ASYNC:
$order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, $message, false)->save();
break;
case \Genesis\API\Constants\Transaction\States::ERROR:
case \Genesis\API\Constants\Transaction\States::DECLINED:
/** @var Mage_Sales_Model_Order_Invoice $invoice */
foreach ($order->getInvoiceCollection() as $invoice) {
$invoice->cancel();
}
$order->registerCancellation($message)->setCustomerNoteNotify(true)->save();
break;
default:
$order->save();
break;
}
}