Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ The SofortLib PHP package contains the following:

- the `/src` directory with the class-files
- an `/examples` folder, with examples of usage
- the folder `/test` with the unittests (for PHP Unit).
- the folder `/tests` with the unittests (for PHPUnit).



Expand Down
17 changes: 10 additions & 7 deletions examples/Ideal.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@
define('PASSWORD', 'password_password');

$SofortIdeal = new Ideal(CONFIGKEY, PASSWORD);
//$SofortIdeal = new Ideal(CONFIGKEY, PASSWORD, 'md5');
//$SofortIdeal = new Ideal(CONFIGKEY, PASSWORD, 'sha256');
// $SofortIdeal = new Ideal(CONFIGKEY, PASSWORD, 'md5');
// $SofortIdeal = new Ideal(CONFIGKEY, PASSWORD, 'sha256');
$SofortIdeal->setReason('Testzweck', 'Testzweck4');
$SofortIdeal->setAmount(10);
//$SofortIdeal->setSenderAccountNumber('2345678902');
// $SofortIdeal->setSenderHolder('Name of Sender');
// $SofortIdeal->setSenderAccountNumber('2345678902');
$SofortIdeal->setSenderBankCode('31');
$SofortIdeal->setSenderCountryId('NL');
$SofortIdeal->setSuccessUrl('http://www.yourdomain.org/yourshop/success.php');
$SofortIdeal->setAbortUrl('http://www.yourdomain.org/yourshop/abort.php?transaction=-TRANSACTION-');
$SofortIdeal->setNotificationUrl('http://www.yourdomain.org/yourshop/notification.php?transaction=-TRANSACTION-');
//$SofortIdeal->setVersion('Framework 0.0.1');
//$SofortIdeal->setUserVariable('User-Var 1');
//$SofortIdeal->setUserVariable('User-Var 2');
//$SofortIdeal->setUserVariable('User-Var 3');
// $SofortIdeal->setLanguageCode('EN');
// $SofortIdeal->setVersion('Framework 0.0.1');
// $SofortIdeal->setTimeout('300');

echo 'User should be redirected to: <a href="'.$SofortIdeal->getPaymentUrl().'" target="_blank">Link</a>';
2 changes: 1 addition & 1 deletion examples/Sofortueberweisung.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

$Sofortueberweisung->sendRequest();

