Skip to content

Commit

Permalink
Merge pull request #2 from Beem-Dev/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
alphaolomi committed Apr 25, 2022
2 parents 3a5729f + 636825c commit fcf4660
Show file tree
Hide file tree
Showing 42 changed files with 1,102 additions and 132 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
patreon: alphaolomi
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) Alpha Olomi <alphaolomi@gmail.com>
Copyright (c) Alpha Olomi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
36 changes: 25 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,51 @@ You can install the package via composer:
composer require beem/laravel-beem
```

You can publish and run the migrations with:
<!-- You can publish and run the migrations with:
```bash
php artisan vendor:publish --tag="laravel-beem-migrations"
php artisan vendor:publish --tag="beem-migrations"
php artisan migrate
```
``` -->

You can publish the config file with:

```bash
php artisan vendor:publish --tag="laravel-beem-config"
php artisan vendor:publish --tag="beem-config"
```

This is the contents of the published config file:
<!-- This is the contents of the published config file:
```php
return [
];
```
``` -->

Optionally, you can publish the views using
<!-- Optionally, you can publish the views using
```bash
php artisan vendor:publish --tag="laravel-beem-views"
```
``` -->

## Services
- [ ] SMS
- [ ] CONTACTS
- [ ] MULTICOUNTRY SMS AND SMPP
- [ ] USSD
- [ ] AIRTIME
- [ ] PAYMENTS COLLECTIONS
- [ ] PAYMENTS CHECKOUT
- [ ] DISBURSEMENTS
- [ ] OTP

## Usage

```php
$beem = new Beem\Laravel\Beem();
WIP

<!-- ```php
$beem = new Beem\Laravel\Beem;
echo $beem->echoPhrase('Hello, Beem\Laravel!');
```
``` -->

## Testing

Expand All @@ -71,6 +84,7 @@ Please review [our security policy](../../security/policy) on how to report secu

## Credits

- [Bryce Andy](https://github.com/bryceandy) for the initial implementation.
- [Alpha Olomi](https://github.com/alphaolomi)
- [All Contributors](../../contributors)

Expand Down
34 changes: 19 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"laravel",
"laravel-beem"
],
"homepage": "https://github.com/beem/laravel-beem",
"homepage": "https://github.com/beem-dev/laravel-beem",
"license": "MIT",
"authors": [
{
Expand All @@ -16,31 +16,31 @@
}
],
"require": {
"php": "^8.0",
"spatie/laravel-package-tools": "^1.9.2",
"illuminate/contracts": "^9.0"
"php": "^7.3|^8.0",
"guzzlehttp/guzzle": "^7.4",
"illuminate/contracts": "^7.0|^8.0|^9.0",
"spatie/laravel-package-tools": "^1.9.2"
},
"require-dev": {
"nunomaduro/collision": "^6.0",
"nunomaduro/larastan": "^2.0.1",
"orchestra/testbench": "^7.0",
"nunomaduro/collision": "v5.11|^6.2",
"nunomaduro/larastan": "^1.0|^2.0.1",
"orchestra/testbench": "^6.24|^7.0",
"pestphp/pest": "^1.21",
"pestphp/pest-plugin-laravel": "^1.1",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "^9.5",
"spatie/laravel-ray": "^1.26"
"phpunit/phpunit": "^9.5"
},
"autoload": {
"psr-4": {
"Beem\\Laravel\\Beem\\": "src",
"Beem\\Laravel\\Beem\\Database\\Factories\\": "database/factories"
"Beem\\Laravel\\": "src",
"Beem\\Laravel\\Database\\Factories\\": "database/factories"
}
},
"autoload-dev": {
"psr-4": {
"Beem\\Laravel\\Beem\\Tests\\": "tests"
"Beem\\Laravel\\Tests\\": "tests"
}
},
"scripts": {
Expand All @@ -49,15 +49,19 @@
"test-coverage": "vendor/bin/pest --coverage"
},
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true,
"phpstan/extension-installer": true
}
},
"extra": {
"laravel": {
"providers": [
"Beem\\Laravel\\Beem\\BeemServiceProvider"
"Beem\\Laravel\\BeemServiceProvider"
],
"aliases": {
"Beem": "Beem\\Laravel\\Beem\\Facades\\Beem"
"Beem": "Beem\\Laravel\\Facades\\Beem"
}
}
},
Expand Down
34 changes: 33 additions & 1 deletion config/beem.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
<?php
// config for Beem\Laravel/Beem

