Пример #1
0
 public function logError(Exception $e, Model_Transaction $tx)
 {
     $body = $e->getJsonBody();
     $err = $body['error'];
     $tx->txn_status = $err['type'];
     $tx->error = $err['message'];
     $tx->status = 'processed';
     $tx->updated_at = date('Y-m-d H:i:s');
     $this->di['db']->store($tx);
     if ($this->di['config']['debug']) {
         error_log(json_encode($e->getJsonBody()));
     }
     throw new Exception($tx->error);
 }
Пример #2
0
 /**
  * Stripe Exception handler
  *
  * Function will check the exception is instance of Stripe_ERROR. If it is instance of Stripe_ERROR then
  * function will chek the type. If type is card_error then it sets result to 80 and saves the message to rtrans
  * reference. otherwise it sets to 85 other stripe issue. If exception is not stripe one set result to 90. 
  * 
  * @param Exception $e        Exception object
  * @param string    $function function name to complete the logs.
  * @return void
  */
 private function exceptionHendler($e, $rtrans, $function)
 {
     $error = $e->getJsonBody()['error'];
     if ($e instanceof Stripe_Error) {
         if ($error['type'] == 'card_error') {
             $rtrans->setResult('80');
             $rtrans->setReference($error['message']);
         } else {
             $rtrans->setResult('85');
         }
     } else {
         $rtrans->setResult('90');
     }
     $this->_log("[RTRANS: {$rtrans->getId()}] Stripe::{$function}() - result: exception: " . print_r($error, true));
 }