if($Sofortueberweisung->isError()) {
if ($Sofortueberweisung->isError()) {
// SOFORT-API didn't accept the data
echo $Sofortueberweisung->getError();
} else {
Expand Down
5 changes: 3 additions & 2 deletions examples/TransactionData.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

//$SofortLibTransactionData->setTime('2012-11-14T18:00+02:00', '2012-12-13T00:00+02:00');
//$SofortLibTransactionData->setNumber(5, 1);
//$SofortLibTransactionData->setProduct('payment');

$SofortLibTransactionData->sendRequest();

Expand Down Expand Up @@ -72,7 +73,7 @@
);

foreach($methods as $method => $params) {
if(count($params) == 2) {
if (count($params) == 2) {
$output[] = $method . ': ' . $SofortLibTransactionData->$method($params[0], $params[1]);
} else if($params !== '') {
$output[] = $method . ': ' . $SofortLibTransactionData->$method($params);
Expand All @@ -81,7 +82,7 @@
}
}

if($SofortLibTransactionData->isError()) {
if ($SofortLibTransactionData->isError()) {
echo $SofortLibTransactionData->getError();
} else {
echo implode('<br />', $output);
Expand Down
13 changes: 7 additions & 6 deletions src/Sofort/SofortLib/AbstractWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
/**
* SofortLibPHP version - Constant
*/
use Sofort\SofortLib\DataHandler\AbstractDataHandler;
use Sofort\SofortLib\Factory\Factory;
use Sofort\SofortLib\Logger\AbstractLoggerHandler;

if (!defined('SOFORTLIB_VERSION')) {
define('SOFORTLIB_VERSION', '3.0.0');
}
Expand Down Expand Up @@ -143,12 +147,9 @@ public function __construct($configKey, $apiUrl = '')
$apiUrl = (getenv('sofortApiUrl') != '') ? getenv('sofortApiUrl') : self::GATEWAY_URL;
}

$SofortLibHttp = Factory::getHttpConnection($apiUrl);
$XmlDataHandler = Factory::getDataHandler($configKey);
$this->setDataHandler($XmlDataHandler);
$FileLogger = Factory::getLogger();
$this->setLogger($FileLogger);
$this->_DataHandler->setConnection($SofortLibHttp);
$this->setDataHandler(Factory::getDataHandler($configKey));
$this->setLogger(Factory::getLogger());
$this->_DataHandler->setConnection(Factory::getHttpConnection($apiUrl));
$this->enableLogging = (getenv('sofortDebug') == 'true') ? true : false;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

namespace Sofort\SofortLib;
namespace Sofort\SofortLib\DataHandler;

use Sofort\SofortLib\Http\AbstractHttp;

/**
* @copyright 2010-2016 SOFORT GmbH
Expand Down Expand Up @@ -134,7 +136,7 @@ public function getProjectId()
/**
* Getter for the raw request data
*
* @return string
* @return string[]
*/
public function getRawRequest()
{
Expand All @@ -145,7 +147,7 @@ public function getRawRequest()
/**
* Getter for the raw response data
*
* @return string
* @return string[]
*/
public function getRawResponse()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Sofort\SofortLib;
namespace Sofort\SofortLib\DataHandler;

use Sofort\SofortLib\Xml\ArrayToXml;
use Sofort\SofortLib\Xml\XmlToArray;
Expand All @@ -15,18 +15,6 @@
*/
class XmlDataHandler extends AbstractDataHandler
{

/**
* Should be moved to somewhere else (where it fits better)
*
* @param string $configKey
*/
public function __construct($configKey)
{
parent::__construct($configKey);
}


/**
* Preparing data and parsing result received
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<?php

namespace Sofort\SofortLib;
namespace Sofort\SofortLib\Factory;

use Sofort\SofortLib\DataHandler\XmlDataHandler;
use Sofort\SofortLib\Http\HttpCurl;
use Sofort\SofortLib\Http\HttpSocket;
use Sofort\SofortLib\Logger\FileLogger;

/**
* @copyright 2010-2016 SOFORT GmbH
Expand All @@ -21,8 +26,6 @@ class Factory
*/
static public function getDataHandler($configKey)
{
require_once(dirname(__FILE__) . '/XmlDataHandler.php');

return new XmlDataHandler($configKey);
}

Expand All @@ -38,12 +41,8 @@ static public function getDataHandler($configKey)
static public function getHttpConnection($data, $url = false, $headers = false)
{
if (function_exists('curl_init')) {
require_once(dirname(__FILE__) . '/HttpCurl.php');

return new HttpCurl($data, $url, $headers);
} else {
require_once(dirname(__FILE__) . '/HttpSocket.php');

return new HttpSocket($data, $url, $headers);
}
}
Expand All @@ -56,8 +55,6 @@ static public function getHttpConnection($data, $url = false, $headers = false)
*/
static public function getLogger()
{
require_once(dirname(__FILE__) . '/FileLogger.php');

return new FileLogger();
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Sofort\SofortLib;
namespace Sofort\SofortLib\Http;

/**
* @copyright 2010-2016 SOFORT GmbH
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Sofort\SofortLib;
namespace Sofort\SofortLib\Http;

/**
* @copyright 2010-2016 SOFORT GmbH
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Sofort\SofortLib;
namespace Sofort\SofortLib\Http;

/**
* @copyright 2010-2016 SOFORT GmbH
Expand Down Expand Up @@ -77,7 +77,7 @@ public function post($data, $url = null, $useHeaders = false)
* This is a fallback with fsockopen if curl is not activated
* we still need openssl and ssl wrapper support (PHP >= 4.3.0)
*
* @param string $uri
* @param string[] $uri
* @param string $out
* @return string
*/
Expand Down
63 changes: 50 additions & 13 deletions src/Sofort/SofortLib/Ideal.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,22 @@ public function getPaymentUrl()


/**
* Set the url where you want forward after successful transaction
* abort URLs cant be set in iDeal
*
* @param string $abortUrl url
* @return Ideal $this
*
* @deprecated
*/
public function setAbortUrl($abortUrl)
{
$this->_parameters['user_variable_4'] = $abortUrl;
return $this;
}


public function setTimeout($timeout)
{
$this->_parameters['interface_timeout'] = $timeout;

return $this;
}
Expand All @@ -169,18 +177,50 @@ public function setAmount($amount = 0.00)


/**
* Set the url where you want notification about status changes
* being sent to. Use SofortLibTransactionData
* to further process that notification
* Setter for languageCode
*
* @param string $languageCode | fallback EN
* @return Multipay $this
*/
public function setLanguageCode($languageCode = '')
{
$this->_parameters['language_id'] = !empty($languageCode) ? $languageCode : 'EN';

return $this;
}


/**
* Add another variable this can be your internal order-ID or multiple variables
*
* @param string $userVariable the contents of the variable
* @return Multipay $this
*/
public function setUserVariable($userVariable)
{
$i = 0;

while (array_key_exists('user_variable_'.$i, $this->_parameters)) {
$i++;
}

$this->_parameters['user_variable_'.$i] = $userVariable;

return $this;
}


/**
* Notification URLs cant be set in iDeal
*
* @param string $notificationUrl url
* @param string $notifyOn
* @return Ideal
*
* @deprecated
*/
public function setNotificationUrl($notificationUrl, $notifyOn = '')
{
$this->_parameters['user_variable_5'] = $notificationUrl;

return $this;
}

Expand Down Expand Up @@ -260,19 +300,16 @@ public function setSenderHolder($senderHolder)


/**
* The customer will be redirected to this url after a successful
* transaction, this should be a page where a short confirmation is
* displayed
* Success URLs cant be set in iDeal
*
* @param string $successUrl url
* @param bool $redirect (default true)
* @return Ideal
*
* @deprecated
*/
public function setSuccessUrl($successUrl, $redirect = true)
{
$this->_parameters['user_variable_3'] = $successUrl;
$this->setSuccessLinkRedirect($redirect);

return $this;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Sofort/SofortLib/IdealNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function getCurrency()
/**
* Get the notification details
*
* @param string $request (POST-Data)
* @param string[] $request (POST-Data)
* @return IdealNotification $this
*/
public function getNotification($request)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Sofort\SofortLib;
namespace Sofort\SofortLib\Logger;

/**
* @copyright 2010-2016 SOFORT GmbH
Expand All @@ -13,10 +13,5 @@
abstract class AbstractLoggerHandler
{

public function __construct()
{
}


abstract function log($message, $log = 'log');
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Sofort\SofortLib;
namespace Sofort\SofortLib\Logger;

/**
* @copyright 2010-2016 SOFORT GmbH
Expand Down Expand Up @@ -59,7 +59,7 @@ class FileLogger extends AbstractLoggerHandler
*/
public function __construct($path = '')
{
$srcDir = dirname(dirname(dirname(__FILE__)));
$srcDir = dirname(dirname(dirname(dirname(__FILE__))));

$this->_logfilePath = ($path != '') ? $path : $srcDir . '/logs/log.txt';
$this->_errorLogfilePath = $srcDir . '/logs/error_log.txt';
Expand Down
2 changes: 1 addition & 1 deletion src/Sofort/SofortLib/Multipay.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function setEmailCustomer($customersEmail)
* @param string $languageCode | fallback EN
* @return Multipay $this
*/
public function setLanguageCode($languageCode)
public function setLanguageCode($languageCode = '')
{
$this->_parameters['language_code'] = !empty($languageCode) ? $languageCode : 'EN';

Expand Down
Loading