/** * @magentoConfigFixture current_store design/theme/full_name default/default/default * @magentoDataFixture Mage/Sales/_files/order.php */ public function testSendNewOrderEmail() { $order = new Mage_Sales_Model_Order(); $order->loadByIncrementId('100000001'); $order->setCustomerEmail('*****@*****.**'); $payment = $order->getPayment(); $paymentInfoBlock = Mage::helper('Mage_Payment_Helper_Data')->getInfoBlock($payment); $paymentInfoBlock->setArea('invalid-area'); $payment->setBlockMock($paymentInfoBlock); $this->assertEmpty($order->getEmailSent()); $order->sendNewOrderEmail(); $this->assertNotEmpty($order->getEmailSent()); $this->assertEquals('frontend', $paymentInfoBlock->getArea()); }
/** * Register authorized payment */ protected function _registerPaymentAuthorization() { $this->_importPaymentInformation(); $this->_order->getPayment()->setPreparedMessage($this->_createIpnComment(''))->setTransactionId($this->getRequestData('txn_id'))->setParentTransactionId($this->getRequestData('parent_txn_id'))->setCurrencyCode($this->getRequestData('mc_currency'))->setIsTransactionClosed(0)->registerAuthorizationNotification($this->getRequestData('mc_gross')); if (!$this->_order->getEmailSent()) { $this->_order->queueNewOrderEmail(); } $this->_order->save(); }
/** * Mark transaction as completed * * @param \PayPal\Api\WebhookEvent $webhookEvent */ protected function paymentSaleCompleted(\PayPal\Api\WebhookEvent $webhookEvent) { $paymentResource = $webhookEvent->getResource(); $parentTransactionId = $paymentResource->parent_payment; $payment = $this->_order->getPayment(); $payment->setTransactionId($paymentResource->id)->setCurrencyCode($paymentResource->amount->currency)->setParentTransactionId($parentTransactionId)->setIsTransactionClosed(true)->registerCaptureNotification($paymentResource->amount->total, true); $this->_order->save(); // notify customer $invoice = $payment->getCreatedInvoice(); if ($invoice && !$this->_order->getEmailSent()) { $this->_order->queueNewOrderEmail()->addStatusHistoryComment(Mage::helper('iways_paypalplus')->__('Notified customer about invoice #%s.', $invoice->getIncrementId()))->setIsCustomerNotified(true)->save(); } }
/** * Process completed payment (either full or partial) */ public function _registerPaymentCapture() { $session = $session = Mage::getSingleton('checkout/session'); $purchaseId = $session->getPurchaseId(); $this->_order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId()); $payment = $this->_order->getPayment(); $payment->setTransactionId($purchaseId)->setCurrencyCode('EUR')->setIsTransactionClosed(0)->registerCaptureNotification($this->getRequestData('amount') / 100); Mage::helper('sign2pay')->setStatusOnOrder($this->_order, Mage::getStoreConfig('payment/sign2pay/complete_order_status', Mage::app()->getStore())); $this->_order->save(); // notify customer $invoice = $payment->getCreatedInvoice(); if ($invoice && !$this->_order->getEmailSent()) { $this->_order->sendNewOrderEmail()->addStatusHistoryComment(Mage::helper('sign2pay')->__('Notified customer about invoice #%s.', $invoice->getIncrementId()))->setIsCustomerNotified(true)->save(); } return $this; }
/** * Process a succesful order. Sets its new state and status, sends an order confirmation email * and creates an invoice if set in config. * * @param $newStates * @param bool $description * @return bool */ protected function _processSuccess($newStates, $description = false) { //send new order email if it hasnt already been sent if (!$this->_order->getEmailSent()) { $this->sendNewOrderEmail(); } $this->_autoInvoice(); $description = Mage::helper('buckaroo3extended')->__($description); $description .= " (#{$this->_postArray['brq_statuscode']})"; //sets the transaction key if its defined ($trx) //will retrieve it from the response array, if response actually is an array if (!$this->_order->getTransactionKey() && array_key_exists('brq_transactions', $this->_postArray)) { $this->_order->setTransactionKey($this->_postArray['brq_transactions']); $this->_order->save(); } if ($this->_order->getState() == Mage_Sales_Model_Order::STATE_PROCESSING) { $this->_order->addStatusHistoryComment($description, $newStates[1])->save(); $this->_order->setStatus($newStates[1])->save(); } else { $this->_order->addStatusHistoryComment($description)->save(); } return true; }
/** * Update order's customer information based on PayU information * @var array result data from payu with billing and shipping info */ protected function updateCustomerData($data) { try { $customerRecord = $data; $this->_order->setCustomerFirstname($customerRecord->firstName); $this->_order->setCustomerLastname($customerRecord->lastName); $this->_order->setCustomerEmail($customerRecord->email); if (isset($data->delivery) && !empty($data->delivery)) { $shippingAddress = $data->delivery; /* $billing = $this->_order->getBillingAddress(); $billing->setCity($shippingAddress->city); $billing->setStreet($shippingAddress->street); $billing->setPostcode($shippingAddress->postalCode); $billing->setCountryId($shippingAddress->countryCode); $this->_order->setBillingAddress($billing)->save(); */ $recipient = explode(" ", $shippingAddress->recipientName); $shipping = $this->_order->getShippingAddress(); $shipping->setFirstname($recipient[0]); $shipping->setLastname($recipient[1]); //$shipping->setTelephone($customerRecord['phone']); $shipping->setCity($shippingAddress->city); $shipping->setStreet($shippingAddress->street); $shipping->setPostcode($shippingAddress->postalCode); $shipping->setCountryId($shippingAddress->countryCode); $this->_order->setShippingAddress($shipping)->save(); } /* if (isset($data['billing']) && !empty( $data['billing'] )) { $billingAddress = $data['billing']; $billing = $this->_order->getBillingAddress(); $recipient = explode(" ", $billingAddress['recipientName']); $billing->setFirstname($recipient[0]); $billing->setLastname($recipient[1]); $billing->setCompany($billingAddress['recipientName']); $billing->setTelephone($customerRecord['phone']); $billing->setCity($billingAddress['city']); $billing->setStreet($billingAddress['street']); $billing->setPostcode($billingAddress['postalCode']); $billing->setCountryId($billingAddress['countryCode']); //$this->_order->setCustomerTaxvat($billingAddress['TIN']); $this->_order->setBillingAddress($billing)->save(); } else { $billing = $this->_order->getBillingAddress(); $billing->setFirstname($customerRecord['firstName']); $billing->setLastname($customerRecord['lastName']); $billing->setTelephone($customerRecord['phone']); $this->_order->setBillingAddress($billing)->save(); } */ if (!$this->_order->getEmailSent()) { $this->_order->sendNewOrderEmail(); $this->_order->setEmailSent(1); } $this->_order->save(); } catch (Error $e) { Mage::logException("Can not update order data: " . $e); } }
/** * 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(); }
/** * 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 == Netresearch_OPS_Model_Payment_Abstract::OPS_AWAIT_CUSTOMER_PAYMENT) { $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage::helper('ops')->__('Waiting for payment. Barclaycard status: %s.', Mage::helper('ops')->getStatusText($status))); // send new order mail for bank transfer, since it is 'successfully' authorized at this point if ($order->getPayment()->getMethodInstance() instanceof Netresearch_OPS_Model_Payment_BankTransfer && $order->getEmailSent() != 1) { $order->sendNewOrderEmail(); } } elseif ($status == Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED_WAITING) { $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage::helper('ops')->__('Authorization uncertain. Barclaycard status: %s.', Mage::helper('ops')->getStatusText($status))); } else { // for 3DS payments the order has to be retrieved from the payment review step if ($this->isInlinePayment($order->getPayment()) && 0 < strlen(trim($order->getPayment()->getAdditionalInformation('HTML_ANSWER'))) && $order->getPayment()->getAdditionalInformation('status') == Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED) { $order->getPayment()->setIsTransactionApproved(true)->registerPaymentReviewAction(Mage_Sales_Model_Order_Payment::REVIEW_ACTION_UPDATE, true)->save(); } 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('ops')->__('Processed by Barclaycard. Payment ID: %s. Barclaycard status: %s.', $payId, Mage::helper('ops')->getStatusText($status))); } $order->save(); }