diff --git a/README.md b/README.md
index 152f37e..31a7220 100644
--- a/README.md
+++ b/README.md
@@ -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).
diff --git a/examples/Ideal.php b/examples/Ideal.php
index 8b62e9f..65dfcde 100644
--- a/examples/Ideal.php
+++ b/examples/Ideal.php
@@ -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: Link';
diff --git a/examples/Sofortueberweisung.php b/examples/Sofortueberweisung.php
index 06a7232..b1380c1 100644
--- a/examples/Sofortueberweisung.php
+++ b/examples/Sofortueberweisung.php
@@ -27,7 +27,7 @@
$Sofortueberweisung->sendRequest();
-if($Sofortueberweisung->isError()) {
+if ($Sofortueberweisung->isError()) {
// SOFORT-API didn't accept the data
echo $Sofortueberweisung->getError();
} else {
diff --git a/examples/TransactionData.php b/examples/TransactionData.php
index fb85956..8ac69e5 100644
--- a/examples/TransactionData.php
+++ b/examples/TransactionData.php
@@ -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();
@@ -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);
@@ -81,7 +82,7 @@
}
}
-if($SofortLibTransactionData->isError()) {
+if ($SofortLibTransactionData->isError()) {
echo $SofortLibTransactionData->getError();
} else {
echo implode('
', $output);
diff --git a/src/Sofort/SofortLib/AbstractWrapper.php b/src/Sofort/SofortLib/AbstractWrapper.php
index f24e2c9..054fcbf 100644
--- a/src/Sofort/SofortLib/AbstractWrapper.php
+++ b/src/Sofort/SofortLib/AbstractWrapper.php
@@ -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');
}
@@ -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;
}
diff --git a/src/Sofort/SofortLib/AbstractDataHandler.php b/src/Sofort/SofortLib/DataHandler/AbstractDataHandler.php
similarity index 97%
rename from src/Sofort/SofortLib/AbstractDataHandler.php
rename to src/Sofort/SofortLib/DataHandler/AbstractDataHandler.php
index 769d649..697451d 100644
--- a/src/Sofort/SofortLib/AbstractDataHandler.php
+++ b/src/Sofort/SofortLib/DataHandler/AbstractDataHandler.php
@@ -1,6 +1,8 @@
= 4.3.0)
*
- * @param string $uri
+ * @param string[] $uri
* @param string $out
* @return string
*/
diff --git a/src/Sofort/SofortLib/Ideal.php b/src/Sofort/SofortLib/Ideal.php
index fbf739e..f1540cb 100644
--- a/src/Sofort/SofortLib/Ideal.php
+++ b/src/Sofort/SofortLib/Ideal.php
@@ -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;
}
@@ -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;
}
@@ -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;
}
diff --git a/src/Sofort/SofortLib/IdealNotification.php b/src/Sofort/SofortLib/IdealNotification.php
index 1e901d5..e4c165f 100644
--- a/src/Sofort/SofortLib/IdealNotification.php
+++ b/src/Sofort/SofortLib/IdealNotification.php
@@ -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)
diff --git a/src/Sofort/SofortLib/AbstractLoggerHandler.php b/src/Sofort/SofortLib/Logger/AbstractLoggerHandler.php
similarity index 78%
rename from src/Sofort/SofortLib/AbstractLoggerHandler.php
rename to src/Sofort/SofortLib/Logger/AbstractLoggerHandler.php
index bc85096..2939016 100644
--- a/src/Sofort/SofortLib/AbstractLoggerHandler.php
+++ b/src/Sofort/SofortLib/Logger/AbstractLoggerHandler.php
@@ -1,6 +1,6 @@
_logfilePath = ($path != '') ? $path : $srcDir . '/logs/log.txt';
$this->_errorLogfilePath = $srcDir . '/logs/error_log.txt';
diff --git a/src/Sofort/SofortLib/Multipay.php b/src/Sofort/SofortLib/Multipay.php
index f16eb98..d2c7ffd 100644
--- a/src/Sofort/SofortLib/Multipay.php
+++ b/src/Sofort/SofortLib/Multipay.php
@@ -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';
diff --git a/src/Sofort/SofortLib/TransactionData.php b/src/Sofort/SofortLib/TransactionData.php
index 40e6604..cd301d6 100644
--- a/src/Sofort/SofortLib/TransactionData.php
+++ b/src/Sofort/SofortLib/TransactionData.php
@@ -11,7 +11,7 @@
* This class is for retrieving information about transactions, you can search by transaction-id or by date
*
* eg:
- * $SofortLibTransactionData = new SofortLibTransactionData('yourapikey');
+ * $SofortLibTransactionData = new TransactionData('yourapikey');
* $SofortLibTransactionData->addTransaction('1234-456-789654-31321')->sendRequest();
*
* echo $SofortLibTransactionData->getStatus();
@@ -555,6 +555,20 @@ public function setNumber($number, $page = 1)
}
+ /**
+ * Request for transactions for a certian product
+ *
+ * @param string $product (payment|paycode)
+ * @return TransactionData
+ */
+ public function setProduct($product)
+ {
+ $this->_parameters['product'] = $product;
+
+ return $this;
+ }
+
+
/**
* Request for transactions with certain status
*
diff --git a/src/Sofort/SofortLib/Xml/XmlToArrayNode.php b/src/Sofort/SofortLib/Xml/XmlToArrayNode.php
index f9cc2e0..9506f4a 100644
--- a/src/Sofort/SofortLib/Xml/XmlToArrayNode.php
+++ b/src/Sofort/SofortLib/Xml/XmlToArrayNode.php
@@ -30,7 +30,7 @@ class XmlToArrayNode
/**
* Data
*
- * @var string
+ * @var string[]
*/
private $_data = '';
diff --git a/tests/unit/AbstractDataHandlerTest.php b/tests/unit/AbstractDataHandlerTest.php
index d7598bf..b2d4f99 100644
--- a/tests/unit/AbstractDataHandlerTest.php
+++ b/tests/unit/AbstractDataHandlerTest.php
@@ -1,10 +1,12 @@
getTestClass(array(self::$configkey));;
/** @var AbstractDataHandler $AbstractDataHandler */
- $AbstractDataHandler = $this->getMockForAbstractClass('Sofort\SofortLib\AbstractDataHandler', array(), '',
+ $AbstractDataHandler = $this->getMockForAbstractClass('Sofort\SofortLib\DataHandler\AbstractDataHandler', array(), '',
false);
$AbstractWrapperMock->setDataHandler($AbstractDataHandler);
$this->assertEquals($AbstractDataHandler, $AbstractWrapperMock->getDataHandler());
@@ -399,7 +403,7 @@ public function testGetLogger()
/** @var AbstractWrapper $AbstractWrapperMock */
$AbstractWrapperMock = $this->getTestClass(array(self::$configkey));;
/** @var FileLogger $FileLogger */
- $FileLogger = $this->getMockForAbstractClass('Sofort\SofortLib\FileLogger');
+ $FileLogger = $this->getMockForAbstractClass('Sofort\SofortLib\Logger\FileLogger');
$AbstractWrapperMock->setLogger($FileLogger);
$this->assertEquals($AbstractWrapperMock->getLogger(), $FileLogger);
}
@@ -410,7 +414,7 @@ public function testGetRawRequest()
/** @var AbstractWrapper $AbstractWrapperMock */
$AbstractWrapperMock = $this->getTestClass(array(self::$configkey));;
/** @var AbstractDataHandler|\PHPUnit_Framework_MockObject_MockObject $AbstractDataHandler */
- $AbstractDataHandler = $this->getMockForAbstractClass('Sofort\SofortLib\AbstractDataHandler',
+ $AbstractDataHandler = $this->getMockForAbstractClass('Sofort\SofortLib\DataHandler\AbstractDataHandler',
array(),
'',
false,
@@ -429,7 +433,7 @@ public function testGetRawResponse()
/** @var AbstractWrapper $AbstractWrapperMock */
$AbstractWrapperMock = $this->getTestClass(array(self::$configkey));;
/** @var AbstractDataHandler|\PHPUnit_Framework_MockObject_MockObject $AbstractDataHandler */
- $AbstractDataHandler = $this->getMockForAbstractClass('Sofort\SofortLib\AbstractDataHandler',
+ $AbstractDataHandler = $this->getMockForAbstractClass('Sofort\SofortLib\DataHandler\AbstractDataHandler',
array(),
'',
false,
@@ -468,7 +472,7 @@ public function testLog()
/** @var AbstractWrapper $AbstractWrapperMock */
$AbstractWrapperMock = $this->getTestClass(array(self::$configkey));;
/** @var FileLogger|\PHPUnit_Framework_MockObject_MockObject $FileLoggerHandler */
- $FileLoggerHandler = $this->getMockForAbstractClass('Sofort\SofortLib\FileLogger');
+ $FileLoggerHandler = $this->getMockForAbstractClass('Sofort\SofortLib\Logger\FileLogger');
$FileLoggerHandler->expects($this->any())->method('log')->with('log')->will($this->returnValue('log'));
$AbstractWrapperMock->setLogger($FileLoggerHandler);
@@ -481,7 +485,7 @@ public function testLogError()
/** @var AbstractWrapper $AbstractWrapperMock */
$AbstractWrapperMock = $this->getTestClass(array(self::$configkey));;
/** @var FileLogger|\PHPUnit_Framework_MockObject_MockObject $FileLoggerHandler */
- $FileLoggerHandler = $this->getMockForAbstractClass('Sofort\SofortLib\FileLogger');
+ $FileLoggerHandler = $this->getMockForAbstractClass('Sofort\SofortLib\Logger\FileLogger');
$FileLoggerHandler->expects($this->any())->method('log')->with('error')->will($this->returnValue('error'));
$AbstractWrapperMock->setLogger($FileLoggerHandler);
@@ -494,7 +498,7 @@ public function testLogWarning()
/** @var AbstractWrapper $AbstractWrapperMock */
$AbstractWrapperMock = $this->getTestClass(array(self::$configkey));;
/** @var FileLogger|\PHPUnit_Framework_MockObject_MockObject $FileLoggerHandler */
- $FileLoggerHandler = $this->getMockForAbstractClass('Sofort\SofortLib\FileLogger');
+ $FileLoggerHandler = $this->getMockForAbstractClass('Sofort\SofortLib\Logger\FileLogger');
$FileLoggerHandler->expects($this->any())->method('log')->with('warning')->will($this->returnValue('warning'));
$AbstractWrapperMock->setLogger($FileLoggerHandler);
@@ -508,7 +512,7 @@ public function testSendRequest()
/** @var AbstractWrapper $AbstractWrapperMock */
$AbstractWrapperMock = $this->getTestClass(array(self::$configkey));;
/** @var AbstractDataHandler|\PHPUnit_Framework_MockObject_MockObject $AbstractDataHandler */
- $AbstractDataHandler = $this->getMockForAbstractClass('Sofort\SofortLib\AbstractDataHandler',
+ $AbstractDataHandler = $this->getMockForAbstractClass('Sofort\SofortLib\DataHandler\AbstractDataHandler',
array(),
'',
false,
@@ -578,7 +582,7 @@ public function testSetDataHandler()
/** @var AbstractWrapper $AbstractWrapperMock */
$AbstractWrapperMock = $this->getTestClass(array(self::$configkey));;
/** @var AbstractDataHandler|\PHPUnit_Framework_MockObject_MockObject $AbstractDataHandler */
- $AbstractDataHandler = $this->getMockForAbstractClass('Sofort\SofortLib\AbstractDataHandler', array(), '',
+ $AbstractDataHandler = $this->getMockForAbstractClass('Sofort\SofortLib\DataHandler\AbstractDataHandler', array(), '',
false);
$AbstractWrapperMock->setDataHandler($AbstractDataHandler);
$this->assertEquals($AbstractDataHandler, $AbstractWrapperMock->getDataHandler());
@@ -647,7 +651,7 @@ public function testSetLogger()
/** @var AbstractWrapper $AbstractWrapperMock */
$AbstractWrapperMock = $this->getTestClass(array(self::$configkey));;
/** @var AbstractLoggerHandler $AbstractLoggerHandler */
- $AbstractLoggerHandler = $this->getMockForAbstractClass('Sofort\SofortLib\AbstractLoggerHandler');
+ $AbstractLoggerHandler = $this->getMockForAbstractClass('Sofort\SofortLib\Logger\AbstractLoggerHandler');
$AbstractWrapperMock->setLogger($AbstractLoggerHandler);
$this->assertAttributeEquals($AbstractLoggerHandler, '_Logger', $AbstractWrapperMock);
}
diff --git a/tests/unit/BillcodeTest.php b/tests/unit/BillcodeTest.php
index 581d0bd..f15c631 100644
--- a/tests/unit/BillcodeTest.php
+++ b/tests/unit/BillcodeTest.php
@@ -2,6 +2,8 @@
namespace Sofort\SofortLib;
+use Sofort\SofortLib\DataHandler\AbstractDataHandler;
+
class BillcodeTest extends TestWrapper
{
@@ -12,7 +14,7 @@ public function testCreateBillcode()
$validate_only = self::_getProperty('_validateOnly', $this->_classToTest);
$SofortLibBillcode = new Billcode(self::$configkey);
/** @var AbstractDataHandler $AbstractDataHandler */
- $AbstractDataHandler = $this->getMockForAbstractClass('Sofort\SofortLib\AbstractDataHandler',
+ $AbstractDataHandler = $this->getMockForAbstractClass('Sofort\SofortLib\DataHandler\AbstractDataHandler',
array(),
'',
false,
diff --git a/tests/unit/FileLoggerTest.php b/tests/unit/FileLoggerTest.php
index c23c06e..62fabfc 100644
--- a/tests/unit/FileLoggerTest.php
+++ b/tests/unit/FileLoggerTest.php
@@ -2,6 +2,8 @@
namespace Sofort\SofortLib;
+use Sofort\SofortLib\Logger\FileLogger;
+
class FileLoggerTest extends \PHPUnit_Framework_TestCase
{
@@ -17,7 +19,7 @@ public function testConstruct()
public function testLog()
{
/** @var FileLogger|\PHPUnit_Framework_MockObject_MockObject $stub */
- $stub = $this->getMock('\Sofort\SofortLib\FileLogger', array('_log'));
+ $stub = $this->getMock('\Sofort\SofortLib\Logger\FileLogger', array('_log'));
$stub->expects($this->at(0))->method('_log')->with('log')->will($this->returnValue('log'));
$this->assertEquals('log', $stub->log('log'));
diff --git a/tests/unit/HttpCurlTest.php b/tests/unit/HttpCurlTest.php
index 8e29fcd..ded2de8 100644
--- a/tests/unit/HttpCurlTest.php
+++ b/tests/unit/HttpCurlTest.php
@@ -2,6 +2,12 @@
namespace Sofort\SofortLib;
+use Sofort\SofortLib\Http\HttpCurl;
+
+if (!defined('SOFORTLIB_VERSION')) {
+ define('SOFORTLIB_VERSION', '3.0.0');
+}
+
class HttpCurlTest extends TestWrapper
{
@@ -9,7 +15,7 @@ public function testPost()
{
/** @var HttpCurl|\PHPUnit_Framework_MockObject_MockObject $MockPost */
$MockPost = $this->getMock(
- 'Sofort\SofortLib\HttpCurl',
+ 'Sofort\SofortLib\Http\HttpCurl',
array('_curlRequest'),
array('http://www.sofort.com', 'gzip', 'http://www.sofort.com')
);
diff --git a/tests/unit/HttpSocketTest.php b/tests/unit/HttpSocketTest.php
index 91b7ab1..586504b 100644
--- a/tests/unit/HttpSocketTest.php
+++ b/tests/unit/HttpSocketTest.php
@@ -2,6 +2,8 @@
namespace Sofort\SofortLib;
+use Sofort\SofortLib\Http\HttpSocket;
+
if (!defined('SOFORTLIB_VERSION')) {
define('SOFORTLIB_VERSION', '3.0.0');
}
@@ -33,7 +35,7 @@ public function testPost()
{
/** @var HttpSocket|\PHPUnit_Framework_MockObject_MockObject $MockPost */
$MockPost = $this->getMock(
- '\Sofort\SofortLib\HttpSocket',
+ '\Sofort\SofortLib\Http\HttpSocket',
array('_socketRequest'),
array(self::$testapi_url, 'gzip', 'http://www.sofort.com')
);
diff --git a/tests/unit/IdealTest.php b/tests/unit/IdealTest.php
index 2de67b2..1bb0e9e 100644
--- a/tests/unit/IdealTest.php
+++ b/tests/unit/IdealTest.php
@@ -107,9 +107,7 @@ public function testGetPaymentUrl()
$SofortIdeal->setSenderAccountNumber('2345678902');
$SofortIdeal->setSenderBankCode('31');
$SofortIdeal->setSenderCountryId('NL');
- $SofortIdeal->setSuccessUrl('http://www.google.de');
- $SofortIdeal->setAbortUrl('http://www.google.de');
- $SofortIdeal->setNotificationUrl('http://www.google.de');
+ $SofortIdeal->setLanguageCode('NL');
$SofortIdeal->setVersion('Framework 0.0.1');
$getPaymentUrl = $SofortIdeal->getPaymentUrl();
@@ -126,9 +124,9 @@ public function testGetPaymentUrl()
'user_variable_0' => '',
'user_variable_1' => '',
'user_variable_2' => '',
- 'user_variable_3' => 'http://www.google.de',
- 'user_variable_4' => 'http://www.google.de',
- 'user_variable_5' => 'http://www.google.de',
+ 'user_variable_3' => '',
+ 'user_variable_4' => '',
+ 'user_variable_5' => '',
);
$hashString = '';
@@ -144,8 +142,7 @@ public function testGetPaymentUrl()
. '&project_id=' . self::$project_id
. '&reason_1=Testzweck&reason_2=Testzweck4&amount=10'
. '&sender_account_number=2345678902&sender_bank_code=31&sender_country_id=NL'
- . '&user_variable_3=http%3A%2F%2Fwww.google.de&success_link_redirect=1&user_variable_4=http%3A%2F%2Fwww.google.de'
- . '&user_variable_5=http%3A%2F%2Fwww.google.de&interface_version=Framework+0.0.1'
+ . '&language_id=NL&interface_version=Framework+0.0.1'
. '&hash=' . $hashStringSha1;
$this->assertEquals($urlSha1, $getPaymentUrl);
@@ -157,9 +154,6 @@ public function testGetPaymentUrl()
$SofortIdeal->setSenderAccountNumber('2345678902');
$SofortIdeal->setSenderBankCode('31');
$SofortIdeal->setSenderCountryId('NL');
- $SofortIdeal->setSuccessUrl('http://www.google.de');
- $SofortIdeal->setAbortUrl('http://www.google.de');
- $SofortIdeal->setNotificationUrl('http://www.google.de');
$SofortIdeal->setVersion('Framework 0.0.1');
$getPaymentUrl = $SofortIdeal->getPaymentUrl();
@@ -169,8 +163,7 @@ public function testGetPaymentUrl()
. '&project_id=' . self::$project_id
. '&reason_1=Testzweck&reason_2=Testzweck4&amount=10'
. '&sender_account_number=2345678902&sender_bank_code=31&sender_country_id=NL'
- . '&user_variable_3=http%3A%2F%2Fwww.google.de&success_link_redirect=1&user_variable_4=http%3A%2F%2Fwww.google.de'
- . '&user_variable_5=http%3A%2F%2Fwww.google.de&interface_version=Framework+0.0.1'
+ . '&interface_version=Framework+0.0.1'
. '&hash=' . $hashStringMd5;
$this->assertEquals($urlMd5, $getPaymentUrl);
@@ -182,21 +175,17 @@ public function testGetPaymentUrl()
$SofortIdeal->setSenderAccountNumber('2345678902');
$SofortIdeal->setSenderBankCode('31');
$SofortIdeal->setSenderCountryId('NL');
- $SofortIdeal->setSuccessUrl('http://www.google.de');
- $SofortIdeal->setAbortUrl('http://www.google.de');
- $SofortIdeal->setNotificationUrl('http://www.google.de');
$SofortIdeal->setVersion('Framework 0.0.1');
$getPaymentUrl = $SofortIdeal->getPaymentUrl();
- $urlWuselschnusel = 'https://www.sofort.com/payment/ideal?'
+ $startUrl = 'https://www.sofort.com/payment/ideal?'
. 'user_id=' . self::$user_id
. '&project_id=' . self::$project_id
. '&reason_1=Testzweck&reason_2=Testzweck4&amount=10'
. '&sender_account_number=2345678902&sender_bank_code=31&sender_country_id=NL'
- . '&user_variable_3=http%3A%2F%2Fwww.google.de&success_link_redirect=1&user_variable_4=http%3A%2F%2Fwww.google.de'
- . '&user_variable_5=http%3A%2F%2Fwww.google.de&interface_version=Framework+0.0.1'
+ . '&interface_version=Framework+0.0.1'
. '&hash=';
- $this->assertEquals($urlWuselschnusel, $getPaymentUrl);
+ $this->assertEquals($startUrl, $getPaymentUrl);
$SofortIdeal = new Ideal(self::$ideal_configkey, self::$ideal_password, 'sha256');
$this->assertAttributeEquals(strtolower('sha256'), '_hashFunction', $SofortIdeal);
@@ -206,10 +195,36 @@ public function testGetPaymentUrl()
$SofortIdeal->setSenderAccountNumber('2345678902');
$SofortIdeal->setSenderBankCode('31');
$SofortIdeal->setSenderCountryId('NL');
- $SofortIdeal->setSuccessUrl('http://www.google.de');
- $SofortIdeal->setAbortUrl('http://www.google.de');
- $SofortIdeal->setNotificationUrl('http://www.google.de');
+ $SofortIdeal->setUserVariable('User-Var1');
+ $SofortIdeal->setUserVariable('User-Var2');
+ $SofortIdeal->setUserVariable('User-Var3');
$SofortIdeal->setVersion('Framework 0.0.1');
+
+ $hashFields = array(
+ 'user_id' => self::$ideal_userid,
+ 'project_id' => self::$ideal_projectid,
+ 'sender_holder' => '',
+ 'sender_account_number' => '2345678902',
+ 'sender_bank_code' => '31',
+ 'sender_country_id' => 'NL',
+ 'amount' => 10,
+ 'reason_1' => 'Testzweck',
+ 'reason_2' => 'Testzweck4',
+ 'user_variable_0' => 'User-Var1',
+ 'user_variable_1' => 'User-Var2',
+ 'user_variable_2' => 'User-Var3',
+ 'user_variable_3' => '',
+ 'user_variable_4' => '',
+ 'user_variable_5' => '',
+ );
+ $hashString = '';
+
+ foreach ($hashFields as $value) {
+ $hashString .= $value;
+ $hashString .= '|';
+ }
+
+ $hashString .= self::$ideal_password;
$getPaymentUrl = $SofortIdeal->getPaymentUrl();
$hashStringSha256 = hash('Sha256', $hashString);
@@ -218,39 +233,13 @@ public function testGetPaymentUrl()
. '&project_id=' . self::$project_id
. '&reason_1=Testzweck&reason_2=Testzweck4&amount=10'
. '&sender_account_number=2345678902&sender_bank_code=31&sender_country_id=NL'
- . '&user_variable_3=http%3A%2F%2Fwww.google.de&success_link_redirect=1&user_variable_4=http%3A%2F%2Fwww.google.de'
- . '&user_variable_5=http%3A%2F%2Fwww.google.de&interface_version=Framework+0.0.1'
+ . '&user_variable_0=User-Var1&user_variable_1=User-Var2&user_variable_2=User-Var3'
+ . '&interface_version=Framework+0.0.1'
. '&hash=' . $hashStringSha256;
$this->assertEquals($urlSha256, $getPaymentUrl);
}
- /**
- * @dataProvider providerSetAbortUrl
- * @param string $provided
- */
- public function testSetAbortUrl($provided)
- {
- $SofortIdeal = new Ideal(self::$ideal_configkey, self::$ideal_password);
- $SofortIdeal->setAbortUrl($provided);
- $received = $SofortIdeal->getParameters();
- $this->assertEquals($provided, $received['user_variable_4']);
- }
-
-
- /**
- * @dataProvider providerSetNotificationUrl
- * @param string $provided
- */
- public function testSetNotificationUrl($provided)
- {
- $SofortIdeal = new Ideal(self::$ideal_configkey, self::$ideal_password);
- $SofortIdeal->setNotificationUrl($provided);
- $received = $SofortIdeal->getParameters();
- $this->assertEquals($provided, $received['user_variable_5']);
- }
-
-
/**
* @dataProvider providerSetReason
* @param array $provided
@@ -314,17 +303,4 @@ public function testSetSenderHolder($provided)
$received = $SofortIdeal->getParameters();
$this->assertEquals($provided, $received['sender_holder']);
}
-
-
- /**
- * @dataProvider providerSetSuccessUrl
- * @param string $provided
- */
- public function testSetSuccessUrl($provided)
- {
- $SofortIdeal = new Ideal(self::$ideal_configkey, self::$ideal_password);
- $SofortIdeal->setSuccessUrl($provided);
- $received = $SofortIdeal->getParameters();
- $this->assertEquals($provided, $received['user_variable_3']);
- }
}
\ No newline at end of file
diff --git a/tests/unit/PaycodeDetailsAbstractTest.php b/tests/unit/PaycodeDetailsAbstractTest.php
index 1cf0ec1..251d198 100644
--- a/tests/unit/PaycodeDetailsAbstractTest.php
+++ b/tests/unit/PaycodeDetailsAbstractTest.php
@@ -2,6 +2,8 @@
namespace Sofort\SofortLib;
+use Sofort\SofortLib\DataHandler\AbstractDataHandler;
+
/**
* Class constructed just to test the methods of the abstract class
* @author mm
@@ -315,7 +317,7 @@ public function testSendRequest()
$SofortLibPaycodeDetailsAbstractMock = new PaycodeDetailsAbstractMock(self::$configkey);
$validate_only = self::_getProperty('_validateOnly', $this->_classToTest);
/** @var AbstractDataHandler $AbstractDataHandler */
- $AbstractDataHandler = $this->getMockForAbstractClass('Sofort\SofortLib\AbstractDataHandler',
+ $AbstractDataHandler = $this->getMockForAbstractClass('Sofort\SofortLib\DataHandler\AbstractDataHandler',
array(),
'',
false,
diff --git a/tests/unit/PaycodeTest.php b/tests/unit/PaycodeTest.php
index f3b43ab..253f181 100644
--- a/tests/unit/PaycodeTest.php
+++ b/tests/unit/PaycodeTest.php
@@ -2,6 +2,8 @@
namespace Sofort\SofortLib;
+use Sofort\SofortLib\DataHandler\AbstractDataHandler;
+
class PaycodeTest extends TestWrapper
{
@@ -12,7 +14,7 @@ public function testCreatePaycode()
$validate_only = self::_getProperty('_validateOnly', $this->_classToTest);
$SofortLibPaycode = new Paycode(self::$configkey);
/** @var AbstractDataHandler $AbstractDataHandler */
- $AbstractDataHandler = $this->getMockForAbstractClass('Sofort\SofortLib\AbstractDataHandler',
+ $AbstractDataHandler = $this->getMockForAbstractClass('Sofort\SofortLib\DataHandler\AbstractDataHandler',
array(),
'',
false,
diff --git a/tests/unit/SofortUeberweisungTest.php b/tests/unit/SofortUeberweisungTest.php
index 832de04..b3f0f87 100644
--- a/tests/unit/SofortUeberweisungTest.php
+++ b/tests/unit/SofortUeberweisungTest.php
@@ -2,6 +2,8 @@
namespace Sofort\SofortLib;
+use Sofort\SofortLib\DataHandler\XmlDataHandler;
+
class SofortueberweisungTest extends TestWrapper
{
@@ -347,7 +349,7 @@ public function testParser()
$XmlDataHandler = new XmlDataHandler(self::$configkey);
//mock http
- $http = $this->getMock('Sofort\SofortLib\AbstractHttp', array('post'), array(self::$testapi_url));
+ $http = $this->getMock('Sofort\SofortLib\Http\AbstractHttp', array('post'), array(self::$testapi_url));
$http->expects($this->any())->method('post')->will($this->returnArgument(0));
$XmlDataHandler->setConnection($http);
diff --git a/tests/unit/TransactionDataTest.php b/tests/unit/TransactionDataTest.php
index 1656e2c..4eff83a 100644
--- a/tests/unit/TransactionDataTest.php
+++ b/tests/unit/TransactionDataTest.php
@@ -1404,6 +1404,19 @@ public function providerSetStatus()
}
+ public function providerSetProduct()
+ {
+ return array(
+ array(
+ array(
+ 'payment',
+ 'paycode',
+ )
+ )
+ );
+ }
+
+
public function providerSetStatusModifiedTime()
{
return array(
@@ -2826,6 +2839,22 @@ public function testSetStatus($provided)
}
+ /**
+ * @dataProvider providerSetProduct
+ * @param $provided
+ */
+ public function testSetProduct($provided)
+ {
+ $SofortLibTransactionData = new TransactionData(self::$configkey);
+
+ foreach ($provided as $product) {
+ $SofortLibTransactionData->setProduct($product);
+ $received = $SofortLibTransactionData->getParameters();
+ $this->assertEquals($product, $received['product']);
+ }
+ }
+
+
/**
* @dataProvider providerSetStatusModifiedTime
* @param $provided