function onPaymentNotification(&$statuses)
 {
     $this->pluginParams();
     $configKey = $this->plugin_params->user_id . ':' . $this->plugin_params->project_id . ':' . $this->plugin_params->token;
     require_once dirname(__FILE__) . '/library/sofortLib.php';
     $notification = new SofortLib_Notification();
     $notification->getNotification();
     echo $notification->getTime();
     $transactionId = $notification->getTransactionId();
     //$return_url = HIKASHOP_LIVE.'index.php?option=com_hikashop&ctrl=checkout&task=after_end&order_id='.$order_id.$this->url_itemid;
     // fetch some information for the transaction id retrieved above
     $transactionData = new SofortLib_TransactionData($configKey);
     $transactionData->setTransaction($transactionId);
     $transactionData->sendRequest();
     $method_id = $transactionData->getUserVariable(1);
     $this->pluginParams($method_id);
     $this->payment_params =& $this->plugin_params;
     global $Itemid;
     $this->url_itemid = empty($Itemid) ? '' : '&Itemid=' . $Itemid;
     $cancel_url = HIKASHOP_LIVE . 'index.php?option=com_hikashop&ctrl=order&task=cancel_order' . $this->url_itemid;
     if (empty($this->payment_params)) {
         $this->redirect($cancel_url);
         return false;
     }
     $order_id = $transactionData->getUserVariable(0);
     echo $order_id;
     $dbOrder = $this->getOrder($order_id);
     if (empty($dbOrder)) {
         $this->redirect_url = $cancel_url;
         return false;
     }
     $history = new stdClass();
     $history->history_data = 'TransactionId: ' . $transactionId;
     $history->notified = 0;
     if ($transactionData->getStatus() == 'pending') {
         $email = new stdClass();
         $email->subject = JText::sprintf('PAYMENT_NOTIFICATION_FOR_ORDER', 'Sofort', $transactionData->getStatus(), $dbOrder->order_number);
         $email->body = str_replace('<br/>', "\r\n", JText::sprintf('PAYMENT_NOTIFICATION_STATUS', 'Sofort', $transactionData->getStatus())) . "\r\n\r\n" . $transactionData->getStatusReason();
         $action = false;
         $order_status = $this->payment_params->pending_status;
         $this->modifyOrder($order_id, $order_status, $history, $email);
         return false;
     }
     if ($transactionData->getStatus() != 'received') {
         $order_status = 'created';
         $email = new stdClass();
         $email->body = str_replace('<br/>', "\r\n", JText::sprintf('PAYMENT_NOTIFICATION_STATUS', 'Sofort', $order_status)) . ' ' . JText::_('STATUS_NOT_CHANGED') . "\r\n\r\n" . $transactionData->getStatusReason();
         $email->subject = JText::sprintf('PAYMENT_NOTIFICATION_FOR_ORDER', 'Sofort', $order_status, $dbOrder->order_number);
         $this->modifyOrder($order_id, $order_status, $history, $email);
         return false;
     }
     $order_status = $this->payment_params->verified_status;
     $history->history_data = 'TransactionId: ' . $transactionId;
     $history->notified = 1;
     $email = new stdClass();
     $email->subject = JText::sprintf('PAYMENT_NOTIFICATION_FOR_ORDER', 'Sofort', $transactionData->getStatus(), $dbOrder->order_number);
     $email->body = str_replace('<br/>', "\r\n", JText::sprintf('PAYMENT_NOTIFICATION_STATUS', 'Sofort', $order_status)) . ' ' . JText::sprintf('ORDER_STATUS_CHANGED', $order_status) . "\r\n\r\n" . $transactionData->getStatusReason();
     $this->modifyOrder($order_id, $order_status, $history, $email);
     return true;
 }
