Example #1
0
 /**
  * Возврат платежа после добавления карты
  */
 public function refund()
 {
     $api = new Api();
     if (!Input::has('newCard')) {
         return Response::json(['data' => '', 'message' => 'Action not found']);
     }
     $lastPay = PaymentCloud::getLastPay($api->id());
     if (!$lastPay || $lastPay['amount'] != 1) {
         return $this->responseErrorMessage('Ошибка! Не найден платеж.', 500);
     }
     $result = $api->refundPayment($lastPay['payment_id'], $lastPay['amount']);
     if (!$result->success) {
         return $this->responseErrorMessage($result->message, 500);
     }
     return Response::json(['data' => '', 'message' => $result->message]);
 }