public function run() { try { $params = Yii::app()->order->getPaymentFormParams(); } catch (Exception $e) { header("Content-type: application/json"); $params = array(); $params['error'] = $e->getMessage(); echo json_encode($params); exit; } // FIXME move to config $params['url'] = "https://secure.payonlinesystem.com/ru/payment/ivoyanga/"; $params['ReturnUrl'] = "http://test.voyanga.com/buy/waitpayment"; $params['FailUrl'] = "http://test.voyanga.com/buy/waitpayment"; header("Content-type: application/json"); $result = array(); $result['payonline'] = $params; $entry = PaymentLog::forMethod('payonlineForm'); $entry->request = json_encode($params); $entry->orderId = $params['OrderId']; $entry->save(); $result['breakdown'] = Yii::app()->order->getPaymentTransactions(); echo json_encode($result); }
public function run() { if ($this->failure) { $method = 'FailureCallback'; } else { $method = 'SuccessCallback'; } $this->logEntry = PaymentLog::forMethod($method); $this->logEntry->request = '{"callback":1}'; $this->logEntry->response = json_encode($_REQUEST); if (isset($_REQUEST['TransactionID'])) { $this->logEntry->transactionId = $_REQUEST['TransactionID']; } if (isset($_REQUEST['OrderId'])) { $this->logEntry->orderId = $_REQUEST['OrderId']; } $this->logEntry->save(); foreach ($this->keys as $key) { if (!isset($_REQUEST[$key])) { $e = new RequestError("{$key} not found."); $this->handleException($e); return; } $params[$key] = $_REQUEST[$key]; } $parts = explode('-', $params['OrderId']); if (count($parts) < 2) { $e = new RequestError("Wrong OrderId format: " . $params['OrderId']); $this->handleException($e); return; } list($orderId, $billId) = $parts; $bill = Bill::model()->findByPk($billId); $channel = $bill->getChannel(); $sign = $channel->getSignature($params); if ($sign != $params['SecurityKey']) { $e = new SignatureError("Signature mismatch actual: " . $params['SecurityKey'] . ". Expected: " . $sign . "."); $this->handleException($e); // return; } $booker = $channel->booker; if ($booker instanceof FlightBooker) { $booker = new FlightBookerComponent(); $booker->setFlightBookerFromId($channel->booker->id); } // Hoteles are allways wrapped into metabooker //FIXME logme # if($this->getStatus($booker)=='paid') # return; if ($this->getStatus($booker) == 'paymentInProgress') { return; } $this->logEntry->startProfile(); $this->handle($bill, $booker, $channel, $orderId); $this->logEntry->finishProfile(); $this->logEntry->save(); }
public function refund() { $allParams = $this->formParams(); $entry = PaymentLog::forMethod('refund'); $entry->orderId = $allParams['OrderId']; $params = array(); $params['MerchantId'] = $this->credentials['id']; //! FIXME: can this amount change? // $params['Amount'] = sprintf("%.2f", $this->amount);// $this->bill->amount); $params['TransactionId'] = $this->bill->transactionId; $params['SecurityKey'] = $this->getSignature($params); $entry->request = json_encode($params); $entry->save(); $entry->startProfile(); list($code, $result) = $this->callApi('transaction/void', $params); $entry->finishProfile(); $entry->response = json_encode($result); $entry->save(); if ($result['Result'] == 'Ok') { if (isset($result['Id'])) { $entry->transactionId = $result['Id']; } return true; } $entry->errorDescription = "RefundError: " . $this->rawResponse; $entry->save(); return false; }