function sofort_ipn()
{
    global $edd_options;
    if (isset($_GET['sofort']) && $_GET['sofort'] == 'ipn') {
        require_once 'library/sofortLib.php';
        $notification = new SofortLib_Notification();
        $notification->getNotification();
        $transactionId = $notification->getTransactionId();
        if ($transactionId) {
            // fetch some information for the transaction id retrieved above
            $transactionData = new SofortLib_TransactionData(trim($edd_options['sofort_config_id']));
            $transactionData->setTransaction($transactionId);
            $transactionData->sendRequest();
            $reason = $transactionData->getReason();
            $payment_id = str_replace('CartId ', '', $reason[0]);
            edd_update_payment_status($payment_id, 'publish');
            edd_insert_payment_note($payment_id, 'Payment Successful. Transaction ID is ' . $transactionId);
        }
        exit;
    }
}
 /**
  * Construct the SofortLib_TransactionData object
  * Collect every order's item and set it accordingly
  * TransactionData is used encapsulated in this class to retrieve information about the order's details
  * @return object SofortLib_TransactionData
  * @private
  */
 private function _setupTransactionData()
 {
     $SofortLib_TransactionData = new SofortLib_TransactionData($this->_configKey, $this->_apiUrl);
     $SofortLib_TransactionData->setTransaction($this->_transactionId);
     $SofortLib_TransactionData->sendRequest();
     if (!$SofortLib_TransactionData->getCount()) {
         return false;
     }
     $this->setStatus($SofortLib_TransactionData->getStatus());
     $this->setStatusReason($SofortLib_TransactionData->getStatusReason());
     $this->setStatusOfInvoice($SofortLib_TransactionData->getInvoiceStatus());
     $this->setInvoiceObjection($SofortLib_TransactionData->getInvoiceObjection());
     $this->setLanguageCode($SofortLib_TransactionData->getLanguageCode());
     $this->setTransaction($this->getTransactionId());
     $this->setTime($SofortLib_TransactionData->getTime());
     $this->setPaymentMethod($SofortLib_TransactionData->getPaymentMethod());
     $this->setInvoiceUrl($SofortLib_TransactionData->getInvoiceUrl());
     $this->setAmount($SofortLib_TransactionData->getAmount());
     $this->setAmountRefunded($SofortLib_TransactionData->getAmountRefunded());
     $itemArray = $SofortLib_TransactionData->getItems();
     // should there be any items, fetch them accordingly
     $this->_items = array();
     if (is_array($itemArray) && !empty($itemArray)) {
         foreach ($itemArray as $item) {
             $this->setItem($item['item_id'], $item['product_number'], $item['product_type'], $item['title'], $item['description'], $item['quantity'], $item['unit_price'], $item['tax']);
             $this->_amount += $item['unit_price'] * $item['quantity'];
         }
     }
     /*
      * set the state according to the state given by transaction information (status, status_reason, invoice_status)
      * @see $statusMask
      */
     $this->setState($this->_calcInvoiceStatusCode());
     return $SofortLib_TransactionData;
 }
 public function getLastTransactions($limit = null)
 {
     $from = date(FORMAT_DB_DATE, time() - DAY);
     $to = date(FORMAT_DB_DATE);
     //die(returns($this->settings));
     $transactionDataObj = new SofortLib_TransactionData($this->_configKey());
     $transactionDataObj->setTime($from, $to);
     if ($limit) {
         $transactionDataObj->setNumber($limit);
     }
     $res = $transactionDataObj->sendRequest();
     if (!empty($res->errors)) {
         trigger_error(returns($this->errors));
         return false;
     }
     return $transactionDataObj->getTransaction(0);
 }
Exemple #5
0
 private function _setupTransactionData()
 {
     $SofortLib_TransactionData = new SofortLib_TransactionData($this->_configKey, $this->_apiUrl);
     $SofortLib_TransactionData->setTransaction($this->_transactionId);
     $SofortLib_TransactionData->sendRequest();
     if (!$SofortLib_TransactionData->getCount()) {
         return false;
     }
     $this->setStatus($SofortLib_TransactionData->getStatus());
     $this->setStatusReason($SofortLib_TransactionData->getStatusReason());
     $this->setStatusOfInvoice($SofortLib_TransactionData->getInvoiceStatus());
     $this->setInvoiceObjection($SofortLib_TransactionData->getInvoiceObjection());
     $this->setLanguageCode($SofortLib_TransactionData->getLanguageCode());
     $this->setTransaction($this->getTransactionId());
     $this->setTime($SofortLib_TransactionData->getTime());
     $this->setPaymentMethod($SofortLib_TransactionData->getPaymentMethod());
     $this->setInvoiceUrl($SofortLib_TransactionData->getInvoiceUrl());
     $this->setAmount($SofortLib_TransactionData->getAmount());
     $this->setAmountRefunded($SofortLib_TransactionData->getAmountRefunded());
     $itemArray = $SofortLib_TransactionData->getItems();
     $this->_items = array();
     if (is_array($itemArray) && !empty($itemArray)) {
         foreach ($itemArray as $item) {
             $this->setItem($item['item_id'], $item['product_number'], $item['product_type'], $item['title'], $item['description'], $item['quantity'], $item['unit_price'], $item['tax']);
             $this->_amount += $item['unit_price'] * $item['quantity'];
         }
     }
     $this->setState($this->_calcInvoiceStatusCode());
     return $SofortLib_TransactionData;
 }
