/** * @test */ public function shouldCallKlarnaGetAddresses() { $first = new \KlarnaAddr(); $first->setCountry('SE'); $second = new \KlarnaAddr(); $second->setCountry('SE'); $klarnaMock = $this->createKlarnaMock(); $klarnaMock->expects($this->once())->method('getAddresses')->with('thePno')->will($this->returnValue(array($first, $second))); $action = new GetAddressesAction($klarnaMock); $action->setApi(new Config()); $action->execute($getAddresses = new GetAddresses('thePno')); $this->assertCount(2, $getAddresses->getAddresses()); $this->assertSame($first, $getAddresses->getFirstAddress()); }
/** * Attempt to guess customer country to determine if things should be shown. * * @param string $option payment option * * @return string or null */ public static function deduceCountry($option) { $customer_country_id = isset($_SESSION['customer_country_id']) ? $_SESSION['customer_country_id'] : STORE_COUNTRY; $currency = $_SESSION['currency']; $addr = null; if ($customer_country_id !== null) { $addr = new KlarnaAddr(); $addr->setCountry(self::getCountryByID($customer_country_id)); } $lang = self::getLanguageCode(); self::configureKiTT($option); self::configureKlarna($option); return KiTT::locator()->locate($currency, $lang, $addr); }
/** * The invoice_address function is used to retrieve the address of a purchase. * * * * @link http://integration.klarna.com/en/api/other-functions/functions/invoiceaddress * @param string $invNo Invoice number. * @throws KlarnaException * @return KlarnaAddr */ public function invoiceAddress($invNo) { $this->checkInvNo($invNo, __METHOD__); $digestSecret = self::digest($this->colon($this->eid, $invNo, $this->secret)); $paramList = array($this->eid, $invNo, $digestSecret); self::printDebug('invoice_address', $paramList); $result = $this->xmlrpc_call('invoice_address', $paramList); $addr = new KlarnaAddr(); if (strlen($result[0]) > 0) { $addr->isCompany = false; $addr->setFirstName($result[0]); $addr->setLastName($result[1]); } else { $addr->isCompany = true; $addr->setCompanyName($result[1]); } $addr->setStreet($result[2]); $addr->setZipCode($result[3]); $addr->setCity($result[4]); $addr->setCountry($result[5]); return $addr; }