/** * @param Mage_Sales_Model_Order $order * @param Mage_Customer_Model_Customer $customer * * @return bool|int|null */ protected function createCustomer($order, $customer) { $billing = $order->getBillingAddress(); if (Mage::app()->getStore()->isAdmin()) { $customer = Mage::getSingleton('adminhtml/session_quote')->getCustomer(); } else { $customer->setWebsiteId(Mage::app()->getWebsite()->getId()); $customer->loadByEmail($billing->getEmail()); } //TODO fix user being created again if validation fails if (!($userCode = $customer->getVindiUserCode())) { $userCode = 'mag-' . $customer->getId() . '-' . time(); $customer->setVindiUserCode($userCode); $customer->save(); } $address = ['street' => $billing->getStreet(1), 'number' => $billing->getStreet(2), 'additional_details' => $billing->getStreet(3), 'neighborhood' => $billing->getStreet(4), 'zipcode' => $billing->getPostcode(), 'city' => $billing->getCity(), 'state' => $billing->getRegionCode(), 'country' => $billing->getCountry()]; $customerVindi = ['name' => $billing->getFirstname() . ' ' . $billing->getLastname(), 'email' => $order->getBillingAddress()->getEmail(), 'registry_code' => $order->getData('customer_taxvat'), 'code' => $userCode, 'address' => $address]; if (Mage::getStoreConfig('vindi_subscription/general/send_nfe_information')) { switch ($this->getCustomerTipoPessoa($customer)) { case "Física": $customerVindi['metadata'] = ['carteira_de_identidade' => $customer->getIe()]; break; case "Jurídica": $customerVindi['metadata'] = ['inscricao_estadual' => $customer->getIe()]; break; } } $customerId = $this->api()->findOrCreateCustomer($customerVindi); if ($customerId === false) { Mage::throwException('Falha ao registrar o usuário. Verifique os dados e tente novamente!'); } return $customerId; }
protected function _createCustomer(Mage_Sales_Model_Order $order) { $addresses = array(); $primaryPhone = null; $company = null; if ($order->getBillingAddress()) { $addresses[] = Mage::helper('xcom_chronicle')->createAddress($order->getBillingAddress(), array(Xcom_Chronicle_Helper_Data::ADDRESS_TAG_BILLING)); $company = $order->getBillingAddress()->getCompany(); $primaryPhone = $order->getBillingAddress()->getTelephone(); } if ($order->getShippingAddress()) { $addresses[] = Mage::helper('xcom_chronicle')->createAddress($order->getShippingAddress(), array(Xcom_Chronicle_Helper_Data::ADDRESS_TAG_SHIPPING)); } $data = array('id' => Mage::helper('xcom_chronicle')->createEntityId('guest' . $order->getRealOrderId()), 'fullName' => $this->_createCustomerName($order), 'addresses' => $addresses, 'primaryPhone' => array('number' => $primaryPhone, 'type' => 'UNKNOWN'), 'email' => array('emailAddress' => $order->getCustomerEmail(), 'extension' => null), 'gender' => null, 'dateOfBirth' => null, 'company' => $company, 'dateCreated' => date('c', strtotime($order->getCreatedAt())), 'lastModified' => date('c', strtotime($order->getUpdatedAt())), 'sourceIds' => null, 'emailOptOut' => null, 'doNotCall' => null); return $data; }
/** * @return array */ protected function _prepareCustomerData() { $customer_id = null; $customer = null; $customer_log = null; $billing_address = $this->_order->getBillingAddress(); $customer_verified = false; $customer_orders_count = 0; $gender = $this->_order->getCustomerGender(); if (!$this->_order->getCustomerIsGuest()) { $customer_id = $this->_order->getCustomerId(); if ($customer_id) { /** @var Mage_Customer_Model_Customer $customer */ $customer = Mage::getModel("customer/customer"); $customer->load($customer_id); /** @var Mage_Log_Model_Customer $customer_log */ $customer_log = Mage::getModel('log/customer')->load($customer_id); } $customer_verified = $this->getCustomerIsConfirmedStatus($customer); $orders = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('customer_id', $customer_id); /** @noinspection PhpUndefinedMethodInspection */ $customer_orders_count = $orders->count(); } $data = array_filter(array('customer_id' => $customer_id, 'customer_is_guest' => $this->_order->getCustomerIsGuest(), 'verified' => $customer_verified, 'language_code' => $this->_language_code, 'last_login_on' => $customer_log ? $customer_log->getLoginAt() : null, 'created_on' => $customer ? $customer->getData('created_at') : null, 'updated_on' => $customer ? $customer->getData('updated_at') : null, 'birthdate' => $this->_order->getCustomerDob(), 'email' => $this->_order->getCustomerEmail(), 'title' => '', 'prefix' => $this->_order->getCustomerPrefix(), 'suffix' => $this->_order->getCustomerSuffix(), 'first_name' => $this->_order->getCustomerFirstname(), 'middle_name' => $this->_order->getCustomerMiddlename(), 'last_name' => $this->_order->getCustomerLastname(), 'company_name' => $billing_address ? $billing_address->getCompany() : null, 'gender' => $gender == 1 ? 'male' : ($gender == 2 ? 'female' : null), 'telephone1' => $billing_address ? $billing_address->getTelephone() : null, 'telephone2' => '', 'telephone3' => '', 'fax' => $billing_address ? $billing_address->getFax() : null, 'vat_number' => $this->_order->getCustomerTaxvat(), 'reg_ip_address' => '', 'customer_orders_count' => $customer_orders_count)); return $data; }
public function prepareValues(Mage_Sales_Model_Order $order) { $billing_address = $order->getBillingAddress(); $additional_data = unserialize($order->getPayment()->getAdditionalData()); $code_banco = $additional_data['code_banco']; $data_vencimento = $additional_data['data_vencimento']; $numero_boleto = str_replace('-', '', $order->getIncrementId()); $strtotime = strtotime($order->getCreatedAt()); $data = array('logoempresa' => $this->getConfig('logoempresa'), 'nosso_numero' => $numero_boleto, 'numero_documento' => $numero_boleto, 'data_vencimento' => $data_vencimento, 'data_documento' => date('d/m/Y', $strtotime), 'data_processamento' => date('d/m/Y', $strtotime), 'valor_boleto' => number_format($order->getGrandTotal() + $this->getLayoutConfig($code_banco, 'valor_adicional'), 2, ',', ''), 'valor_unitario' => number_format($order->getGrandTotal() + $this->getLayoutConfig($code_banco, 'valor_adicional'), 2, ',', ''), 'sacado' => $billing_address->getFirstname() . ' ' . $billing_address->getLastname(), 'sacadocpf' => $order->getCustomerTaxvat(), 'endereco1' => implode(' ', $billing_address->getStreet()), 'endereco2' => $billing_address->getCity() . ' - ' . $billing_address->getRegion() . ' - CEP: ' . $billing_address->getPostcode(), 'identificacao' => $this->getLayoutConfig($code_banco, 'identificacao'), 'cpf_cnpj' => $this->getLayoutConfig($code_banco, 'cpf_cnpj'), 'endereco' => $this->getLayoutConfig($code_banco, 'endereco'), 'cidade_uf' => $this->getLayoutConfig($code_banco, 'cidade_uf'), 'cedente' => $this->getLayoutConfig($code_banco, 'cedente'), 'agencia' => $this->getLayoutConfig($code_banco, 'agencia'), 'agencia_dv' => $this->getLayoutConfig($code_banco, 'agencia_dv'), 'conta' => $this->getLayoutConfig($code_banco, 'conta'), 'conta_dv' => $this->getLayoutConfig($code_banco, 'conta_dv'), 'carteira' => $this->getLayoutConfig($code_banco, 'carteira'), 'especie' => $this->getLayoutConfig($code_banco, 'especie'), 'especie_doc' => $this->getLayoutConfig($code_banco, 'especie_doc'), 'aceite' => $this->getLayoutConfig($code_banco, 'aceite'), 'quantidade' => $this->getLayoutConfig($code_banco, 'quantidade')); if ($code_banco == 'santander_banespa') { $data['ponto_venda'] = $this->getLayoutConfig($code_banco, 'ponto_venda'); $data['carteira_descricao'] = $this->getLayoutConfig($code_banco, 'carteira_descricao'); $data['codigo_cliente'] = $this->getLayoutConfig($code_banco, 'codigo_cliente'); } if ($code_banco == 'bradesco') { $data['conta_cedente'] = $this->getLayoutConfig($code_banco, 'conta_cedente'); $data['conta_cedente_dv'] = $this->getLayoutConfig($code_banco, 'conta_cedente_dv'); } if ($code_banco == 'cef' || $code_banco == 'cef_sinco' || $code_banco == 'cef_sigcb') { $data['conta_cedente_caixa'] = $this->getLayoutConfig($code_banco, 'conta_cedente_caixa'); $data['conta_cedente_dv_caixa'] = $this->getLayoutConfig($code_banco, 'conta_cedente_dv_caixa'); $data['inicio_nosso_numero'] = $this->getLayoutConfig($code_banco, 'inicio_nosso_numero'); } if ($code_banco == 'bb') { $data['convenio'] = $this->getLayoutConfig($code_banco, 'convenio'); $data['contrato'] = $this->getLayoutConfig($code_banco, 'contrato'); $data['variacao_carteira'] = $this->getLayoutConfig($code_banco, 'variacao_carteira'); $data['formatacao_convenio'] = $this->getLayoutConfig($code_banco, 'formatacao_convenio'); $data['formatacao_nosso_numero'] = $this->getLayoutConfig($code_banco, 'formatacao_nosso_numero'); } if ($code_banco == 'hsbc') { $data['codigo_cedente'] = $this->getLayoutConfig($code_banco, 'codigo_cedente'); } if ($code_banco == 'cef_sinco') { $data['campo_fixo_obrigatorio'] = $this->getLayoutConfig($code_banco, 'campo_fixo_obrigatorio'); } if ($code_banco == 'cef_sigcb') { $data['nosso_numero1'] = $this->getLayoutConfig($code_banco, 'nosso_numero1'); $data['nosso_numero_const1'] = $this->getLayoutConfig($code_banco, 'nosso_numero_const1'); $data['nosso_numero2'] = $this->getLayoutConfig($code_banco, 'nosso_numero2'); $data['nosso_numero_const2'] = $this->getLayoutConfig($code_banco, 'nosso_numero_const2'); $data['nosso_numero3'] = $numero_boleto; } if ($code_banco == 'sicoob') { $data['convenio'] = $this->getLayoutConfig($code_banco, 'codigo_cedente'); $data["numero_parcela"] = '001'; } $instrucoes = explode("\n", $this->getLayoutConfig($code_banco, 'instrucoes_boleto')); for ($i = 0; $i < 4; $i++) { $instrucao = isset($instrucoes[$i]) ? $instrucoes[$i] : ''; $data['instrucoes' . ($i + 1)] = $instrucao; } $info = sprintf($this->getLayoutConfig($code_banco, 'informacoes'), $order->getIncrementId()); $informacoes = explode("\n", $info); for ($i = 0; $i < 3; $i++) { $informacao = isset($informacoes[$i]) ? $informacoes[$i] : ''; $data['demonstrativo' . ($i + 1)] = $informacao; } return $data; }
/** * Returns the current customers email adress. * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order $object * @return string the customers email adress */ public function getCustomerEmail($object) { $email = $object->getCustomerEmail(); if (empty($email)) { $email = $object->getBillingAddress()->getEmail(); } return $email; }
public function redirectAction() { // Retrieve order $order = new Mage_Sales_Model_Order(); $ccavenue['order_id'] = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order->loadByIncrementId($ccavenue['order_id']); // Get CCAvenue Parameters $ccavenue['action'] = Mage::getStoreConfig('payment/ccavenue/submit_url'); $ccavenue['merchant_id'] = Mage::getStoreConfig('payment/ccavenue/merchant_id'); $ccavenue['amount'] = round($order->base_grand_total, 2); $ccavenue['redirect_url'] = Mage::getBaseUrl() . 'ccavenue/payment/response'; $ccavenue['working_key'] = Mage::getStoreConfig('payment/ccavenue/working_key'); $ccavenue['checksum'] = $this->getCheckSum($ccavenue['merchant_id'], $ccavenue['amount'], $ccavenue['order_id'], $ccavenue['redirect_url'], $ccavenue['working_key']); // Retrieve order details $billingAddress = $order->getBillingAddress(); $billingData = $billingAddress->getData(); $shippingAddress = $order->getShippingAddress(); if ($shippingAddress) { $shippingData = $shippingAddress->getData(); } $ccavenue['billing_cust_name'] = $billingData['firstname'] . ' ' . $billingData['lastname']; $ccavenue['billing_cust_address'] = $billingAddress->street; $ccavenue['billing_cust_state'] = $billingAddress->region; $ccavenue['billing_cust_country'] = Mage::getModel('directory/country')->load($billingAddress->country_id)->getName(); $ccavenue['billing_cust_tel'] = $billingAddress->telephone; $ccavenue['billing_cust_email'] = $order->customer_email; if ($shippingAddress) { $ccavenue['delivery_cust_name'] = $shippingData['firstname'] . ' ' . $shippingData['lastname']; $ccavenue['delivery_cust_address'] = $shippingAddress->street; $ccavenue['delivery_cust_state'] = $shippingAddress->region; $ccavenue['delivery_cust_country'] = Mage::getModel('directory/country')->load($shippingAddress->country_id)->getName(); $ccavenue['delivery_cust_tel'] = $shippingAddress->telephone; $ccavenue['delivery_city'] = $shippingAddress->city; $ccavenue['delivery_zip'] = $shippingAddress->postcode; } else { $ccavenue['delivery_cust_name'] = ''; $ccavenue['delivery_cust_address'] = ''; $ccavenue['delivery_cust_state'] = ''; $ccavenue['delivery_cust_country'] = ''; $ccavenue['delivery_cust_tel'] = ''; $ccavenue['delivery_city'] = ''; $ccavenue['delivery_zip'] = ''; } $ccavenue['merchant_param'] = ''; $ccavenue['billing_city'] = $billingAddress->city; $ccavenue['billing_zip'] = $billingAddress->postcode; $ccavenue['billing_cust_notes'] = ''; // Insert into CCAvenue Response Log Table $now = Mage::getModel('core/date')->timestamp(time()); Mage::getModel('ccavenue/ccavenueredirect')->setMerchantId($ccavenue['merchant_id'])->setAmount($ccavenue['amount'])->setOrderId($ccavenue['order_id'])->setRedirectUrl($ccavenue['redirect_url'])->setChecksum($ccavenue['checksum'])->setBillingCustName(addslashes($ccavenue['billing_cust_name']))->setBillingCustAddress(addslashes($ccavenue['billing_cust_address']))->setBillingCustCountry(addslashes($ccavenue['billing_cust_country']))->setBillingCustState(addslashes($ccavenue['billing_cust_state']))->setBillingZip($ccavenue['billing_zip'])->setBillingCustTel($ccavenue['billing_cust_tel'])->setBillingCustEmail($ccavenue['billing_cust_email'])->setDeliveryCustName(addslashes($ccavenue['delivery_cust_name']))->setDeliveryCustAddress(addslashes($ccavenue['delivery_cust_address']))->setDeliveryCustCountry(addslashes($ccavenue['delivery_cust_country']))->setDeliveryCustState(addslashes($ccavenue['delivery_cust_state']))->setDeliveryCustTel($ccavenue['delivery_cust_tel'])->setBillingCustNotes($ccavenue['billing_cust_notes'])->setMerchantParam($ccavenue['merchant_param'])->setBillingCustCity(addslashes($ccavenue['billing_city']))->setBillingZipCode($ccavenue['billing_zip'])->setDeliveryCustCity(addslashes($ccavenue['delivery_city']))->setDeliveryZipCode($ccavenue['delivery_zip'])->setCcavenueRedirectIp($this->get_uer_ip())->setCcavenueRedirectDtime(date('Y-m-d H:i:s', $now))->save(); // Add data to registry so it's accessible in the view file Mage::register('ccavenue', $ccavenue); // Render layout $this->loadLayout(); $block = $this->getLayout()->createBlock('Mage_Core_Block_Template', 'ccavenue', array('template' => 'ccavenue/redirect.phtml')); $this->getLayout()->getBlock('content')->append($block); $this->renderLayout(); }
/** * Sends notification mail for selected shipping rate * * The code for this functionality is based on Mage_Sales_Model_Order::sendNewOrderEmail() * * @param Mage_Sales_Model_Order $order * @return boolean * @throws Exception * @see Mage_Sales_Model_Order */ public function sendEmailNotification($order) { if (strncmp($order->getShippingMethod(), 'shippingrates_', 14) != 0) { return false; } $notificationMail = $order->getShippingCarrier()->getNotificationMail($order->getShippingMethod()); if (!strlen(trim($notificationMail))) { return false; } $storeId = $order->getStore()->getId(); // Start store emulation process $appEmulation = Mage::getSingleton('core/app_emulation'); $initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeId); try { // Retrieve specified view block from appropriate design package (depends on emulated store) $paymentBlock = Mage::helper('payment')->getInfoBlock($order->getPayment())->setIsSecureMode(true); $paymentBlock->getMethod()->setStore($storeId); $paymentBlockHtml = $paymentBlock->toHtml(); } catch (Exception $exception) { // Stop store emulation process $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo); throw $exception; } // Stop store emulation process $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo); // Retrieve corresponding email template id and customer name if ($order->getCustomerIsGuest()) { $templateId = Mage::getStoreConfig(Mage_Sales_Model_Order::XML_PATH_EMAIL_GUEST_TEMPLATE, $storeId); $customerName = $order->getBillingAddress()->getName(); } else { $templateId = Mage::getStoreConfig(Mage_Sales_Model_Order::XML_PATH_EMAIL_TEMPLATE, $storeId); $customerName = $order->getCustomerName(); } $mailer = Mage::getModel('core/email_template_mailer'); $emailInfo = Mage::getModel('core/email_info'); $emailInfo->addTo($notificationMail); $mailer->addEmailInfo($emailInfo); // Set all required params and send emails $mailer->setSender(Mage::getStoreConfig(Mage_Sales_Model_Order::XML_PATH_EMAIL_IDENTITY, $storeId)); $mailer->setStoreId($storeId); $mailer->setTemplateId($templateId); $mailer->setTemplateParams(array('order' => $order, 'billing' => $order->getBillingAddress(), 'payment_html' => $paymentBlockHtml)); $mailer->send(); return true; }
/** * Detect an order as a test order when the second street line * address of the order billing address matches the constant * IOrderCreateRequest::TEST_TYPE_AUTOCANCEL. Flag the OCR * payload as a test order. * * @return self */ protected function handleTestOrder() { /** @var Mage_Customer_Model_Address_Abstract */ $billingAddress = $this->_order->getBillingAddress(); if ($this->isTestOrder($billingAddress)) { $this->_payload->setTestType(IOrderCreateRequest::TEST_TYPE_AUTOCANCEL); } return $this; }
/** * Fill in the values the order create request requires. * * @return self */ protected function _buildNewPayload() { $this->_payload->setBillingAddress($this->_getRomBillingAddress($this->_order->getBillingAddress()))->setCurrency($this->_order->getOrderCurrencyCode())->setLevelOfService($this->_config->levelOfService)->setLocale($this->_getLocale())->setOrderHistoryUrl($this->_helper->getOrderHistoryUrl($this->_order))->setOrderId($this->_order->getIncrementId())->setOrderTotal($this->_order->getBaseGrandTotal())->setOrderType($this->_config->orderType)->setRequestId($this->_coreHelper->generateRequestId('OCR-')); $createdAt = $this->_getAsDateTime($this->_order->getCreatedAt()); if ($createdAt) { $this->_payload->setCreateTime($createdAt); } return $this->_setCustomerData($this->_order, $this->_payload)->_setOrderContext($this->_order, $this->_payload)->_setShipGroups($this->_order, $this->_payload)->_setPaymentData($this->_order, $this->_payload); }
/** * Saves billing section to order * @param Mage_Sales_Model_Order $Order * @return */ public function preset(Mage_Sales_Model_Order $order, $data) { $ba = $order->getBillingAddress(); foreach ($data as $k => $v) { $ba->setData($k, $v); } $ba->implodeStreetAddress(); $ba->save(); return $order; }
/** * (re)Render all items and totals */ protected function _render() { if (!$this->_shouldRender) { return; } // regular items from the sales entity $this->_items = array(); foreach ($this->_salesEntity->getAllItems() as $item) { if (!$item->getParentItem()) { $this->_addRegularItem($item); } } end($this->_items); $lastRegularItemKey = key($this->_items); // regular totals $shippingDescription = ''; if ($this->_salesEntity instanceof Mage_Sales_Model_Order) { $shippingDescription = $this->_salesEntity->getShippingDescription(); $this->_totals = array(self::TOTAL_SUBTOTAL => $this->_salesEntity->getBaseSubtotal(), self::TOTAL_TAX => $this->_salesEntity->getBaseTaxAmount(), self::TOTAL_SHIPPING => $this->_salesEntity->getBaseShippingAmount(), self::TOTAL_DISCOUNT => abs($this->_salesEntity->getBaseDiscountAmount())); $this->_applyHiddenTaxWorkaround($this->_salesEntity); } else { $address = $this->_salesEntity->getIsVirtual() ? $this->_salesEntity->getBillingAddress() : $this->_salesEntity->getShippingAddress(); $shippingDescription = $address->getShippingDescription(); $this->_totals = array(self::TOTAL_SUBTOTAL => $this->_salesEntity->getBaseSubtotal(), self::TOTAL_TAX => $address->getBaseTaxAmount(), self::TOTAL_SHIPPING => $address->getBaseShippingAmount(), self::TOTAL_DISCOUNT => abs($address->getBaseDiscountAmount())); $this->_applyHiddenTaxWorkaround($address); } $originalDiscount = $this->_totals[self::TOTAL_DISCOUNT]; // arbitrary items, total modifications Mage::dispatchEvent('paypal_prepare_line_items', array('paypal_cart' => $this)); // distinguish original discount among the others if ($originalDiscount > 0.0001 && isset($this->_totalLineItemDescriptions[self::TOTAL_DISCOUNT])) { $this->_totalLineItemDescriptions[self::TOTAL_DISCOUNT][] = Mage::helper('sales')->__('Discount (%s)', Mage::app()->getStore()->convertPrice($originalDiscount, true, false)); } // discount, shipping as items if ($this->_isDiscountAsItem && $this->_totals[self::TOTAL_DISCOUNT]) { $this->addItem(Mage::helper('paypal')->__('Discount'), 1, -1.0 * $this->_totals[self::TOTAL_DISCOUNT], $this->_renderTotalLineItemDescriptions(self::TOTAL_DISCOUNT)); } $shippingItemId = $this->_renderTotalLineItemDescriptions(self::TOTAL_SHIPPING, $shippingDescription); if ($this->_isShippingAsItem && (double) $this->_totals[self::TOTAL_SHIPPING]) { $this->addItem(Mage::helper('paypal')->__('Shipping'), 1, (double) $this->_totals[self::TOTAL_SHIPPING], $shippingItemId); } // compound non-regular items into subtotal foreach ($this->_items as $key => $item) { if ($key > $lastRegularItemKey && $item->getAmount() != 0) { $this->_totals[self::TOTAL_SUBTOTAL] += $item->getAmount(); } } $this->_validate(); // if cart items are invalid, prepare cart for transfer without line items if (!$this->_areItemsValid) { $this->removeItem($shippingItemId); } $this->_shouldRender = false; }
public function redirectAction() { // Retrieve order $order = new Mage_Sales_Model_Order(); $customcard['order_id'] = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order->loadByIncrementId($customcard['order_id']); // Get Custom card method Parameters $customcard['action'] = Mage::getStoreConfig('payment/paymentmodulepackbankin_checkout/submit_url'); $customcard['merchant_id'] = Mage::getStoreConfig('payment/paymentmodulepackbankin_checkout/merchant_id'); $customcard['amount'] = round($order->base_grand_total, 2); $customcard['redirect_url'] = Mage::getBaseUrl() . 'paymentmodulepackbankin_checkout/payment/response'; // Retrieve order details $billingAddress = $order->getBillingAddress(); $billingData = $billingAddress->getData(); $shippingAddress = $order->getShippingAddress(); if ($shippingAddress) { $shippingData = $shippingAddress->getData(); } $customcard['billing_cust_name'] = $billingData['firstname'] . ' ' . $billingData['lastname']; $customcard['billing_cust_address'] = $billingAddress->street; $customcard['billing_cust_state'] = $billingAddress->region; $customcard['billing_cust_country'] = Mage::getModel('directory/country')->load($billingAddress->country_id)->getName(); $customcard['billing_cust_tel'] = $billingAddress->telephone; $customcard['billing_cust_email'] = $order->customer_email; if ($shippingAddress) { $customcard['delivery_cust_name'] = $shippingData['firstname'] . ' ' . $shippingData['lastname']; $customcard['delivery_cust_address'] = $shippingAddress->street; $customcard['delivery_cust_state'] = $shippingAddress->region; $customcard['delivery_cust_country'] = Mage::getModel('directory/country')->load($shippingAddress->country_id)->getName(); $customcard['delivery_cust_tel'] = $shippingAddress->telephone; $customcard['delivery_city'] = $shippingAddress->city; $customcard['delivery_zip'] = $shippingAddress->postcode; } else { $customcard['delivery_cust_name'] = ''; $customcard['delivery_cust_address'] = ''; $customcard['delivery_cust_state'] = ''; $customcard['delivery_cust_country'] = ''; $customcard['delivery_cust_tel'] = ''; $customcard['delivery_city'] = ''; $customcard['delivery_zip'] = ''; } $customcard['merchant_param'] = ''; $customcard['billing_city'] = $billingAddress->city; $customcard['billing_zip'] = $billingAddress->postcode; $customcard['billing_cust_notes'] = ''; // Add data to registry so it's accessible in the view file Mage::register('customcard', $customcard); // Render layout $this->loadLayout(); $block = $this->getLayout()->createBlock('Mage_Core_Block_Template', 'customcard', array('template' => 'paymentmodulepackbankin/redirect.phtml')); $this->getLayout()->getBlock('content')->append($block); $this->renderLayout(); }
/** * Encodes a single Magento Order. * * @param Mage_Sales_Model_Order $order * * @return RTDOrder */ protected function _encodeOrder(Mage_Sales_Model_Order $order) { $encodedOrder = new RTDOrder(); $customMapping = Mage::getConfig()->getNode('rtd_mappings/order'); foreach ($customMapping->asArray() as $magentoKey => $rtdKey) { $encodedOrder->setParam($rtdKey, $order->{'get' . $magentoKey}()); } $this->_encodeShippingAddress($encodedOrder, $order->getShippingAddress()); $this->_encodeBillingAddress($encodedOrder, $order->getBillingAddress()); $this->_encodeOrderLines($encodedOrder, $order); $this->_encodeShipment($encodedOrder, $order); return $encodedOrder; }
/** * @param Mage_Sales_Model_Order $order * @return int */ protected function _createCustomer(Mage_Sales_Model_Order $order) { /** @var $customer Mage_Customer_Model_Customer */ $customer = Mage::getModel('customer/customer')->setWebsiteId($order->getStore()->getWebsiteId())->loadByEmail($order->getCustomerEmail()); $customerGroupId = 1; // @todo load general customer group ID? if (!$customer->getId()) { $customer->addData(array('prefix' => $order->getCustomerPrefix(), 'firstname' => $order->getCustomerFirstname(), 'middlename' => $order->getCustomerMiddlename(), 'lastname' => $order->getCustomerLastname(), 'suffix' => $order->getCustomerSuffix(), 'email' => $order->getCustomerEmail(), 'group_id' => $customerGroupId, 'taxvat' => $order->getCustomerTaxvat(), 'website_id' => $order->getStore()->getWebsiteId(), 'default_billing' => '_item1', 'default_shipping' => '_item2')); // Billing Address /** @var $billingAddress Mage_Sales_Model_Order_Address */ $billingAddress = $order->getBillingAddress(); /** @var $customerBillingAddress Mage_Customer_Model_Address */ $customerBillingAddress = Mage::getModel('customer/address'); $billingAddressArray = $billingAddress->toArray(); unset($billingAddressArray['entity_id']); unset($billingAddressArray['parent_id']); unset($billingAddressArray['customer_id']); unset($billingAddressArray['customer_address_id']); unset($billingAddressArray['quote_address_id']); $customerBillingAddress->addData($billingAddressArray); $customerBillingAddress->setPostIndex('_item1'); $customer->addAddress($customerBillingAddress); // Shipping Address /** @var $shippingAddress Mage_Sales_Model_Order_Address */ $shippingAddress = $order->getShippingAddress(); /** @var $customerShippingAddress Mage_Customer_Model_Address */ $customerShippingAddress = Mage::getModel('customer/address'); $shippingAddressArray = $shippingAddress->toArray(); unset($shippingAddressArray['entity_id']); unset($shippingAddressArray['parent_id']); unset($shippingAddressArray['customer_id']); unset($shippingAddressArray['customer_address_id']); unset($shippingAddressArray['quote_address_id']); $customerShippingAddress->addData($shippingAddressArray); $customerShippingAddress->setPostIndex('_item2'); $customer->addAddress($customerShippingAddress); // Save the customer $customer->setPassword($customer->generatePassword()); $customer->save(); } // Link customer to order $order->setCustomerId($customer->getId()); $order->setCustomerIsGuest(0); $order->setCustomerGroupId($customerGroupId); $order->save(); return $customer->getId(); }
/** * Generate and return the Wirecard billing Object * * @param bool $specificPaymentType * @return WirecardCEE_Client_QPay_Request_Initiation_ConsumerData_Address */ protected function _getBillingObject($specificPaymentType = false) { $billing = $this->_order->getBillingAddress(); $billingAddressObj = new WirecardCEE_Client_QPay_Request_Initiation_ConsumerData_Address(WirecardCEE_Client_QPay_Request_Initiation_ConsumerData_Address::TYPE_BILLING); $billingAddressObj->setFirstname($billing->getFirstname()); $billingAddressObj->setLastname($billing->getLastname()); $billingAddressObj->setAddress1($billing->getStreet1()); $billingAddressObj->setCity($billing->getCity()); $billingAddressObj->setCountry($billing->getCountry()); $billingAddressObj->setZipCode($billing->getPostcode()); if ($specificPaymentType != 'invoice' && $specificPaymentType != 'installment') { $billingAddressObj->setAddress2($billing->getStreet2()); $billingAddressObj->setState($billing->getRegionCode()); $billingAddressObj->setFax($billing->getFax()); $billingAddressObj->setPhone($billing->getTelephone()); } return $billingAddressObj; }
/** * @param Mage_Sales_Model_Order $order * @return boolean $isDifferent */ protected function _addressesesAreDifferent($order) { $isDifferent = 0; if ($order->getIsVirtual()) { return $isDifferent; } $billingAddress = $order->getBillingAddress(); $shippingAddress = $order->getShippingAddress(); $methods = array('getStreetFull', 'getCity', 'getCountryId', 'getPostcode', 'getRegionId'); foreach ($methods as $method_name) { $billingValue = call_user_func(array($billingAddress, $method_name)); $shippingValue = call_user_func(array($shippingAddress, $method_name)); if ($billingValue != $shippingValue) { $isDifferent = 1; break; } } return $isDifferent; }
/** * Add the items from the given order to the Order Sync queue. Does nothing if * Order Sync is disabled for the store that the order was placed in. * * @param Mage_Sales_Model_Order $order * @param bool $force Skip enabled check * * @return $this */ public function addOrderToQueue(Mage_Sales_Model_Order $order, $force = false) { if (!$this->isEnabled($order->getStoreId()) && !$force) { return $this; } $items = array(); $order_date = Mage::helper("klevu_search/compat")->now(); $session_id = session_id(); $ip_address = Mage::helper("klevu_search")->getIp(); $order_email = 'unknown'; if ($order->getCustomerId()) { $order_email = $order->getCustomer()->getEmail(); //logged in customer } else { $order_email = $order->getBillingAddress()->getEmail(); //not logged in customer } foreach ($order->getAllVisibleItems() as $item) { /** @var Mage_Sales_Model_Order_Item $item */ // For configurable products add children items only, for all other products add parents if ($item->getProductType() == Mage_Catalog_Model_Product_Type_Configurable::TYPE_CODE) { foreach ($item->getChildrenItems() as $child) { if ($child->getId() != null) { $items[] = array($child->getId(), $session_id, $ip_address, $order_date, $order_email); } } } else { if ($item->getId() != null) { $items[] = array($item->getId(), $session_id, $ip_address, $order_date, $order_email); } } } // in case of multiple addresses used for shipping // its possible that items object here is empty // if so, we do not add to the item. if (!empty($items)) { $this->addItemsToQueue($items); } return $this; }
/** * Build up the customers data onto an object * * @param Mage_Sales_Model_Order $order * * @return array */ private function buildCustomer(Mage_Sales_Model_Order $order, $includeId = true) { $customer = array('firstName' => $order->getCustomerFirstname(), 'lastName' => $order->getCustomerLastname(), 'email' => $order->getCustomerEmail(), 'phone' => $order->getBillingAddress()->getTelephone()); // Shall we include the customer ID? if ($includeId) { $customer['id'] = $this->getBraintreeId(); } // Handle empty data with alternatives if (empty($customer['firstName'])) { $customer['firstName'] = $order->getBillingAddress()->getFirstname(); } if (empty($customer['lastName'])) { $customer['lastName'] = $order->getBillingAddress()->getLastname(); } if (empty($customer['email'])) { $customer['email'] = $order->getBillingAddress()->getEmail(); } return $customer; }
/** * This adds the buyer information to the invoice. * * @param Bitpay\Invoice $invoice * @param Mage_Sales_Model_Order $order * @return Bitpay\Invoice */ private function addBuyerInfo($invoice, $order) { if (false === isset($invoice) || true === empty($invoice) || false === isset($order) || true === empty($order)) { $this->debugData('[ERROR] In Bitpay_Core_Model_Method_Bitcoin::addBuyerInfo(): missing or invalid invoice or order parameter.'); throw new \Exception('In Bitpay_Core_Model_Method_Bitcoin::addBuyerInfo(): missing or invalid invoice or order parameter.'); } else { $this->debugData('[INFO] In Bitpay_Core_Model_Method_Bitcoin::addBuyerInfo(): function called with good invoice and order parameters.'); } $buyer = new Bitpay\Buyer(); if (false === isset($buyer) || true === empty($buyer)) { $this->debugData('[ERROR] In Bitpay_Core_Model_Method_Bitcoin::addBuyerInfo(): could not construct new BitPay buyer object.'); throw new \Exception('In Bitpay_Core_Model_Method_Bitcoin::addBuyerInfo(): could not construct new BitPay buyer object.'); } $buyer->setFirstName($order->getCustomerFirstname()); $buyer->setLastName($order->getCustomerLastname()); if (Mage::getStoreConfig('payment/bitpay/fullscreen')) { $address = $order->getBillingAddress(); } else { $quote = Mage::getSingleton('checkout/session')->getQuote(); $address = $quote->getBillingAddress(); } $street = $address->getStreet1(); if (null !== $street && '' !== $street) { $buyer->setAddress(array($street, $address->getStreet2(), $address->getStreet3(), $address->getStreet4())); } $region = $address->getRegion(); $regioncode = $address->getRegionCode(); if (null !== $regioncode && '' !== $regioncode) { $buyer->setState($regioncode); } else { if (null !== $region && '' !== $region) { $buyer->setState($region); } } $country = $address->getCountry(); if (null !== $country && '' !== $country) { $buyer->setCountry($country); } $city = $address->getCity(); if (null !== $city && '' !== $city) { $buyer->setCity($city); } $postcode = $address->getPostcode(); if (null !== $postcode && '' !== $postcode) { $buyer->setZip($postcode); } $email = $address->getEmail(); if (null !== $email && '' !== $email) { $buyer->setEmail($email); } $telephone = $address->getTelephone(); if (null !== $telephone && '' !== $telephone) { $buyer->setPhone($telephone); } $invoice->setBuyer($buyer); return $invoice; }
protected function _initBillingAddressFromOrder(Mage_Sales_Model_Order $order) { $this->getQuote()->getBillingAddress()->setCustomerAddressId(''); Mage::helper('core')->copyFieldset('sales_copy_order_billing_address', 'to_order', $order->getBillingAddress(), $this->getQuote()->getBillingAddress()); }
/** * Writes the row(s) for the given order in the csv file. * A row is added to the csv file for each ordered item. * * @param Mage_Sales_Model_Order $order The order to write csv of * @param $fp The file handle of the csv file */ protected function writeOrder($order, $fp) { $customerDetails = $order->getBillingAddress(); $orderdate = substr_replace($order->getData('created_at'), '', -8); $orderId = $order->getData('increment_id'); $customerFirstName = $customerDetails->getFirstname(); $customerLastName = $customerDetails->getLastname(); $fullName = $customerFirstName . ' ' . $customerLastName; $grandTotal = $order->getData('subtotal'); $taxAmount = $order->getData('tax_amount'); $paymentMethod = $this->getPaymentMethod($order); $taxcode = $this->setTaxCode($customerDetails->getCountry(), $order); $refundedAmount = $order->getData('total_refunded'); $refundedTaxAmount = $order->getData('tax_refunded'); $accountCodeSales = Mage::getStoreConfig('order_export/sage/sage_sales_account'); $nominalCodeSales = Mage::getStoreConfig('order_export/sage/sage_sales_nominal'); $nominalCodeShip = Mage::getStoreConfig('order_export/sage/sage_ship_nominal'); $accountCodePayments = Mage::getStoreConfig('order_export/sage/sage_pay_account'); $nominalCodePayments = Mage::getStoreConfig('order_export/sage/sage_pay_nominal'); $csvData = array('SI', $accountCodeSales, $nominalCodeSales, '0', $orderdate, $orderId, $fullName, $grandTotal, $taxcode, $taxAmount, '1', $paymentMethod, 'import'); fputcsv($fp, $csvData, self::DELIMITER, self::ENCLOSURE); if ($order->getShippingAmount() != NULL && $order->getShippingAmount() != 0) { $shippingAmount = $order->getData('shipping_amount'); $shipTaxAmount = $order->getData('shipping_tax_amount'); $ship_csvData = array('SI', $accountCodeSales, $nominalCodeShip, '0', $orderdate, $orderId, $fullName, $shippingAmount, $taxcode, $shipTaxAmount, '1', $paymentMethod, 'import'); fputcsv($fp, $ship_csvData, self::DELIMITER, self::ENCLOSURE); } if ($refundedAmount > 0) { $refundcsvData = array('SC', $accountCodeSales, $nominalCodeSales, '0', $orderdate, $orderId, $fullName, $refundedAmount, $taxcode, $refundedTaxAmount, '1', $paymentMethod, 'import'); fputcsv($fp, $refundcsvData, self::DELIMITER, self::ENCLOSURE); } foreach ($order->getPaymentsCollection() as $payment) { $paymentAmount = $payment->getData('amount_paid'); $orderTax = $order->getData('tax_amount'); $payCsvData = array('SA', $accountCodePayments, $nominalCodePayments, '0', $orderdate, $orderId, $fullName, $paymentAmount, $taxcode, $orderTax, '1', $payment->getMethod(), 'import'); fputcsv($fp, $payCsvData, self::DELIMITER, self::ENCLOSURE); } }
/** * Sets the customer info if available * * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order $object * @return $this */ protected function _addCustomer($object) { $format = Mage::getStoreConfig('tax/avatax/cust_code_format', $object->getStoreId()); $customer = Mage::getModel('customer/customer'); if ($object->getCustomerId()) { $customer->load($object->getCustomerId()); $taxClass = Mage::getModel('tax/class')->load($customer->getTaxClassId())->getOpAvataxCode(); $this->_request->setCustomerUsageType($taxClass); } switch ($format) { case OnePica_AvaTax_Model_Source_Customercodeformat::LEGACY: if ($customer->getId()) { $customerCode = $customer->getName() . ' (' . $customer->getId() . ')'; } else { $address = $object->getBillingAddress() ? $object->getBillingAddress() : $object; $customerCode = $address->getFirstname() . ' ' . $address->getLastname() . ' (Guest)'; } break; case OnePica_AvaTax_Model_Source_Customercodeformat::CUST_EMAIL: $customerCode = $object->getCustomerEmail() ? $object->getCustomerEmail() : $customer->getEmail(); break; case OnePica_AvaTax_Model_Source_Customercodeformat::CUST_ID: default: $customerCode = $object->getCustomerId() ? $object->getCustomerId() : 'guest-' . $object->getId(); break; } $this->_request->setCustomerCode($customerCode); return $this; }
/** * Register on Magento's registry GUEST customer data for MergeVars for on checkout subscribe * * @param Mage_Sales_Model_Order $order * @return void */ public function registerGuestCustomer($order) { if (Mage::registry('mc_guest_customer')) { return; } $customer = new Varien_Object(); $customer->setId('guest' . time()); $customer->setEmail($order->getBillingAddress()->getEmail()); $customer->setStoreId($order->getStoreId()); $customer->setFirstname($order->getBillingAddress()->getFirstname()); $customer->setLastname($order->getBillingAddress()->getLastname()); $customer->setPrimaryBillingAddress($order->getBillingAddress()); $customer->setPrimaryShippingAddress($order->getShippingAddress()); Mage::register('mc_guest_customer', $customer, TRUE); }
/** * @param int $amount * @param string $description * @param Mage_Sales_Model_Order $order * @param string $redirect_url * @param string $method * @param string $issuer * * @return bool */ public function createPayment($amount, $description, $order, $redirect_url, $method, $issuer) { if (!$this->setAmount($amount)) { $this->error_message = "Het opgegeven bedrag \"{$amount}\" is ongeldig"; return FALSE; } if (!$this->setRedirectURL($redirect_url)) { $this->error_message = "De opgegeven redirect URL \"{$redirect_url}\" is onjuist"; return FALSE; } $this->setDescription($description); try { $api = $this->_getMollieAPI(); } catch (Mollie_API_Exception $e) { $this->error_message = $e->getMessage(); return FALSE; } $store = Mage::app()->getStore(); $params = array("amount" => $this->getAmount(), "description" => $this->getDescription(), "redirectUrl" => $this->getRedirectURL(), "method" => $method, "issuer" => empty($issuer) ? NULL : $issuer, "metadata" => array("order_id" => $order->getId(), "store_id" => $store->getId()), "locale" => $this->getLocaleCode(), "webhookUrl" => $this->getWebhookURL()); if ($method == "banktransfer" && $this->getBankTransferDueDateDays()) { $params += array("dueDate" => $this->getBankTransferDueDateDays(), "billingEmail" => $order->getCustomerEmail()); } if ($billing = $order->getBillingAddress()) { $params += array("billingCity" => $billing->getCity(), "billingRegion" => $billing->getRegion(), "billingPostal" => $billing->getPostcode(), "billingCountry" => $billing->getCountryId()); } if ($shipping = $order->getShippingAddress()) { $params += array("shippingAddress" => $shipping->getStreetFull(), "shippingCity" => $shipping->getCity(), "shippingRegion" => $shipping->getRegion(), "shippingPostal" => $shipping->getPostcode(), "shippingCountry" => $shipping->getCountry()); } try { $payment = $api->payments->create($params); } catch (Mollie_API_Exception $e) { try { if ($e->getField() == "webhookUrl") { unset($params["webhookUrl"]); $payment = $api->payments->create($params); } else { throw $e; } } catch (Mollie_API_Exception $e) { $this->error_message = __METHOD__ . ' said: Unable to set up payment. Reason: ' . $e->getMessage(); Mage::log($this->error_message); return FALSE; } } $this->setTransactionId($payment->id); $this->payment_url = (string) $payment->getPaymentUrl(); return TRUE; }
/** * Get order request data as array * * @param Mage_Sales_Model_Order $order * @return array */ protected function _getOrderData(Mage_Sales_Model_Order $order) { $request = array('subtotal' => $this->_formatPrice($this->_formatPrice($order->getPayment()->getBaseAmountAuthorized()) - $this->_formatPrice($order->getBaseTaxAmount()) - $this->_formatPrice($order->getBaseShippingAmount())), 'tax' => $this->_formatPrice($order->getBaseTaxAmount()), 'shipping' => $this->_formatPrice($order->getBaseShippingAmount()), 'invoice' => $order->getIncrementId(), 'address_override' => 'false', 'currency_code' => $order->getBaseCurrencyCode(), 'buyer_email' => $order->getCustomerEmail()); // append to request billing address data if ($billingAddress = $order->getBillingAddress()) { $request = array_merge($request, $this->_getBillingAddress($billingAddress)); } // append to request shipping address data if ($shippingAddress = $order->getShippingAddress()) { $request = array_merge($request, $this->_getShippingAddress($shippingAddress)); } return $request; }
/** * Add Payex Order Address * @param $orderRef * @param Mage_Sales_Model_Order $order * @return bool */ public function addOrderAddress($orderRef, $order) { $billingAddress = $order->getBillingAddress()->getStreet(); $billingCountryCode = $order->getBillingAddress()->getCountry(); $billingCountry = Mage::getModel('directory/country')->load($billingCountryCode)->getName(); $params = array('accountNumber' => '', 'orderRef' => $orderRef, 'billingFirstName' => $order->getBillingAddress()->getFirstname(), 'billingLastName' => $order->getBillingAddress()->getLastname(), 'billingAddress1' => $billingAddress[0], 'billingAddress2' => isset($billingAddress[1]) ? $billingAddress[1] : '', 'billingAddress3' => '', 'billingPostNumber' => (string) $order->getBillingAddress()->getPostcode(), 'billingCity' => (string) $order->getBillingAddress()->getCity(), 'billingState' => (string) $order->getBillingAddress()->getRegion(), 'billingCountry' => $billingCountry, 'billingCountryCode' => $billingCountryCode, 'billingEmail' => (string) $order->getBillingAddress()->getEmail(), 'billingPhone' => (string) $order->getBillingAddress()->getTelephone(), 'billingGsm' => ''); // add Shipping $shipping_params = array('deliveryFirstName' => '', 'deliveryLastName' => '', 'deliveryAddress1' => '', 'deliveryAddress2' => '', 'deliveryAddress3' => '', 'deliveryPostNumber' => '', 'deliveryCity' => '', 'deliveryState' => '', 'deliveryCountry' => '', 'deliveryCountryCode' => '', 'deliveryEmail' => '', 'deliveryPhone' => '', 'deliveryGsm' => ''); if (!$order->getIsVirtual()) { $deliveryAddress = $order->getShippingAddress()->getStreet(); $deliveryCountryCode = $order->getShippingAddress()->getCountry(); $deliveryCountry = Mage::getModel('directory/country')->load($deliveryCountryCode)->getName(); $shipping_params = array('deliveryFirstName' => $order->getShippingAddress()->getFirstname(), 'deliveryLastName' => $order->getShippingAddress()->getLastname(), 'deliveryAddress1' => $deliveryAddress[0], 'deliveryAddress2' => isset($deliveryAddress[1]) ? $deliveryAddress[1] : '', 'deliveryAddress3' => '', 'deliveryPostNumber' => (string) $order->getShippingAddress()->getPostcode(), 'deliveryCity' => (string) $order->getShippingAddress()->getCity(), 'deliveryState' => (string) $order->getShippingAddress()->getRegion(), 'deliveryCountry' => $deliveryCountry, 'deliveryCountryCode' => $deliveryCountryCode, 'deliveryEmail' => (string) $order->getShippingAddress()->getEmail(), 'deliveryPhone' => (string) $order->getShippingAddress()->getTelephone(), 'deliveryGsm' => ''); } $params += $shipping_params; $result = Mage::helper('payexautopay/api')->getPx()->AddOrderAddress2($params); Mage::helper('payexautopay/tools')->debugApi($result, 'PxOrder.AddOrderAddress2'); return true; }
/** * Getter for billing address of order by format * * @param Mage_Sales_Model_Order $order * @return string */ public function getBillingAddressFormattedHtml($order) { $billingAddress = $order->getBillingAddress(); if (!$billingAddress instanceof Mage_Sales_Model_Order_Address) { return ''; } return $billingAddress->format('html'); }
/** * Inserts the customer address. The default address is the billing address. * * @param Zend_Pdf_Page &$page Current page object of Zend_Pdf * @param Mage_Sales_Model_Order $order Order object * * @return void */ protected function _insertCustomerAddress(&$page, $order) { $this->_setFontRegular($page, 9); $billing = $this->_formatAddress($order->getBillingAddress()->format('pdf')); foreach ($billing as $line) { $page->drawText(trim(strip_tags($line)), $this->margin['left'] + $this->getHeaderblockOffset(), $this->y, $this->encoding); $this->Ln(12); } }
/** * Set entity data to request * * @param Mage_Sales_Model_Order $order * @param Mage_Authorizenet_Model_Directpost $paymentMethod * @return Mage_Authorizenet_Model_Directpost_Request */ public function setDataFromOrder(Mage_Sales_Model_Order $order, Mage_Authorizenet_Model_Directpost $paymentMethod) { $payment = $order->getPayment(); $this->setXFpSequence($order->getQuoteId()); $this->setXInvoiceNum($order->getIncrementId()); $this->setXAmount($payment->getBaseAmountAuthorized()); $this->setXCurrencyCode($order->getBaseCurrencyCode()); $this->setXTax(sprintf('%.2F', $order->getBaseTaxAmount()))->setXFreight(sprintf('%.2F', $order->getBaseShippingAmount())); //need to use strval() because NULL values IE6-8 decodes as "null" in JSON in JavaScript, but we need "" for null values. $billing = $order->getBillingAddress(); if (!empty($billing)) { $this->setXFirstName(strval($billing->getFirstname()))->setXLastName(strval($billing->getLastname()))->setXCompany(strval($billing->getCompany()))->setXAddress(strval($billing->getStreet(1)))->setXCity(strval($billing->getCity()))->setXState(strval($billing->getRegion()))->setXZip(strval($billing->getPostcode()))->setXCountry(strval($billing->getCountry()))->setXPhone(strval($billing->getTelephone()))->setXFax(strval($billing->getFax()))->setXCustId(strval($billing->getCustomerId()))->setXCustomerIp(strval($order->getRemoteIp()))->setXCustomerTaxId(strval($billing->getTaxId()))->setXEmail(strval($order->getCustomerEmail()))->setXEmailCustomer(strval($paymentMethod->getConfigData('email_customer')))->setXMerchantEmail(strval($paymentMethod->getConfigData('merchant_email'))); } $shipping = $order->getShippingAddress(); if (!empty($shipping)) { $this->setXShipToFirstName(strval($shipping->getFirstname()))->setXShipToLastName(strval($shipping->getLastname()))->setXShipToCompany(strval($shipping->getCompany()))->setXShipToAddress(strval($shipping->getStreet(1)))->setXShipToCity(strval($shipping->getCity()))->setXShipToState(strval($shipping->getRegion()))->setXShipToZip(strval($shipping->getPostcode()))->setXShipToCountry(strval($shipping->getCountry())); } $this->setXPoNum(strval($payment->getPoNumber())); return $this; }
/** * extracts the parameter for the direct link request from the quote, order and, optionally from existing request params * * @param Mage_Sales_Model_Quote $quote * @param Mage_Sales_Model_Order $order * @param array $requestParams * * @return array - the parameters for the direct link request */ public function getDirectLinkRequestParams(Mage_Sales_Model_Quote $quote, Mage_Sales_Model_Order $order, $requestParams = array()) { $billingAddress = $order->getBillingAddress(); $shippingAddress = $this->getShippingAddress($order, $billingAddress); $requestParams = $this->getBaseRequestParams($quote, $order, $billingAddress); $requestParams = array_merge($requestParams, $this->getPaymentSpecificParams($quote)); if ($this->getConfig()->canSubmitExtraParameter($quote->getStoreId())) { $shipToParams = $this->getRequestHelper()->extractShipToParameters($shippingAddress, $quote); $shipToParams = $this->decodeParamsForDirectLinkCall($shipToParams); $requestParams = array_merge($requestParams, $shipToParams); } $requestParams = $this->addCustomerSpecificParams($requestParams); $requestParams = $this->addParamsForAdminPayments($requestParams); return $requestParams; }