本文整理汇总了PHP中Varien_Object::getOrder方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Object::getOrder方法的具体用法?PHP Varien_Object::getOrder怎么用?PHP Varien_Object::getOrder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Object
的用法示例。
在下文中一共展示了Varien_Object::getOrder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: order
public function order(Varien_Object $payment, $amount)
{
$order = $payment->getOrder();
$order_id = $order->getId();
$order_increment_id = $order->getIncrementId();
$store_id = $order->getStoreId();
$ccType = $payment->getCcType();
// reorder
$reorder_increment_id = explode('-', $order_increment_id);
// reorder
$order_increment_id = $reorder_increment_id[0];
$order_suffix_id = @$reorder_increment_id[1];
$expiration = strtotime('+' . $this->_getStoreConfig($ccType, 'expiration') . 'days');
$transaction_expiration = date('Y-m-d', $expiration);
$increment = $this->_getStoreConfig('slips', 'order_id_increment');
$order_increment_prefix = $this->_getOrderIncrementPrefix($store_id);
$number = $order_increment_id - $order_increment_prefix;
if (!empty($order_suffix_id)) {
$number *= pow(10, strlen($order_suffix_id));
$number += $order_suffix_id;
}
$number += $increment;
$data = array('order_id' => $order_id, 'amount' => $amount, 'expiration' => $transaction_expiration, 'number' => $number);
$result = Mage::getModel('utils/sql')->insert('gamuza_slips_transactions', $data);
if (!$result) {
Mage::throwException(Mage::helper('slips')->__('Unable to save the Slip and Deposit informations. Please verify your database.'));
}
$this->setStore($payment->getOrder()->getStoreId());
$payment->setAmount($amount);
$payment->setLastTransId($order_id);
$payment->setStatus(self::STATUS_APPROVED);
return $this;
}
示例2: beforeSave
/**
* Perform operation before save
*
* @param Varien_Object $object
* @return Mage_Sales_Model_Resource_Order_Attribute_Backend_Child
*/
public function beforeSave($object)
{
if ($object->getOrder()) {
$object->setParentId($object->getOrder()->getId());
}
parent::beforeSave($object);
return $this;
}
示例3: beforeSave
/**
* Method is invoked before save
*
* @param Varien_Object $object
* @return Mage_Sales_Model_Resource_Order_Invoice_Attribute_Backend_Order
*/
public function beforeSave($object)
{
if ($object->getOrder()) {
$object->setOrderId($object->getOrder()->getId());
$object->setBillingAddressId($object->getOrder()->getBillingAddress()->getId());
}
return parent::beforeSave($object);
}
示例4: refund
/**
* Request an online refund
*
* @param Varien_Object $payment
* @param string $amount
*
* @since 1.0.2
* @return \Icepay_IceAdvanced_Model_Checkout_Standard
*/
public function refund(Varien_Object $payment, $amount)
{
// Get Magento Order
$order = $payment->getOrder();
// Get StoreId
$storeId = $order->getStoreId();
// Check if Auto Refund is enabled
if (!Mage::getStoreConfig(Icepay_IceCore_Model_Config::AUTOREFUND, $storeId)) {
return $this;
}
// Fetch ICEPAY merchant settings
$merchantID = Mage::getStoreConfig(Icepay_IceCore_Model_Config::MERCHANTID, $storeId);
$secretCode = Mage::getStoreConfig(Icepay_IceCore_Model_Config::SECRETCODE, $storeId);
// Get CurrencyCode
$currency = $order->getOrderCurrencyCode();
// Amount must be in cents
$amount = (int) (string) ($amount * 100);
// Fetch ICEPAY Payment ID
$paymentID = $payment->getLastTransId();
// Setup webservice
$webservice = Mage::getModel('Icepay_IceAdvanced_Model_Webservice_Refund');
$webservice->init($merchantID, $secretCode);
// Request refund
try {
$webservice->requestRefund($paymentID, $amount, $currency);
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError("ICEPAY: Refund Failed! {$e->getMessage()}");
Mage::helper('icecore')->log("ICEPAY: Refund Failed! {$e->getMessage()}");
}
return $this;
}
示例5: getChilds
/**
* Getting all available childs for Invoice, Shipmen or Creditmemo item
*
* @param Varien_Object $item
* @return array
*/
public function getChilds($item)
{
$_itemsArray = array();
if ($item instanceof Mage_Sales_Model_Order_Item) {
$_items = $item->getOrder()->getAllItems();
} else {
if ($item instanceof Mage_Sales_Model_Order_Invoice_Item) {
$_items = $item->getInvoice()->getAllItems();
} else {
if ($item instanceof Mage_Sales_Model_Order_Shipment_Item) {
$_items = $item->getShipment()->getAllItems();
} else {
if ($item instanceof Mage_Sales_Model_Order_Creditmemo_Item) {
$_items = $item->getCreditmemo()->getAllItems();
}
}
}
}
if ($_items) {
foreach ($_items as $_item) {
$parentItem = $_item->getParentItem();
if ($parentItem) {
$_itemsArray[$parentItem->getId()][$_item->getId()] = $_item;
} else {
$_itemsArray[$_item->getId()][$_item->getId()] = $_item;
}
}
}
if (isset($_itemsArray[$item->getId()])) {
return $_itemsArray[$item->getId()];
} else {
return null;
}
}
示例6: authorize
/**
* @param Mage_Sales_Model_Order_Payment $payment
* @param float $amount
* @return Bitpay_Core_Model_PaymentMethod
*/
public function authorize(Varien_Object $payment, $amount, $iframe = false)
{
if (false === isset($payment) || false === isset($amount) || true === empty($payment) || true === empty($amount)) {
$this->debugData('[ERROR] In Bitpay_Core_Model_Method_Bitcoin::authorize(): missing payment or amount parameters.');
throw new \Exception('In Bitpay_Core_Model_Method_Bitcoin::authorize(): missing payment or amount parameters.');
}
$amount = $payment->getOrder()->getQuote()->getGrandTotal();
$this->debugData('[INFO] Bitpay_Core_Model_Method_Bitcoin::authorize(): authorizing new order.');
// Create BitPay Invoice
$invoice = $this->initializeInvoice();
if (false === isset($invoice) || true === empty($invoice)) {
$this->debugData('[ERROR] In Bitpay_Core_Model_Method_Bitcoin::authorize(): could not initialize invoice.');
throw new \Exception('In Bitpay_Core_Model_Method_Bitcoin::authorize(): could not initialize invoice.');
}
$invoice = $this->prepareInvoice($invoice, $payment, $amount);
try {
$bitpayInvoice = \Mage::helper('bitpay')->getBitpayClient()->createInvoice($invoice);
} catch (\Exception $e) {
$this->debugData('[ERROR] In Bitpay_Core_Model_Method_Bitcoin::authorize(): ' . $e->getMessage());
\Mage::throwException('In Bitpay_Core_Model_Method_Bitcoin::authorize(): Could not authorize transaction.');
}
self::$_redirectUrl = Mage::getStoreConfig('payment/bitpay/fullscreen') ? $bitpayInvoice->getUrl() : $bitpayInvoice->getUrl() . '&view=iframe';
$this->debugData(array('[INFO] BitPay Invoice created', sprintf('Invoice URL: "%s"', $bitpayInvoice->getUrl())));
$quote = \Mage::getSingleton('checkout/session')->getQuote();
$order = \Mage::getModel('sales/order')->load($quote->getId(), 'quote_id');
// Save BitPay Invoice in database for reference
$mirrorInvoice = \Mage::getModel('bitpay/invoice')->prepareWithBitpayInvoice($bitpayInvoice)->prepareWithOrder(array('increment_id' => $order->getIncrementId(), 'quote_id' => $quote->getId()))->save();
$this->debugData('[INFO] Leaving Bitpay_Core_Model_Method_Bitcoin::authorize(): invoice id ' . $bitpayInvoice->getId());
return $this;
}
示例7: capture
public function capture(Varien_Object $payment, $amount)
{
$order = $payment->getOrder();
$billing = $order->getBillingAddress();
$shipping = $order->getShippingAddress();
$amount = round($order->getGrandTotal(), 2);
try {
$params = array("sellerId" => $this->getSid(), "merchantOrderId" => $order->getIncrementId(), "token" => Mage::app()->getRequest()->getParam('token'), "currency" => $order->getOrderCurrencyCode(), "total" => $amount, "billingAddr" => array("name" => $billing->getName(), "addrLine1" => $billing->getStreet(1), "addrLine2" => $billing->getStreet(2), "city" => $billing->getCity(), "state" => $billing->getRegion(), "zipCode" => $billing->getPostcode(), "country" => $billing->getCountry(), "email" => $order->getCustomerEmail(), "phoneNumber" => $billing->getTelephone()));
if ($shipping) {
$shippingAddr = array("name" => $shipping->getName(), "addrLine1" => $shipping->getStreet(1), "addrLine2" => $shipping->getStreet(2), "city" => $shipping->getCity(), "state" => $shipping->getRegion(), "zipCode" => $shipping->getPostcode(), "country" => $shipping->getCountry(), "email" => $order->getCustomerEmail(), "phoneNumber" => $billing->getTelephone());
array_merge($shippingAddr, $params);
}
$charge = Twocheckout_Charge::auth($params);
} catch (Twocheckout_Error $e) {
Mage::throwException(Mage::helper('paygate')->__($e->getMessage()));
}
if ($charge['response']['responseCode'] == 'APPROVED') {
$payment->setTransactionId($charge['response']['transactionId'])->setIsTransactionClosed(0);
$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true)->save();
$order->setData('ext_order_id', $charge['response']['transactionId']);
$order->save();
} else {
Mage::throwException(Mage::helper('paygate')->__('Payment capturing error: %s', "Could not Authorize Transaction"));
}
return $this;
}
示例8: _createCharge
/**
* @param Varien_Object $payment
* @param $amount
* @param array $extraConfig
* @return mixed
*/
protected function _createCharge(Varien_Object $payment, $amount, $extraConfig = array())
{
$config = array();
$scretKey = $this->getConfigData('privatekey');
$order = $payment->getOrder();
$billingAddress = $order->getBillingAddress();
$shippingAddress = $order->getBillingAddress();
$orderedItems = $order->getAllItems();
$currencyDesc = $order->getBaseCurrencyCode();
$orderId = $order->getIncrementId();
$Api = CheckoutApi_Api::getApi(array('mode' => $this->getConfigData('mode')));
$amountCents = $Api->valueToDecimal($amount, $currencyDesc);
$street = Mage::helper('customer/address')->convertStreetLines($billingAddress->getStreet(), 2);
$billingAddressConfig = array('addressLine1' => $street[0], 'addressLine2' => $street[1], 'postcode' => $billingAddress->getPostcode(), 'country' => $billingAddress->getCountry(), 'city' => $billingAddress->getCity(), 'phone' => array('number' => $billingAddress->getTelephone()));
$street = Mage::helper('customer/address')->convertStreetLines($shippingAddress->getStreet(), 2);
$shippingAddressConfig = array('addressLine1' => $street[0], 'addressLine2' => $street[1], 'postcode' => $shippingAddress->getPostcode(), 'country' => $shippingAddress->getCountry(), 'city' => $shippingAddress->getCity(), 'phone' => array('number' => $shippingAddress->getTelephone()), 'recipientName' => $shippingAddress->getFirstname() . ' ' . $shippingAddress->getLastname());
$products = array();
foreach ($orderedItems as $item) {
$product = Mage::getModel('catalog/product')->load($item->getProductId());
$products[] = array('name' => $item->getName(), 'sku' => $item->getSku(), 'price' => $item->getPrice(), 'quantity' => $item->getQtyOrdered(), 'image' => Mage::helper('catalog/image')->init($product, 'image')->__toString());
}
$config = array();
$config['authorization'] = $scretKey;
$config['mode'] = $this->getConfigData('mode');
$config['timeout'] = $this->getConfigData('timeout');
$config['postedParam'] = array('value' => $amountCents, 'currency' => $currencyDesc, 'shippingDetails' => $shippingAddressConfig, 'products' => $products, 'description' => "Order number::{$orderId}", 'metadata' => array("trackId" => $orderId), 'card' => array('billingDetails' => $billingAddressConfig));
$config['postedParam'] = array_merge($config['postedParam'], $extraConfig);
return $config;
}
示例9: order
public function order(Varien_Object $payment, $amount)
{
$order = $payment->getOrder();
//montaremos os dados a ser enviados via POST pra api em $params
$params = Mage::helper('ricardomartins_pagseguro/internal')->getCreditCardApiCallParams($order, $payment);
//chamamos a API
$xmlRetorno = $this->callApi($params, $payment);
$this->proccessNotificatonResult($xmlRetorno);
if (isset($xmlRetorno->errors)) {
$errMsg = array();
foreach ($xmlRetorno->errors as $error) {
$errMsg[] = (string) $error->message . '(' . $error->code . ')';
}
Mage::throwException('Um ou mais erros ocorreram no seu pagamento.' . PHP_EOL . implode(PHP_EOL, $errMsg));
}
if (isset($xmlRetorno->code)) {
$additional = array('transaction_id' => (string) $xmlRetorno->code);
if ($existing = $payment->getAdditionalInformation()) {
if (is_array($existing)) {
$additional = array_merge($additional, $existing);
}
}
$payment->setAdditionalInformation($additional);
}
return $this;
}
示例10: displayPrices
/**
* Get "double" prices html (block with base and place currency)
*
* @param Varien_Object $dataObject
* @param float $basePrice
* @param float $price
* @param bool $strong
* @param string $separator
* @return string
*/
public function displayPrices($dataObject, $basePrice, $price, $strong = false, $separator = '<br/>')
{
$order = false;
if ($dataObject instanceof Mage_Sales_Model_Order) {
$order = $dataObject;
} else {
$order = $dataObject->getOrder();
}
if ($order && $order->isCurrencyDifferent()) {
$res = '<strong>';
$res .= $order->formatBasePrice($basePrice);
$res .= '</strong>' . $separator;
$res .= '[' . $order->formatPrice($price) . ']';
} elseif ($order) {
$res = $order->formatPrice($price);
if ($strong) {
$res = '<strong>' . $res . '</strong>';
}
} else {
$res = Mage::app()->getStore()->formatPrice($price);
if ($strong) {
$res = '<strong>' . $res . '</strong>';
}
}
return $res;
}
示例11: validate
/**
* Validate Address Rule Condition
*
* @param Varien_Object $object
* @return bool
*/
public function validate(Varien_Object $object)
{
if ($this->getAttribute() == 'payment_method' && !$object->hasPaymentMethod()) {
if ($object->getOrder()) {
$object->setPaymentMethod($object->getOrder()->getPayment()->getMethod());
} else {
$object->setPaymentMethod($object->getPayment()->getMethod());
}
}
if ($object instanceof Mage_Sales_Model_Order_Shipment) {
$object = $object->getOrder();
}
#Zend_Debug::dump($object->getData());
#Zend_Debug::dump($this->validateAttribute($object->getData($this->getAttribute())), $object->getData($this->getAttribute()));
return $this->validateAttribute($object->getData($this->getAttribute()));
}
示例12: capture
/**
* Capture (confirm) an open transaction ('AUTHORIZED') at svea. We use the
* ConfirmTransaction class directly because the operation is simple.
*
* @param Varien_Object $payment
* @param float $amount
* @return $this|void
* @throws Mage_Payment_Exception
*/
public function capture(Varien_Object $payment, $amount)
{
$sveaOrderId = $payment->getParentTransactionId();
if (null === $sveaOrderId) {
// If there is no previous authorization
$sveaOrderId = $payment->getTransactionId();
}
$order = $payment->getOrder();
$paymentMethodConfig = $this->getSveaStoreConfClass($order->getStoreId());
$config = new SveaMageConfigProvider($paymentMethodConfig);
$countryId = $order->getBillingAddress()->getCountryId();
$confirmTransactionRequest = new Svea\HostedService\ConfirmTransaction($config);
$confirmTransactionRequest->countryCode = $countryId;
$confirmTransactionRequest->transactionId = $sveaOrderId;
$defaultCaptureDate = explode('T', date('c'));
// [0] contains date part
$confirmTransactionRequest->captureDate = $defaultCaptureDate[0];
$response = $confirmTransactionRequest->doRequest();
if ($response->accepted !== 1) {
$message = 'Capture failed for transaction ' . $sveaOrderId . ': ' . $response->errormessage . ' (' . $response->resultcode . ')';
throw new Mage_Payment_Exception($message);
}
$result = $this->_flatten($response);
$payment->setIsTransactionClosed(true)->setTransactionAdditionalInfo(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $result);
return $this;
}
示例13: importLegacyData
/**
* Try to create a card record from legacy data.
*/
public function importLegacyData(Varien_Object $payment)
{
// Customer ID -- pull from customer if possible, otherwise go to Authorize.Net.
if ($this->getCustomer()->getAuthnetcimProfileId() != '') {
$this->setProfileId($this->getCustomer()->getAuthnetcimProfileId());
} else {
$this->_createCustomerProfile();
}
// Payment ID -- pull from order if possible.
$this->setPaymentId($payment->getOrder()->getExtCustomerId());
if ($this->getProfileId() == '' || $this->getPaymentId() == '') {
Mage::helper('tokenbase')->log($this->getMethod(), 'Authorize.Net CIM: Unable to covert legacy data for processing. Please seek support.');
Mage::throwException(Mage::helper('tokenbase')->__('Authorize.Net CIM: Unable to covert legacy data for processing. Please seek support.'));
}
if ($payment->getCcType() != '') {
$this->setAdditional('cc_type', $payment->getCcType());
}
if ($payment->getCcLast4() != '') {
$this->setAdditional('cc_last4', $payment->getCcLast4());
}
if ($payment->getCcExpYear() > date('Y') || $payment->getCcExpYear() == date('Y') && $payment->getCcExpMonth() >= date('n')) {
$this->setAdditional('cc_exp_year', $payment->getCcExpYear())->setAdditional('cc_exp_month', $payment->getCcExpMonth())->setExpires(sprintf("%s-%s-%s 23:59:59", $payment->getCcExpYear(), $payment->getCcExpMonth(), date('t', strtotime($payment->getCcExpYear() . '-' . $payment->getCcExpMonth()))));
}
return $this;
}
示例14: capture
/**
* For Svea, Deliver order
*
* @param Varien_Object $payment
* @param float $amount
* @return type
*/
public function capture(Varien_Object $payment, $amount)
{
//Alternative: $sveaOrderId = $payment->getTransactionId(), comes with -capture
$sveaOrderId = $this->getInfoInstance()->getAdditionalInformation('svea_order_id');
if (empty($sveaOrderId)) {
if (!$this->getConfigData('autodeliver')) {
$errorTranslated = Mage::helper('svea_webpay')->responseCodes("", 'no_orderid');
Mage::throwException($errorTranslated);
}
$sveaOrderId = $this->getInfoInstance()->getAdditionalInformation('svea_order_id');
}
$order = $payment->getOrder();
$countryCode = $order->getBillingAddress()->getCountryId();
$paymentMethodConfig = $this->getSveaStoreConfClass($order->getStoreId());
$conf = new SveaMageConfigProvider($paymentMethodConfig);
$sveaObject = WebPay::deliverOrder($conf);
$response = $sveaObject->setCountryCode($countryCode)->setOrderId($sveaOrderId)->deliverPaymentPlanOrder()->doRequest();
if ($response->accepted == 1) {
$successMessage = Mage::helper('svea_webpay')->__('delivered');
$orderStatus = $this->getConfigData('paid_order_status') ?: $order->getStatus();
if (!empty($orderStatus)) {
$order->addStatusToHistory($orderStatus, $successMessage, false);
}
$rawDetails = $this->_sveaResponseToArray($response);
$payment->setTransactionId($response->contractNumber)->setIsTransactionClosed(false)->setTransactionAdditionalInfo(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $rawDetails);
} else {
$errorMessage = $response->errormessage;
$statusCode = $response->resultcode;
$errorTranslated = Mage::helper('svea_webpay')->responseCodes($statusCode, $errorMessage);
$order->addStatusToHistory($order->getStatus(), $errorTranslated, false);
Mage::throwException($errorTranslated);
}
}
示例15: _prepareData
/**
* @param null|Varien_Object $dataObject
* @return Xcom_Xfabric_Model_Message_Request
*/
public function _prepareData(Varien_Object $dataObject = null)
{
$avroDataObject = Mage::getModel('xcom_chronicle/message_order', array('order' => $dataObject->getOrder(), 'type' => 'regular'));
$data = array('cancelledOrders' => array($avroDataObject->toArray()));
$this->setMessageData($data);
return parent::_prepareData($dataObject);
}