AAAAcheckouthtml.intf.php000066600000005500151375524320010721 0ustar00 * @copyright 2012 Klarna AB (http://klarna.com) * @license http://opensource.org/licenses/BSD-2-Clause BSD-2 * @link http://integration.klarna.com/ */ /** * This interface provides methods to supply checkout page specific HTML.
* Can be used to insert device identification, fraud prevention,
* client side validation code into the checkout page. * * @category Payment * @package KlarnaAPI * @author MS Dev * @copyright 2012 Klarna AB (http://klarna.com) * @license http://opensource.org/licenses/BSD-2-Clause BSD-2 * @link http://integration.klarna.com/ */ abstract class CheckoutHTML { /** * Creates a session ID used for e.g. client identification and fraud * prevention. * * This method creates a 40 character long integer. * The first 30 numbers is microtime + random numbers. * The last 10 numbers is the eid zero-padded. * * All random functions are automatically seeded as of PHP 4.2.0. * * E.g. for eid 1004 output could be: * 1624100001298454658880354228080000001004 * * @param int $eid merchant id * * @return string A integer with a string length of 40. */ public static function getSessionID($eid) { $eid = strval($eid); while (strlen($eid) < 10) { $eid = "0" . $eid; //Zero-pad the eid. } $sid = str_replace(array(' ', ',', '.'), '', microtime()); $sid[0] = rand(1, 9); //Make sure we always have a non-zero first. //microtime + rand = 30 numbers in length while (strlen($sid) < 30) { //rand is automatically seeded as of PHP 4.2.0 $sid .= rand(0, 9999); } $sid = substr($sid, 0, 30); $sid .= $eid; return $sid; } /** * Initializes this object, this method is always called * before {@link CheckoutHTML::toHTML()}. * This method is used in {@link Klarna::addTransaction()}, * {@link Klarna::reserveAmount()} and in {@link Klarna::checkoutHTML()} * * @param Klarna $klarna The API instance * @param int $eid merchant id * * @return void */ abstract public function init($klarna, $eid); /** * This returns the HTML code for this object, * which will be used in the checkout page. * * @return string HTML */ abstract public function toHTML(); /** * This function is used to clear any stored values * (in SESSION, COOKIE or similar) * which are required to be unique between purchases. * * @return void */ abstract public function clear(); } threatmetrix.class.php000066600000007554151375524320011127 0ustar00 * @copyright 2012 Klarna AB (http://klarna.com) * @license http://opensource.org/licenses/BSD-2-Clause BSD-2 * @link http://integration.klarna.com/ */ /** * ThreatMetrix is a fraud prevention and device identification software. * * @category Payment * @package KlarnaAPI * @author MS Dev * @copyright 2012 Klarna AB (http://klarna.com) * @license http://opensource.org/licenses/BSD-2-Clause BSD-2 * @link http://integration.klarna.com/ */ class ThreatMetrix extends CheckoutHTML { /** * The ID used in conjunction with the Klarna API. * * @var int */ const ID = 'dev_id_1'; /** * ThreatMetrix organizational ID. * * @var string */ protected $orgID = 'qicrzsu4'; /** * Session ID for the client. * * @var string */ protected $sessionID; /** * Hostname used to access ThreatMetrix. * * @var string */ protected $host = 'h.online-metrix.net'; /** * Protocol used to access ThreatMetrix. * * @var string */ protected $proto = 'https'; /** * Initializes this object, this method is always called * before {@link CheckoutHTML::toHTML()}. * This method is used in {@link Klarna::addTransaction()}, * {@link Klarna::reserveAmount()} and in {@link Klarna::checkoutHTML()} * * @param Klarna $klarna The API instance * @param int $eid Merchant ID * * @return void */ public function init($klarna, $eid) { if (!is_int($eid)) { throw new Klarna_ConfigFieldMissingException('eid'); } if (isset($_SESSION)) { if (!isset($_SESSION[self::ID]) || (strlen($_SESSION[self::ID]) < 40) ) { $_SESSION[self::ID] = parent::getSessionID($eid); $this->sessionID = $_SESSION[self::ID]; } else { $this->sessionID = $_SESSION[self::ID]; } } else { $this->sessionID = parent::getSessionID($eid); } $klarna->setSessionID(self::ID, $this->sessionID); } /** * This function is used to clear any stored values * (in SESSION, COOKIE or similar) * which are required to be unique between purchases. * * @return void */ public function clear() { if (isset($_SESSION) && isset($_SESSION[self::ID])) { $_SESSION[self::ID] = null; unset($_SESSION[self::ID]); } } /** * This returns the HTML code for this object, * which will be used in the checkout page. * * @return string */ public function toHTML() { $html = "

". "". "". ""; return $html; } } index.html000066600000000057151375524320006556 0ustar00 .htaccess000066600000000177151375524320006362 0ustar00 Order allow,deny Deny from all