Skip to main content

Khalti Integration

blade for api


@extends('layouts.frontMaster')
@section('content')    <!--suppress ALL -->    <br>    <br>    <br>    <html>    <head>        <script            src="https://code.jquery.com/jquery-3.3.1.min.js"            integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="            crossorigin="anonymous"></script>        <script src="https://khalti.com/static/khalti-checkout.js"></script>    </head>    <body>    ...
    <!-- Place this where you need payment button -->    <button id="payment-button">Pay with Khalti</button>    {{--<button id="payment-button" onclick="clickedbtn()">Clickme</button>--}}    <!-- Place this where you need payment button -->    <!-- Paste this code anywhere in you body tag -->    <script>        var config = {
            // replace the publicKey with yours            "publicKey": "test_public_key_15903a44695e4e409a98aa3fcb281c4c",            "productIdentity": "1234567890",            "productName": "Dragon",            "productUrl": "http://gameofthrones.wikia.com/wiki/Dragons",            "eventHandler": {
                onSuccess (payload) {
                    $.ajax({
                        type: "get",                        url: "/khaltiapi",                        data: { payload: payload},                        dataType: "json",                        success: function(response) {
                            console.log(response);                            },
                        error: function(xhr, ajaxOptions, thrownError) { alert(xhr.responseText); }
                    });                                      // hit merchant api for initiating verfication                    console.log(payload);                },                onError (error) {
                    console.log(error);                },                onClose () {
                    console.log('widget is closing');                }
            }
        };
        var checkout = new KhaltiCheckout(config);        var btn = document.getElementById("payment-button");        btn.onclick = function () {
            checkout.show({amount: 10000});        }
    </script>       <!-- Paste this code anywhere in you body tag -->    ...
    </body>    </html>    {{--<h1>this is Final page for submission</h1>--}}
@endsection


Route: for blade

Route for Ajax Call;
Route::get('/khaltiapi', 'BikeBookingController@khaltiapi')->name('bike.khalti');


Controller: for blade view

Controller for : hadndeling ajax call

    public function khaltiapi(Request $request)    {        $payloads=$request->input('payload');//        $payload=[2.1,234,345,4535];//        print_r($payloads);
//        $x=$request->input('ListID');        $token= $payloads['token'];        $amount= $payloads['amount'];        $amount=(int)$amount;//        return $amount;
        $args = http_build_query(array(            'token' => $token,            'amount'  => $amount        ));//        return $token;        $url = "https://khalti.com/api/v2/payment/verify/";
# Make the call using API.        $ch = curl_init();        curl_setopt($ch, CURLOPT_URL, $url);        curl_setopt($ch, CURLOPT_POST, 1);        curl_setopt($ch, CURLOPT_POSTFIELDS,$args);        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $headers = ['Authorization:Key test_secret_key_179d2e03983e4cea9cec75c2349f0823'];        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// Response        $response = curl_exec($ch);        echo $response;        $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);        curl_close($ch);        return $response;    }









Comments

Popular posts from this blog

laravel file manager sorting by time default

Ref :  https://github.com/UniSharp/laravel-filemanager/issues/337 To load files order by "time DESC" you can change the code in vendor/unisharp/laravel-filemanager/src/traits/LfmHelpers.php public function sortFilesAndDirectories($arr_items, $sort_type) { if ($sort_type == 'time') { $key_to_sort = 'updated'; } elseif ($sort_type == 'alphabetic') { $key_to_sort = 'name'; } else { $key_to_sort = 'updated'; } return strcmp($a->{$key_to_sort}, $b->{$key_to_sort}); }); return $arr_items; } with public function sortFilesAndDirectories($arr_items, $sort_type) { if ($sort_type == 'time') { $key_to_sort = 'updated'; } elseif ($sort_type == 'alphabetic') { $key_to_sort = 'name'; } else { $key_to_sort = 'updated'; ...

some important points for web developers and hosting

check dns https://www.whatsmydns.net/ https://check-host.net/ https://www.site24x7.com/ping-test.html attacks https://www.computerhope.com/unix/uping.htm https://vitux.com/linux-ping-command/ https://www.howtoforge.com/linux-ping-command/ https://www.poftut.com/linux-ping-command-tutorial-examples/ https://phoenixnap.com/kb/linux-ping-command-examples https://sandilands.info/sgordon/ping-flooding-dos-attack-in-a-virtual-network https://www.geeksforgeeks.org/ping-command-in-linux-with-examples/

Installing Admin LTE in Laravel

step 1:  Reference---  https://hdtuto.com/article/laravel-56-adminlte-bootstrap-theme-installation-example Step 2 : after completion first reference view this link:    https://github.com/JeroenNoten/Laravel-AdminLTE step 3:  For more additional information view this link:   https://github.com/jeroennoten/Laravel-AdminLTE#2-updating Now you are done statically : https://adminlte.io/blog/integrate-adminlte-with-laravel Steps: 1:  composer require jeroennoten/laravel-adminlte 2: 'providers' => [ .... JeroenNoten\LaravelAdminLte\ServiceProvider::class, ], 3: php artisan vendor:publish --provider="JeroenNoten\LaravelAdminLte\ServiceProvider" --tag=assets 5: php artisan vendor:publish --provider="JeroenNoten\LaravelAdminLte\ServiceProvider" --tag=config 6: php artisan vendor:publish --provider="JeroenNoten\LaravelAdminLte\ServiceProvider" --tag=views 7: for admin pannel php artisan ...