本文整理汇总了PHP中Mage_Sales_Model_Order_Payment::getIsRecurring方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Order_Payment::getIsRecurring方法的具体用法?PHP Mage_Sales_Model_Order_Payment::getIsRecurring怎么用?PHP Mage_Sales_Model_Order_Payment::getIsRecurring使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Order_Payment
的用法示例。
在下文中一共展示了Mage_Sales_Model_Order_Payment::getIsRecurring方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doCapturePayment
/**
* Call Capture API (do the Capture only, must Authorized previously)
*
* @param Mage_Sales_Model_Order_Payment $payment
* @param $amount
* @return Eway_Rapid31_Model_Request_Direct
*/
public function doCapturePayment(Mage_Sales_Model_Order_Payment $payment, $amount)
{
// Empty Varien_Object's data
$this->unsetData();
/* @var Mage_Sales_Model_Order_Invoice $invoice */
$invoice = Mage::registry('current_invoice');
$order = $payment->getOrder();
$paymentParam = Mage::getModel('ewayrapid/field_payment');
$paymentParam->setTotalAmount($amount)->setCurrencyCode($order->getBaseCurrencyCode());
if ($invoice && $invoice->getIncrementId()) {
$paymentParam->setInvoiceNumber($invoice->getIncrementId())->setInvoiceReference($invoice->getIncrementId())->setInvoiceDescription(Mage::helper('ewayrapid')->__('Invoice created from Magento'));
}
$this->setPayment($paymentParam);
$this->setTransactionId($payment->getLastTransId());
$response = $this->_doRapidAPI('CapturePayment');
if ($response->isSuccess()) {
$payment->setTransactionId($response->getTransactionID());
return $this;
} else {
if ($payment->getIsRecurring()) {
Mage::getSingleton('core/session')->setData('errorMessage', $response->getMessage());
}
Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while doing the capture. Please try again. (Error message: %s)', $response->getMessage()));
}
}
示例2: _buildRequest
protected function _buildRequest(Mage_Sales_Model_Order_Payment $payment, $amount)
{
// Empty Varien_Object's data
$this->unsetData();
// in case recurring profile, $methodInstance is not exist, and $payment->getIsRecurring() is used
if (!$payment->getIsRecurring()) {
$methodInstance = $payment->getMethodInstance();
$infoInstance = $methodInstance->getInfoInstance();
Mage::helper('ewayrapid')->unserializeInfoInstace($infoInstance);
}
$order = $payment->getOrder();
$shipping = $order->getShippingAddress();
$this->setCustomerIP(Mage::helper('core/http')->getRemoteAddr());
if (Mage::helper('ewayrapid')->isBackendOrder()) {
$this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_MOTO);
} elseif ($payment->getIsRecurring()) {
$this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_RECURRING);
} else {
$this->setTransactionType(Eway_Rapid31_Model_Config::TRANSACTION_PURCHASE);
}
$this->setDeviceID('Magento ' . Mage::getEdition() . ' ' . Mage::getVersion());
$this->setShippingMethod('Other');
$paymentParam = Mage::getModel('ewayrapid/field_payment');
$paymentParam->setTotalAmount($amount)->setCurrencyCode($order->getBaseCurrencyCode());
$this->setPayment($paymentParam);
$customerParam = Mage::getModel('ewayrapid/field_customer');
$customerTokenId = null;
/** get $customerTokenId if product is recurring profile */
if ($payment->getIsRecurring()) {
/** @todo save customer id and tokent id into payment when place order */
$customer = Mage::getModel('customer/customer')->load($payment->getCustomerId());
$customerHelper = Mage::helper('ewayrapid/customer');
$customerHelper->setCurrentCustomer($customer);
$customerTokenId = $customerHelper->getCustomerTokenId($payment->getTokenId());
} else {
/** get $customerTokenId if product is normal item */
if ($infoInstance->getSavedToken()) {
$customerHelper = Mage::helper('ewayrapid/customer');
$customerTokenId = $customerHelper->getCustomerTokenId($infoInstance->getSavedToken());
} else {
Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while making the transaction: Token info does not exist.'));
}
}
if ($customerTokenId) {
$customerParam->setTokenCustomerID($customerTokenId);
if ($this->getTransactionType() == Eway_Rapid31_Model_Config::TRANSACTION_PURCHASE) {
$cardDetails = Mage::getModel('ewayrapid/field_cardDetails');
$cardDetails->setCVN($infoInstance->getCcCid());
$customerParam->setCardDetails($cardDetails);
}
$this->setCustomer($customerParam);
} else {
Mage::throwException(Mage::helper('ewayrapid')->__('An error occurred while making the transaction: Token info does not exist.'));
}
$shippingParam = Mage::getModel('ewayrapid/field_shippingAddress');
$shippingParam->setFirstName($shipping->getFirstname())->setLastName($shipping->getLastname())->setStreet1($shipping->getStreet1())->setStreet2($shipping->getStreet2())->setCity($shipping->getCity())->setState($shipping->getRegion())->setPostalCode($shipping->getPostcode())->setCountry(strtolower($shipping->getCountryModel()->getIso2Code()))->setEmail($shipping->getEmail())->setPhone($shipping->getTelephone())->setFax($shipping->getFax());
$this->setShippingAddress($shippingParam);
if (isset($methodInstance) && $methodInstance->getConfigData('transfer_cart_items') || $payment->getIsRecurring() || !$payment->getIsInitialFee()) {
$orderItems = $order->getAllVisibleItems();
$lineItems = array();
foreach ($orderItems as $orderItem) {
/* @var Mage_Sales_Model_Order_Item $orderItem */
$lineItem = Mage::getModel('ewayrapid/field_lineItem');
$lineItem->setSKU($orderItem->getSku());
$lineItem->setDescription(substr($orderItem->getName(), 0, 26));
$lineItem->setQuantity($orderItem->getQtyOrdered());
$lineItem->setUnitCost(round($orderItem->getBasePrice() * 100));
$lineItem->setTax(round($orderItem->getBaseTaxAmount() * 100));
$lineItem->setTotal(round($orderItem->getBaseRowTotalInclTax() * 100));
$lineItems[] = $lineItem;
}
$this->setItems($lineItems);
}
return $this;
}