本文整理汇总了PHP中Mage_Sales_Model_Order::prepareInvoice方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Order::prepareInvoice方法的具体用法?PHP Mage_Sales_Model_Order::prepareInvoice怎么用?PHP Mage_Sales_Model_Order::prepareInvoice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Order
的用法示例。
在下文中一共展示了Mage_Sales_Model_Order::prepareInvoice方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* @throws Payone_Core_Exception_InvoicePreparationNoItems|Payone_Core_Exception_InvoiceSave
* @param Mage_Sales_Model_Order $order
* @param array $itemsQty
* @param null $invoiceIncrementId
* @return Mage_Sales_Model_Order_Invoice
*/
protected function create(Mage_Sales_Model_Order $order, array $itemsQty = array(), $invoiceIncrementId = null)
{
/* @var $invoice Mage_Sales_Model_Order_Invoice */
$invoice = $order->prepareInvoice($itemsQty);
if ($invoiceIncrementId) {
$invoice->setIncrementId($invoiceIncrementId);
}
$invoice->setTransactionId($order->getPayment()->getLastTransId());
if (count($invoice->getAllItems()) <= 0) {
throw new Payone_Core_Exception_InvoicePreparationNoItems($order->getIncrementId());
}
if ($invoice) {
$invoice->register();
$invoice->setEmailSent(false);
$invoice->getOrder()->setIsInProcess(true);
try {
$transactionSave = $this->getFactory()->getModelResourceTransaction();
$transactionSave->addObject($invoice);
$transactionSave->addObject($invoice->getOrder());
$transactionSave->save();
} catch (Mage_Core_Exception $e) {
throw new Payone_Core_Exception_InvoiceSave($e->getMessage());
}
return $invoice;
}
return null;
}
示例2: _createInvoice
/**
* Builds invoice for order
*/
protected function _createInvoice()
{
if (!$this->_order->canInvoice()) {
return;
}
$invoice = $this->_order->prepareInvoice();
$invoice->register()->capture();
$this->_order->addRelatedObject($invoice);
}
示例3: _createInvoice
/**
* Create invoice
*/
protected function _createInvoice(Mage_Sales_Model_Order $order, $captureReferenceIds)
{
if ($order->canInvoice()) {
$transactionSave = Mage::getModel('core/resource_transaction');
// Create invoice
$invoice = $order->prepareInvoice()->register();
$invoice->setTransactionId(current($captureReferenceIds));
$transactionSave->addObject($invoice)->addObject($invoice->getOrder());
return $transactionSave->save();
}
return false;
}
示例4: createInvoiceForOrder
/**
* @param Mage_Sales_Model_Order $order
* @return bool|Mage_Sales_Model_Order_Invoice
*/
public function createInvoiceForOrder(Mage_Sales_Model_Order $order)
{
if (!Mage::getStoreConfig('payment/lliqpay_cc/create_invoice') || !$order->canInvoice()) {
return false;
}
$invoice = $order->prepareInvoice();
if (!$invoice) {
return false;
}
$invoice->register()->pay();
Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder())->save();
return $invoice;
}
示例5: _confirmOrder
/**
* Confirm the payment of an order
*
* @param array $data
*/
protected function _confirmOrder($data)
{
if (!$this->_succeeded($this->order)) {
if ($data['paymentState'] == 'PENDING') {
$this->order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true, Mage::helper('wirecard_checkout_page')->__('The payment authorization is pending.'))->save();
} else {
$this->order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, Mage::helper('wirecard_checkout_page')->__('The amount has been authorized and captured by Wirecard Checkout Page.'))->save();
// invoice payment
if ($this->order->canInvoice()) {
$invoice = $this->order->prepareInvoice();
$invoice->register()->capture();
Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder())->save();
}
// send new order email to customer
$this->order->sendNewOrderEmail();
}
}
$payment = $this->order->getPayment();
$additionalInformation = array();
$additionalInformationString = '';
foreach ($data as $fieldName => $fieldValue) {
switch ($fieldName) {
case 'amount':
case 'currency':
case 'language':
case 'responseFingerprint':
case 'responseFingerprintOrder':
case 'form_key':
case 'paymentState':
case 'orderId':
break;
default:
$additionalInformation[htmlentities($fieldName)] = htmlentities($fieldValue);
$additionalInformationString .= ' | ' . $fieldName . ' - ' . $fieldValue;
}
}
if (count($additionalInformation) != 0) {
$payment->setAdditionalInformation($additionalInformation);
$payment->setAdditionalData(serialize($additionalInformation));
if ($payment->hasAdditionalInformation()) {
Mage::log('Added Additional Information to Order ' . $data['orderId'] . ' :' . $additionalInformationString);
}
}
$payment->save();
}
示例6: _savePaidInvoice
/**
* Save an invoice for the order.
*
* @param Mage_Sales_Model_Order $order
*
* @return bool
*/
protected function _savePaidInvoice(Mage_Sales_Model_Order $order, $transaction_id = null)
{
$invoice = $order->prepareInvoice()->register()->setTransactionId($transaction_id)->pay();
Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder())->save();
if (!Mage::Helper('mpm/data')->getConfig('mollie', 'skip_invoice_mails')) {
$invoice->sendEmail();
}
return TRUE;
}
示例7: invoice
public function invoice(Mage_Sales_Model_Order $order, $transactionId, $mail)
{
if ($order->canInvoice()) {
$invoice = $order->prepareInvoice();
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE);
$invoice->register();
Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder())->save();
$invoice->setTransactionId($transactionId);
$invoice->pay();
$invoice->save();
$invoice->sendEmail($mail, '');
} else {
foreach ($order->getInvoiceCollection() as $invoice) {
$invoice->pay()->save();
}
}
}
示例8: saveInvoice
/**
* Save invoice for order
*
* @param Mage_Sales_Model_Order $order
* @return boolean Can save invoice or not
*/
protected function saveInvoice(Mage_Sales_Model_Order $order)
{
if ($order->canInvoice()) {
$invoice = $order->prepareInvoice();
$invoice->register()->capture();
Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder())->save();
return true;
}
return false;
}
示例9: registerPaymentCapture
public function registerPaymentCapture(Mage_Sales_Model_Order $order, $transactionId, $amount, array $post)
{
$payment = $order->getPayment();
foreach ($post as $key => $value) {
$payment->setTransactionAdditionalInfo($key, $value);
}
$payment->setTransactionId($transactionId)->setShouldCloseParentTransaction(true)->setIsTransactionClosed(true)->setIsTransactionPending(false)->save();
$invoice = $order->prepareInvoice();
$invoice->register();
$order->setIsCustomerNotified(false)->setIsInProcess(true)->save();
$formattedAmount = $order->getOrderCurrency()->format($amount, null, false);
$this->_addTransaction($order, $invoice, $payment, $transactionId);
$order->addStatusHistoryComment($this->_helper()->__("Registered notification about captured amount of %s. Transaction ID: %s.", $formattedAmount, $transactionId))->setIsCustomerNotified(false)->save();
/** @var $transactionSave Mage_Core_Model_Resource_Transaction */
$transactionSave = Mage::getModel('core/resource_transaction');
$transactionSave->addObject($invoice)->addObject($invoice->getOrder())->save();
# Notify customer
if ($invoice && !$order->getEmailSent()) {
$order->sendNewOrderEmail()->addStatusHistoryComment($this->_helper()->__('Notified customer about invoice #%s.', $invoice->getIncrementId()))->setIsCustomerNotified(true)->save();
}
}
示例10: createInvoice
/**
* Depending on the settings we create an invoice and capture it.
*
* @param Mage_Sales_Model_Order $order
* @param boolean Returns true if an invoice has been created.
*/
protected function createInvoice(Mage_Sales_Model_Order $order, Customweb_SaferpayCw_Model_Transaction $transaction)
{
try {
$isSettlementAfterOrder = $this->getPaymentMethodConfigurationValue('settlement');
$isCaptureAfterOrder = $transaction->getTransactionObject()->isCaptured();
$this->getHelper()->log("Payment config: settlement='" . $isSettlementAfterOrder . "' capturing='" . $isCaptureAfterOrder . "'");
if ($isSettlementAfterOrder != 'settlement_direct') {
return false;
}
// Do not create multiple invoices
if ($order->hasInvoices()) {
return false;
}
$invoice = $order->prepareInvoice();
if ($isCaptureAfterOrder) {
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
}
$invoice->register();
$invoice->setTransactionId($transaction->getTransactionObject()->getPaymentId());
$transactionSave = Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder());
$transactionSave->save();
if ($this->getConfigData('invoice_send_email')) {
$invoice->sendEmail();
}
return true;
} catch (Exception $e) {
$this->getHelper()->log("Create Invoice: " . $e->getMessage());
return false;
}
}
示例11: _createInvoiceAndCapture
/**
* @param Mage_Sales_Model_Order $order
* @param array $itemsQty
* @param string $comment
* @param bool $email
* @param bool $includeComment
* @return string
*/
protected function _createInvoiceAndCapture($order, $itemsQty, $comment = null, $email = false, $includeComment = false)
{
/** @var $helper RetailOps_Api_Helper_Data */
$helper = Mage::helper('retailops_api');
try {
$itemsQtyFomratted = array();
if ($itemsQty) {
foreach ($order->getAllItems() as $item) {
$itemsQtyFomratted[$item->getId()] = isset($itemsQty[$item->getId()]) ? $itemsQty[$item->getId()] : 0;
}
}
$invoice = $order->prepareInvoice($itemsQtyFomratted);
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
$invoice->register();
if ($comment !== null) {
$invoice->addComment($comment, $email);
}
if ($email) {
$invoice->setEmailSent(true);
}
$invoice->getOrder()->setIsInProcess(true);
$transactionSave = Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder())->save();
$invoice->sendEmail($email, $includeComment ? $comment : '');
$result['invoice'] = $helper->removeObjectsFromResult($this->_getAttributes($invoice, 'invoice'));
$result['items'] = array();
foreach ($invoice->getAllItems() as $item) {
$result['items'][] = $helper->removeObjectsFromResult($this->_getAttributes($item, 'invoice_item'));
}
$result['status'] = RetailOps_Api_Helper_Data::API_STATUS_SUCCESS;
} catch (Exception $e) {
$result['status'] = RetailOps_Api_Helper_Data::API_STATUS_FAIL;
$result['message'] = $e->getMessage();
}
return $result;
}
示例12: _processDirectSale
/**
* Process Configured Payment Action: Direct Sale, create invoice if state is Pending
*
* @param Mage_Sales_Model_Order $order Order
* @param array $params Request params
*/
protected function _processDirectSale($order, $params, $instantCapture = 0)
{
Mage::register('ops_auto_capture', true);
$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 the payment of the customer'));
// 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();
}
$order->save();
} 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 waiting from Barclaycard'));
$order->save();
} elseif ($order->getState() == Mage_Sales_Model_Order::STATE_PENDING_PAYMENT || $instantCapture) {
if ($status == Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED) {
if ($order->getStatus() != Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) {
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PROCESSING, Mage::helper('ops')->__('Processed by Barclaycard'));
}
} else {
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, Mage::helper('ops')->__('Processed by Barclaycard'));
$order->save();
}
if (!$order->getInvoiceCollection()->getSize() && $order->getState() == Mage_Sales_Model_Order::STATE_PROCESSING && $order->canInvoice()) {
$invoice = $order->prepareInvoice();
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
$invoice->register();
$invoice->setState(Mage_Sales_Model_Order_Invoice::STATE_PAID);
$invoice->getOrder()->setIsInProcess(true);
$invoice->save();
$this->sendInvoiceToCustomer($invoice);
$transactionSave = Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder())->save();
/*
* If the payment method is a redirect-payment-method send the email
* In any other case Magento sends an email automatically in Mage_Checkout_Model_Type_Onepage::saveOrder
*/
if ($this->isRedirectPaymentMethod($order) === true && $order->getEmailSent() != 1) {
$order->sendNewOrderEmail();
}
$eventData = array('data_object' => $order, 'order' => $order);
Mage::dispatchEvent('ops_sales_order_save_commit_after', $eventData);
}
if ($this->isInlinePayment($order->getPayment()) && 0 < strlen(trim($order->getPayment()->getAdditionalInformation('HTML_ANSWER'))) && $order->getPayment()->getAdditionalInformation('status') == Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_REQUESTED) {
$order->getPayment()->setIsTransactionApproved(true)->registerPaymentReviewAction(Mage_Sales_Model_Order_Payment::REVIEW_ACTION_UPDATE, true)->save();
$this->setInvoicesToPaid($order);
$order->getPayment()->getAuthorizationTransaction()->setIsClosed(true)->save();
$order->getPayment()->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, $order->getPayment())->setIsClosed(true)->save();
$order->sendNewOrderEmail();
$order->save();
}
if ($this->isInlinePayment($order->getPayment()) && Mage::getModel('ops/config')->getSendInvoice() && Mage::getModel('ops/config')->getPaymentAction($order->getStoreId()) === Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) {
foreach ($order->getInvoiceCollection() as $invoice) {
$this->sendInvoiceToCustomer($invoice);
}
}
} else {
$order->save();
}
}
示例13: create_invoice
/**
* Create object invoice
* @param Mage_Sales_Model_Order $order
* @param string $transactionReference
* @param boolean $capture
* @param boolean $paid
* @return Mage_Sales_Model_Order_Invoice $invoice
*/
protected function create_invoice($order, $transactionReference, $capture = true, $paid = false)
{
/* @var $invoice Mage_Sales_Model_Order_Invoice */
$invoice = $order->prepareInvoice();
$invoice->setTransactionId($transactionReference);
$capture_case = Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE;
if ($capture) {
$capture_case = Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE;
}
$invoice->setRequestedCaptureCase($capture_case);
$invoice->register();
$invoice->getOrder()->setIsInProcess(true);
if ($paid) {
$invoice->setIsPaid(1);
}
return $invoice;
}
示例14: _processDirectSale
/**
* Process Configured Payment Action: Direct Sale, create invoce if state is Pending
*
* @param Mage_Sales_Model_Order $order Order
* @param array $params Request params
*/
protected function _processDirectSale($order, $params, $instantCapture = 0)
{
Mage::register('postfinance_auto_capture', true);
$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 the payment of the customer'));
$order->save();
} 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 waiting from PostFinance'));
$order->save();
} elseif ($order->getState() == Mage_Sales_Model_Order::STATE_PENDING_PAYMENT || $instantCapture) {
if ($status == PostFinance_Payment_Model_Payment_Abstract::POSTFINANCE_AUTHORIZED) {
if ($order->getStatus() != Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) {
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PROCESSING, Mage::helper('postfinance')->__('Processed by PostFinance'));
}
} else {
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PROCESSING, Mage::helper('postfinance')->__('Processed by PostFinance'));
}
if (!$order->getInvoiceCollection()->getSize()) {
$invoice = $order->prepareInvoice();
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
$invoice->register();
$invoice->setState(Mage_Sales_Model_Order_Invoice::STATE_PAID);
$invoice->getOrder()->setIsInProcess(true);
$invoice->save();
$transactionSave = Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder())->save();
/*
* If the payment method is a redirect-payment-method send the email
* In any other case Magento sends an email automatically in Mage_Checkout_Model_Type_Onepage::saveOrder
*/
if ($this->isRedirectPaymentMethod($order) === true && $order->getEmailSent() !== '1') {
$order->sendNewOrderEmail();
}
}
} else {
$order->save();
}
}
示例15: createInvoice
/**
* @param Mage_Sales_Model_Order $order
*
* @return bool
*/
public function createInvoice($order)
{
if (!$order->getId()) {
return false;
}
$this->log(sprintf('Gerando fatura para o pedido: %s.', $order->getId()));
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, 'O pagamento foi confirmado e o pedido está sendo processado.', true);
if (!$order->canInvoice()) {
$this->log(sprintf('Impossível gerar fatura para o pedido %s.', $order->getId()), 4);
// TODO define how to handle this
return false;
}
$invoice = $order->prepareInvoice();
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE);
$invoice->register();
Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder())->save();
$invoice->sendEmail(true);
$this->log('Fatura gerada com sucesso.');
return true;
}