return [

/*
|--------------------------------------------------------------------------
| Beem API Key
|--------------------------------------------------------------------------
|
| You can obtain this key after creating a Beem vendor account, then
| visit the Profile tab and click on "Authentication Information"
|
*/
'api_key' => env('BEEM_KEY'),

/*
|--------------------------------------------------------------------------
| Beem Secret Key
|--------------------------------------------------------------------------
|
| You can obtain this key after creating a Beem vendor account, then visit
| the Profile tab and click on "Authentication Information" then Generate
|
*/
'secret_key' => env('BEEM_SECRET'),

/*
|--------------------------------------------------------------------------
| Beem Path
|--------------------------------------------------------------------------
|
| This path name will be used as a prefix for all routes available
|
*/
'path' => env('BEEM_PATH', 'beem'),

];
Empty file added database/factories/.gitkeep
Empty file.
19 changes: 0 additions & 19 deletions database/factories/ModelFactory.php

This file was deleted.

Empty file added database/migrations/.gitkeep
Empty file.
19 changes: 0 additions & 19 deletions database/migrations/create_beem_table.php.stub

This file was deleted.

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

use Beem\Laravel\Http\Controllers\AirtimeCallbackController;
use Beem\Laravel\Http\Controllers\PaymentCheckoutCallbackController;
use Beem\Laravel\Http\Controllers\PaymentCollectionController;
use Beem\Laravel\Http\Controllers\SmsDeliveryReportController;
use Beem\Laravel\Http\Controllers\TwoWaySmsCallbackController;
use Beem\Laravel\Http\Controllers\UssdCallbackController;
use Illuminate\Support\Facades\Route;

Route::post('sms-delivery-report', SmsDeliveryReportController::class)
->name('beem.sms-delivery-report');

Route::post('outbound-sms', TwoWaySmsCallbackController::class)
->name('beem.outbound-sms');

Route::post('ussd-callback', UssdCallbackController::class)
->name('beem.ussd-callback');

Route::post('airtime-callback', AirtimeCallbackController::class)
->name('beem.airtime-callback');

Route::post('payment-collection', PaymentCollectionController::class)
->name('beem.payment-collection');

Route::post('payment-checkout', PaymentCheckoutCallbackController::class)
->name('beem.payment-checkout');
29 changes: 28 additions & 1 deletion src/Beem.php
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,7 +1,34 @@
<?php

namespace Beem\Laravel\Beem;
namespace Beem\Laravel;

use Beem\Laravel\Traits\Airtime\HandlesAirtime;
use Beem\Laravel\Traits\Contacts\HandlesContacts;
use Beem\Laravel\Traits\Disbursements\HandlesDisbursements;
use Beem\Laravel\Traits\Otp\HandlesOtp;
use Beem\Laravel\Traits\PaymentCollections\HandlesPaymentCollections;
use Beem\Laravel\Traits\Sms\HandlesSms;
use Beem\Laravel\Traits\Ussd\HandlesUssd;
use Illuminate\Config\Repository;
use Illuminate\Contracts\Foundation\Application;

class Beem
{
use HandlesAirtime;
use HandlesContacts;
use HandlesDisbursements;
use HandlesOtp;
use HandlesPaymentCollections;
use HandlesSms;
use HandlesUssd;

/**
* Fetch the prefix name for all routes
*
* @return Repository|Application|mixed
*/
public static function pathPrefix()
{
return config('beem.path');
}
}
10 changes: 10 additions & 0 deletions src/BeemRedirect.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Beem\Laravel;

use Beem\Laravel\Traits\PaymentCheckouts\HandlesPaymentCheckouts;

class BeemRedirect
{
use HandlesPaymentCheckouts;
}
47 changes: 34 additions & 13 deletions src/BeemServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,42 @@
<?php

namespace Beem\Laravel\Beem;
namespace Beem\Laravel;

use Beem\Laravel\Beem\Commands\BeemCommand;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;

class BeemServiceProvider extends PackageServiceProvider
class BeemServiceProvider extends ServiceProvider
{
public function configurePackage(Package $package): void
public function boot()
{
/* More info: https://github.com/spatie/laravel-package-tools */
$package
->name('laravel-beem')
->hasConfigFile()
->hasViews()
->hasMigration('create_laravel-beem_table')
->hasCommand(BeemCommand::class);
if ($this->app->runningInConsole()) {
$this->publishes([
__DIR__ . '/../config/beem.php' => config_path('beem.php'),
], 'beem-config');
}
}

public function register()
{
$this->registerFacades();

$this->registerRoutes();
}

private function registerFacades()
{
$this->app->singleton('Beem', fn ($app) => new \Beem\Laravel\Beem());

$this->app->singleton('BeemRedirect', fn ($app) => new \Beem\Laravel\BeemRedirect());
}

private function registerRoutes()
{
$prefix = Beem::pathPrefix();

Route::group(
compact('prefix'),
fn () => $this->loadRoutesFrom(__DIR__ . '/../routes/web.php')
);
}
}
Loading

0 comments on commit fcf4660

Please sign in to comment.