render('payments.index'); } /** * Display the specified resource. * * @param Request $request * @param Payment $payment * @return Factory|View */ public function show(Request $request, Payment $payment) { $payment->load('invoices'); return $this->render('payments.show', [ 'payment' => $payment, ]); } /** * Presents the payment screen for a given * gateway and payment method. * The request will also contain the amount * and invoice ids for reference. * * @param Request $request * @return RedirectResponse|mixed */ public function process(Request $request) { return (new InstantPayment($request))->run(); } public function response(PaymentResponseRequest $request) { $gateway = CompanyGateway::findOrFail($request->input('company_gateway_id')); $payment_hash = PaymentHash::whereRaw('BINARY `hash`= ?', [$request->payment_hash])->first(); return $gateway ->driver(auth()->user()->client) ->setPaymentMethod($request->input('payment_method_id')) ->setPaymentHash($payment_hash) ->checkRequirements() ->processPaymentResponse($request); } /** * Pay for invoice/s using credits only. * * @param Request $request The request object * @return Response The response view */ public function credit_response(Request $request) { $payment_hash = PaymentHash::whereRaw('BINARY `hash`= ?', [$request->input('payment_hash')])->first(); /* Hydrate the $payment */ if ($payment_hash->payment()->exists()) { $payment = $payment_hash->payment; } else { $payment = PaymentFactory::create($payment_hash->fee_invoice->company_id, $payment_hash->fee_invoice->user_id); $payment->client_id = $payment_hash->fee_invoice->client_id; $payment->saveQuietly(); $payment_hash->payment_id = $payment->id; $payment_hash->save(); } $payment = $payment->service()->applyCredits($payment_hash)->save(); event('eloquent.created: App\Models\Payment', $payment); if (property_exists($payment_hash->data, 'billing_context')) { $billing_subscription = \App\Models\Subscription::find($payment_hash->data->billing_context->subscription_id); return (new SubscriptionService($billing_subscription))->completePurchase($payment_hash); } return redirect()->route('client.payments.show', ['payment' => $this->encodePrimaryKey($payment->id)]); } public function processCreditPayment(Request $request, array $data) { return render('gateways.credit.index', $data); } }