예제 #1
0
 private function initValidator()
 {
     $fields = $this->type->fields();
     $rules = array();
     foreach ($fields as $value) {
         $rules[$value] = self::$rules[$value];
     }
     $this->validator = Validator::make($this->input, $rules);
 }
 /**
  * @param array  $input
  * @param int    $code
  * @param string $message
  *
  * @return void
  *
  * @dataProvider auth
  */
 public function testAuth($input, $code = null, $message = null)
 {
     Secure::sign($input, 'auth', 'secret');
     $opType = new Type('auth', $input);
     try {
         $this->assertTrue($opType->validate());
         if ($code) {
             $this->assertFalse(true, 'Exception must be there with code ' . $code);
         }
     } catch (ProcessorException $e) {
         $this->assertEquals($code, $e->getCode(), $e->getMessage());
         $this->assertContains($message, $e->getMessage());
     }
 }
예제 #3
0
 private function getResponseData()
 {
     $data = array('term' => $this->payment->item()->term, 'type' => $this->payment->item()->type, 'order' => $this->payment->item()->order, 'amount' => $this->payment->item()->amount, 'cur' => $this->payment->item()->cur, 'rc' => $this->payment->item()->rc, 'approval' => $this->payment->item()->approval, 'irn' => $this->payment->item()->irn, 'rrn' => $this->payment->item()->rrn, 'status' => $this->payment->item()->status, 'time' => Time::ts());
     $rc = $this->payment->item()->rc;
     $pan = $this->payment->item()->pan;
     if ($pan) {
         $data['pan'] = $pan;
     }
     if ($rc !== '00') {
         if (isset(ProcessorException::$errors[$rc])) {
             $data['message'] = ProcessorException::$errors[$rc];
         }
     }
     Secure::sign($data, $this->type->sid(), $this->term->secret);
     return $data;
 }
예제 #4
0
 /**
  *
  * Check, clear and verify input params
  *
  * @param string $action
  * @param string $type
  * @param array  $input
  * @param bool   $disableClear
  *
  * @return null
  */
 private function getVerifiedInput($action, $type, $input, $disableClear = false)
 {
     $rawInput = $input;
     if (!$disableClear) {
         $input = Type::clearInput($type, $input);
     }
     $clearInput = $input;
     $termId = $input['term'];
     $term = Terminal::find($termId);
     $sign = $input['sign'];
     Secure::sign($input, $type, $term->secret);
     $isCorrect = $sign === $input['sign'];
     if (!$isCorrect) {
         Log::warning($action . '.pull', array('message' => 'Invalid signature', 'rawInput' => $rawInput, 'clearInput' => $clearInput, 'resultInput' => $input));
         return null;
     }
     Log::info($action . '.pull', array('message' => 'Correct signature', 'rawInput' => $rawInput, 'clearInput' => $clearInput, 'resultInput' => $input));
     return $clearInput;
 }
예제 #5
0
 /**
  * Process logic by payment Type
  *
  * @return string $rc
  */
 private function doProcessType()
 {
     $type = new Type($this->payment->type, $this->payment->toArray());
     $paymentExist = self::findDouble($this->payment->id, $this->payment->term, $this->payment->order, $this->payment->amount, $type->sid(), array(Status::SUCCESS, Status::PROCESSED));
     if ($paymentExist) {
         return '-3';
     }
     switch ($type->sid()) {
         case Type::AUTH:
         case Type::SALE:
         case Type::PAYMENT:
             break;
         case Type::COMPLETE:
             // completing auth request
             $payment = self::find($this->payment->term, $this->payment->order, $this->payment->irn, $this->payment->rrn, Type::AUTH, Status::SUCCESS);
             if (!$payment) {
                 return '-2';
             }
             break;
         case Type::REFUND:
             // refund for finished processing: sale, complete, payment
             $payment = self::find($this->payment->term, $this->payment->order, $this->payment->irn, $this->payment->rrn, array(Type::SALE, Type::COMPLETE, Type::PAYMENT), Status::SUCCESS);
             if (!$payment) {
                 // refund for not finishing processing: auth
                 $payment = self::find($this->payment->term, $this->payment->order, $this->payment->irn, $this->payment->rrn, Type::AUTH, Status::SUCCESS);
                 if (!$payment) {
                     return '-2';
                 }
             }
             break;
     }
     return '00';
 }