public function initContent() { $log = null; $this->display_header = false; $this->display_footer = false; parent::initContent(); $transaction = Tools::getValue('transaction'); if (Tools::isEmpty($transaction)) { die(Tools::displayError('Wrong use of the HTTP notifications. Please set up your sofortüberweisung.de notification to call this URL only with POST method.')); } $orderState = _PS_OS_PAYMENT_; $baseDir = dirname(__FILE__); $useSSL = true; // Get class instance $su = new Sofortueberweisung(); // Set order state to "awaiting payment" $orderState = Configuration::get('_SU_OS_OK_'); $cartId = 0; // Check incoming response if ($su->checkResponse($_POST, $log)) { // Get cartId from the response $cartId = (int) Tools::getValue('user_variable_0'); // Get the cart object $cart = new Cart($cartId); // Get the customer object $customer = new Customer((int) $cart->id_customer); // Get order sum $orderSum = (double) Tools::getValue('amount'); $currency_special = $cart->id_currency; $message = 'Payment through Sofortüberweisung.de - Transaction-ID: ' . $transaction . ' '; $secure_key = $customer->secure_key; // Create order $su->updateOrder($cartId, $orderState, $orderSum, $message, $currency_special, $secure_key); } }
public function initContent() { $this->display_column_left = false; $this->display_column_right = false; parent::initContent(); $this->context = $this->context; if (!isset($this->context->customer) || !$this->context->customer->isLogged(true)) { Tools::redirect($this->context->link->getPageLink('authentication', true, (int) $this->context->language->id, array('back' => $this->context->link->getPageLink('order', true, (int) $this->context->language->id)))); } $su = new Sofortueberweisung(); $this->context->smarty->assign($su->execPayment($this->context->cart)); $this->setTemplate('tpl-frontend-redirect.tpl'); }
/** * @dataProvider reasonProvider */ public function testSetReason($provided, $expected) { $Sofortueberweisung = new Sofortueberweisung(self::$configkey); $Sofortueberweisung->setReason($provided[0], $provided[1]); $this->assertEquals($expected, $Sofortueberweisung->getReason()); }
/** * @dataProvider providerSetVersion $provided */ public function testSetVersion($provided) { $Sofortueberweisung = new Sofortueberweisung(self::$configkey); $Sofortueberweisung->setVersion($provided); $received = $Sofortueberweisung->getParameters(); $this->assertEquals($provided, $received['interface_version']); }
<?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); }
<?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:123456:edc788a4316ce7e2ac0ede037aa623d7'; $Sofortueberweisung = new Sofortueberweisung($configkey); $Sofortueberweisung->setAmount(10.21); $Sofortueberweisung->setCurrencyCode('EUR'); $Sofortueberweisung->setReason('Testueberweisung', 'Verwendungszweck'); $Sofortueberweisung->setSuccessUrl('http://www.google.de', true); $Sofortueberweisung->setAbortUrl('http://www.google.de'); $Sofortueberweisung->setNotificationUrl('http://www.google.de'); // $Sofortueberweisung->setSenderSepaAccount('SFRTDE20XXX', 'DE06000000000023456789', 'Max Mustermann'); // $Sofortueberweisung->setSenderCountryCode('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->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); }
<?php namespace Sofort\SofortLib; require __DIR__ . '/../vendor/autoload.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->setReason('Testueberweisung', 'Verwendungszweck'); $Sofortueberweisung->setSuccessUrl('YOUR_SUCCESS_URL', true); // i.e. http://my.shop/order/success $Sofortueberweisung->setAbortUrl('YOUR_ABORT_URL'); // $Sofortueberweisung->setSenderSepaAccount('SFRTDE20XXX', 'DE06000000000023456789', 'Max Mustermann'); // $Sofortueberweisung->setSenderCountryCode('DE'); // $Sofortueberweisung->setNotificationUrl('YOUR_NOTIFICATION_URL', 'loss,pending'); // $Sofortueberweisung->setNotificationUrl('YOUR_NOTIFICATION_URL', 'loss'); // $Sofortueberweisung->setNotificationUrl('YOUR_NOTIFICATION_URL', 'pending'); // $Sofortueberweisung->setNotificationUrl('YOUR_NOTIFICATION_URL', 'received'); // $Sofortueberweisung->setNotificationUrl('YOUR_NOTIFICATION_URL', 'refunded'); $Sofortueberweisung->setNotificationUrl('YOUR_NOTIFICATION_URL'); //$Sofortueberweisung->setCustomerprotection(true); $Sofortueberweisung->sendRequest(); if ($Sofortueberweisung->isError()) { // SOFORT-API didn't accept the data echo $Sofortueberweisung->getError(); } else { // get unique transaction-ID useful for check payment status $transactionId = $Sofortueberweisung->getTransactionId();
/** * (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; }