Skip to content

Commit

Permalink
Version 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
PrevailExcel committed Dec 4, 2022
1 parent 70e7b8c commit f2b1cfa
Show file tree
Hide file tree
Showing 9 changed files with 376 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# The MIT License (MIT)

Copyright (c) 2015 Prevail Ejimadu <[email protected]>

> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in
> all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> THE SOFTWARE.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

/*
* This file is part of the Laravel NOWPayments package.
*
* (c) Prevail Ejimadu <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

class CreateNowpaymentsLoggerTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('nowpayments_api_call_logger', function (Blueprint $table) {
$table->id();
$table->string('endpoint');
$table->integer('count')->default(0);
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('nowpayments_api_call_logger');
}
};
191 changes: 191 additions & 0 deletions resources/views/dashboard.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
<!DOCTYPE html>
<html lang="en">

<!--
* This file is part of the Laravel NOWPayments package.
*
* (c) Prevail Ejimadu <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
-->

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Laravel NOWPayment</title>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.21/css/jquery.dataTables.min.css">
<link href="http://fontawesome.io/assets/font-awesome/css/font-awesome.css" rel="stylesheet" media="screen">

<style>
body {
background-color: #dedede;
}
.topbar {
background: #2A3F54;
border-color: #2A3F54;
border-radius: 0px;
}
.topbar .navbar-header a {
color: #ffffff;
}
.wrapper {
padding-left: 0px;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}
.main {
width: 100%;
position: relative;
padding-bottom: 20px;
}
.content {
margin-top: 70px;
padding: 0 30px;
}
</style>

<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.21/js/jquery.dataTables.min.js"></script>

</head>

<body>
<nav class="navbar navbar-default navbar-fixed-top topbar">
<div class="container-fluid">

<div class="navbar-header">

<a href="#" class="navbar-brand">
<span class="visible-xs">Laravel NOWPayments</span>
<span class="hidden-xs">Laravel NOWPayments</span>
</a>

<p class="navbar-text">
<a href="#" class="sidebar-toggle">
<i class="fa fa-bars"></i>
</a>
</p>

</div>
</div>
</nav>

<article class="wrapper">
<section class="main">
<section class="tab-content">
<section class="tab-pane active fade in content" id="dashboard">
<div class="row">
<div class="col-xs-6 col-sm-2">
<div class="panel panel-primary border">
<div class="panel-body">
<h5>API Status: <b>ON</b></h5>
</div>
</div>
</div>

<div class="col-xs-6 col-sm-2 offset-sm-10">
<div class="panel panel-primary border">
<div class="panel-body">
<h5>Enviroment: <b
style="text-transform: capitalize">{{ config('nowpayments.env') }}</b></h5>
</div>
</div>
</div>

<div class="col-xs-12 col-sm-9">
<div class="panel panel-primary">
<div class="panel-heading">
<h4><b>Payment List</b></h4>
</div>
<div class="panel-body">
<div class="table-responsive">
<table id="pList" class="table table-sm table-hover table-striped">
<thead>
<tr>
<th scope="col">Payment ID</th>
<th scope="col">Order ID</th>
<th scope="col">Original Price</th>
<th scope="col">Amount Sent</th>
<th scope="col">Amount Received</th>
<th scope="col">Status</th>
<th scope="col">Address</th>
<th scope="col">Created at</th>
</tr>
</thead>
<tbody>
@forelse($payments as $pay)
<tr>
<th scope="row">{{ $pay['payment_id'] }}</th>
<td>{{ $pay['order_id'] }}</td>
<td>{{ $pay['price_amount'] }} {{ $pay['price_currency'] }}</td>
<td>{{ $pay['pay_amount'] }} {{ $pay['pay_currency'] }}</td>
<td>{{ $pay['outcome_amount'] }} {{ $pay['outcome_currency'] }}
</td>
<td>{{ $pay['payment_status'] }}</td>
<td>{{ $pay['pay_address'] }}</td>
<td>{{ Carbon\Carbon::parse($pay['created_at'])->format('d M Y, H:i A') }}
</td>
</tr>
@empty
<div class="alert alert-info">No Payments initiated yet</div>
@endforelse
</tbody>
</table>
</div>
</div>
</div>
</div>

<div class="col-xs-12 col-sm-3">
<div class="panel panel-default">
<div class="panel-heading">
<b>API Log</b>
</div>
<ul class="list-group">
@foreach ($logs as $log)
<li class="list-group-item">{{ $log->endpoint }} <span
class="float-right badge badge-secondary">{{ $log->count }}</span>
</li>
@endforeach
</ul>
</div>

<div class="panel panel-default">
<div class="panel-heading">
What's New in Laravel NOWPayments
</div>
<div class="panel-body">
Docs here on <a href="https://github.com/PrevailExcel/laravel-nowpayments"
target="_blank">Github</a><br>
Version: v{{ $version }} <br>
<a href="https://www.buymeacoffee.com/prevail" target="_blank">Buy Me A Coffee</a>
</div>
</div>
</div>
</div>
</section>
</section>
</section>
</article>

<script type="text/javascript">
$(document).ready(function() {
// DataTable
$('#pList').DataTable()
});
</script>
</body>

</html>
21 changes: 21 additions & 0 deletions routes/routes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

use Illuminate\Support\Facades\Route;
use PrevailExcel\Nowpayments\Http\Controllers\DashboardController;
use PrevailExcel\Nowpayments\Http\Middleware\Authorize;

/*
* This file is part of the Laravel NOWPayments package.
*
* (c) Prevail Ejimadu <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

Route::group([
'prefix' => config('nowpayments.path', 'laravel-nowpayments'),
'middleware' => config('nowpayments.middleware', [Authorize::class]),
], function () {
Route::get('/', DashboardController::class)->name('nowpayments.dashboard');
});
27 changes: 27 additions & 0 deletions src/Http/Controllers/DashboardController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace PrevailExcel\Nowpayments\Http\Controllers;

use Illuminate\Http\Request;
use PrevailExcel\Nowpayments\Facades\Nowpayments;
use PrevailExcel\Nowpayments\Models\Logger;

/*
* This file is part of the Laravel NOWPayments package.
*
* (c) Prevail Ejimadu <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

class DashboardController
{
public function __invoke(Request $request)
{
$payments = Nowpayments::getListOfPayments("limit=200")['data'];
$logs = Logger::get();
$version = Nowpayments::VERSION;
return view('nowpayments::dashboard', compact('payments', 'logs', 'version'));
}
}
31 changes: 31 additions & 0 deletions src/Http/Middleware/Authorize.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace PrevailExcel\Nowpayments\Http\Middleware;

use Illuminate\Support\Facades\Gate;

/*
* This file is part of the Laravel NOWPayments package.
*
* (c) Prevail Ejimadu <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

class Authorize
{
/**
* Authorize the current user.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return \Illuminate\Http\Response
*/
public function handle($request, $next)
{
return Gate::check('viewNowpaymentsDashboard', [$request->user()])
? $next($request)
: abort(403);
}
}
25 changes: 25 additions & 0 deletions src/Models/Logger.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace PrevailExcel\Nowpayments\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

/*
* This file is part of the Laravel NOWPayments package.
*
* (c) Prevail Ejimadu <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

class Logger extends Model
{
use HasFactory;
protected $fillable = [
'endpoint', 'count'
];
protected $table = 'nowpayments_api_call_logger';
public $timestamps = false;
}
9 changes: 9 additions & 0 deletions utils/helpers/nowpayments.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

if (! function_exists("nowpayments"))
{
function nowpayments() {

return app()->make('laravel-nowpayments');
}
}
10 changes: 10 additions & 0 deletions vendor/composer/autoload_files.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

// autoload_files.php @generated by Composer

$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);

return array(
'7c85b489815bd8b5ec4256895b1d300d' => $baseDir . '/utils/helpers/nowpayments.php',
);

0 comments on commit f2b1cfa

Please sign in to comment.