Exemple #1
0
 function payment_recieve()
 {
     $returnedPayment = new TpReturnedPayment($this->config);
     //overime prijaty podpis
     if ($returnedPayment->verifySignature()) {
         $status = $returnedPayment->getStatus();
         switch ($status) {
             case TpReturnedPayment::STATUS_OK:
                 return "OK";
             case TpReturnedPayment::STATUS_CANCELED:
                 return "ERROR";
             case TpReturnedPayment::STATUS_ERROR:
                 return "ERROR";
             case TpReturnedPayment::STATUS_UNDERPAID:
                 return "UNDERPAID";
             case TpReturnedPayment::STATUS_WAITING:
                 return "WAITING";
             default:
                 return "ERROR";
         }
     } else {
         return "ERROR";
     }
 }
Exemple #2
0
 /**
  * @param bool $throwException
  * @throws ThePayException
  * @return bool
  */
 public function verifySignature($throwException = TRUE)
 {
     if ($this->error) {
         if ($throwException) {
             throw new ThePayException($this->error->getMessage(), $this->error->getCode());
         }
         return FALSE;
     }
     try {
         parent::verifySignature();
     } catch (\TpInvalidSignatureException $e) {
         if ($throwException) {
             throw new ThePayException('Invalid signature.');
         }
         return FALSE;
     }
     if (!is_numeric(parent::getValue())) {
         if ($throwException) {
             throw new ThePayException('Price is not numeric.');
         }
         return FALSE;
     }
     return TRUE;
 }