/** * @param Payment $payment * @param CHttpRequest $request * @return bool */ public function processCheckout(Payment $payment, CHttpRequest $request) { $amount = $request->getParam('OutSum'); $orderId = (int) $request->getParam('InvId'); $crc = strtoupper($request->getParam('SignatureValue')); $order = Order::model()->findByPk($orderId); if (null === $order) { Yii::log(Yii::t('RobokassaModule.robokassa', 'Order with id = {id} not found!', ['{id}' => $orderId]), CLogger::LEVEL_ERROR, self::LOG_CATEGORY); return false; } if ($order->isPaid()) { Yii::log(Yii::t('RobokassaModule.robokassa', 'Order with id = {id} already payed!', ['{id}' => $orderId]), CLogger::LEVEL_ERROR, self::LOG_CATEGORY); return false; } $settings = $payment->getPaymentSystemSettings(); $myCrc = strtoupper(md5("{$amount}:{$orderId}:" . $settings['password2'])); if ($myCrc !== $crc) { Yii::log(Yii::t('RobokassaModule.robokassa', 'Error pay order with id = {id}! Bad crc!', ['{id}' => $orderId]), CLogger::LEVEL_ERROR, self::LOG_CATEGORY); return false; } if ($amount != Yii::app()->money->convert($order->total_price, $payment->currency_id)) { Yii::log(Yii::t('RobokassaModule.robokassa', 'Error pay order with id = {id}! Incorrect price!', ['{id}' => $orderId]), CLogger::LEVEL_ERROR, self::LOG_CATEGORY); return false; } if ($order->pay($payment)) { Yii::log(Yii::t('RobokassaModule.robokassa', 'Success pay order with id = {id}!', ['{id}' => $orderId]), CLogger::LEVEL_INFO, self::LOG_CATEGORY); return true; } else { Yii::log(Yii::t('RobokassaModule.robokassa', 'Error pay order with id = {id}! Error change status!', ['{id}' => $orderId]), CLogger::LEVEL_ERROR, self::LOG_CATEGORY); return false; } }
/** * @param Payment $payment * @param CHttpRequest $request */ public function processCheckout(Payment $payment, CHttpRequest $request) { $settings = $payment->getPaymentSystemSettings(); $params = ['action' => $request->getParam('action'), 'orderSumAmount' => $request->getParam('orderSumAmount'), 'orderSumCurrencyPaycash' => $request->getParam('orderSumCurrencyPaycash'), 'orderSumBankPaycash' => $request->getParam('orderSumBankPaycash'), 'shopId' => $settings['shopid'], 'invoiceId' => $request->getParam('invoiceId'), 'customerNumber' => $request->getParam('customerNumber'), 'password' => $settings['password']]; /* @var $order Order */ $order = Order::model()->findByPk($request->getParam('orderNumber')); if ($order === null) { $message = Yii::t('YandexMoneyModule.ymoney', 'The order doesn\'t exist.'); Yii::log($message, CLogger::LEVEL_ERROR); $this->showResponse($params, $message, 200); } if ($order->isPaid()) { $message = Yii::t('YandexMoneyModule.ymoney', 'The order #{n} is already payed.', $order->getPrimaryKey()); Yii::log($message, CLogger::LEVEL_ERROR); $this->showResponse($params, $message, 200); } if ($this->getOrderCheckSum($params) !== $request->getParam('md5')) { $message = Yii::t('YandexMoneyModule.ymoney', 'Wrong checksum'); Yii::log($message, CLogger::LEVEL_ERROR); $this->showResponse($params, $message, 200); } if ((double) $order->getTotalPriceWithDelivery() !== (double) $params['orderSumAmount']) { $message = Yii::t('YandexMoneyModule.ymoney', 'Wrong payment amount'); Yii::log($message, CLogger::LEVEL_ERROR); $this->showResponse($params, $message, 200); } if ($params['action'] === 'checkOrder') { $this->showResponse($params); } if ($params['action'] === 'paymentAviso' && $order->pay($payment)) { Yii::log(Yii::t('YandexMoneyModule.ymoney', 'The order #{n} has been payed successfully.', $order->getPrimaryKey()), CLogger::LEVEL_INFO); $this->showResponse($params); } }
public function __construct(Payment $payment) { $settings = $payment->getPaymentSystemSettings(); $this->key = $settings['key']; $this->mode = $settings['paymode']; }