public function HandleNotifyUrl($eShopId, $status, $ip, $rawPostStream = 'php://input') { $shop_id = static::DecryptShopId($eShopId); $notification = new SofortLibNotification(); $success = $notification->getNotification(file_get_contents($rawPostStream)); if ($success === false) { throw new SofortLibNotificationException($notification); } $transaction = $notification->getTransactionId(); $time = $notification->getTime(); App::uses('SofortComNotification', 'SofortCom.Model'); $SofortComNotification = new SofortComNotification(); $SofortComNotification->Add($transaction, $status, $time, $ip); $transactionData = new SofortLibTransactionData($this->Config['configkey']); $transactionData->addTransaction($transaction); $transactionData->sendRequest(); $transactionData->setNumber(1); call_user_func_array(array($this->Controller, $this->Config['notifyCallback']), array($shop_id, $status, $transaction, $time, $transactionData)); }
/** * 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); }