本文整理汇总了PHP中Mage_Sales_Model_Order_Payment::capture方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Order_Payment::capture方法的具体用法?PHP Mage_Sales_Model_Order_Payment::capture怎么用?PHP Mage_Sales_Model_Order_Payment::capture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Order_Payment
的用法示例。
在下文中一共展示了Mage_Sales_Model_Order_Payment::capture方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: capture
/**
* Capture the payment online
* Requires an invoice. If there is no invoice specified, will automatically prepare an invoice for order
* Updates transactions hierarchy, if required
* Updates payment totals, updates order status and adds proper comments
*
* TODO: eliminate logic duplication with registerCaptureNotification()
*
* @return Mage_Sales_Model_Order_Payment
* @throws Mage_Core_Exception
*/
public function capture($invoice)
{
if (!Mage::helper('imagecc')->isActive()) {
return parent::capture($invoice);
}
if (is_null($invoice)) {
$invoice = $this->_invoice();
$this->setCreatedInvoice($invoice);
return $this;
// @see Mage_Sales_Model_Order_Invoice::capture()
}
$amountToCapture = $this->_formatAmount($invoice->getGrandTotal());
$order = $this->getOrder();
// prepare parent transaction and its amount
$paidWorkaround = 0;
if (!$invoice->wasPayCalled()) {
$paidWorkaround = (double) $amountToCapture;
}
$this->_isCaptureFinal($paidWorkaround);
$this->_generateTransactionId(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, $this->getAuthorizationTransaction());
Mage::dispatchEvent('sales_order_payment_capture', array('payment' => $this, 'invoice' => $invoice));
/**
* Fetch an update about existing transaction. It can determine whether the transaction can be paid
* Capture attempt will happen only when invoice is not yet paid and the transaction can be paid
*/
if ($invoice->getTransactionId()) {
$this->getMethodInstance()->setStore($order->getStoreId())->fetchTransactionInfo($this, $invoice->getTransactionId());
}
$status = true;
if (!$invoice->getIsPaid() && !$this->getIsTransactionPending()) {
// attempt to capture: this can trigger "is_transaction_pending"
$this->getMethodInstance()->setStore($order->getStoreId())->capture($this, $amountToCapture);
$transaction = $this->_addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, $invoice, true);
if ($this->getIsTransactionPending()) {
$message = Mage::helper('sales')->__('Capturing amount of %s is pending approval on gateway.', $this->_formatPrice($amountToCapture));
$state = Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW;
if ($this->getIsFraudDetected()) {
$status = Mage_Sales_Model_Order::STATUS_FRAUD;
}
$invoice->setIsPaid(false);
} else {
// normal online capture: invoice is marked as "paid"
$message = Mage::helper('sales')->__('Captured amount of %s online.', $this->_formatPrice($amountToCapture));
$state = Mage_Sales_Model_Order::STATE_PROCESSING;
$invoice->setIsPaid(true);
$this->_updateTotals(array('base_amount_paid_online' => $amountToCapture));
}
if ($order->isNominal()) {
$message = $this->_prependMessage(Mage::helper('sales')->__('Nominal order registered.'));
} else {
$message = $this->_prependMessage($message);
$message = $this->_appendTransactionToMessage($transaction, $message);
}
$order->setState($state, $status, $message);
$this->getMethodInstance()->processInvoice($invoice, $this);
// should be deprecated
return $this;
}
Mage::throwException(Mage::helper('sales')->__('The transaction "%s" cannot be captured yet.', $invoice->getTransactionId()));
}
开发者ID:vinayshuklasourcefuse,项目名称:sareez,代码行数:71,代码来源:Intellimage_CurrencyCheckout_Model_Sales_Order_Payment.php