/**
  * (non-PHPdoc)
  * @see IActionController::executeAction()
  */
 public function executeAction($parameters)
 {
     $configKey = trim($this->_websoccer->getConfig("sofortcom_configkey"));
     if (!strlen($configKey)) {
         throw new Exception("Sofort.com configuration key is not configured.");
     }
     // verify user
     $userId = $parameters['u'];
     $result = $this->_db->querySelect("id", $this->_websoccer->getConfig("db_prefix") . "_user", "id = %d", $userId);
     $user = $result->fetch_array();
     $result->free();
     if (!$user) {
         throw new Exception("illegal user id");
     }
     // read the notification from php://input  (http://php.net/manual/en/wrappers.php.php)
     $SofortLib_Notification = new SofortLibNotification();
     $TestNotification = $SofortLib_Notification->getNotification(file_get_contents('php://input'));
     // read data
     $SofortLibTransactionData = new SofortLibTransactionData($configKey);
     $SofortLibTransactionData->addTransaction($TestNotification);
     // verify transaction data
     $SofortLibTransactionData->sendRequest();
     if ($SofortLibTransactionData->isError()) {
         EmailHelper::sendSystemEmail($this->_websoccer, $this->_websoccer->getConfig("systememail"), "Failed Sofort.com payment notification", "Error: " . $SofortLibTransactionData->getError());
         throw new Exception($SofortLibTransactionData->getError());
     } else {
         // verify status
         if ($SofortLibTransactionData->getStatus() != 'received') {
             EmailHelper::sendSystemEmail($this->_websoccer, $this->_websoccer->getConfig("systememail"), "Failed Sofort.com payment notification: invalid status", "Status: " . $SofortLibTransactionData->getStatus());
             throw new Exception("illegal status");
         }
         // credit amount
         $amount = $SofortLibTransactionData->getAmount();
         PremiumDataService::createPaymentAndCreditPremium($this->_websoccer, $this->_db, $userId, $amount, "sofortcom-notify");
     }
     return null;
 }
 /**
  * Process the callback data from the payment provider
  */
 public function callback($request)
 {
     $this->extend('onBeforeCallback');
     $data = $this->request->postVars();
     $status = "error";
     $key = $this->payment_gateway->ConfigKey;
     $content = file_get_contents('php://input');
     // Check if CallBack data exists and install id matches the saved ID
     if (isset($content)) {
         $notification = new SofortLibNotification();
         $transaction_id = $notification->getNotification($content);
         $sofort = new SofortLibTransactionData($key);
         $sofort->addTransaction($transaction_id);
         $sofort->sendRequest();
         switch ($sofort->getStatus()) {
             case 'received':
                 $status = "paid";
                 break;
             case 'loss':
                 $status = "failed";
                 break;
             case 'pending':
                 $status = "pending";
                 break;
             case 'refunded':
                 $status = "refunded";
                 break;
             default:
                 $status = "error";
         }
         $payment_data = ArrayData::array_to_object(array("OrderID" => 0, "PaymentProvider" => "Sofort", "PaymentID" => $notification->getTransactionId(), "Status" => $status, "GatewayData" => $data));
         $this->setPaymentData($payment_data);
         $this->extend('onAfterCallback');
         return $this->renderWith(array("Sofort_callback", "Checkout", "Page"));
     }
     return $this->httpError(500);
 }
Пример #3
0
 /**
  * Get sofort status with reason
  * 
  * @return array
  */
 public function getStatusData($rawBody)
 {
     $transactionData = array('status' => 'undefined', 'reason' => 'undefined');
     $notificationSdk = new SofortLibNotification();
     $transactionId = $notificationSdk->getNotification($rawBody);
     if ($transactionId) {
         $transactionDataSdk = new SofortLibTransactionData(Mage::getStoreConfig('payment/paymentnetwork_pnsofortueberweisung/cofiguration_key', Mage::app()->getStore()->getStoreId()));
         $transactionDataSdk->addTransaction($transactionId)->sendRequest();
         $transactionData['status'] = $transactionDataSdk->getStatus();
         $transactionData['reason'] = $transactionDataSdk->getStatusReason();
         $transactionData['amount_refunded'] = $transactionDataSdk->getAmountRefunded();
         $transactionData['transaction_id'] = $transactionId;
     }
     return $transactionData;
 }