public function delete($participant) { $user = Auth::user(); $club = $user->clubs()->FirstOrFail(); $participant = Participant::Find($participant); $player = Player::Find($participant->player_id); $event = Evento::find($participant->event->id); // $payment = Payment::find($payment); $title = 'League Together - ' . $event->name . ' Event'; return View::make('app.club.event.participant.delete')->with('page_title', $title)->withEvent($event)->withClub($club)->withPlayer($player)->with('participant', $participant)->withUser($user); }
public function doRefund($id) { $user = Auth::user(); $club = $user->clubs()->FirstOrFail(); $uuid = Uuid::generate(); $payment = Payment::where('club_id', '=', $club->id)->where('transaction', '=', $id)->FirstOrFail(); $user_parent = User::find($payment->user_id); $uuid = Uuid::generate(); if ($payment->event_type) { $participant = Participant::Find($payment->items->first()->participant_id); $event = Evento::find($participant->event->id); } else { $participant = Member::Find($payment->items->first()->member_id); $event = Team::find($participant->team->id); } $player = Player::Find($participant->player->id); //$amount = $payment->getOriginal('subtotal'); $amount = Input::get('amount'); if ($amount > $payment->getOriginal('subtotal')) { return Redirect::action('AccountingController@refund', $payment->transaction)->with('error', "You cannot refund more than " . $payment->getOriginal('subtotal')); } if ($amount <= 0 || $amount == '') { return Redirect::action('AccountingController@refund', $payment->transaction)->with('error', "Amount must be more than 0"); } if ($amount > 0) { $param = array('transactionid' => $payment->transaction, 'club' => $club->id, 'amount' => number_format($amount, 2, ".", "")); $transaction = $payment->refund($param); if ($transaction->response == 3 || $transaction->response == 2) { return Response::json($transaction); return Redirect::action('AccountingController@transaction', $payment->transaction)->with('error', $transaction->responsetext); } else { $payment1 = new Payment(); $payment1->id = $uuid; $payment1->customer = $user_parent->profile->customer_vault; $payment1->transaction = $transaction->transactionid; $payment1->subtotal = -$transaction->total; $payment1->total = -$transaction->total; $payment1->club_id = $club->id; $payment1->user_id = $user_parent->id; $payment1->player_id = $player->id; $payment1->type = $transaction->type; $sale = new Item(); $sale->description = $event->name . " ({$transaction->type})"; $sale->quantity = 1; $sale->price = -$transaction->total; $sale->payment_id = $uuid; if ($payment->event_type) { $payment1->event_type = $event->type_id; } else { $payment1->event_type = NULL; } $payment1->save(); $sale->save(); $data = array('club' => $club, 'transaction' => $transaction, 'user' => $user, 'contact' => $user_parent); //send notification for refund confirmation $mail = Mail::send('emails.receipt.refund', $data, function ($message) use($user, $club, $user_parent) { $message->to($user_parent->email)->subject("Refund Confirmation | " . $club->name); foreach ($club->users()->get() as $value) { $message->bcc($value->email, $club->name); } }); } //end of transaction result } //end of amount test return Redirect::action('AccountingController@transaction', $payment->transaction); }