allowedSorts([ 'amount', 'succeeded', 'created_at', ]) ->allowedFilters([ AllowedFilter::exact('user_id'), AllowedFilter::exact('succeeded'), ]); return TransactionResource::collection( $builder->paginate($request->per_page) ); } public function pay(Request $request, int $business) { \permit('isBusinessOwner'); return Transaction::create([ 'user_id'=> Auth::id(), 'business_id'=> $business, 'amount'=> $request->amount, ]); } public function redirection($transaction) { $transaction = Transaction::findOrFail($transaction); if ($transaction->isWentToPaymentGateway()) { throw new \Exception("Siktir baba ye bar ghablan rafti."); } return $transaction->prepare()->redirect(); } public function callback(Request $request) { $transaction = Transaction::findByAuthority($request->get('Authority'))->verify(); if (!$transaction->hasBeenAppliedToWallet() && $transaction->succeeded) { $transaction->business->increment("wallet", $transaction->amount); $transaction->amountWasAppliedToWallet(); return true; } throw new \Exception("تراکنش تایید نشد"); } }