/** * @param array $attributes * @return PaytrailResult */ public static function create(array $attributes) { $model = new PaytrailResult(); $model->attributes = $attributes; if (!$model->save()) { throw new CException('Failed to save paytrail result.'); } return $model; }
/** * @param PaymentTransaction $transaction * @throws CException */ public function processTransaction(PaymentTransaction $transaction) { if ($this->_payment === null) { throw new CException(sprintf('Cannot process transaction #%d without payment.', $transaction->id)); } if ($this->needPayment()) { $response = $this->_client->processPayment($this->_payment->toObject()); } else { $params = array('ORDER_NUMBER' => $this->_payment->orderNumber, 'TIMESTAMP' => time(), 'PAID' => true, 'METHOD' => 'none'); $response = new PaytrailResponse(); $response->configure(array('orderNumber' => $this->_payment->orderNumber, 'url' => $this->createUrl('successUrl', $params))); } $this->_result = PaytrailResult::create(array('paymentId' => $this->_payment->id, 'orderNumber' => $response->getOrderNumber(), 'token' => $response->getToken(), 'url' => $response->getUrl())); }