public function bulk($ids, $action, $params = [])
{
if ($action == 'refund') {
if (!$ids) {
return 0;
}
$payments = $this->getRepo()->findByPublicIdsWithTrashed($ids);
$successful = 0;
foreach ($payments as $payment) {
if (Auth::user()->can('edit', $payment)) {
$amount = !empty($params['amount']) ? floatval($params['amount']) : null;
if ($accountGateway = $payment->account_gateway) {
$paymentDriver = $accountGateway->paymentDriver();
if ($paymentDriver->refundPayment($payment, $amount)) {
$successful++;
}
}
}
}
return $successful;
} else {
return parent::bulk($ids, $action);
}
}
/** * @return mixed */ public function bulk() { $action = Input::get('action'); $amount = Input::get('amount'); $ids = Input::get('public_id') ? Input::get('public_id') : Input::get('ids'); $count = $this->paymentService->bulk($ids, $action, ['amount' => $amount]); if ($count > 0) { $message = Utils::pluralize($action == 'refund' ? 'refunded_payment' : $action . 'd_payment', $count); Session::flash('message', $message); } return redirect()->to('payments'); }