public function testParser()
    {
        $Sofortueberweisung = new Sofortueberweisung(self::$configkey);
        $Sofortueberweisung->setConfigKey(self::$configkey);
        $XmlDataHandler = new XmlDataHandler(self::$configkey);
        //mock http
        $http = $this->getMock('SofortLibHttp', array('post'), array(self::$testapi_url));
        //$http = new SofortLibHttp('https://mattzick.user.pag/payment/api/xml');
        $http->expects($this->any())->method('post')->will($this->returnArgument(0));
        $XmlDataHandler->setConnection($http);
        $Sofortueberweisung->setAmount(10.21);
        $Sofortueberweisung->setCurrencyCode('EUR');
        $Sofortueberweisung->setSenderAccount('88888888', '12345678', 'Max Mustermann');
        $Sofortueberweisung->setReason('Testueberweisung', 'Verwendungszweck');
        $Sofortueberweisung->setSuccessUrl('http://www.google.de', true);
        $Sofortueberweisung->setAbortUrl('http://www.google.de');
        $Sofortueberweisung->setNotificationUrl('http://www.google.de');
        $data = $Sofortueberweisung->getData();
        /* hand over data */
        $Sofortueberweisung->setDataHandler($XmlDataHandler)->getDataHandler()->handle($data);
        // assert we have a good looking result
        $result = $Sofortueberweisung->getDataHandler()->getRequest();
        $expected = '<?xml version="1.0" encoding="UTF-8" ?>
<multipay version="1.0"><su /><amount>10.21</amount><currency_code>EUR</currency_code><sender><bank_code>88888888</bank_code><account_number>12345678</account_number><holder>Max Mustermann</holder></sender><reasons><reason>Testueberweisung</reason><reason>Verwendungszweck</reason></reasons><success_url>http://www.google.de</success_url><success_link_redirect>1</success_link_redirect><abort_url>http://www.google.de</abort_url><notification_urls><notification_url>http://www.google.de</notification_url></notification_urls><project_id>' . self::$project_id . '</project_id></multipay>';
        $this->assertEquals($expected, $result);
    }
 /**
  * (non-PHPdoc)
  * @see IActionController::executeAction()
  */
 public function executeAction($parameters)
 {
     $configKey = trim($this->_websoccer->getConfig("sofortcom_configkey"));
     if (!strlen($configKey)) {
         // user should actually not come here, hence no i18n
         throw new Exception("Sofort.com configuration key is not configured.");
     }
     // verify amount (check if specified in options)
     $amount = $parameters['amount'];
     $priceOptions = explode(',', $this->_websoccer->getConfig('premium_price_options'));
     $validAmount = FALSE;
     if (count($priceOptions)) {
         foreach ($priceOptions as $priceOption) {
             $optionParts = explode(':', $priceOption);
             $realMoney = trim($optionParts[0]);
             // credit amount and end here
             if ($amount == $realMoney) {
                 $validAmount = TRUE;
             }
         }
     }
     if (!$validAmount) {
         // amount comes actually from a selection list, hence can be invalid only by cheating -> no i18n
         throw new Exception("Invalid amount");
     }
     // create transaction model
     $Sofortueberweisung = new Sofortueberweisung($configKey);
     $abortOrSuccessUrl = $this->_websoccer->getInternalUrl('premiumaccount', null, TRUE);
     // use actual notify url
     $notifyUrl = $this->_websoccer->getInternalActionUrl('sofortcom-notify', 'u=' . $this->_websoccer->getUser()->id, 'home', TRUE);
     $Sofortueberweisung->setAmount($amount);
     $Sofortueberweisung->setCurrencyCode($this->_websoccer->getConfig("premium_currency"));
     $Sofortueberweisung->setReason($this->_websoccer->getConfig("projectname"));
     $Sofortueberweisung->setSuccessUrl($abortOrSuccessUrl, true);
     $Sofortueberweisung->setAbortUrl($abortOrSuccessUrl);
     $Sofortueberweisung->setNotificationUrl($notifyUrl, 'received');
     $Sofortueberweisung->sendRequest();
     if ($Sofortueberweisung->isError()) {
         throw new Exception($Sofortueberweisung->getError());
     } else {
         // redirect to payment url
         $paymentUrl = $Sofortueberweisung->getPaymentUrl();
         header('Location: ' . $paymentUrl);
         exit;
     }
     return null;
 }
<?php

require_once dirname(__FILE__) . '/../payment/sofortLibSofortueberweisung.inc.php';
// enter your configuration key – you only can create a new configuration key by creating
// a new Gateway project in your account at sofort.com
$configkey = '12345:12345:5dbdad2bc861d907eedfd9528127d002';
$Sofortueberweisung = new Sofortueberweisung($configkey);
$Sofortueberweisung->setAmount(10.21);
$Sofortueberweisung->setCurrencyCode('EUR');
$Sofortueberweisung->setSenderSepaAccount('88888888', '12345678', 'Max Mustermann');
$Sofortueberweisung->setSenderCountryCode('DE');
$Sofortueberweisung->setReason('Testueberweisung', 'Verwendungszweck');
$Sofortueberweisung->setSuccessUrl('http://www.google.de', true);
$Sofortueberweisung->setAbortUrl('http://www.google.de');
// $Sofortueberweisung->setNotificationUrl('http://www.google.de', 'loss,pending');
// $Sofortueberweisung->setNotificationUrl('http://www.yahoo.com', 'loss');
// $Sofortueberweisung->setNotificationUrl('http://www.bing.com', 'pending');
// $Sofortueberweisung->setNotificationUrl('http://www.sofort.com', 'received');
// $Sofortueberweisung->setNotificationUrl('http://www.youtube.com', 'refunded');
// $Sofortueberweisung->setNotificationUrl('http://www.youtube.com', 'untraceable');
$Sofortueberweisung->setNotificationUrl('http://www.twitter.com');
$Sofortueberweisung->setCustomerprotection(true);
$Sofortueberweisung->sendRequest();
if ($Sofortueberweisung->isError()) {
    //SOFORT-API didn't accept the data
    echo $Sofortueberweisung->getError();
} else {
    //buyer must be redirected to $paymentUrl else payment cannot be successfully completed!
    $paymentUrl = $Sofortueberweisung->getPaymentUrl();
    header('Location: ' . $paymentUrl);
}