/** * 1)Called everytime the adyen_sepa is called or used in checkout * @descrition Assign data to info model instance * * @param mixed $data * @return Mage_Payment_Model_Info */ public function assignData($data) { if (!$data instanceof Varien_Object) { $data = new Varien_Object($data); } $info = $this->getInfoInstance(); $sepa = array('account_name' => $data->getAccountName(), 'iban' => $data->getIban(), 'country' => $data->getCountry(), 'accept_sepa' => $data->getAcceptSepa()); $info = $this->getInfoInstance(); $info->setCcOwner($data->getOwner())->setCcType($data->getBankLocation())->setCcLast4(substr($data->getAccountNumber(), -4))->setCcNumber($data->getAccountNumber())->setCcNumberEnc($data->getBankCode())->setPoNumber(serialize($sepa)); /* @note misused field for the elv */ return $this; }
public function formatAddress(Varien_Object $address, $html = false) { $address->getRegion(); $address->getCountry(); $template = $this->getData('address_template_' . ($html ? 'html' : 'plain')); if (empty($template)) { if (!$this->getId()) { $template = '{{firstname}} {{lastname}}'; } elseif (!$html) { $template = "{{firstname}} {{lastname}}\n{{company}}\n{{street1}}\n{{street2}}\n{{city}}, {{region}} {{postcode}}"; } else { $template = "{{firstname}} {{lastname}}<br/>\n{{street}}<br/>\n{{city}}, {{region}} {{postcode}}<br/>\nT: {{telephone}}"; } } $filter = new Varien_Filter_Template_Simple(); $addressText = $filter->setData($address->getData())->filter($template); if ($html) { $addressText = preg_replace('#(<br\\s*/?>\\s*){2,}#im', '<br/>', $addressText); } else { $addressText = preg_replace('#(\\n\\s*){2,}#m', "\n", $addressText); } return $addressText; }
/** * Get billing address request data * * @param Varien_Object $address * @return array */ protected function _getBillingAddress(Varien_Object $address) { $request = array('billing_first_name' => $address->getFirstname(), 'billing_last_name' => $address->getLastname(), 'billing_city' => $address->getCity(), 'billing_state' => $address->getRegion(), 'billing_zip' => $address->getPostcode(), 'billing_country' => $address->getCountry()); // convert streets to tow lines format $street = Mage::helper('customer/address')->convertStreetLines($address->getStreet(), 2); $request['billing_address1'] = isset($street[0]) ? $street[0] : ''; $request['billing_address2'] = isset($street[1]) ? $street[1] : ''; return $request; }
/** * Adopt specified address object to be compatible with Paypal * Puerto Rico should be as state of USA and not as a country * * @param Varien_Object $address */ protected function _applyCountryWorkarounds(Varien_Object $address) { if ($address->getCountry() == 'PR') { $address->setCountry('US'); $address->setRegionCode('PR'); } }
/** * Assigning shipping address to soap object * * @param Varien_Object $shipping */ protected function addShippingAddress($shipping) { //checking if we have shipping address, in case of virtual order we will not have it if ($shipping) { $shipTo = new stdClass(); $shipTo->firstName = $shipping->getFirstname(); $shipTo->lastName = $shipping->getLastname(); $shipTo->company = $shipping->getCompany(); $shipTo->street1 = $shipping->getStreet(1); $shipTo->street2 = $shipping->getStreet(2); $shipTo->city = $shipping->getCity(); $shipTo->state = $shipping->getRegion(); $shipTo->postalCode = $shipping->getPostcode(); $shipTo->country = $shipping->getCountry(); $shipTo->phoneNumber = $this->cleanPhoneNum($shipping->getTelephone()); $this->_request->shipTo = $shipTo; Mage::getSingleton('core/session')->setShipping($shipTo); } }
/** * Format address * * @param Varien_Object $address * @return string */ public function format(Varien_Object $address) { $formattedAddress = null; $pieces = array(); if ($address->getStreet()) { $street = $address->getStreet(); if (is_array($street) && count($street)) { $street = $street[0]; } array_push($pieces, strval($street)); } if ($address->getCity()) { array_push($pieces, strval($address->getCity())); } if ($address->getRegionId() || $address->getRegion() || $address->getPostcode()) { $regionAndPostalCodePieces = array(); $regionId = $address->getRegion() ? $address->getRegion() : $address->getRegionId(); if (is_numeric($regionId)) { $region = $this->getRegionById($regionId); if ($region) { array_push($regionAndPostalCodePieces, strval($region->getName())); } } else { array_push($regionAndPostalCodePieces, strval($regionId)); } if ($address->getPostcode()) { array_push($regionAndPostalCodePieces, strval($address->getPostcode())); } if (count($regionAndPostalCodePieces)) { array_push($pieces, implode(' ', $regionAndPostalCodePieces)); } } if ($address->getCountryId() || $address->getCountry()) { if ($address->getCountry()) { array_push($pieces, strval($address->getCountry())); } else { if ($address->getCountryId()) { $country = $this->getCountryById($address->getCountryId()); if ($country) { array_push($pieces, strval($country->getName())); } } } } if (count($pieces)) { $formattedAddress = implode(', ', $pieces); } return $formattedAddress; }