/**
 * Copyright (c) 2012 SOFORT AG
 * 
 * Released under the GNU General Public License (Version 2)
 * [http://www.gnu.org/licenses/gpl-2.0.html]
 *
 * $Date$
 * @version SofortLib 1.5.0rc  $Id$
 * @author SOFORT AG http://www.sofort.com (integration@sofort.com)
 *
 */
// read the notification from php://input  (http://php.net/manual/en/wrappers.php.php)
// this class should be used as a callback function
require_once '../../library/sofortLib.php';
$notification = new SofortLib_Notification();
$notification->getNotification();
echo $notification->getTime();
$transactionId = $notification->getTransactionId();
// fetch some information for the transaction id retrieved above
$transactionData = new SofortLib_TransactionData();
$transactionData->setTransaction($transactionId);
$transactionData->sendRequest();
echo '<table border="1">';
echo '<tr><td>transaction was: </td><td align="right">' . $transactionData->getTransaction() . '</td></tr>';
echo '<tr><td>start date is: </td><td align="right">' . $transactionData->getSofortaboStartDate() . '</td></tr>';
echo '<tr><td>amount is: </td><td align="right">' . $transactionData->getAmount() . ' ' . $transactionData->getCurrency() . '</td></tr>';
echo '<tr><td>interval is: </td><td align="right">' . $transactionData->getSofortaboInterval() . '</td></tr>';
echo '<tr><td>minimum payments: </td><td align="right">' . $transactionData->getSofortaboMinimumPayments() . '</td></tr>';
echo '<tr><td>status is: </td><td align="right">' . $transactionData->getStatus() . ' - ' . $transactionData->getStatusReason() . '</td></tr>';
echo '</table>';
<?php

/**
 * Copyright (c) 2012 SOFORT AG
 * 
 * Released under the GNU General Public License (Version 2)
 * [http://www.gnu.org/licenses/gpl-2.0.html]
 *
 * $Date: 2012-11-21 12:02:12 +0100 (Wed, 21 Nov 2012) $
 * @version SofortLib 1.5.0rc  $Id: example_transactionData.php 5724 2012-11-21 11:02:12Z rotsch $
 * @author SOFORT AG http://www.sofort.com (integration@sofort.com)
 *
 */
require_once '../../library/sofortLib.php';
define('CONFIGKEY', '12345:67890:123456789abcdef123456abcdef12345');
//your configkey or userid:projektid:apikey
$sofort = new SofortLib_TransactionData(CONFIGKEY);
// use an array of transactionIDs (or set a single transactionID if you like, just pass a string to setTransaction)
$transactionIds[] = '16263-99178-4E019D4F-5E12';
$transactionIds[] = '16263-99178-4E01B143-5E25';
$sofort->setTransaction($transactionIds);
// or simply add a single transactionID, using addTransaction (you could easily add an array of transactionIDs as well!)
$singleTransactionId = '16263-99178-4E01B5E0-1ACD';
$sofort->addTransaction($singleTransactionId);
$sofort->sendRequest();
// get the information you need, depends on what transaction you where looking for...
echo 'Amount: ' . $sofort->getAmount(0) . "<br />";
echo 'Status: ' . $sofort->getStatus(0);
 /**
  * This action handles the asynchronous callbacks
  * The sofortLib is used to obtain data about
  */
 public function notifyAction()
 {
     Shopware()->Plugins()->Controller()->ViewRenderer()->setNoRender();
     $helper = new Shopware_Plugins_Frontend_SofortPayment_Components_Helpers_Helper();
     $configKey = $helper->option()->getConfigKey("sofortbanking");
     //Step 3: Handling Notifications about status changes
     $notification = $helper->library()->getNotificationInstance();
     $notification->setLogger(new Shopware_Plugins_Frontend_SofortPayment_Components_Services_Logger());
     $notification->setLogEnabled();
     $notification->getNotification();
     $transactionId = $notification->getTransactionId();
     //Step 4: Inquire changed Transactiondata
     $transactionData = new SofortLib_TransactionData($configKey);
     $transactionData->setTransaction($transactionId);
     $transactionData->sendRequest();
     //Step 5: Handling the Response to the Inquiry for changed Transaction Data
     $orderId = $helper->database()->getOrderByTransactionId($transactionId);
     $state = $this->convertLibState($transactionData->getStatus(), $transactionData->getStatusReason());
     $order = Shopware()->Modules()->Order();
     if ($state != 0) {
         $order->setPaymentStatus($orderId, $state, false);
         $order->setOrderStatus($orderId, 0, false);
     }
 }