diff --git a/.env b/.env index 31f6f1cc..8e17ff47 100644 --- a/.env +++ b/.env @@ -45,3 +45,10 @@ MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" MAILCHIMP_APIKEY = ea5072cae56749ce8e619be267a7119e-us5 MAILCHIMP_LIST_ID = 313064917c +RAVE_PUBLIC_KEY=FLWPUBK_TEST-2632b2661e8fb72e6cce1f4482169959-X +RAVE_SECRET_KEY=FLWSECK_TEST-0dc7495ac8531f128c392aa75a8b2b78-X +RAVE_TITLE="Start NG" +RAVE_ENVIRONMENT="staging" +RAVE_LOGO="https://res.cloudinary.com/sgnolebagabriel/image/upload/v1572346080/startng/Logo_2_ee1iqv.png" +RAVE_PREFIX="startdotng" +RAVE_SECRET_HASH= \ No newline at end of file diff --git a/app/Http/Controllers/CourseController.php b/app/Http/Controllers/CourseController.php index 901df944..6948568d 100755 --- a/app/Http/Controllers/CourseController.php +++ b/app/Http/Controllers/CourseController.php @@ -280,12 +280,13 @@ public function registerCourses($id) return back()->with('error', 'You Have Previously Registered for the Course'); } else{ - $add_course = new RegisteredCourses; - $add_course->course_id = $id; - $add_course->user_id = auth()->user()->id; - $add_course->progress = 0; - $add_course->save(); - return back()->with('success', 'Registration was Succesful'); + $course = Course::find($id); + $user = User::find(auth()->user()->id); + $data = array( + 'course' => $course, + 'user' => $user + ); + return view("user.payment")->with($data); } } else{ diff --git a/app/Http/Controllers/RaveController.php b/app/Http/Controllers/RaveController.php new file mode 100644 index 00000000..c50db470 --- /dev/null +++ b/app/Http/Controllers/RaveController.php @@ -0,0 +1,74 @@ +txref); + + $chargeResponsecode = $data->data->chargecode; + $chargeAmount = $data->data->amount; + $chargeCurrency = $data->data->currency; + $course_id = $data->data->meta[0]->metavalue; + + $course = Course::find($course_id); + + $amount = $course->price; + $currency = "NGN"; + if (($chargeResponsecode == "00" || $chargeResponsecode == "0") && ($chargeAmount == $amount) && ($chargeCurrency == $currency)) { + // transaction was successful... + // please check other things like whether you already gave value for this ref + // if the email matches the customer who owns the product etc + //Give Value and return to Success page + + + $add_course = new RegisteredCourses; + $add_course->course_id = $id; + $add_course->user_id = auth()->user()->id; + $add_course->progress = 0; + $add_course->save(); + return back()->with('success', 'Registration was Succesful'); + + } else { + //Dont Give Value and return to Failure page + + return redirect('/failed'); + } + + //dd($data); + // Get the transaction from your DB using the transaction reference (txref) + // Check if you have previously given value for the transaction. If you have, redirect to your successpage else, continue + // Comfirm that the transaction is successful + // Confirm that the chargecode is 00 or 0 + // Confirm that the currency on your db transaction is equal to the returned currency + // Confirm that the db transaction amount is equal to the returned amount + // Update the db transaction record (includeing parameters that didn't exist before the transaction is completed. for audit purpose) + // Give value for the transaction + // Update the transaction to note that you have given value for the transaction + // You can also redirect to your success page from here + } +} \ No newline at end of file diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php index 324a166b..7fafaa85 100755 --- a/app/Http/Middleware/VerifyCsrfToken.php +++ b/app/Http/Middleware/VerifyCsrfToken.php @@ -19,6 +19,6 @@ class VerifyCsrfToken extends Middleware * @var array */ protected $except = [ - // + 'rave/callback' ]; } diff --git a/composer.json b/composer.json index 13a82702..28ac3768 100644 --- a/composer.json +++ b/composer.json @@ -11,6 +11,7 @@ "php": "^7.2", "fideloper/proxy": "^4.0", "intervention/image": "^2.5", + "kingflamez/laravelrave": "^1.1", "laracasts/flash": "^3.0", "laravel/framework": "^5.8", "laravel/tinker": "^1.0", diff --git a/composer.lock b/composer.lock index db113ae4..9cf18240 100755 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b71f7e30f41af9d2f6ef44d628d2d7a2", + "content-hash": "c687c2812ae1d7f965fa7a5e5aca2365", "packages": [ { "name": "dnoegel/php-xdg-base-dir", @@ -424,6 +424,147 @@ ], "time": "2019-09-03T16:45:42+00:00" }, + { + "name": "guzzlehttp/psr7", + "version": "1.6.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "239400de7a173fe9901b9ac7c06497751f00727a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/239400de7a173fe9901b9ac7c06497751f00727a", + "reference": "239400de7a173fe9901b9ac7c06497751f00727a", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "psr/http-message": "~1.0", + "ralouphie/getallheaders": "^2.0.5 || ^3.0.0" + }, + "provide": { + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "ext-zlib": "*", + "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.8" + }, + "suggest": { + "zendframework/zend-httphandlerrunner": "Emit PSR-7 responses" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.6-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Schultze", + "homepage": "https://github.com/Tobion" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "psr-7", + "request", + "response", + "stream", + "uri", + "url" + ], + "time": "2019-07-01T23:21:34+00:00" + }, + { + "name": "intervention/image", + "version": "2.5.1", + "source": { + "type": "git", + "url": "https://github.com/Intervention/image.git", + "reference": "abbf18d5ab8367f96b3205ca3c89fb2fa598c69e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Intervention/image/zipball/abbf18d5ab8367f96b3205ca3c89fb2fa598c69e", + "reference": "abbf18d5ab8367f96b3205ca3c89fb2fa598c69e", + "shasum": "" + }, + "require": { + "ext-fileinfo": "*", + "guzzlehttp/psr7": "~1.1", + "php": ">=5.4.0" + }, + "require-dev": { + "mockery/mockery": "~0.9.2", + "phpunit/phpunit": "^4.8 || ^5.7" + }, + "suggest": { + "ext-gd": "to use GD library based image processing.", + "ext-imagick": "to use Imagick based image processing.", + "intervention/imagecache": "Caching extension for the Intervention Image library" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.4-dev" + }, + "laravel": { + "providers": [ + "Intervention\\Image\\ImageServiceProvider" + ], + "aliases": { + "Image": "Intervention\\Image\\Facades\\Image" + } + } + }, + "autoload": { + "psr-4": { + "Intervention\\Image\\": "src/Intervention/Image" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Oliver Vogel", + "email": "oliver@olivervogel.com", + "homepage": "http://olivervogel.com/" + } + ], + "description": "Image handling and manipulation library with support for Laravel integration", + "homepage": "http://image.intervention.io/", + "keywords": [ + "gd", + "image", + "imagick", + "laravel", + "thumbnail", + "watermark" + ], + "time": "2019-11-02T09:15:47+00:00" + }, { "name": "jakub-onderka/php-console-color", "version": "v0.2", @@ -512,6 +653,77 @@ "description": "Highlight PHP code in terminal", "time": "2018-09-29T18:48:56+00:00" }, + { + "name": "kingflamez/laravelrave", + "version": "1.1.3", + "source": { + "type": "git", + "url": "https://github.com/kingflamez/laravelrave.git", + "reference": "ca1a8360c7d32a91add2c088563e7e8df34c9e40" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kingflamez/laravelrave/zipball/ca1a8360c7d32a91add2c088563e7e8df34c9e40", + "reference": "ca1a8360c7d32a91add2c088563e7e8df34c9e40", + "shasum": "" + }, + "require": { + "illuminate/support": "5.*", + "mashape/unirest-php": "^3.0", + "php": "^5.6.0|^7.0" + }, + "require-dev": { + "mockery/mockery": ">=0.7.2", + "orchestra/testbench": "~3.0", + "phpunit/phpunit": "4.*", + "satooshi/php-coveralls": "^0.7.0", + "scrutinizer/ocular": "~1.1" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "KingFlamez\\Rave\\RaveServiceProvider" + ], + "aliases": { + "Rave": "KingFlamez\\Rave\\Facades\\Rave" + } + } + }, + "autoload": { + "classmap": [ + "src/Rave.php" + ], + "psr-4": { + "KingFlamez\\Rave\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "kingflamez", + "email": "flamekeed@gmail.com" + } + ], + "description": "A Laravel 5 Package for Flutterwave Rave", + "keywords": [ + "Flutterwave Rave", + "flutterwave", + "github", + "kingflamez", + "laravel", + "laravel 5", + "open source", + "payments", + "php", + "rave", + "ravepay.co" + ], + "time": "2018-10-13T13:49:15+00:00" + }, { "name": "laracasts/flash", "version": "3.0.3", @@ -1161,6 +1373,52 @@ ], "time": "2019-10-06T11:29:25+00:00" }, + { + "name": "mashape/unirest-php", + "version": "v3.0.4", + "source": { + "type": "git", + "url": "https://github.com/Mashape/unirest-php.git", + "reference": "842c0f242dfaaf85f16b72e217bf7f7c19ab12cb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Mashape/unirest-php/zipball/842c0f242dfaaf85f16b72e217bf7f7c19ab12cb", + "reference": "842c0f242dfaaf85f16b72e217bf7f7c19ab12cb", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "codeclimate/php-test-reporter": "0.1.*", + "phpunit/phpunit": "~4.4" + }, + "suggest": { + "ext-json": "Allows using JSON Bodies for sending and parsing requests" + }, + "type": "library", + "autoload": { + "psr-0": { + "Unirest\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Unirest PHP", + "homepage": "https://github.com/Mashape/unirest-php", + "keywords": [ + "client", + "curl", + "http", + "https", + "rest" + ], + "time": "2016-08-11T17:49:21+00:00" + }, { "name": "monolog/monolog", "version": "1.25.1", @@ -1656,6 +1914,56 @@ ], "time": "2017-02-14T16:28:37+00:00" }, + { + "name": "psr/http-message", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "time": "2016-08-06T14:39:51+00:00" + }, { "name": "psr/log", "version": "1.1.1", @@ -1825,6 +2133,46 @@ ], "time": "2018-10-13T15:16:03+00:00" }, + { + "name": "ralouphie/getallheaders", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "120b605dfeb996808c31b6477290a714d356e822" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", + "reference": "120b605dfeb996808c31b6477290a714d356e822", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^5 || ^6.5" + }, + "type": "library", + "autoload": { + "files": [ + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "time": "2019-03-08T08:55:37+00:00" + }, { "name": "ramsey/uuid", "version": "3.8.0", diff --git a/config/app.php b/config/app.php index 6e19c0af..7657e81d 100755 --- a/config/app.php +++ b/config/app.php @@ -163,6 +163,7 @@ Illuminate\View\ViewServiceProvider::class, Collective\Html\HtmlServiceProvider::class, Intervention\Image\ImageServiceProvider::class, + KingFlamez\Rave\RaveServiceProvider::class, Maatwebsite\Excel\ExcelServiceProvider::class, //Cyberduck\LaravelExcel\ExcelServiceProvider::class, /* @@ -218,6 +219,7 @@ 'Notification' => Illuminate\Support\Facades\Notification::class, 'Password' => Illuminate\Support\Facades\Password::class, 'Queue' => Illuminate\Support\Facades\Queue::class, + 'Rave' => KingFlamez\Rave\Facades\Rave::class, 'Redirect' => Illuminate\Support\Facades\Redirect::class, 'Redis' => Illuminate\Support\Facades\Redis::class, 'Request' => Illuminate\Support\Facades\Request::class, diff --git a/config/rave.php b/config/rave.php new file mode 100644 index 00000000..5c1ee203 --- /dev/null +++ b/config/rave.php @@ -0,0 +1,55 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +return [ + + /** + * Public Key: Your Rave publicKey. Sign up on https://rave.flutterwave.com/ to get one from your settings page + * + */ + 'publicKey' => env('RAVE_PUBLIC_KEY'), + + /** + * Secret Key: Your Rave secretKey. Sign up on https://rave.flutterwave.com/ to get one from your settings page + * + */ + 'secretKey' => env('RAVE_SECRET_KEY'), + + /** + * Company/Business/Store Name: The name of your store + * + */ + 'title' => env('RAVE_TITLE', 'Rave Payment Gateway'), + + /** + * Environment: This can either be 'staging' or 'live' + * + */ + 'env' => env('RAVE_ENVIRONMENT', 'staging'), + + /** + * Logo: Enter the URL of your company/business logo + * + */ + 'logo' => env('RAVE_LOGO', ''), + + /** + * Prefix: This is added to the front of your transaction reference numbers + * + */ + 'prefix' => env('RAVE_PREFIX', 'rave'), + + /** + * Prefix: This is added to the front of your transaction reference numbers + * + */ + 'secretHash' => env('RAVE_SECRET_HASH', ''), +]; diff --git a/resources/views/pages/payent.blade.php b/resources/views/pages/payent.blade.php new file mode 100644 index 00000000..aab6e5d1 --- /dev/null +++ b/resources/views/pages/payent.blade.php @@ -0,0 +1,23 @@ +@php +$array = array(array('metaname' => 'color', 'metavalue' => 'blue'), + array('metaname' => 'size', 'metavalue' => 'big')); +@endphp +

Buy Movie Tickets N500.00

+
+ {{ csrf_field() }} + + + + + + + + + + + {{-- --}} + {{-- --}} + {{-- --}} + {{-- --}} + +
\ No newline at end of file diff --git a/resources/views/user/payment.blade.php b/resources/views/user/payment.blade.php new file mode 100644 index 00000000..5c1c3191 --- /dev/null +++ b/resources/views/user/payment.blade.php @@ -0,0 +1,42 @@ +@extends('layouts.user-dashboard') + +@section('content') +
+
+
+
DETAILS
+
+
+
+

Pay for {{$course->title}}

+
+
+ @php + $array = array('metaname' => 'course_id', 'metavalue' => $course->id); + @endphp +
+ {{ csrf_field() }} + + + + + + + + + + + {{-- --}} + {{-- --}} + {{-- --}} + {{-- --}} + +
+
+
+
+
+ +@endsection + + \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 4a53aa50..eb4b2621 100755 --- a/routes/web.php +++ b/routes/web.php @@ -65,3 +65,7 @@ Auth::routes(); Route::get('/home', 'HomeController@index')->name('home'); + +#FlutterWave routes +Route::post('/pay', 'RaveController@initialize')->name('pay'); +Route::post('/rave/callback', 'RaveController@callback')->name('callback'); diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 0e5981e2..377333dc 100755 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -6,14 +6,13 @@ $baseDir = dirname($vendorDir); return array( - 'App\\Assignment' => $baseDir . '/app/Assignment.php', 'App\\Console\\Kernel' => $baseDir . '/app/Console/Kernel.php', 'App\\Course' => $baseDir . '/app/Course.php', 'App\\CourseContent' => $baseDir . '/app/CourseContent.php', 'App\\Courses' => $baseDir . '/app/Courses.php', 'App\\Exceptions\\Handler' => $baseDir . '/app/Exceptions/Handler.php', + 'App\\Exports\\ScoreExport' => $baseDir . '/app/Exports/ScoreExport.php', 'App\\Http\\Controllers\\AdminController' => $baseDir . '/app/Http/Controllers/AdminController.php', - 'App\\Http\\Controllers\\AssignmentController' => $baseDir . '/app/Http/Controllers/AssignmentController.php', 'App\\Http\\Controllers\\Auth\\ConfirmPasswordController' => $baseDir . '/app/Http/Controllers/Auth/ConfirmPasswordController.php', 'App\\Http\\Controllers\\Auth\\ForgotPasswordController' => $baseDir . '/app/Http/Controllers/Auth/ForgotPasswordController.php', 'App\\Http\\Controllers\\Auth\\LoginController' => $baseDir . '/app/Http/Controllers/Auth/LoginController.php', @@ -28,6 +27,7 @@ 'App\\Http\\Controllers\\DashboardController' => $baseDir . '/app/Http/Controllers/DashboardController.php', 'App\\Http\\Controllers\\ForgotPassController' => $baseDir . '/app/Http/Controllers/ForgotPassController.php', 'App\\Http\\Controllers\\HomeController' => $baseDir . '/app/Http/Controllers/HomeController.php', + 'App\\Http\\Controllers\\RaveController' => $baseDir . '/app/Http/Controllers/RaveController.php', 'App\\Http\\Controllers\\ResourcesController' => $baseDir . '/app/Http/Controllers/ResourcesController.php', 'App\\Http\\Controllers\\ReviewController' => $baseDir . '/app/Http/Controllers/ReviewController.php', 'App\\Http\\Controllers\\ScheduleController' => $baseDir . '/app/Http/Controllers/ScheduleController.php', @@ -43,6 +43,7 @@ 'App\\Http\\Middleware\\TrimStrings' => $baseDir . '/app/Http/Middleware/TrimStrings.php', 'App\\Http\\Middleware\\TrustProxies' => $baseDir . '/app/Http/Middleware/TrustProxies.php', 'App\\Http\\Middleware\\VerifyCsrfToken' => $baseDir . '/app/Http/Middleware/VerifyCsrfToken.php', + 'App\\Imports\\ScoreImport' => $baseDir . '/app/Imports/ScoreImport.php', 'App\\Mail\\TestEmail' => $baseDir . '/app/Mail/TestEmail.php', 'App\\Models\\Contact' => $baseDir . '/app/Contact.php', 'App\\Notifications\\LarashopAdminResetPassword' => $baseDir . '/app/Notifications/LarashopAdminResetPassword.php', @@ -1852,6 +1853,9 @@ 'JakubOnderka\\PhpConsoleColor\\InvalidStyleException' => $vendorDir . '/jakub-onderka/php-console-color/src/InvalidStyleException.php', 'JakubOnderka\\PhpConsoleHighlighter\\Highlighter' => $vendorDir . '/jakub-onderka/php-console-highlighter/src/Highlighter.php', 'JsonException' => $vendorDir . '/symfony/polyfill-php73/Resources/stubs/JsonException.php', + 'KingFlamez\\Rave\\Facades\\Rave' => $vendorDir . '/kingflamez/laravelrave/src/Facades/Rave.php', + 'KingFlamez\\Rave\\Rave' => $vendorDir . '/kingflamez/laravelrave/src/Rave.php', + 'KingFlamez\\Rave\\RaveServiceProvider' => $vendorDir . '/kingflamez/laravelrave/src/RaveServiceProvider.php', 'Laracasts\\Flash\\Flash' => $vendorDir . '/laracasts/flash/src/Laracasts/Flash/Flash.php', 'Laracasts\\Flash\\FlashNotifier' => $vendorDir . '/laracasts/flash/src/Laracasts/Flash/FlashNotifier.php', 'Laracasts\\Flash\\FlashServiceProvider' => $vendorDir . '/laracasts/flash/src/Laracasts/Flash/FlashServiceProvider.php', @@ -4296,6 +4300,11 @@ 'TijsVerkoyen\\CssToInlineStyles\\Css\\Property\\Property' => $vendorDir . '/tijsverkoyen/css-to-inline-styles/src/Css/Property/Property.php', 'TijsVerkoyen\\CssToInlineStyles\\Css\\Rule\\Processor' => $vendorDir . '/tijsverkoyen/css-to-inline-styles/src/Css/Rule/Processor.php', 'TijsVerkoyen\\CssToInlineStyles\\Css\\Rule\\Rule' => $vendorDir . '/tijsverkoyen/css-to-inline-styles/src/Css/Rule/Rule.php', + 'Unirest\\Exception' => $vendorDir . '/mashape/unirest-php/src/Unirest/Exception.php', + 'Unirest\\Method' => $vendorDir . '/mashape/unirest-php/src/Unirest/Method.php', + 'Unirest\\Request' => $vendorDir . '/mashape/unirest-php/src/Unirest/Request.php', + 'Unirest\\Request\\Body' => $vendorDir . '/mashape/unirest-php/src/Unirest/Request/Body.php', + 'Unirest\\Response' => $vendorDir . '/mashape/unirest-php/src/Unirest/Response.php', 'Webmozart\\Assert\\Assert' => $vendorDir . '/webmozart/assert/src/Assert.php', 'Whoops\\Exception\\ErrorException' => $vendorDir . '/filp/whoops/src/Whoops/Exception/ErrorException.php', 'Whoops\\Exception\\Formatter' => $vendorDir . '/filp/whoops/src/Whoops/Exception/Formatter.php', diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php index b8d54b7f..40277bd6 100755 --- a/vendor/composer/autoload_namespaces.php +++ b/vendor/composer/autoload_namespaces.php @@ -6,6 +6,7 @@ $baseDir = dirname($vendorDir); return array( + 'Unirest\\' => array($vendorDir . '/mashape/unirest-php/src'), 'PhpOption\\' => array($vendorDir . '/phpoption/phpoption/src'), 'Parsedown' => array($vendorDir . '/erusev/parsedown'), 'Mockery' => array($vendorDir . '/mockery/mockery/library'), diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php index 1678572b..8f7506fd 100755 --- a/vendor/composer/autoload_psr4.php +++ b/vendor/composer/autoload_psr4.php @@ -52,6 +52,7 @@ 'League\\Flysystem\\' => array($vendorDir . '/league/flysystem/src'), 'Laravel\\Ui\\' => array($vendorDir . '/laravel/ui/src'), 'Laravel\\Tinker\\' => array($vendorDir . '/laravel/tinker/src'), + 'KingFlamez\\Rave\\' => array($vendorDir . '/kingflamez/laravelrave/src'), 'JakubOnderka\\PhpConsoleHighlighter\\' => array($vendorDir . '/jakub-onderka/php-console-highlighter/src'), 'JakubOnderka\\PhpConsoleColor\\' => array($vendorDir . '/jakub-onderka/php-console-color/src'), 'Intervention\\Image\\' => array($vendorDir . '/intervention/image/src/Intervention/Image'), diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 795a9724..4470cede 100755 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -168,6 +168,10 @@ class ComposerStaticInitff3a5c77ed1089282876bda2c74049d4 'Laravel\\Ui\\' => 11, 'Laravel\\Tinker\\' => 15, ), + 'K' => + array ( + 'KingFlamez\\Rave\\' => 16, + ), 'J' => array ( 'JakubOnderka\\PhpConsoleHighlighter\\' => 35, @@ -403,6 +407,10 @@ class ComposerStaticInitff3a5c77ed1089282876bda2c74049d4 array ( 0 => __DIR__ . '/..' . '/laravel/tinker/src', ), + 'KingFlamez\\Rave\\' => + array ( + 0 => __DIR__ . '/..' . '/kingflamez/laravelrave/src', + ), 'JakubOnderka\\PhpConsoleHighlighter\\' => array ( 0 => __DIR__ . '/..' . '/jakub-onderka/php-console-highlighter/src', @@ -494,6 +502,13 @@ class ComposerStaticInitff3a5c77ed1089282876bda2c74049d4 ); public static $prefixesPsr0 = array ( + 'U' => + array ( + 'Unirest\\' => + array ( + 0 => __DIR__ . '/..' . '/mashape/unirest-php/src', + ), + ), 'P' => array ( 'PhpOption\\' => @@ -533,14 +548,13 @@ class ComposerStaticInitff3a5c77ed1089282876bda2c74049d4 ); public static $classMap = array ( - 'App\\Assignment' => __DIR__ . '/../..' . '/app/Assignment.php', 'App\\Console\\Kernel' => __DIR__ . '/../..' . '/app/Console/Kernel.php', 'App\\Course' => __DIR__ . '/../..' . '/app/Course.php', 'App\\CourseContent' => __DIR__ . '/../..' . '/app/CourseContent.php', 'App\\Courses' => __DIR__ . '/../..' . '/app/Courses.php', 'App\\Exceptions\\Handler' => __DIR__ . '/../..' . '/app/Exceptions/Handler.php', + 'App\\Exports\\ScoreExport' => __DIR__ . '/../..' . '/app/Exports/ScoreExport.php', 'App\\Http\\Controllers\\AdminController' => __DIR__ . '/../..' . '/app/Http/Controllers/AdminController.php', - 'App\\Http\\Controllers\\AssignmentController' => __DIR__ . '/../..' . '/app/Http/Controllers/AssignmentController.php', 'App\\Http\\Controllers\\Auth\\ConfirmPasswordController' => __DIR__ . '/../..' . '/app/Http/Controllers/Auth/ConfirmPasswordController.php', 'App\\Http\\Controllers\\Auth\\ForgotPasswordController' => __DIR__ . '/../..' . '/app/Http/Controllers/Auth/ForgotPasswordController.php', 'App\\Http\\Controllers\\Auth\\LoginController' => __DIR__ . '/../..' . '/app/Http/Controllers/Auth/LoginController.php', @@ -555,6 +569,7 @@ class ComposerStaticInitff3a5c77ed1089282876bda2c74049d4 'App\\Http\\Controllers\\DashboardController' => __DIR__ . '/../..' . '/app/Http/Controllers/DashboardController.php', 'App\\Http\\Controllers\\ForgotPassController' => __DIR__ . '/../..' . '/app/Http/Controllers/ForgotPassController.php', 'App\\Http\\Controllers\\HomeController' => __DIR__ . '/../..' . '/app/Http/Controllers/HomeController.php', + 'App\\Http\\Controllers\\RaveController' => __DIR__ . '/../..' . '/app/Http/Controllers/RaveController.php', 'App\\Http\\Controllers\\ResourcesController' => __DIR__ . '/../..' . '/app/Http/Controllers/ResourcesController.php', 'App\\Http\\Controllers\\ReviewController' => __DIR__ . '/../..' . '/app/Http/Controllers/ReviewController.php', 'App\\Http\\Controllers\\ScheduleController' => __DIR__ . '/../..' . '/app/Http/Controllers/ScheduleController.php', @@ -570,6 +585,7 @@ class ComposerStaticInitff3a5c77ed1089282876bda2c74049d4 'App\\Http\\Middleware\\TrimStrings' => __DIR__ . '/../..' . '/app/Http/Middleware/TrimStrings.php', 'App\\Http\\Middleware\\TrustProxies' => __DIR__ . '/../..' . '/app/Http/Middleware/TrustProxies.php', 'App\\Http\\Middleware\\VerifyCsrfToken' => __DIR__ . '/../..' . '/app/Http/Middleware/VerifyCsrfToken.php', + 'App\\Imports\\ScoreImport' => __DIR__ . '/../..' . '/app/Imports/ScoreImport.php', 'App\\Mail\\TestEmail' => __DIR__ . '/../..' . '/app/Mail/TestEmail.php', 'App\\Models\\Contact' => __DIR__ . '/../..' . '/app/Contact.php', 'App\\Notifications\\LarashopAdminResetPassword' => __DIR__ . '/../..' . '/app/Notifications/LarashopAdminResetPassword.php', @@ -2379,6 +2395,9 @@ class ComposerStaticInitff3a5c77ed1089282876bda2c74049d4 'JakubOnderka\\PhpConsoleColor\\InvalidStyleException' => __DIR__ . '/..' . '/jakub-onderka/php-console-color/src/InvalidStyleException.php', 'JakubOnderka\\PhpConsoleHighlighter\\Highlighter' => __DIR__ . '/..' . '/jakub-onderka/php-console-highlighter/src/Highlighter.php', 'JsonException' => __DIR__ . '/..' . '/symfony/polyfill-php73/Resources/stubs/JsonException.php', + 'KingFlamez\\Rave\\Facades\\Rave' => __DIR__ . '/..' . '/kingflamez/laravelrave/src/Facades/Rave.php', + 'KingFlamez\\Rave\\Rave' => __DIR__ . '/..' . '/kingflamez/laravelrave/src/Rave.php', + 'KingFlamez\\Rave\\RaveServiceProvider' => __DIR__ . '/..' . '/kingflamez/laravelrave/src/RaveServiceProvider.php', 'Laracasts\\Flash\\Flash' => __DIR__ . '/..' . '/laracasts/flash/src/Laracasts/Flash/Flash.php', 'Laracasts\\Flash\\FlashNotifier' => __DIR__ . '/..' . '/laracasts/flash/src/Laracasts/Flash/FlashNotifier.php', 'Laracasts\\Flash\\FlashServiceProvider' => __DIR__ . '/..' . '/laracasts/flash/src/Laracasts/Flash/FlashServiceProvider.php', @@ -4823,6 +4842,11 @@ class ComposerStaticInitff3a5c77ed1089282876bda2c74049d4 'TijsVerkoyen\\CssToInlineStyles\\Css\\Property\\Property' => __DIR__ . '/..' . '/tijsverkoyen/css-to-inline-styles/src/Css/Property/Property.php', 'TijsVerkoyen\\CssToInlineStyles\\Css\\Rule\\Processor' => __DIR__ . '/..' . '/tijsverkoyen/css-to-inline-styles/src/Css/Rule/Processor.php', 'TijsVerkoyen\\CssToInlineStyles\\Css\\Rule\\Rule' => __DIR__ . '/..' . '/tijsverkoyen/css-to-inline-styles/src/Css/Rule/Rule.php', + 'Unirest\\Exception' => __DIR__ . '/..' . '/mashape/unirest-php/src/Unirest/Exception.php', + 'Unirest\\Method' => __DIR__ . '/..' . '/mashape/unirest-php/src/Unirest/Method.php', + 'Unirest\\Request' => __DIR__ . '/..' . '/mashape/unirest-php/src/Unirest/Request.php', + 'Unirest\\Request\\Body' => __DIR__ . '/..' . '/mashape/unirest-php/src/Unirest/Request/Body.php', + 'Unirest\\Response' => __DIR__ . '/..' . '/mashape/unirest-php/src/Unirest/Response.php', 'Webmozart\\Assert\\Assert' => __DIR__ . '/..' . '/webmozart/assert/src/Assert.php', 'Whoops\\Exception\\ErrorException' => __DIR__ . '/..' . '/filp/whoops/src/Whoops/Exception/ErrorException.php', 'Whoops\\Exception\\Formatter' => __DIR__ . '/..' . '/filp/whoops/src/Whoops/Exception/Formatter.php', diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index db4a69b1..ffd59c84 100755 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -906,17 +906,17 @@ }, { "name": "intervention/image", - "version": "dev-master", - "version_normalized": "9999999-dev", + "version": "2.5.1", + "version_normalized": "2.5.1.0", "source": { "type": "git", "url": "https://github.com/Intervention/image.git", - "reference": "a59085a161dc63db97cbe81fd576025c8e699570" + "reference": "abbf18d5ab8367f96b3205ca3c89fb2fa598c69e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Intervention/image/zipball/a59085a161dc63db97cbe81fd576025c8e699570", - "reference": "a59085a161dc63db97cbe81fd576025c8e699570", + "url": "https://api.github.com/repos/Intervention/image/zipball/abbf18d5ab8367f96b3205ca3c89fb2fa598c69e", + "reference": "abbf18d5ab8367f96b3205ca3c89fb2fa598c69e", "shasum": "" }, "require": { @@ -933,7 +933,7 @@ "ext-imagick": "to use Imagick based image processing.", "intervention/imagecache": "Caching extension for the Intervention Image library" }, - "time": "2019-11-02T09:24:56+00:00", + "time": "2019-11-02T09:15:47+00:00", "type": "library", "extra": { "branch-alias": { @@ -1068,6 +1068,79 @@ ], "description": "Highlight PHP code in terminal" }, + { + "name": "kingflamez/laravelrave", + "version": "1.1.3", + "version_normalized": "1.1.3.0", + "source": { + "type": "git", + "url": "https://github.com/kingflamez/laravelrave.git", + "reference": "ca1a8360c7d32a91add2c088563e7e8df34c9e40" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kingflamez/laravelrave/zipball/ca1a8360c7d32a91add2c088563e7e8df34c9e40", + "reference": "ca1a8360c7d32a91add2c088563e7e8df34c9e40", + "shasum": "" + }, + "require": { + "illuminate/support": "5.*", + "mashape/unirest-php": "^3.0", + "php": "^5.6.0|^7.0" + }, + "require-dev": { + "mockery/mockery": ">=0.7.2", + "orchestra/testbench": "~3.0", + "phpunit/phpunit": "4.*", + "satooshi/php-coveralls": "^0.7.0", + "scrutinizer/ocular": "~1.1" + }, + "time": "2018-10-13T13:49:15+00:00", + "type": "library", + "extra": { + "laravel": { + "providers": [ + "KingFlamez\\Rave\\RaveServiceProvider" + ], + "aliases": { + "Rave": "KingFlamez\\Rave\\Facades\\Rave" + } + } + }, + "installation-source": "dist", + "autoload": { + "classmap": [ + "src/Rave.php" + ], + "psr-4": { + "KingFlamez\\Rave\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "kingflamez", + "email": "flamekeed@gmail.com" + } + ], + "description": "A Laravel 5 Package for Flutterwave Rave", + "keywords": [ + "Flutterwave Rave", + "flutterwave", + "github", + "kingflamez", + "laravel", + "laravel 5", + "open source", + "payments", + "php", + "rave", + "ravepay.co" + ] + }, { "name": "laracasts/flash", "version": "3.0.3", @@ -1792,6 +1865,54 @@ "vector" ] }, + { + "name": "mashape/unirest-php", + "version": "v3.0.4", + "version_normalized": "3.0.4.0", + "source": { + "type": "git", + "url": "https://github.com/Mashape/unirest-php.git", + "reference": "842c0f242dfaaf85f16b72e217bf7f7c19ab12cb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Mashape/unirest-php/zipball/842c0f242dfaaf85f16b72e217bf7f7c19ab12cb", + "reference": "842c0f242dfaaf85f16b72e217bf7f7c19ab12cb", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "codeclimate/php-test-reporter": "0.1.*", + "phpunit/phpunit": "~4.4" + }, + "suggest": { + "ext-json": "Allows using JSON Bodies for sending and parsing requests" + }, + "time": "2016-08-11T17:49:21+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-0": { + "Unirest\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Unirest PHP", + "homepage": "https://github.com/Mashape/unirest-php", + "keywords": [ + "client", + "curl", + "http", + "https", + "rest" + ] + }, { "name": "mockery/mockery", "version": "1.2.4", diff --git a/vendor/intervention/image b/vendor/intervention/image index a59085a1..abbf18d5 160000 --- a/vendor/intervention/image +++ b/vendor/intervention/image @@ -1 +1 @@ -Subproject commit a59085a161dc63db97cbe81fd576025c8e699570 +Subproject commit abbf18d5ab8367f96b3205ca3c89fb2fa598c69e diff --git a/vendor/kingflamez/laravelrave/.editorconfig b/vendor/kingflamez/laravelrave/.editorconfig new file mode 100644 index 00000000..cd8eb86e --- /dev/null +++ b/vendor/kingflamez/laravelrave/.editorconfig @@ -0,0 +1,15 @@ +; This file is for unifying the coding style for different editors and IDEs. +; More information at http://editorconfig.org + +root = true + +[*] +charset = utf-8 +indent_size = 4 +indent_style = space +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false diff --git a/vendor/kingflamez/laravelrave/.gitignore b/vendor/kingflamez/laravelrave/.gitignore new file mode 100644 index 00000000..f1f7ac8a --- /dev/null +++ b/vendor/kingflamez/laravelrave/.gitignore @@ -0,0 +1,7 @@ +build +vendor +.DS_Store +composer.lock +.idea +src/Rave3.php +clover.xml diff --git a/vendor/kingflamez/laravelrave/.scrutinizer.yml b/vendor/kingflamez/laravelrave/.scrutinizer.yml new file mode 100644 index 00000000..4a18bf71 --- /dev/null +++ b/vendor/kingflamez/laravelrave/.scrutinizer.yml @@ -0,0 +1,17 @@ +checks: + php: true +filter: + paths: ["src/*"] + excluded_paths: + - tests/* + - resources/* + - vendors/* + +build: + tests: + override: + - + command: 'vendor/bin/phpunit --coverage-clover=clover.yml' + coverage: + file: 'clover.yml' + format: 'clover' diff --git a/vendor/kingflamez/laravelrave/.travis.yml b/vendor/kingflamez/laravelrave/.travis.yml new file mode 100644 index 00000000..824ad9e6 --- /dev/null +++ b/vendor/kingflamez/laravelrave/.travis.yml @@ -0,0 +1,10 @@ +language: php +php: + - '5.6' + - '7.1' + - '7.2' + +install: composer install + +script: composer run tests + diff --git a/vendor/kingflamez/laravelrave/LICENSE.md b/vendor/kingflamez/laravelrave/LICENSE.md new file mode 100644 index 00000000..3ba116f8 --- /dev/null +++ b/vendor/kingflamez/laravelrave/LICENSE.md @@ -0,0 +1,21 @@ +# The MIT License (MIT) + +Copyright (c) 2017 Oluwole Adebiyi (Flamez) + +> 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. diff --git a/vendor/kingflamez/laravelrave/README.md b/vendor/kingflamez/laravelrave/README.md new file mode 100644 index 00000000..f571d621 --- /dev/null +++ b/vendor/kingflamez/laravelrave/README.md @@ -0,0 +1,65 @@ +# Flutterwave Rave (Laravel 5 Package) + +[![Latest Version on Packagist][ico-version]][link-packagist] +[![Software License][ico-license]](LICENSE.md) +[![Total Downloads][ico-downloads]][link-downloads] + + +> Implement Flutterwave Rave payment gateway easily with Laravel + +- Go to [Flutterwave Rave Live](https://rave.flutterwave.com/) to get your **`LIVE`** public and private key +- Go to [Flutterwave Rave Sandbox](https://ravesandbox.flutterwave.com/) to get your **`TEST`** public and private key + + +## Documentation + +> ### A friendly documentation can be found [here](https://laravelrave.netlify.com/) + + +> ### A sample implementation can be found [here](https://github.com/kingflamez/laravelrave-implementation/) + + +## ToDo + + - Support Direct Charges + - Support Tokenized payment + + +## Credits + +- [Oluwole Adebiyi (Flamez)][link-author] +- [Emmanuel Okeke](https://github.com/emmanix2002) +- [Adebayo Mustafa](https://github.com/AdebsAlert) +- [Tunde Aromire](https://github.com/toondaey) +- [Ifunanya Ikemma](https://github.com/Iphytech) + +## Contributing +Please feel free to fork this package and contribute by submitting a pull request to enhance the functionalities. I will appreciate that a lot. Also please add your name to the credits. + +Kindly [follow me on twitter](https://twitter.com/mrflamez_)! + +## License + +The MIT License (MIT). Please see [License File](LICENSE.md) for more information. + +[ico-version]: https://img.shields.io/packagist/v/kingflamez/laravelrave.svg?style=flat-square +[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square + + + + + +[ico-downloads]: https://img.shields.io/packagist/dt/kingflamez/laravelrave.svg?style=flat-square + +[link-packagist]: https://packagist.org/packages/kingflamez/laravelrave +[link-travis]: https://travis-ci.org/toondaey/laravelrave +[link-scrutinizer]: https://scrutinizer-ci.com/g/kingflamez/laravelrave/code-structure +[link-code-quality]: https://scrutinizer-ci.com/g/toondaey/laravelrave/?branch=master +[link-downloads]: https://packagist.org/packages/kingflamez/laravelrave +[link-author]: https://github.com/kingflamez +[link-contributors]: ../../contributors +[link-coverage]: https://scrutinizer-ci.com/g/toondaey/laravelrave/?branch=master +[link-code-intelligence]: https://scrutinizer-ci.com/code-intelligence diff --git a/vendor/kingflamez/laravelrave/composer.json b/vendor/kingflamez/laravelrave/composer.json new file mode 100644 index 00000000..2cebea3d --- /dev/null +++ b/vendor/kingflamez/laravelrave/composer.json @@ -0,0 +1,51 @@ +{ + "name": "kingflamez/laravelrave", + "description": "A Laravel 5 Package for Flutterwave Rave", + "keywords": ["php","github", "laravel","Open Source","payments", "kingflamez", "Flutterwave Rave", "Flutterwave", "rave", "ravepay.co","laravel 5"], + "license": "MIT", + "authors": [ + { + "name": "kingflamez", + "email": "flamekeed@gmail.com" + } + ], + "minimum-stability": "stable", + "require": { + "php": "^5.6.0|^7.0", + "illuminate/support": "5.*", + "mashape/unirest-php": "^3.0" + }, + "require-dev": { + "phpunit/phpunit" : "4.*", + "scrutinizer/ocular": "~1.1", + "satooshi/php-coveralls": "^0.7.0", + "mockery/mockery": ">=0.7.2", + "orchestra/testbench": "~3.0" + }, + "autoload": { + "classmap": [ + "src/Rave.php" + ], + "psr-4": { + "KingFlamez\\Rave\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Tests\\": "tests/" + } + }, + "scripts": { + "tests": "vendor/bin/phpunit --coverage-clover=\"clover.xml\"" + }, + "extra": { + "laravel": { + "providers": [ + "KingFlamez\\Rave\\RaveServiceProvider" + ], + "aliases": { + "Rave": "KingFlamez\\Rave\\Facades\\Rave" + } + } + } +} diff --git a/vendor/kingflamez/laravelrave/phpunit.xml b/vendor/kingflamez/laravelrave/phpunit.xml new file mode 100644 index 00000000..32e7bbc5 --- /dev/null +++ b/vendor/kingflamez/laravelrave/phpunit.xml @@ -0,0 +1,25 @@ + + + + + ./tests/Feature + + + + ./tests/Unit + + + + + ./src + + + diff --git a/vendor/kingflamez/laravelrave/resources/config/rave.php b/vendor/kingflamez/laravelrave/resources/config/rave.php new file mode 100644 index 00000000..5c1ee203 --- /dev/null +++ b/vendor/kingflamez/laravelrave/resources/config/rave.php @@ -0,0 +1,55 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +return [ + + /** + * Public Key: Your Rave publicKey. Sign up on https://rave.flutterwave.com/ to get one from your settings page + * + */ + 'publicKey' => env('RAVE_PUBLIC_KEY'), + + /** + * Secret Key: Your Rave secretKey. Sign up on https://rave.flutterwave.com/ to get one from your settings page + * + */ + 'secretKey' => env('RAVE_SECRET_KEY'), + + /** + * Company/Business/Store Name: The name of your store + * + */ + 'title' => env('RAVE_TITLE', 'Rave Payment Gateway'), + + /** + * Environment: This can either be 'staging' or 'live' + * + */ + 'env' => env('RAVE_ENVIRONMENT', 'staging'), + + /** + * Logo: Enter the URL of your company/business logo + * + */ + 'logo' => env('RAVE_LOGO', ''), + + /** + * Prefix: This is added to the front of your transaction reference numbers + * + */ + 'prefix' => env('RAVE_PREFIX', 'rave'), + + /** + * Prefix: This is added to the front of your transaction reference numbers + * + */ + 'secretHash' => env('RAVE_SECRET_HASH', ''), +]; diff --git a/vendor/kingflamez/laravelrave/resources/img/RaveInterface.jpg b/vendor/kingflamez/laravelrave/resources/img/RaveInterface.jpg new file mode 100644 index 00000000..9a3cf471 Binary files /dev/null and b/vendor/kingflamez/laravelrave/resources/img/RaveInterface.jpg differ diff --git a/vendor/kingflamez/laravelrave/resources/img/pay.jpg b/vendor/kingflamez/laravelrave/resources/img/pay.jpg new file mode 100644 index 00000000..b46382b1 Binary files /dev/null and b/vendor/kingflamez/laravelrave/resources/img/pay.jpg differ diff --git a/vendor/kingflamez/laravelrave/resources/img/rave.jpg b/vendor/kingflamez/laravelrave/resources/img/rave.jpg new file mode 100644 index 00000000..a80c8042 Binary files /dev/null and b/vendor/kingflamez/laravelrave/resources/img/rave.jpg differ diff --git a/vendor/kingflamez/laravelrave/resources/img/rave_logo.png b/vendor/kingflamez/laravelrave/resources/img/rave_logo.png new file mode 100644 index 00000000..9ae231ca Binary files /dev/null and b/vendor/kingflamez/laravelrave/resources/img/rave_logo.png differ diff --git a/vendor/kingflamez/laravelrave/src/Facades/Rave.php b/vendor/kingflamez/laravelrave/src/Facades/Rave.php new file mode 100644 index 00000000..dc11e6b4 --- /dev/null +++ b/vendor/kingflamez/laravelrave/src/Facades/Rave.php @@ -0,0 +1,26 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace KingFlamez\Rave\Facades; + +use Illuminate\Support\Facades\Facade; + +class Rave extends Facade +{ + /** + * Get the registered name of the component + * @return string + */ + protected static function getFacadeAccessor() + { + return 'laravelrave'; + } +} diff --git a/vendor/kingflamez/laravelrave/src/Rave.php b/vendor/kingflamez/laravelrave/src/Rave.php new file mode 100644 index 00000000..ec080d59 --- /dev/null +++ b/vendor/kingflamez/laravelrave/src/Rave.php @@ -0,0 +1,1078 @@ + + * @version 1.2 + **/ + +class Rave { + + protected $publicKey; + protected $secretKey; + protected $paymentMethod = 'both'; + protected $customLogo; + protected $customTitle; + protected $secretHash; + protected $txref; + protected $integrityHash; + protected $env = 'staging'; + protected $transactionPrefix; + protected $urls = [ + "live" => "https://api.ravepay.co", + "others" => "https://ravesandboxapi.flutterwave.com", + ]; + protected $baseUrl; + protected $transactionData; + protected $overrideTransactionReference; + protected $verifyCount = 0; + protected $request; + protected $unirestRequest; + protected $body; + + /** + * Construct + * @return object + * */ + function __construct (LaravelRequest $request, Request $unirestRequest, Body $body) { + $this->request = $request; + $this->body = $body; + $this->unirestRequest= $unirestRequest; + $prefix = Config::get('rave.prefix'); + $overrideRefWithPrefix = false; + + $this->publicKey = Config::get('rave.publicKey'); + $this->secretKey = Config::get('rave.secretKey'); + $this->env = Config::get('rave.env'); + $this->customLogo = Config::get('rave.logo'); + $this->customTitle = Config::get('rave.title'); + $this->secretHash = Config::get('rave.secretHash'); + $this->transactionPrefix = $prefix.'_'; + $this->overrideTransactionReference = $overrideRefWithPrefix; + + + Log::notice('Generating Reference Number....'); + if ($this->overrideTransactionReference) { + $this->txref = $this->transactionPrefix; + } else { + $this->txref = uniqid($this->transactionPrefix); + } + Log::notice('Generated Reference Number....' . $this->txref); + + $this->baseUrl = $this->urls[($this->env === "live" ? "$this->env" : "others")]; + + Log::notice('Rave Class Initializes....'); + } + + + /******************************************************************** + ******************************************************************** + * Modal Payment Start + ******************************************************************** + ********************************************************************/ + + /** + * Generates a checksum value for the information to be sent to the payment gateway + * @return object + * */ + public function createCheckSum($redirectURL){ + if ($this->request->payment_method) { + $this->paymentMethod = $this->request->payment_method; // value can be card, account or both + } + + if ($this->request->logo) { + $this->customLogo = $this->request->logo; // This might not be included if you have it set in your .env file + } + + if ($this->request->title) { + $this->customTitle = $this->request->title; // This can be left blank if you have it set in your .env file + } + + if ($this->request->ref) { + $this->txref = $this->request->ref; + } + + Log::notice('Generating Checksum....'); + $options = array( + "PBFPubKey" => $this->publicKey, + "amount" => $this->request->amount, + "customer_email" => $this->request->email, + "customer_firstname" => $this->request->firstname, + "txref" => $this->txref, + "payment_method" => $this->paymentMethod, + "customer_lastname" => $this->request->lastname, + "country" => $this->request->country, + "currency" => $this->request->currency, + "custom_description" => $this->request->description, + "custom_logo" => $this->customLogo, + "custom_title" => $this->customTitle, + "customer_phone" => $this->request->phonenumber, + "redirect_url" => $redirectURL, + "hosted_payment" => 1 + ); + + if (!empty($this->request->paymentplan)) { + $options["payment_plan"] = $this->request->paymentplan; + } + + ksort($options); + + $this->transactionData = $options; + + $hashedPayload = ''; + + foreach($options as $value){ + $hashedPayload .= $value; + } + + $completeHash = $hashedPayload.$this->secretKey; + + $this->integrityHash = hash('sha256', $completeHash); + return $this; + } + + + + /** + * Generates the final json to be used in configuring the payment call to the rave payment gateway + * @return string + * */ + public function initialize($redirectURL) + { + $meta = array(); + if (!empty($this->request->metadata)) { + $meta = json_decode($this->request->metadata, true); + } + + $this->createCheckSum($redirectURL); + $this->transactionData = array_merge($this->transactionData, array('data-integrity_hash' => $this->integrityHash), array('meta' => $meta)); + + $json = json_encode($this->transactionData); + echo ''; + echo ''; + echo '
Proccessing...
'; + echo ''; + echo ''; + echo ''; + echo ''; + + return $json; + } + + /** + * Handle canceled payments with this method + * @param string $referenceNumber This should be the reference number of the transaction that was canceled + * @return mixed + * */ + public function paymentCanceled($referenceNumber, $data) + { + $this->txref = $referenceNumber; + if (request()->cancelled) { + $cancelledResponse = '{"status": "cancelled" , "message": "Customer cancelled the transaction", "data":{ "status": "cancelled", "txRef" :"' . $this->txref . '"}}'; + $resp = json_decode($cancelledResponse); + return $resp; + } else { + return $data; + } + } + + /******************************************************************** + ******************************************************************** + * Modal Payment Ends + ******************************************************************** + ********************************************************************/ + + + /******************************************************************** + ******************************************************************** + * Miscs Start + ******************************************************************** + ********************************************************************/ + + + /** + * Refunds + * @return object + * */ + public function refund() + { + $data = array( + 'ref' => $this->request->ref, + 'seckey' => $this->secretKey + ); + + if (!empty($this->request->amount)) { + $data = array( + 'amount' => $this->request->amount, + 'ref' => $this->request->ref, + 'seckey' => $this->secretKey + ); + } + + // make request to endpoint using unirest. + $headers = array('Content-Type' => 'application/json'); + $body = $this->body->json($data); + $url = $this->baseUrl . '/gpx/merchant/transactions/refund'; + + // Make `POST` request and handle response with unirest + $response = $this->unirestRequest->post($url, $headers, $body); + + //check the status is success + if ($response->body && $response->body->status === "success") { + return $response->body; + } + + return $response->body; + } + + + /** + * Exchange Rates + * @return object + * */ + public function exchangeRates() + { + $data = array( + 'origin_currency' => $this->request->origin_currency, + 'destination_currency' => $this->request->destination_currency, + 'seckey' => $this->secretKey + ); + + if (!empty($this->request->amount)) { + $data = array( + 'origin_currency' => $this->request->origin_currency, + 'destination_currency' => $this->request->destination_currency, + 'amount' => $this->request->amount, + 'seckey' => $this->secretKey + ); + } + + // make request to endpoint using unirest. + $headers = array('Content-Type' => 'application/json'); + $body = $this->body->json($data); + $url = $this->baseUrl . '/gpx/merchant/transactions/refund'; + + // Make `POST` request and handle response with unirest + $response = $this->unirestRequest->post($url, $headers, $body); + + //check the status is success + if ($response->body && $response->body->status === "success") { + return $response->body; + } + + return $response->body; + } + + + /** + * Receive Webhook + * @param $secrethash + * @return object + * */ + public function receiveWebhook() + { + // Retrieve the request's body + $body = @file_get_contents("php://input"); + + // retrieve the signature sent in the reques header's. + $signature = (isset($_SERVER['verif-hash']) ? $_SERVER['verif-hash'] : ''); + + /* It is a good idea to log all events received. Add code * + * here to log the signature and body to db or file */ + + if (!$signature) { + // only a post with rave signature header gets our attention + exit(); + } + + // Store the same signature on your server as an env variable and check against what was sent in the headers + $local_signature = $this->secretHash; + + // confirm the event's signature + if( $signature !== $local_signature ){ + // silently forget this ever happened + exit(); + } + + http_response_code(200); // PHP 5.4 or greater + // parse event (which is json string) as object + // Give value to your customer but don't give any output + // Remember that this is a call from rave's servers and + // Your customer is not seeing the response here at all + $response = json_decode($body); + return $response; + } + + + /** + * Used for KYC to validate bvn + * @param string $bvn the customers bvn + * @return object + * */ + public function validateBVN($bvn) + { + $url = $this->baseUrl . '/kyc/bvn/'.$bvn.'?seckey=' . $this->secretKey; + $headers = array('Content-Type' => 'application/json'); + + // Make `GET` request and handle response with unirest + $response = $this->unirestRequest->get($url, $headers); + + //check the status is success + if ($response->body) { + return $response->body; + } + + return $response; + } + + + /******************************************************************** + ******************************************************************** + * Miscs End + ******************************************************************** + ********************************************************************/ + + + + /******************************************************************** + ******************************************************************** + * Charges Start + ******************************************************************** + ********************************************************************/ + + /** + * Verifies a transaction with the transaction reference + * @param string $referenceNumber This should be the reference number of the transaction you want to verify + * @return object + * */ + public function verifyTransaction($referenceNumber) + { + $this->txref = $referenceNumber; + $this->verifyCount++; + Log::notice('Verifying Transaction....' . $this->txref); + + $data = array( + 'txref' => $this->txref, + 'SECKEY' => $this->secretKey, + 'last_attempt' => '1' + // 'only_successful' => '1' + ); + + // make request to endpoint using unirest. + $headers = array('Content-Type' => 'application/json'); + $body = $this->body->json($data); + $url = $this->baseUrl . '/flwv3-pug/getpaidx/api/v2/verify'; + + // Make `POST` request and handle response with unirest + $response = $this->unirestRequest->post($url, $headers, $body); + + //check the status is success + if ($response->body && $response->body->status === "success") { + return $response->body; + } else { + if ($this->verifyCount > 4) { + $this->paymentCanceled($this->txref, $response->body); + } else { + sleep(3); + $this->verifyTransaction($this->txref); + } + } + } + + /******************************************************************** + ******************************************************************** + * Charges End + ******************************************************************** + ********************************************************************/ + + + /******************************************************************** + ******************************************************************** + * Payment Plans Start + ******************************************************************** + ********************************************************************/ + + /** + * Creates a payment plan + * @return object + * */ + public function createPaymentPlan() + { + + $data = array( + 'amount' => $this->request->amount, + 'interval' => $this->request->interval, + 'name' => $this->request->name, + 'duration' => $this->request->duration, + 'seckey' => $this->secretKey + ); + + // make request to endpoint using unirest. + $headers = array('Content-Type' => 'application/json'); + $body = $this->body->json($data); + $url = $this->baseUrl . '/v2/gpx/paymentplans/create'; + + // Make `POST` request and handle response with unirest + $response = $this->unirestRequest->post($url, $headers, $body); + + //check the status is success + if ($response->body && $response->body->status === "success") { + return $response->body; + } + + return $response->body; + } + + /** + * Edits a payment plan + * @param id $id This is the payment plan id + * @return object + * */ + public function editPaymentPlan($id) + { + + $data = array( + 'name' => $this->request->name, + 'status' => $this->request->status, + 'seckey' => $this->secretKey + ); + + // make request to endpoint using unirest. + $headers = array('Content-Type' => 'application/json'); + $body = $this->body->json($data); + $url = $this->baseUrl . '/v2/gpx/paymentplans/'.$id.'/edit'; + + // Make `POST` request and handle response with unirest + $response = $this->unirestRequest->post($url, $headers, $body); + + //check the status is success + if ($response->body && $response->body->status === "success") { + return $response->body; + } + + return $response->body; + } + + /** + * Cancels a payment plan + * @param id $id This is the payment plan id + * @return object + * */ + public function cancelPaymentPlan($id) + { + + $data = array( + 'seckey' => $this->secretKey + ); + + // make request to endpoint using unirest. + $headers = array('Content-Type' => 'application/json'); + $body = $this->body->json($data); + $url = $this->baseUrl . '/v2/gpx/paymentplans/'.$id.'/cancel'; + + // Make `POST` request and handle response with unirest + $response = $this->unirestRequest->post($url, $headers, $body); + + //check the status is success + if ($response->body && $response->body->status === "success") { + return $response->body; + } + + return $response->body; + } + + + /** + * List all the payment plans + * @return object + * */ + public function listPaymentPlans() + { + $url = $this->baseUrl . '/v2/gpx/paymentplans/query?seckey=' . $this->secretKey; + $headers = array('Content-Type' => 'application/json'); + + // Make `GET` request and handle response with unirest + $response = $this->unirestRequest->get($url, $headers); + + //check the status is success + if ($response->body) { + return $response->body; + } + + return $response; + } + + /** + * Fetches a payment plan + * @return object + * */ + public function fetchPaymentPlan($id='', $q='') + { + $url = $this->baseUrl . '/v2/gpx/paymentplans/query?seckey=' . $this->secretKey . '&q='.$q.'&id='.$id; + $headers = array('Content-Type' => 'application/json'); + + // Make `GET` request and handle response with unirest + $response = $this->unirestRequest->get($url, $headers); + + //check the status is success + if ($response->body) { + return $response->body; + } + + return $response; + } + + + /******************************************************************** + ******************************************************************** + * Payment Plans End + ******************************************************************** + ********************************************************************/ + + /******************************************************************** + ******************************************************************** + * Subscriptions Plans Start + ******************************************************************** + ********************************************************************/ + + /** + * List all the subscriptions + * @return object + * */ + public function listSubscriptions() + { + $url = $this->baseUrl . '/v2/gpx/subscriptions/query?seckey=' . $this->secretKey; + $headers = array('Content-Type' => 'application/json'); + + // Make `GET` request and handle response with unirest + $response = $this->unirestRequest->get($url, $headers); + + //check the status is success + if ($response->body) { + return $response->body; + } + + return $response; + } + + + /** + * Fetches a subscription + * @return object + * */ + public function fetchSubscription($id = '', $email = '') + { + $url = $this->baseUrl . '/v2/gpx/subscriptions/query?seckey=' . $this->secretKey . '&email=' . $email . '&id=' . $id; + $headers = array('Content-Type' => 'application/json'); + + // Make `GET` request and handle response with unirest + $response = $this->unirestRequest->get($url, $headers); + + //check the status is success + if ($response->body) { + return $response->body; + } + + return $response; + } + + /** + * Cancels a subscription + * @param id $id This is the subscription id + * @return object + * */ + public function cancelSubscription($id) + { + + $data = array( + 'seckey' => $this->secretKey + ); + + // make request to endpoint using unirest. + $headers = array('Content-Type' => 'application/json'); + $body = $this->body->json($data); + $url = $this->baseUrl . '/v2/gpx/subscriptions/' . $id . '/cancel'; + + // Make `POST` request and handle response with unirest + $response = $this->unirestRequest->post($url, $headers, $body); + + //check the status is success + if ($response->body && $response->body->status === "success") { + return $response->body; + } + + return $response->body; + } + + /** + * Activates a subscription + * @param id $id This is the subscription id + * @return object + * */ + public function activateSubscription($id) + { + + $data = array( + 'seckey' => $this->secretKey + ); + + // make request to endpoint using unirest. + $headers = array('Content-Type' => 'application/json'); + $body = $this->body->json($data); + $url = $this->baseUrl . '/v2/gpx/subscriptions/' . $id . '/activate'; + + // Make `POST` request and handle response with unirest + $response = $this->unirestRequest->post($url, $headers, $body); + + //check the status is success + if ($response->body && $response->body->status === "success") { + return $response->body; + } + + return $response->body; + } + + /******************************************************************** + ******************************************************************** + * Subscriptions Plans End + ******************************************************************** + ********************************************************************/ + + + + /******************************************************************** + ******************************************************************** + * Sub acccount Begin + ******************************************************************** + ********************************************************************/ + /** + + * Create Sub Account + * @return object + * */ + + public function createSubAccount() + { + $data = array( + 'account_bank' => $this->request->account_bank, + 'account_number' => $this->request->account_number, + 'business_name' => $this->request->business_name, + 'business_email' => $this->request->business_email, + 'business_contact' => $this->request->business_contact, + 'business_contact_mobile' => $this->request->business_contact_mobile, + 'business_mobile' => $this->request->business_mobile, + 'meta' => $this->meta, + 'seckey' => $this->seckey, + 'split_type' => $this->request->slit_type, + 'split_value' => $this->request->split_value + ); + + // make request to endpoint using unirest. + $headers = array('Content-Type' => 'application/json'); + $body = $this->body->json($data); + $url = $this->baseUrl . '/v2/gpx/subaccounts/create'; + // Make `POST` request and handle response with unirest + $response = $this->unirestRequest->post($url, $headers, $body); + + //check the status is success + if ($response->body && $response->body->status === "success") { + return $response->body; + } + + return $response->body; + + } + + /* List all the sub accounts + * @return object + * */ + public function listSubAccount() + { + $url = $this->baseUrl . '/v2/gpx/subaccounts/?seckey='. $this->secretKey; + $headers = array('Content-Type' => 'application/json'); + + // Make `GET` request and handle response with unirest + $response = $this->unirestRequest->get($url, $headers); + + //check the status is success + if ($response->body) { + return $response->body; + } + + return $response; + } + /** + * Fetches a sub account + * @return object + * */ + public function fetchSubAccount() + { + $id = $this->request->id; + $url = $this->baseUrl . '/v2/gpx/subaccounts/get/'.$id.'?seckey=' . $this->secretKey; + $headers = array('Content-Type' => 'application/json'); + + // Make `GET` request and handle response with unirest + $response = $this->unirestRequest->get($url, $headers); + + //check the status is success + if ($response->body) { + return $response->body; + } + + return $response; + } + + + /******************************************************************** + ******************************************************************** + * Sub acccount Ends + ******************************************************************** + ********************************************************************/ + + + /******************************************************************** + ******************************************************************** + * Transfer Begin + ******************************************************************** + ********************************************************************/ + /** + + * Initialiate a transfer + * @return object + * */ + + public function initiateTransfer($arrdata) + { + // make request to endpoint using unirest. + $headers = array('Content-Type' => 'application/json'); + $body = $this->body->json($arrdata); + $url = $this->baseUrl . '/v2/gpx/transfers/create'; + // Make `POST` request and handle response with unirest + $response = $this->unirestRequest->post($url, $headers, $body); + //check the status is success + if ($response->body && $response->body->status === "success") { + return $response->body; + } + return $response->body; + } + + /** + + * Initialiate a bulk transfer + * @return object + * */ + public function bulkTransfer($arrdata) + { + // make request to endpoint using unirest. + $headers = array('Content-Type' => 'application/json'); + $body = $this->body->json($arrdata); + $url = $this->baseUrl . '/v2/gpx/transfers/create_bulk'; + // Make `POST` request and handle response with unirest + $response = $this->unirestRequest->post($url, $headers, $body); + + //check the status is success + if ($response->body && $response->body->status === "success") { + return $response->body; + } + + return $response->body; + + } + /** + * Fetches a transfer + * @return object + * */ + public function fetchTransfer($id= '', $q= '', $reference= '') + { + $url = $this->baseUrl . '/v2/gpx/transfers?seckey=' . $this->secretKey . '&q='.$q.'&id='.$id. '&reference='.$reference; + $headers = array('Content-Type' => 'application/json'); + + // Make `GET` request and handle response with unirest + $response = $this->unirestRequest->get($url, $headers); + + //check the status is success + if ($response->body) { + return $response->body; + } + return $response; + } + + /* List all the Transfers + * @return object + * */ + public function listTransfers() + { + $data = array( + 'seckey' => $this->secretKey + ); + $url = $this->baseUrl . '/v2/gpx/transfers?seckey='. $this->secretKey; + $headers = array('Content-Type' => 'application/json'); + + // Make `GET` request and handle response with unirest + $response = $this->unirestRequest->get($url, $headers); + + //check the status is success + if ($response->body) { + return $response->body; + } + return $response; + } + /* Retrieve status of Bulk Transfers + * @return object + * */ + + public function retrieveStatusofBulkTransfers($patch_id= '') + { + $url = $this->baseUrl . '/v2/gpx/transfers?seckey='. $this->secretKey. '&patch_id='. $patch_id; + $headers = array('Content-Type' => 'application/json'); + + // Make `GET` request and handle response with unirest + $response = $this->unirestRequest->get($url, $headers); + + //check the status is success + if ($response->body) { + return $response->body; + } + return $response; + } + + /* Get the applicable transfer fee + * @return object + * */ + public function getApplicableTransferFee($currency) + { + $url = $this->baseUrl . '/v2/gpx/transfers?seckey='. $this->secretKey. '¤cy='. $currency; + $headers = array('Content-Type' => 'application/json'); + + // Make `GET` request and handle response with unirest + $response = $this->unirestRequest->get($url, $headers); + + return $response; + } + + /* Get the Transfer Balance + * @return object + * */ + public function getTransferBalance($currency) + { + $url = $this->baseUrl . '/v2/gpx/balance?seckey='. $this->seckey. '¤cy='. $currency; + $headers = array('Content-Type' => 'application/json'); + + // Make `GET` request and handle response with unirest + $response = $this->unirestRequest->post($url, $headers); + + return $response; + } + + /* Account Verification + * @return object + * */ + public function accountVerification($arrdata) + { + $body = $this->body->json($arrdata); + $url = $this->baseUrl . '/flwv3-pug/getpaidx/api/resolve_account'; + $headers = array('Content-Type' => 'application/json'); + + // Make `POST` request and handle response with unirest + $response = $this->unirestRequest->post($body , $url, $headers); + + //check the status is success + if ($response->body) { + return $response->body; + } + return $response; + } + + + /******************************************************************** + ******************************************************************** + * Transfer End + ******************************************************************** + ********************************************************************/ + + + /******************************************************************** + ******************************************************************** + * PREAUTHORIZED TRANSACTIONS Begin + ******************************************************************** + ********************************************************************/ + + /* PreAuthorise Card + * @return object + * */ + public function preAuthouriseCard($arrdata) + { + $body = $this->body->json($arrdata); + $url = $this->baseUrl . '/flwv3-pug/getpaidx/api/charge'; + $headers = array('Content-Type' => 'application/json'); + + // Make `GET` request and handle response with unirest + $response = $this->unirestRequest->get($body , $url, $headers); + + //check the status is success + if ($response->body) { + return $response->body; + } + return $response; + } + + /* Capture card + * @return object + * */ + public function capture($arrdata) + { + $body = $this->body->json($arrdata); + $url = $this->baseUrl . '/flwv3-pug/getpaidx/api/capture'; + $headers = array('Content-Type' => 'application/json'); + + // Make `GET` request and handle response with unirest + $response = $this->unirestRequest->post($body , $url, $headers); + + //check the status is success + if ($response->body) { + return $response->body; + } + return $response; + } + + /* Refund + * @return object + * */ + + public function refundPreAuthCard($arrdata) + { + $body = $this->body->json($arrdata); + $url = $this->baseUrl . '/flwv3-pug/getpaidx/api/refundorvoid'; + $headers = array('Content-Type' => 'application/json'); + + // Make `GET` request and handle response with unirest + $response = $this->unirestRequest->post($body , $url, $headers); + + //check the status is success + if ($response->body) { + return $response->body; + } + + return $response; + } + /******************************************************************** + ******************************************************************** + * PreAuntorise transaction End + ******************************************************************** + ********************************************************************/ + + + /******************************************************************** + ******************************************************************** + * Miscellaneous Start + ******************************************************************** + ********************************************************************/ + + /* Get fees + * @return object + * */ + + public function getFees($arrdata) + { + $body = $this->body->json($arrdata); + $url = $this->baseUrl . '/flwv3-pug/getpaidx/api/fee'; + $headers = array('Content-Type' => 'application/json'); + + // Make `GET` request and handle response with unirest + $response = $this->unirestRequest->get($body, $url, $headers); + + //check the status is success + if ($response->body) { + return $response->body; + } + + return $response; + } + + /* List of Direct bank Charge + * @return object + * */ + public function listofDirectBankCharge($country) + { + $url = $this->baseUrl . '/flwv3-pug/getpaidx/api/flwpbf-banks.js?json=1'. '&country='. $country; + $headers = array('Content-Type' => 'application/json'); + + //Make `GET` request and handle response with unirest + $response = $this->unirestRequest->get($url, $headers); + return $response; + } + + /* Exchange Rate + * @return object + * */ + public function exchangeRate($arrdata) + { + $url = $this->baseUrl . '/flwv3-pug/getpaidx/api/forex'; + $headers = array('Content-Type' => 'application/json'); + $body = $this->body->json($arrdata); + + // Make `POST` request and handle response with unirest + $response = $this->unirestRequest->post($body, $url, $headers); + + // check the status is success + if ($response->body && $response->body->status === "success") { + return $response->body; + } + return $response; + } + + /* List Transactions + * @return object + * */ + public function listTransactions($arrdata) + { + $url = $this->baseUrl . '/v2/gpx/transactions/query'; + $headers = array('Content-Type' => 'application/json'); + $body = $this->body->json($arrdata); + + // Make `POST` request and handle response with unirest + $response = $this->unirestRequest->post($body, $url, $headers); + + // check the status is success + if ($response->body && $response->body->status === "success") { + return $response->body; + } + return $response; + } + + /* List of Bank for Transfer + * @return object + * */ + + public function listofBankForTransfer($country) + { + $url = $this->baseUrl . '/banks?'. '&$country='. $country; + $headers = array('Content-Type' => 'application/json'); + + // Make `GET` request and handle response with unirest + $response = $this->unirestRequest->get($url, $headers); + + return $response; + + } + + /******************************************************************** + ******************************************************************** + * Miscellaneous Ends + ******************************************************************** + ********************************************************************/ +} diff --git a/vendor/kingflamez/laravelrave/src/RaveServiceProvider.php b/vendor/kingflamez/laravelrave/src/RaveServiceProvider.php new file mode 100644 index 00000000..fe673059 --- /dev/null +++ b/vendor/kingflamez/laravelrave/src/RaveServiceProvider.php @@ -0,0 +1,53 @@ +publishes([ + $config => config_path('rave.php') + ]); + } + + /** + * Register any package services. + * + * @return void + */ + public function register() + { + + $this->app->singleton('laravelrave', function ($app) { + + return new Rave($app->make("request"), new Request, new Body); + + }); + + $this->app->alias('laravelrave', "KingFlamez\Rave\Rave"); + } + + /** + * Get the services provided by the provider + * + * @return array + */ + public function provides() + { + return ['laravelrave']; + } +} diff --git a/vendor/kingflamez/laravelrave/tests/Concerns/ExtractProperties.php b/vendor/kingflamez/laravelrave/tests/Concerns/ExtractProperties.php new file mode 100644 index 00000000..eb1bd13c --- /dev/null +++ b/vendor/kingflamez/laravelrave/tests/Concerns/ExtractProperties.php @@ -0,0 +1,44 @@ +getProperty($name); + $property->setAccessible(true); + + return [ + "name" => $property->getName(), + "value" => $property->getValue($class), + ]; + } + + /** + * Set property of class. + * + * @param stdClass $class + * @param string $name Property name + * @param mixed $value + */ + function setProperty($class, $name, $value = null) { + + $reflector = new ReflectionClass($class); + $property = $reflector->getProperty($name); + $property->setAccessible(true); + + $property->setValue($class, $value); + } +} diff --git a/vendor/kingflamez/laravelrave/tests/Feature/FeatureTests.php b/vendor/kingflamez/laravelrave/tests/Feature/FeatureTests.php new file mode 100644 index 00000000..0f6a16c6 --- /dev/null +++ b/vendor/kingflamez/laravelrave/tests/Feature/FeatureTests.php @@ -0,0 +1,210 @@ +setData("http://localhost"); + + $this->assertInstanceOf("KingFlamez\Rave\Rave", $rave); + return $rave; + } + + /** + * Test if hash is created. + * + * @test + * @depends getParams + * @return void + */ + function creatingCheckSum(Rave $rave) { + + $rave = $rave->createReferenceNumber(); + $publicKey = "FLWPUBK-MOCK-1cf610974690c2560cb4c36f4921244a-X"; + $rave = $rave->setData("http://localhost"); + $rave = $rave->createCheckSum(); + + $hash = $this->extractProperty($rave, "integrityHash"); + + $this->assertEquals(64, strlen($hash["value"])); + + return $rave; + } + + /** + * Testing payment. + * + * @test + * @depends creatingCheckSum + * @return void + */ + function paymentInitialize(Rave $rave) { + + $response = $rave->eventHandler(new PaymentEventHandler)->initialize("http://localhost"); + + $values = json_decode($response, true); + + $class = $this->data["class"]; + + $this->assertArrayHasKey("meta", $values); + $this->assertArrayHasKey("txref", $values); + $this->assertArrayHasKey("amount", $values); + $this->assertArrayHasKey("country", $values); + $this->assertArrayHasKey("currency", $values); + $this->assertArrayHasKey("PBFPubKey", $values); + $this->assertArrayHasKey("custom_logo", $values); + $this->assertArrayHasKey("redirect_url", $values); + $this->assertArrayHasKey("integrity_hash", $values); + $this->assertArrayHasKey("payment_method", $values); + $this->assertArrayHasKey("customer_phone", $values); + $this->assertArrayHasKey("customer_email", $values); + $this->assertArrayHasKey("pay_button_text", $values); + $this->assertArrayHasKey("customer_lastname", $values); + $this->assertArrayHasKey("custom_description", $values); + $this->assertArrayHasKey("customer_firstname", $values); + } + + /** + * Test if proper actions are taken when payment is cancelled. + * + * @test + * @return void + */ + function paymentCancelledTest() { + + $rave = new Rave(new Request, new UnirestRequest, new Body); + $rave = $rave->createReferenceNumber(); + $ref = $rave->getReferenceNumber(); + + // This section tests if json is returned when no handler is set. + $returned = $rave->paymentCanceled($ref); + + $this->assertInternalType("string", $returned); + + // Tests if json has certain keys when payment is cancelled. + $returned = json_decode($returned, true); + + $this->assertArrayHasKey("txref", $returned); + $this->assertArrayHasKey("status", $returned); + + // This section tests if instance of rave is returned when a handler is set. + $rave = $rave->eventHandler(new PaymentEventHandler)->paymentCanceled($ref); + + $this->assertInstanceOf("KingFlamez\Rave\Rave", $rave); + + return $ref; + } + + /** + * Testing requery transactions. + * + * @test + * @depends paymentCancelledTest + * @dataProvider providesResponse + * @runInSeparateProcess + * @preserveGlobalState disabled + * @param string $ref txref + */ + function requeryTransactionTransactionTest($mResponse, $ref) { + + $data = [ + 'txref' => $ref, + 'SECKEY' => $this->app->config->get("secretKey"), + 'last_attempt' => '1' + // 'only_successful' => '1' + ]; + + $url = "https://rave-api-v2.herokuapp.com"; + $headers = ['Content-Type' => 'application/json']; + + $data = Body::json($data); + $response = json_encode($mResponse); + + $decodedResponse = json_decode($response); + + $mRequest = $this->m->mock("alias:Unirest\Request"); + $mRequest->shouldReceive("post") + ->andReturn($decodedResponse); + + $rave = new Rave(new Request, $mRequest, new Body); + + $raveResponse = $rave->requeryTransaction($ref); + + // Test if data is returned when no handler. + // $this->assertEquals($decodedResponse->body->status, $raveResponse->status); + + $this->setProperty($rave, "handler", new PaymentEventHandler); + + $raveResponse = $rave->requeryTransaction($ref); + + // Tests that an instance of rave is returned when a handler is set + $this->assertInstanceOf("KingFlamez\Rave\Rave", $raveResponse); + } + + /** + * Provides data for all events of requery transaction. + * + * @return array + */ + function providesResponse () { + + return [ + [ + [ + "body" => [ + "status" => "unknown", + "data" => ["status", "unknown"] + ], + ], + ], + [ + [ + "body" => [ + "status" => "success", + ], + ] + ], + [ + [ + "body" => [ + "status" => "success", + "data" => [ + "status" => "failed" + ] + ], + ] + ], + [ + [ + "body" => [ + "status" => "success", + "data" => [ + "status" => "successful" + ] + ], + ] + ] + ]; + } +} diff --git a/vendor/kingflamez/laravelrave/tests/Stubs/PaymentEventHandler.php b/vendor/kingflamez/laravelrave/tests/Stubs/PaymentEventHandler.php new file mode 100644 index 00000000..802775fa --- /dev/null +++ b/vendor/kingflamez/laravelrave/tests/Stubs/PaymentEventHandler.php @@ -0,0 +1,77 @@ +'; //Remember to delete this line + } + + /** + * This is called only when a transaction is successful + * */ + function onSuccessful($transactionData){ + // Get the transaction from your DB using the transaction reference (txref) + // Check if you have previously given value for the transaction. If you have, redirect to your successpage else, continue + // Comfirm that the transaction is successful + // Confirm that the chargecode is 00 or 0 + // Confirm that the currency on your db transaction is equal to the returned currency + // Confirm that the db transaction amount is equal to the returned amount + // Update the db transaction record (includeing parameters that didn't exist before the transaction is completed. for audit purpose) + // Give value for the transaction + // Update the transaction to note that you have given value for the transaction + // You can also redirect to your success page from here + return 'Payment Successful!'.json_encode($transactionData).'
'; //Remember to delete this line + } + + /** + * This is called only when a transaction failed + * */ + function onFailure($transactionData){ + // Get the transaction from your DB using the transaction reference (txref) + // Update the db transaction record (includeing parameters that didn't exist before the transaction is completed. for audit purpose) + // You can also redirect to your failure page from here + return 'Payment Failed!'.json_encode($transactionData).'
'; //Remember to delete this line + } + + /** + * This is called when a transaction is requeryed from the payment gateway + * */ + function onRequery($transactionReference){ + // Do something, anything! + return 'Payment requeried......'.$transactionReference.'
'; //Remember to delete this line + } + + /** + * This is called a transaction requery returns with an error + * */ + function onRequeryError($requeryResponse){ + // Do something, anything! + return 'An error occured while requeying the transaction...'.json_encode($requeryResponse).'
'; //Remember to delete this line + } + + /** + * This is called when a transaction is canceled by the user + * */ + function onCancel($transactionReference){ + // Do something, anything! + // Note: Somethings a payment can be successful, before a user clicks the cancel button so proceed with caution + return 'Payment canceled by user......'.$transactionReference.'
'; //Remember to delete this line + } + + /** + * This is called when a transaction doesn't return with a success or a failure response. This can be a timedout transaction on the Rave server or an abandoned transaction by the customer. + * */ + function onTimeout($transactionReference, $data){ + // Get the transaction from your DB using the transaction reference (txref) + // Queue it for requery. Preferably using a queue system. The requery should be about 15 minutes after. + // Ask the customer to contact your support and you should escalate this issue to the flutterwave support team. Send this as an email and as a notification on the page. just incase the page timesout or disconnects + return 'Payment timeout......'.$transactionReference.' - '.json_encode($data).'
'; //Remember to delete this line + } +} diff --git a/vendor/kingflamez/laravelrave/tests/Stubs/Request.php b/vendor/kingflamez/laravelrave/tests/Stubs/Request.php new file mode 100644 index 00000000..7bcb43e3 --- /dev/null +++ b/vendor/kingflamez/laravelrave/tests/Stubs/Request.php @@ -0,0 +1,29 @@ +{$key} = $value; + }); + } +} diff --git a/vendor/kingflamez/laravelrave/tests/Stubs/env.php b/vendor/kingflamez/laravelrave/tests/Stubs/env.php new file mode 100644 index 00000000..a889b520 --- /dev/null +++ b/vendor/kingflamez/laravelrave/tests/Stubs/env.php @@ -0,0 +1,15 @@ + "rave", + "secretKey" => "FLWSECK-4127f15e63c9098402dcc7891798fb0f-X", + "publicKey" => "FLWPUBK-1cf610974690c2560cb4c36f4921244a-X", + "title" => "Rave Payment Gateway", + "env" => "testing", + "logo" => "https://files.readme.io/ee907a0-small-rave_by_flutterwave.png" +]; diff --git a/vendor/kingflamez/laravelrave/tests/Stubs/request_data.php b/vendor/kingflamez/laravelrave/tests/Stubs/request_data.php new file mode 100644 index 00000000..8dc88276 --- /dev/null +++ b/vendor/kingflamez/laravelrave/tests/Stubs/request_data.php @@ -0,0 +1,46 @@ + [ + "amount" => 30000, + "title" => "A Title", + "lastname" => "Last", + "currency" => "naira", + "country" => "Nigeria", + "firstname" => "First", + "payment_method" => "card", + "phonenumber" => "08012345678", + "email" => "email@example.org", + "pay_button_text" => "Pay Now", + "metadata" => "[{ flightid:3849 }]", + "description" => "Some random description.", + "logo" => "https://files.readme.io/ee907a0-small-rave_by_flutterwave.png", + ], + + /** + * Rave original properties representation. + */ + "class" => [ + "amount", + "country", + "currency", + "lastname", + "firstname", + ["logo" => "customLogo"], + "phonenumber", + ["title" => "customTitle"], + "payButtonText", + ["email" => "customerEmail"], + "payment_method", + ["description" => "customeDescription"], + "metadata", + ] +]; diff --git a/vendor/kingflamez/laravelrave/tests/TestCase.php b/vendor/kingflamez/laravelrave/tests/TestCase.php new file mode 100644 index 00000000..6af4ca12 --- /dev/null +++ b/vendor/kingflamez/laravelrave/tests/TestCase.php @@ -0,0 +1,80 @@ +m = new Mockery; + + $this->envVars = (array) include __DIR__ . "/Stubs/env.php"; + + $this->data = (array) include __DIR__ . "/Stubs/request_data.php"; + + $this->formData = $this->data["form"]; + + parent::setUp(); + } + + /** + * Clear mockery after every test in preparation for a new mock. + * + * @return void + */ + function tearDown() { + + $this->m->close(); + + parent::tearDown(); + } + + /** + * Register package. + * + * @param \Illuminate\Foundation\Application $app + * @return array Packages to register + */ + protected function getPackageProviders($app) + { + return [ "\KingFlamez\Rave\RaveServiceProvider" ]; + } + + /** + * Get alias packages from app. + * + * @param \illuminate\Foundation\Application $app + * @return array Aliases. + */ + protected function getPackageAliases($app) + { + return [ + "Rave" => "\KingFlamez\Rave\Facades\Rave" + ]; + } + + /** + * Configure Environment. + * + * @param \Illuminate\Foundation\Application $app + * @return void + */ + protected function getEnvironmentSetUp($app) + { + array_walk($this->envVars, function ($value, $key) use (&$app) { + + $app["config"]->set("rave.{$key}", $value); + }); + } +} diff --git a/vendor/kingflamez/laravelrave/tests/Unit/RaveServiceProviderTests.php b/vendor/kingflamez/laravelrave/tests/Unit/RaveServiceProviderTests.php new file mode 100644 index 00000000..ab20a5c7 --- /dev/null +++ b/vendor/kingflamez/laravelrave/tests/Unit/RaveServiceProviderTests.php @@ -0,0 +1,29 @@ +assertTrue($this->app->bound('laravelrave')); + } + /** + * Test if service provider returns \Rave as alias for \KingFlamez\Rave\Rave + * + * @test + */ + public function hasAliased() + { + $this->assertTrue($this->app->isAlias("KingFlamez\Rave\Rave")); + $this->assertEquals('laravelrave', $this->app->getAlias("KingFlamez\Rave\Rave")); + } +} diff --git a/vendor/kingflamez/laravelrave/tests/Unit/UnitTests.php b/vendor/kingflamez/laravelrave/tests/Unit/UnitTests.php new file mode 100644 index 00000000..8147d54a --- /dev/null +++ b/vendor/kingflamez/laravelrave/tests/Unit/UnitTests.php @@ -0,0 +1,419 @@ +app->make("laravelrave"); + + $this->assertTrue($rave instanceof Rave); + + return $rave; + } + + /** + * Test Rave initiallizes with default values;. + * + * @test + * + * @depends initiateRaveFromApp + * @param \KingFlamez\Rave\Rave $rave + * @return void + */ + function initializeWithDefaultValues(Rave $rave) { + + $reflector = new ReflectionClass($rave); + $currentEnv = $this->app->config->get("rave.env"); + + $methods = $reflector->getProperties(ReflectionProperty::IS_PROTECTED); + + foreach($methods as $method) { + if ($method->getName() == 'env') $env = $method; + if ($method->getName() == 'urls') $urls = $method; + if ($method->getName() == 'baseUrl') $baseUrl = $method; + if ($method->getName() == 'secretKey') $secretKey = $method; + if ($method->getName() == 'publicKey') $publicKey = $method; + if ($method->getName() == 'customLogo') $customLogo = $method; + if ($method->getName() == 'customTitle') $customTitle = $method; + if ($method->getName() == 'transactionPrefix') $transactionPrefix = $method; + if ($method->getName() == 'overrideTransactionReference') $overrideTransactionReference = $method; + }; + + $env->setAccessible(true); + $urls->setAccessible(true); + $baseUrl->setAccessible(true); + $publicKey->setAccessible(true); + $secretKey->setAccessible(true); + $customLogo->setAccessible(true); + $customTitle->setAccessible(true); + $transactionPrefix->setAccessible(true); + $overrideTransactionReference->setAccessible(true); + + $this->assertFalse($overrideTransactionReference->getValue($rave)); + $this->assertEquals($this->app->config->get("rave.env"), $env->getValue($rave)); + $this->assertEquals($this->app->config->get("rave.logo"), $customLogo->getValue($rave)); + $this->assertEquals($this->app->config->get("rave.title"), $customTitle->getValue($rave)); + $this->assertEquals($this->app->config->get("rave.secretKey"), $secretKey->getValue($rave)); + $this->assertEquals($this->app->config->get("rave.publicKey"), $publicKey->getValue($rave)); + $this->assertEquals( + $urls->getValue($rave)[($currentEnv === "live" ? "live" : "others")], $baseUrl->getValue($rave) + ); + $this->assertEquals($this->app->config->get("rave.prefix")."_", $transactionPrefix->getValue($rave)); + } + + /** + * Tests if transaction reference is generated. + * + * @test + * @depends initiateRaveFromApp + * @return void + */ + function generatesTransactionReference (Rave $rave) { + + $ref = $rave->getReferenceNumber(); + + $prefix = $this->app->config->get("rave.prefix"); + + $this->assertRegExp("/^{$prefix}_\w{13}$/", $ref); + } + + /** + * Testing if environment is modified using setEnvironment. + * + * @test + * @depends initiateRaveFromApp + * @return void + */ + function settingUpEnvironment(Rave $rave) { + + $newEnv = "live"; + $rave->setEnvironment($newEnv); + $env = $this->extractProperty($rave, "env"); + + $this->assertEquals($newEnv, $env["value"]); + } + + /** + * Testing if prefix is modified using setPrefix. + * + * @test + * @depends initiateRaveFromApp + * @return void + */ + function alterPrefix(Rave $rave) { + + $newPrefix = "org"; + $txRef = $rave->setPrefix($newPrefix, true)->getReferenceNumber(); + $transactionPrefix = $this->extractProperty($rave, "transactionPrefix"); + $overrideTransactionReference = $this->extractProperty($rave, "overrideTransactionReference"); + + $this->assertEquals("org", $txRef); + $this->assertTrue($overrideTransactionReference["value"]); + $this->assertEquals("org", $transactionPrefix["value"]); + } + + /** + * Testing if amount is modified using setAmount. + * + * @test + * @depends initiateRaveFromApp + * @return void + */ + function settingAmount(Rave $rave) { + + $newAmountInt = 30000; + $newAmountDouble = 30000.50; + + $rave->setAmount($newAmountInt); + $amountGetterInt = $rave->getAmount(); + $rave->setAmount($newAmountDouble); + $amountGetterDouble = $rave->getAmount(); + + $this->assertInternalType("integer", $amountGetterInt); + $this->assertEquals($newAmountInt, $amountGetterInt); + $this->assertInternalType("double", $amountGetterDouble); + $this->assertEquals($newAmountDouble, $amountGetterDouble); + } + + /** + * Testing if keys are modified using setkeys. + * + * @test + * @depends initiateRaveFromApp + * @return void + */ + function settingKeys(Rave $rave) { + + $newPublicKey = "public_key"; + $newSecretKey = "secret_key"; + $rave->setKeys($newPublicKey, $newSecretKey); + $reflector = new ReflectionClass($rave); + $reflector = $reflector->getProperties(ReflectionProperty::IS_PROTECTED); + + $keys = array_map(function($value) use ($rave, $newPublicKey, $newSecretKey) { + $name = $value->getName(); + if ($name === "publicKey" || $name === "secretKey") { + $value->setAccessible(true); + $key = $value->getValue($rave); + $this->assertEquals(${"new".ucfirst($name)}, $key); + } + }, $reflector); + + } + + /** + * Testing if payment method is modified using setMethod. + * + * @test + * @depends initiateRaveFromApp + * @return void + */ + function settingPaymentMethod(Rave $rave) { + + $newPaymentMethod = "card"; + $rave->setPaymentMethod($newPaymentMethod); + $paymentMethodGetter = $rave->getPaymentMethod(); + + $this->assertInternalType("string", $paymentMethodGetter); + $this->assertEquals($newPaymentMethod, $paymentMethodGetter); + } + + /** + * Testing if description is modified using setDescription. + * + * @test + * @depends initiateRaveFromApp + * @return void + */ + function settingDescription(Rave $rave) { + + $newDescription = "A new description"; + $rave->setDescription($newDescription); + $descriptionGetter = $rave->getDescription(); + + $this->assertInternalType("string", $descriptionGetter); + $this->assertEquals($newDescription, $descriptionGetter); + } + + /** + * Testing if logo is modified using setLogo. + * + * @test + * @depends initiateRaveFromApp + * @return void + */ + function settingLogo(Rave $rave) { + + $newLogo = "http://a.yu8.us/banner_rexegg3.png"; + $rave->setLogo($newLogo); + $logoGetter = $rave->getLogo(); + + $this->assertInternalType("string", $logoGetter); + $this->assertEquals($newLogo, $logoGetter); + } + + /** + * Testing if title is modified using setTitle. + * + * @test + * @depends initiateRaveFromApp + * @return void + */ + function settingTitle(Rave $rave) { + + $newTitle = "http://a.yu8.us/banner_rexegg3.png"; + $rave->setTitle($newTitle); + $titleGetter = $rave->getTitle(); + + $this->assertInternalType("string", $titleGetter); + $this->assertEquals($newTitle, $titleGetter); + } + + /** + * Testing if country is modified using setCountry. + * + * @test + * @depends initiateRaveFromApp + * @return void + */ + function settingCountry(Rave $rave) { + + $newCountry = "Nigeria"; + $rave->setCountry($newCountry); + $countryGetter = $rave->getCountry(); + + $this->assertInternalType("string", $countryGetter); + $this->assertEquals($newCountry, $countryGetter); + } + + /** + * Testing if currency is modified using setCurrency. + * + * @test + * @depends initiateRaveFromApp + * @return void + */ + function settingCurrency(Rave $rave) { + + $newCurrency = "naira"; + $rave->setCurrency($newCurrency); + $currencyGetter = $rave->getCurrency(); + + $this->assertInternalType("string", $currencyGetter); + $this->assertEquals($newCurrency, $currencyGetter); + } + + /** + * Testing if email is modified using setEmail. + * + * @test + * @depends initiateRaveFromApp + * @return void + */ + function settingEmail(Rave $rave) { + + $newEmail = "email@example.com"; + $rave->setEmail($newEmail); + $emailGetter = $rave->getEmail(); + + $this->assertInternalType("string", $emailGetter); + $this->assertEquals($newEmail, $emailGetter); + } + + /** + * Testing if firstname is modified using setFirstname. + * + * @test + * @depends initiateRaveFromApp + * @return void + */ + function settingFirstname(Rave $rave) { + + $newFirstname = "First"; + $rave->setFirstname($newFirstname); + $firstnameGetter = $rave->getFirstname(); + + $this->assertInternalType("string", $firstnameGetter); + $this->assertEquals($newFirstname, $firstnameGetter); + } + + /** + * Testing if lastname is modified using setLastname. + * + * @test + * @depends initiateRaveFromApp + * @return void + */ + function settingLastname(Rave $rave) { + + $newLastname = "Last"; + $rave->setLastname($newLastname); + $lastnameGetter = $rave->getLastname(); + + $this->assertInternalType("string", $lastnameGetter); + $this->assertEquals($newLastname, $lastnameGetter); + } + + /** + * Testing if phoneNumber is modified using setPhoneNumber. + * + * @test + * @depends initiateRaveFromApp + * @return void + */ + function settingPhoneNumber(Rave $rave) { + + $newPhoneNumber = "08012345678"; + $rave->setPhoneNumber($newPhoneNumber); + $phoneNumberGetter = $rave->getPhoneNumber(); + + $this->assertInternalType("string", $phoneNumberGetter); + $this->assertEquals($newPhoneNumber, $phoneNumberGetter); + } + + /** + * Testing if payButtonText is modified using setPayButtonText. + * + * @test + * @depends initiateRaveFromApp + * @return void + */ + function settingPayButtonText(Rave $rave) { + + $newPayButtonText = "Pay Now"; + $rave->setPayButtonText($newPayButtonText); + $payButtonTextGetter = $rave->getPayButtonText(); + + $this->assertInternalType("string", $payButtonTextGetter); + $this->assertEquals($newPayButtonText, $payButtonTextGetter); + } + + /** + * Testing if redirectUrl is modified using setRedirectUrl. + * + * @test + * @depends initiateRaveFromApp + * @return void + */ + function settingRedirectUrl(Rave $rave) { + + $newRedirectUrl = "http://localhost/ipayed"; + $rave->setRedirectUrl($newRedirectUrl); + $redirectUrlGetter = $rave->getRedirectUrl(); + + $this->assertInternalType("string", $redirectUrlGetter); + $this->assertEquals($newRedirectUrl, $redirectUrlGetter); + } + + /** + * Testing if event handler is set using eventHandler. + * + * @test + * @depends initiateRaveFromApp + * @return void + */ + function settingEventHandler(Rave $rave) { + + $newEventHandler = new PaymentEventHandler; + $rave->eventHandler($newEventHandler); + $handler = $this->extractProperty($rave, "handler"); + + $this->assertInstanceOf("Tests\Stubs\PaymentEventHandler", $handler["value"]); + } + + /** + * Testing if meta data is set using setMetaData. + * + * @test + * @depends initiateRaveFromApp + * @return void + */ + function settingMetaData(Rave $rave) { + + $newMetaData = ["date" => Carbon::now()]; + $rave->setMetaData($newMetaData); + $metaData = $rave->getMetaData(); + + $this->assertArraySubset($newMetaData, $metaData[0]); + } +} diff --git a/vendor/mashape/unirest-php/.editorconfig b/vendor/mashape/unirest-php/.editorconfig new file mode 100644 index 00000000..971de2d5 --- /dev/null +++ b/vendor/mashape/unirest-php/.editorconfig @@ -0,0 +1,16 @@ +# http://editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.{json,xml,yml}] +indent_size = 2 + +[*.{md,yml}] +trim_trailing_whitespace = false diff --git a/vendor/mashape/unirest-php/.gitignore b/vendor/mashape/unirest-php/.gitignore new file mode 100644 index 00000000..3a25e7bf --- /dev/null +++ b/vendor/mashape/unirest-php/.gitignore @@ -0,0 +1,7 @@ +.DS_Store +.idea +build +composer.lock +composer.phar +coverage +vendor diff --git a/vendor/mashape/unirest-php/.travis.yml b/vendor/mashape/unirest-php/.travis.yml new file mode 100644 index 00000000..8c543c31 --- /dev/null +++ b/vendor/mashape/unirest-php/.travis.yml @@ -0,0 +1,39 @@ +sudo: false + +language: php + +php: + - '5.4' + - '5.5' + - '5.6' + - '7.0' + - hhvm + +before_script: + - composer selfupdate + - composer install + +after_script: + - vendor/bin/test-reporter --stdout > codeclimate.json + - "curl -X POST -d @codeclimate.json -H 'Content-Type: application/json' -H 'User-Agent: Code Climate (PHP Test Reporter v0.1.1)' https://codeclimate.com/test_reports" + +notifications: + webhooks: + urls: + - https://webhooks.gitter.im/e/802f417bb6e3e1e8b20d + on_success: always + on_failure: always + on_start: false + +matrix: + fast_finish: true + allow_failures: + - php: hhvm + +notifications: + webhooks: + urls: + - https://webhooks.gitter.im/e/d4319553d0aecfd5b9ac + on_success: always + on_failure: always + on_start: false diff --git a/vendor/mashape/unirest-php/LICENSE b/vendor/mashape/unirest-php/LICENSE new file mode 100644 index 00000000..78fe11e6 --- /dev/null +++ b/vendor/mashape/unirest-php/LICENSE @@ -0,0 +1,22 @@ +The MIT License + +Copyright (c) 2013-2015 Mashape (https://www.mashape.com) + +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. diff --git a/vendor/mashape/unirest-php/README.md b/vendor/mashape/unirest-php/README.md new file mode 100644 index 00000000..20ace164 --- /dev/null +++ b/vendor/mashape/unirest-php/README.md @@ -0,0 +1,439 @@ +# Unirest for PHP [![Build Status][travis-image]][travis-url] [![version][packagist-version]][packagist-url] + +[![Downloads][packagist-downloads]][packagist-url] +[![Code Climate][codeclimate-quality]][codeclimate-url] +[![Coverage Status][codeclimate-coverage]][codeclimate-url] +[![Dependencies][versioneye-image]][versioneye-url] +[![Gitter][gitter-image]][gitter-url] +[![License][packagist-license]][license-url] + +![][unirest-logo] + + +[Unirest](http://unirest.io) is a set of lightweight HTTP libraries available in multiple languages, built and maintained by [Mashape](https://github.com/Mashape), who also maintain the open-source API Gateway [Kong](https://github.com/Mashape/kong). + + +## Features + +* Utility methods to call `GET`, `HEAD`, `POST`, `PUT`, `DELETE`, `CONNECT`, `OPTIONS`, `TRACE`, `PATCH` requests +* Supports form parameters, file uploads and custom body entities +* Supports gzip +* Supports Basic, Digest, Negotiate, NTLM Authentication natively +* Customizable timeout +* Customizable default headers for every request (DRY) +* Automatic JSON parsing into a native object for JSON responses + +## Requirements + +- [cURL](http://php.net/manual/en/book.curl.php) +- PHP 5.4+ + +## Installation + +### Using [Composer](https://getcomposer.org) + +To install unirest-php with Composer, just add the following to your `composer.json` file: + +```json +{ + "require-dev": { + "mashape/unirest-php": "3.*" + } +} +``` + +or by running the following command: + +```shell +composer require mashape/unirest-php +``` + +This will get you the latest version of the reporter and install it. If you do want the master, untagged, version you may use the command below: + +```shell +composer require mashape/php-test-reporter dev-master +``` + +Composer installs autoloader at `./vendor/autoloader.php`. to include the library in your script, add: + +```php +require_once 'vendor/autoload.php'; +``` + +If you use Symfony2, autoloader has to be detected automatically. + +*You can see this library on [Packagist](https://packagist.org/packages/mashape/unirest-php).* + +### Install from source + +Download the PHP library from Github, then include `Unirest.php` in your script: + +```shell +git clone git@github.com:Mashape/unirest-php.git +``` + +```php +require_once '/path/to/unirest-php/src/Unirest.php'; +``` + +## Usage + +### Creating a Request + +So you're probably wondering how using Unirest makes creating requests in PHP easier, let's look at a working example: + +```php +$headers = array('Accept' => 'application/json'); +$query = array('foo' => 'hello', 'bar' => 'world'); + +$response = Unirest\Request::post('http://mockbin.com/request', $headers, $query); + +$response->code; // HTTP Status code +$response->headers; // Headers +$response->body; // Parsed body +$response->raw_body; // Unparsed body +``` + +### JSON Requests *(`application/json`)* + +A JSON Request can be constructed using the `Unirest\Request\Body::Json` helper: + +```php +$headers = array('Accept' => 'application/json'); +$data = array('name' => 'ahmad', 'company' => 'mashape'); + +$body = Unirest\Request\Body::json($data); + +$response = Unirest\Request::post('http://mockbin.com/request', $headers, $body); +``` + +**Notes:** +- `Content-Type` headers will be automatically set to `application/json` +- the data variable will be processed through [`json_encode`](http://php.net/manual/en/function.json-encode.php) with default values for arguments. +- an error will be thrown if the [JSON Extension](http://php.net/manual/en/book.json.php) is not available. + +### Form Requests *(`application/x-www-form-urlencoded`)* + +A typical Form Request can be constructed using the `Unirest\Request\Body::Form` helper: + +```php +$headers = array('Accept' => 'application/json'); +$data = array('name' => 'ahmad', 'company' => 'mashape'); + +$body = Unirest\Request\Body::form($data); + +$response = Unirest\Request::post('http://mockbin.com/request', $headers, $body); +``` + +**Notes:** +- `Content-Type` headers will be automatically set to `application/x-www-form-urlencoded` +- the final data array will be processed through [`http_build_query`](http://php.net/manual/en/function.http-build-query.php) with default values for arguments. + +### Multipart Requests *(`multipart/form-data`)* + +A Multipart Request can be constructed using the `Unirest\Request\Body::Multipart` helper: + +```php +$headers = array('Accept' => 'application/json'); +$data = array('name' => 'ahmad', 'company' => 'mashape'); + +$body = Unirest\Request\Body::multipart($data); + +$response = Unirest\Request::post('http://mockbin.com/request', $headers, $body); +``` + +**Notes:** + +- `Content-Type` headers will be automatically set to `multipart/form-data`. +- an auto-generated `--boundary` will be set. + +### Multipart File Upload + +simply add an array of files as the second argument to to the `Multipart` helper: + +```php +$headers = array('Accept' => 'application/json'); +$data = array('name' => 'ahmad', 'company' => 'mashape'); +$files = array('bio' => '/path/to/bio.txt', 'avatar' => '/path/to/avatar.jpg'); + +$body = Unirest\Request\Body::multipart($data, $files); + +$response = Unirest\Request::post('http://mockbin.com/request', $headers, $body); + ``` + +If you wish to further customize the properties of files uploaded you can do so with the `Unirest\Request\Body::File` helper: + +```php +$headers = array('Accept' => 'application/json'); +$body = array( + 'name' => 'ahmad', + 'company' => 'mashape' + 'bio' => Unirest\Request\Body::file('/path/to/bio.txt', 'text/plain'), + 'avatar' => Unirest\Request\Body::file('/path/to/my_avatar.jpg', 'text/plain', 'avatar.jpg') +); + +$response = Unirest\Request::post('http://mockbin.com/request', $headers, $body); + ``` + +**Note**: we did not use the `Unirest\Request\Body::multipart` helper in this example, it is not needed when manually adding files. + +### Custom Body + +Sending a custom body such rather than using the `Unirest\Request\Body` helpers is also possible, for example, using a [`serialize`](http://php.net/manual/en/function.serialize.php) body string with a custom `Content-Type`: + +```php +$headers = array('Accept' => 'application/json', 'Content-Type' => 'application/x-php-serialized'); +$body = serialize((array('foo' => 'hello', 'bar' => 'world')); + +$response = Unirest\Request::post('http://mockbin.com/request', $headers, $body); +``` + +### Authentication + +First, if you are using [Mashape][mashape-url]: +```php +// Mashape auth +Unirest\Request::setMashapeKey(''); +``` + +Otherwise, passing a username, password *(optional)*, defaults to Basic Authentication: + +```php +// basic auth +Unirest\Request::auth('username', 'password'); +``` + +The third parameter, which is a bitmask, will Unirest which HTTP authentication method(s) you want it to use for your proxy authentication. + +If more than one bit is set, Unirest *(at PHP's libcurl level)* will first query the site to see what authentication methods it supports and then pick the best one you allow it to use. *For some methods, this will induce an extra network round-trip.* + +**Supported Methods** + +| Method | Description | +| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `CURLAUTH_BASIC` | HTTP Basic authentication. This is the default choice | +| `CURLAUTH_DIGEST` | HTTP Digest authentication. as defined in [RFC 2617](http://www.ietf.org/rfc/rfc2617.txt) | +| `CURLAUTH_DIGEST_IE` | HTTP Digest authentication with an IE flavor. *The IE flavor is simply that libcurl will use a special "quirk" that IE is known to have used before version 7 and that some servers require the client to use.* | +| `CURLAUTH_NEGOTIATE` | HTTP Negotiate (SPNEGO) authentication. as defined in [RFC 4559](http://www.ietf.org/rfc/rfc4559.txt) | +| `CURLAUTH_NTLM` | HTTP NTLM authentication. A proprietary protocol invented and used by Microsoft. | +| `CURLAUTH_NTLM_WB` | NTLM delegating to winbind helper. Authentication is performed by a separate binary application. *see [libcurl docs](http://curl.haxx.se/libcurl/c/CURLOPT_HTTPAUTH.html) for more info* | +| `CURLAUTH_ANY` | This is a convenience macro that sets all bits and thus makes libcurl pick any it finds suitable. libcurl will automatically select the one it finds most secure. | +| `CURLAUTH_ANYSAFE` | This is a convenience macro that sets all bits except Basic and thus makes libcurl pick any it finds suitable. libcurl will automatically select the one it finds most secure. | +| `CURLAUTH_ONLY` | This is a meta symbol. OR this value together with a single specific auth value to force libcurl to probe for un-restricted auth and if not, only that single auth algorithm is acceptable. | + +```php +// custom auth method +Unirest\Request::proxyAuth('username', 'password', CURLAUTH_DIGEST); +``` + +Previous versions of **Unirest** support *Basic Authentication* by providing the `username` and `password` arguments: + +```php +$response = Unirest\Request::get('http://mockbin.com/request', null, null, 'username', 'password'); +``` + +**This has been deprecated, and will be completely removed in `v.3.0.0` please use the `Unirest\Request::auth()` method instead** + +### Cookies + +Set a cookie string to specify the contents of a cookie header. Multiple cookies are separated with a semicolon followed by a space (e.g., "fruit=apple; colour=red") + +```php +Unirest\Request::cookie($cookie) +``` + +Set a cookie file path for enabling cookie reading and storing cookies across multiple sequence of requests. + +```php +Unirest\Request::cookieFile($cookieFile) +``` + +`$cookieFile` must be a correct path with write permission. + +### Request Object + +```php +Unirest\Request::get($url, $headers = array(), $parameters = null) +Unirest\Request::post($url, $headers = array(), $body = null) +Unirest\Request::put($url, $headers = array(), $body = null) +Unirest\Request::patch($url, $headers = array(), $body = null) +Unirest\Request::delete($url, $headers = array(), $body = null) +``` + +- `url` - Endpoint, address, or uri to be acted upon and requested information from. +- `headers` - Request Headers as associative array or object +- `body` - Request Body as associative array or object + +You can send a request with any [standard](http://www.iana.org/assignments/http-methods/http-methods.xhtml) or custom HTTP Method: + +```php +Unirest\Request::send(Unirest\Method::LINK, $url, $headers = array(), $body); + +Unirest\Request::send('CHECKOUT', $url, $headers = array(), $body); +``` + +### Response Object + +Upon recieving a response Unirest returns the result in the form of an Object, this object should always have the same keys for each language regarding to the response details. + +- `code` - HTTP Response Status Code (Example `200`) +- `headers` - HTTP Response Headers +- `body` - Parsed response body where applicable, for example JSON responses are parsed to Objects / Associative Arrays. +- `raw_body` - Un-parsed response body + +### Advanced Configuration + +You can set some advanced configuration to tune Unirest-PHP: + +#### Custom JSON Decode Flags + +Unirest uses PHP's [JSON Extension](http://php.net/manual/en/book.json.php) for automatically decoding JSON responses. +sometime you may want to return associative arrays, limit the depth of recursion, or use any of the [customization flags](http://php.net/manual/en/json.constants.php). + +To do so, simply set the desired options using the `jsonOpts` request method: + +```php +Unirest\Request::jsonOpts(true, 512, JSON_NUMERIC_CHECK & JSON_FORCE_OBJECT & JSON_UNESCAPED_SLASHES); +``` + +#### Timeout + +You can set a custom timeout value (in **seconds**): + +```php +Unirest\Request::timeout(5); // 5s timeout +``` + +#### Proxy + +Set the proxy to use for the upcoming request. + +you can also set the proxy type to be one of `CURLPROXY_HTTP`, `CURLPROXY_HTTP_1_0`, `CURLPROXY_SOCKS4`, `CURLPROXY_SOCKS5`, `CURLPROXY_SOCKS4A`, and `CURLPROXY_SOCKS5_HOSTNAME`. + +*check the [cURL docs](http://curl.haxx.se/libcurl/c/CURLOPT_PROXYTYPE.html) for more info*. + +```php +// quick setup with default port: 1080 +Unirest\Request::proxy('10.10.10.1'); + +// custom port and proxy type +Unirest\Request::proxy('10.10.10.1', 8080, CURLPROXY_HTTP); + +// enable tunneling +Unirest\Request::proxy('10.10.10.1', 8080, CURLPROXY_HTTP, true); +``` + +##### Proxy Authenticaton + +Passing a username, password *(optional)*, defaults to Basic Authentication: + +```php +// basic auth +Unirest\Request::proxyAuth('username', 'password'); +``` + +The third parameter, which is a bitmask, will Unirest which HTTP authentication method(s) you want it to use for your proxy authentication. + +If more than one bit is set, Unirest *(at PHP's libcurl level)* will first query the site to see what authentication methods it supports and then pick the best one you allow it to use. *For some methods, this will induce an extra network round-trip.* + +See [Authentication](#authentication) for more details on methods supported. + +```php +// basic auth +Unirest\Request::proxyAuth('username', 'password', CURLAUTH_DIGEST); +``` + +#### Default Request Headers + +You can set default headers that will be sent on every request: + +```php +Unirest\Request::defaultHeader('Header1', 'Value1'); +Unirest\Request::defaultHeader('Header2', 'Value2'); +``` + +You can set default headers in bulk by passing an array: + +```php +Unirest\Request::defaultHeaders(array( + 'Header1' => 'Value1', + 'Header2' => 'Value2' +)); +``` + +You can clear the default headers anytime with: + +```php +Unirest\Request::clearDefaultHeaders(); +``` + +#### Default cURL Options + +You can set default [cURL options](http://php.net/manual/en/function.curl-setopt.php) that will be sent on every request: + +```php +Unirest\Request::curlOpt(CURLOPT_COOKIE, 'foo=bar'); +``` + +You can set options bulk by passing an array: + +```php +Unirest\Request::curlOpts(array( + CURLOPT_COOKIE => 'foo=bar' +)); +``` + +You can clear the default options anytime with: + +```php +Unirest\Request::clearCurlOpts(); +``` + +#### SSL validation + +You can explicitly enable or disable SSL certificate validation when consuming an SSL protected endpoint: + +```php +Unirest\Request::verifyPeer(false); // Disables SSL cert validation +``` + +By default is `true`. + +#### Utility Methods + +```php +// alias for `curl_getinfo` +Unirest\Request::getInfo() + +// returns internal cURL handle +Unirest\Request::getCurlHandle() +``` + +---- + +Made with ♥ from the [Mashape][mashape-url] team + +[unirest-logo]: http://cl.ly/image/2P373Y090s2O/Image%202015-10-12%20at%209.48.06%20PM.png + + +[mashape-url]: https://www.mashape.com/ + +[license-url]: https://github.com/Mashape/unirest-php/blob/master/LICENSE + +[gitter-url]: https://gitter.im/Mashape/unirest-php +[gitter-image]: https://img.shields.io/badge/Gitter-Join%20Chat-blue.svg?style=flat + +[travis-url]: https://travis-ci.org/Mashape/unirest-php +[travis-image]: https://img.shields.io/travis/Mashape/unirest-php.svg?style=flat + +[packagist-url]: https://packagist.org/packages/Mashape/unirest-php +[packagist-license]: https://img.shields.io/packagist/l/Mashape/unirest-php.svg?style=flat +[packagist-version]: https://img.shields.io/packagist/v/Mashape/unirest-php.svg?style=flat +[packagist-downloads]: https://img.shields.io/packagist/dm/Mashape/unirest-php.svg?style=flat + +[codeclimate-url]: https://codeclimate.com/github/Mashape/unirest-php +[codeclimate-quality]: https://img.shields.io/codeclimate/github/Mashape/unirest-php.svg?style=flat +[codeclimate-coverage]: https://img.shields.io/codeclimate/coverage/github/Mashape/unirest-php.svg?style=flat + +[versioneye-url]: https://www.versioneye.com/user/projects/54b82450050646ca5c0001f3 +[versioneye-image]: https://img.shields.io/versioneye/d/php/mashape:unirest-php.svg?style=flat diff --git a/vendor/mashape/unirest-php/composer.json b/vendor/mashape/unirest-php/composer.json new file mode 100644 index 00000000..d39af345 --- /dev/null +++ b/vendor/mashape/unirest-php/composer.json @@ -0,0 +1,28 @@ +{ + "name": "mashape/unirest-php", + "description": "Unirest PHP", + "keywords": ["rest", "curl", "http", "https", "client"], + "type": "library", + "homepage": "https://github.com/Mashape/unirest-php", + "license": "MIT", + "author": "Mashape (https://www.mashape.com)", + "require": { + "php": ">=5.4.0", + "ext-curl": "*" + }, + "suggest": { + "ext-json": "Allows using JSON Bodies for sending and parsing requests" + }, + "require-dev": { + "phpunit/phpunit": "~4.4", + "codeclimate/php-test-reporter": "0.1.*" + }, + "autoload": { + "psr-0": { + "Unirest\\": "src/" + } + }, + "support": { + "email": "opensource@mashape.com" + } +} diff --git a/vendor/mashape/unirest-php/phpunit.xml b/vendor/mashape/unirest-php/phpunit.xml new file mode 100644 index 00000000..09663440 --- /dev/null +++ b/vendor/mashape/unirest-php/phpunit.xml @@ -0,0 +1,16 @@ + + + + + + + + + ./tests + + + + + + + diff --git a/vendor/mashape/unirest-php/src/Unirest.php b/vendor/mashape/unirest-php/src/Unirest.php new file mode 100644 index 00000000..17c72b87 --- /dev/null +++ b/vendor/mashape/unirest-php/src/Unirest.php @@ -0,0 +1,7 @@ + '', + 'pass' => '', + 'method' => CURLAUTH_BASIC + ); + + private static $proxy = array( + 'port' => false, + 'tunnel' => false, + 'address' => false, + 'type' => CURLPROXY_HTTP, + 'auth' => array ( + 'user' => '', + 'pass' => '', + 'method' => CURLAUTH_BASIC + ) + ); + + /** + * Set JSON decode mode + * + * @param bool $assoc When TRUE, returned objects will be converted into associative arrays. + * @param integer $depth User specified recursion depth. + * @param integer $options Bitmask of JSON decode options. Currently only JSON_BIGINT_AS_STRING is supported (default is to cast large integers as floats) + * @return array + */ + public static function jsonOpts($assoc = false, $depth = 512, $options = 0) + { + return self::$jsonOpts = array($assoc, $depth, $options); + } + + /** + * Verify SSL peer + * + * @param bool $enabled enable SSL verification, by default is true + * @return bool + */ + public static function verifyPeer($enabled) + { + return self::$verifyPeer = $enabled; + } + + /** + * Verify SSL host + * + * @param bool $enabled enable SSL host verification, by default is true + * @return bool + */ + public static function verifyHost($enabled) + { + return self::$verifyHost = $enabled; + } + + /** + * Set a timeout + * + * @param integer $seconds timeout value in seconds + * @return integer + */ + public static function timeout($seconds) + { + return self::$socketTimeout = $seconds; + } + + /** + * Set default headers to send on every request + * + * @param array $headers headers array + * @return array + */ + public static function defaultHeaders($headers) + { + return self::$defaultHeaders = array_merge(self::$defaultHeaders, $headers); + } + + /** + * Set a new default header to send on every request + * + * @param string $name header name + * @param string $value header value + * @return string + */ + public static function defaultHeader($name, $value) + { + return self::$defaultHeaders[$name] = $value; + } + + /** + * Clear all the default headers + */ + public static function clearDefaultHeaders() + { + return self::$defaultHeaders = array(); + } + + /** + * Set curl options to send on every request + * + * @param array $options options array + * @return array + */ + public static function curlOpts($options) + { + return self::mergeCurlOptions(self::$curlOpts, $options); + } + + /** + * Set a new default header to send on every request + * + * @param string $name header name + * @param string $value header value + * @return string + */ + public static function curlOpt($name, $value) + { + return self::$curlOpts[$name] = $value; + } + + /** + * Clear all the default headers + */ + public static function clearCurlOpts() + { + return self::$curlOpts = array(); + } + + /** + * Set a Mashape key to send on every request as a header + * Obtain your Mashape key by browsing one of your Mashape applications on https://www.mashape.com + * + * Note: Mashape provides 2 keys for each application: a 'Testing' and a 'Production' one. + * Be aware of which key you are using and do not share your Production key. + * + * @param string $key Mashape key + * @return string + */ + public static function setMashapeKey($key) + { + return self::defaultHeader('X-Mashape-Key', $key); + } + + /** + * Set a cookie string for enabling cookie handling + * + * @param string $cookie + */ + public static function cookie($cookie) + { + self::$cookie = $cookie; + } + + /** + * Set a cookie file path for enabling cookie handling + * + * $cookieFile must be a correct path with write permission + * + * @param string $cookieFile - path to file for saving cookie + */ + public static function cookieFile($cookieFile) + { + self::$cookieFile = $cookieFile; + } + + /** + * Set authentication method to use + * + * @param string $username authentication username + * @param string $password authentication password + * @param integer $method authentication method + */ + public static function auth($username = '', $password = '', $method = CURLAUTH_BASIC) + { + self::$auth['user'] = $username; + self::$auth['pass'] = $password; + self::$auth['method'] = $method; + } + + /** + * Set proxy to use + * + * @param string $address proxy address + * @param integer $port proxy port + * @param integer $type (Available options for this are CURLPROXY_HTTP, CURLPROXY_HTTP_1_0 CURLPROXY_SOCKS4, CURLPROXY_SOCKS5, CURLPROXY_SOCKS4A and CURLPROXY_SOCKS5_HOSTNAME) + * @param bool $tunnel enable/disable tunneling + */ + public static function proxy($address, $port = 1080, $type = CURLPROXY_HTTP, $tunnel = false) + { + self::$proxy['type'] = $type; + self::$proxy['port'] = $port; + self::$proxy['tunnel'] = $tunnel; + self::$proxy['address'] = $address; + } + + /** + * Set proxy authentication method to use + * + * @param string $username authentication username + * @param string $password authentication password + * @param integer $method authentication method + */ + public static function proxyAuth($username = '', $password = '', $method = CURLAUTH_BASIC) + { + self::$proxy['auth']['user'] = $username; + self::$proxy['auth']['pass'] = $password; + self::$proxy['auth']['method'] = $method; + } + + /** + * Send a GET request to a URL + * + * @param string $url URL to send the GET request to + * @param array $headers additional headers to send + * @param mixed $parameters parameters to send in the querystring + * @param string $username Authentication username (deprecated) + * @param string $password Authentication password (deprecated) + * @return Response + */ + public static function get($url, $headers = array(), $parameters = null, $username = null, $password = null) + { + return self::send(Method::GET, $url, $parameters, $headers, $username, $password); + } + + /** + * Send a HEAD request to a URL + * @param string $url URL to send the HEAD request to + * @param array $headers additional headers to send + * @param mixed $parameters parameters to send in the querystring + * @param string $username Basic Authentication username (deprecated) + * @param string $password Basic Authentication password (deprecated) + * @return Response + */ + public static function head($url, $headers = array(), $parameters = null, $username = null, $password = null) + { + return self::send(Method::HEAD, $url, $parameters, $headers, $username, $password); + } + + /** + * Send a OPTIONS request to a URL + * @param string $url URL to send the OPTIONS request to + * @param array $headers additional headers to send + * @param mixed $parameters parameters to send in the querystring + * @param string $username Basic Authentication username + * @param string $password Basic Authentication password + * @return Response + */ + public static function options($url, $headers = array(), $parameters = null, $username = null, $password = null) + { + return self::send(Method::OPTIONS, $url, $parameters, $headers, $username, $password); + } + + /** + * Send a CONNECT request to a URL + * @param string $url URL to send the CONNECT request to + * @param array $headers additional headers to send + * @param mixed $parameters parameters to send in the querystring + * @param string $username Basic Authentication username (deprecated) + * @param string $password Basic Authentication password (deprecated) + * @return Response + */ + public static function connect($url, $headers = array(), $parameters = null, $username = null, $password = null) + { + return self::send(Method::CONNECT, $url, $parameters, $headers, $username, $password); + } + + /** + * Send POST request to a URL + * @param string $url URL to send the POST request to + * @param array $headers additional headers to send + * @param mixed $body POST body data + * @param string $username Basic Authentication username (deprecated) + * @param string $password Basic Authentication password (deprecated) + * @return Response response + */ + public static function post($url, $headers = array(), $body = null, $username = null, $password = null) + { + return self::send(Method::POST, $url, $body, $headers, $username, $password); + } + + /** + * Send DELETE request to a URL + * @param string $url URL to send the DELETE request to + * @param array $headers additional headers to send + * @param mixed $body DELETE body data + * @param string $username Basic Authentication username (deprecated) + * @param string $password Basic Authentication password (deprecated) + * @return Response + */ + public static function delete($url, $headers = array(), $body = null, $username = null, $password = null) + { + return self::send(Method::DELETE, $url, $body, $headers, $username, $password); + } + + /** + * Send PUT request to a URL + * @param string $url URL to send the PUT request to + * @param array $headers additional headers to send + * @param mixed $body PUT body data + * @param string $username Basic Authentication username (deprecated) + * @param string $password Basic Authentication password (deprecated) + * @return Response + */ + public static function put($url, $headers = array(), $body = null, $username = null, $password = null) + { + return self::send(Method::PUT, $url, $body, $headers, $username, $password); + } + + /** + * Send PATCH request to a URL + * @param string $url URL to send the PATCH request to + * @param array $headers additional headers to send + * @param mixed $body PATCH body data + * @param string $username Basic Authentication username (deprecated) + * @param string $password Basic Authentication password (deprecated) + * @return Response + */ + public static function patch($url, $headers = array(), $body = null, $username = null, $password = null) + { + return self::send(Method::PATCH, $url, $body, $headers, $username, $password); + } + + /** + * Send TRACE request to a URL + * @param string $url URL to send the TRACE request to + * @param array $headers additional headers to send + * @param mixed $body TRACE body data + * @param string $username Basic Authentication username (deprecated) + * @param string $password Basic Authentication password (deprecated) + * @return Response + */ + public static function trace($url, $headers = array(), $body = null, $username = null, $password = null) + { + return self::send(Method::TRACE, $url, $body, $headers, $username, $password); + } + + /** + * This function is useful for serializing multidimensional arrays, and avoid getting + * the 'Array to string conversion' notice + * @param array|object $data array to flatten. + * @param bool|string $parent parent key or false if no parent + * @return array + */ + public static function buildHTTPCurlQuery($data, $parent = false) + { + $result = array(); + + if (is_object($data)) { + $data = get_object_vars($data); + } + + foreach ($data as $key => $value) { + if ($parent) { + $new_key = sprintf('%s[%s]', $parent, $key); + } else { + $new_key = $key; + } + + if (!$value instanceof \CURLFile and (is_array($value) or is_object($value))) { + $result = array_merge($result, self::buildHTTPCurlQuery($value, $new_key)); + } else { + $result[$new_key] = $value; + } + } + + return $result; + } + + /** + * Send a cURL request + * @param \Unirest\Method|string $method HTTP method to use + * @param string $url URL to send the request to + * @param mixed $body request body + * @param array $headers additional headers to send + * @param string $username Authentication username (deprecated) + * @param string $password Authentication password (deprecated) + * @throws \Unirest\Exception if a cURL error occurs + * @return Response + */ + public static function send($method, $url, $body = null, $headers = array(), $username = null, $password = null) + { + self::$handle = curl_init(); + + if ($method !== Method::GET) { + if ($method === Method::POST) { + curl_setopt(self::$handle, CURLOPT_POST, true); + } else { + curl_setopt(self::$handle, CURLOPT_CUSTOMREQUEST, $method); + } + + curl_setopt(self::$handle, CURLOPT_POSTFIELDS, $body); + } elseif (is_array($body)) { + if (strpos($url, '?') !== false) { + $url .= '&'; + } else { + $url .= '?'; + } + + $url .= urldecode(http_build_query(self::buildHTTPCurlQuery($body))); + } + + $curl_base_options = [ + CURLOPT_URL => self::encodeUrl($url), + CURLOPT_RETURNTRANSFER => true, + CURLOPT_FOLLOWLOCATION => true, + CURLOPT_MAXREDIRS => 10, + CURLOPT_HTTPHEADER => self::getFormattedHeaders($headers), + CURLOPT_HEADER => true, + CURLOPT_SSL_VERIFYPEER => self::$verifyPeer, + //CURLOPT_SSL_VERIFYHOST accepts only 0 (false) or 2 (true). Future versions of libcurl will treat values 1 and 2 as equals + CURLOPT_SSL_VERIFYHOST => self::$verifyHost === false ? 0 : 2, + // If an empty string, '', is set, a header containing all supported encoding types is sent + CURLOPT_ENCODING => '' + ]; + + curl_setopt_array(self::$handle, self::mergeCurlOptions($curl_base_options, self::$curlOpts)); + + if (self::$socketTimeout !== null) { + curl_setopt(self::$handle, CURLOPT_TIMEOUT, self::$socketTimeout); + } + + if (self::$cookie) { + curl_setopt(self::$handle, CURLOPT_COOKIE, self::$cookie); + } + + if (self::$cookieFile) { + curl_setopt(self::$handle, CURLOPT_COOKIEFILE, self::$cookieFile); + curl_setopt(self::$handle, CURLOPT_COOKIEJAR, self::$cookieFile); + } + + // supporting deprecated http auth method + if (!empty($username)) { + curl_setopt_array(self::$handle, array( + CURLOPT_HTTPAUTH => CURLAUTH_BASIC, + CURLOPT_USERPWD => $username . ':' . $password + )); + } + + if (!empty(self::$auth['user'])) { + curl_setopt_array(self::$handle, array( + CURLOPT_HTTPAUTH => self::$auth['method'], + CURLOPT_USERPWD => self::$auth['user'] . ':' . self::$auth['pass'] + )); + } + + if (self::$proxy['address'] !== false) { + curl_setopt_array(self::$handle, array( + CURLOPT_PROXYTYPE => self::$proxy['type'], + CURLOPT_PROXY => self::$proxy['address'], + CURLOPT_PROXYPORT => self::$proxy['port'], + CURLOPT_HTTPPROXYTUNNEL => self::$proxy['tunnel'], + CURLOPT_PROXYAUTH => self::$proxy['auth']['method'], + CURLOPT_PROXYUSERPWD => self::$proxy['auth']['user'] . ':' . self::$proxy['auth']['pass'] + )); + } + + $response = curl_exec(self::$handle); + $error = curl_error(self::$handle); + $info = self::getInfo(); + + if ($error) { + throw new Exception($error); + } + + // Split the full response in its headers and body + $header_size = $info['header_size']; + $header = substr($response, 0, $header_size); + $body = substr($response, $header_size); + $httpCode = $info['http_code']; + + return new Response($httpCode, $body, $header, self::$jsonOpts); + } + + public static function getInfo($opt = false) + { + if ($opt) { + $info = curl_getinfo(self::$handle, $opt); + } else { + $info = curl_getinfo(self::$handle); + } + + return $info; + } + + public static function getCurlHandle() + { + return self::$handle; + } + + public static function getFormattedHeaders($headers) + { + $formattedHeaders = array(); + + $combinedHeaders = array_change_key_case(array_merge(self::$defaultHeaders, (array) $headers)); + + foreach ($combinedHeaders as $key => $val) { + $formattedHeaders[] = self::getHeaderString($key, $val); + } + + if (!array_key_exists('user-agent', $combinedHeaders)) { + $formattedHeaders[] = 'user-agent: unirest-php/2.0'; + } + + if (!array_key_exists('expect', $combinedHeaders)) { + $formattedHeaders[] = 'expect:'; + } + + return $formattedHeaders; + } + + private static function getArrayFromQuerystring($query) + { + $query = preg_replace_callback('/(?:^|(?<=&))[^=[]+/', function ($match) { + return bin2hex(urldecode($match[0])); + }, $query); + + parse_str($query, $values); + + return array_combine(array_map('hex2bin', array_keys($values)), $values); + } + + /** + * Ensure that a URL is encoded and safe to use with cURL + * @param string $url URL to encode + * @return string + */ + private static function encodeUrl($url) + { + $url_parsed = parse_url($url); + + $scheme = $url_parsed['scheme'] . '://'; + $host = $url_parsed['host']; + $port = (isset($url_parsed['port']) ? $url_parsed['port'] : null); + $path = (isset($url_parsed['path']) ? $url_parsed['path'] : null); + $query = (isset($url_parsed['query']) ? $url_parsed['query'] : null); + + if ($query !== null) { + $query = '?' . http_build_query(self::getArrayFromQuerystring($query)); + } + + if ($port && $port[0] !== ':') { + $port = ':' . $port; + } + + $result = $scheme . $host . $port . $path . $query; + return $result; + } + + private static function getHeaderString($key, $val) + { + $key = trim(strtolower($key)); + return $key . ': ' . $val; + } + + /** + * @param array $existing_options + * @param array $new_options + * @return array + */ + private static function mergeCurlOptions(&$existing_options, $new_options) + { + $existing_options = $new_options + $existing_options; + return $existing_options; + } +} diff --git a/vendor/mashape/unirest-php/src/Unirest/Request/Body.php b/vendor/mashape/unirest-php/src/Unirest/Request/Body.php new file mode 100644 index 00000000..edaeccf5 --- /dev/null +++ b/vendor/mashape/unirest-php/src/Unirest/Request/Body.php @@ -0,0 +1,66 @@ + $file) { + $data[$name] = call_user_func(array(__CLASS__, 'File'), $file); + } + } + + return $data; + } +} diff --git a/vendor/mashape/unirest-php/src/Unirest/Response.php b/vendor/mashape/unirest-php/src/Unirest/Response.php new file mode 100644 index 00000000..99eaed09 --- /dev/null +++ b/vendor/mashape/unirest-php/src/Unirest/Response.php @@ -0,0 +1,78 @@ +code = $code; + $this->headers = $this->parseHeaders($headers); + $this->raw_body = $raw_body; + $this->body = $raw_body; + + // make sure raw_body is the first argument + array_unshift($json_args, $raw_body); + + if (function_exists('json_decode')) { + $json = call_user_func_array('json_decode', $json_args); + + if (json_last_error() === JSON_ERROR_NONE) { + $this->body = $json; + } + } + } + + /** + * if PECL_HTTP is not available use a fall back function + * + * thanks to ricardovermeltfoort@gmail.com + * http://php.net/manual/en/function.http-parse-headers.php#112986 + * @param string $raw_headers raw headers + * @return array + */ + private function parseHeaders($raw_headers) + { + if (function_exists('http_parse_headers')) { + return http_parse_headers($raw_headers); + } else { + $key = ''; + $headers = array(); + + foreach (explode("\n", $raw_headers) as $i => $h) { + $h = explode(':', $h, 2); + + if (isset($h[1])) { + if (!isset($headers[$h[0]])) { + $headers[$h[0]] = trim($h[1]); + } elseif (is_array($headers[$h[0]])) { + $headers[$h[0]] = array_merge($headers[$h[0]], array(trim($h[1]))); + } else { + $headers[$h[0]] = array_merge(array($headers[$h[0]]), array(trim($h[1]))); + } + + $key = $h[0]; + } else { + if (substr($h[0], 0, 1) == "\t") { + $headers[$key] .= "\r\n\t".trim($h[0]); + } elseif (!$key) { + $headers[0] = trim($h[0]); + } + } + } + + return $headers; + } + } +} diff --git a/vendor/mashape/unirest-php/tests/Unirest/BodyTest.php b/vendor/mashape/unirest-php/tests/Unirest/BodyTest.php new file mode 100644 index 00000000..9c86df67 --- /dev/null +++ b/vendor/mashape/unirest-php/tests/Unirest/BodyTest.php @@ -0,0 +1,89 @@ +assertEquals($file, sprintf('@%s;filename=%s;type=', $fixture, basename($fixture))); + } else { + $this->assertTrue($file instanceof \CURLFile); + } + } + + public function testHttpBuildQueryWithCurlFile() + { + $fixture = __DIR__ . '/fixtures/upload.txt'; + + $file = Body::File($fixture); + $body = array( + 'to' => 'mail@mailinator.com', + 'from' => 'mail@mailinator.com', + 'file' => $file + ); + + $result = Request::buildHTTPCurlQuery($body); + $this->assertEquals($result['file'], $file); + } + + public function testJson() + { + $body = Body::Json(array('foo', 'bar')); + + $this->assertEquals($body, '["foo","bar"]'); + } + + public function testForm() + { + $body = Body::Form(array('foo' => 'bar', 'bar' => 'baz')); + + $this->assertEquals($body, 'foo=bar&bar=baz'); + + // try again with a string + $body = Body::Form($body); + + $this->assertEquals($body, 'foo=bar&bar=baz'); + } + + public function testMultipart() + { + $arr = array('foo' => 'bar', 'bar' => 'baz'); + + $body = Body::Multipart((object) $arr); + + $this->assertEquals($body, $arr); + + $body = Body::Multipart('flat'); + + $this->assertEquals($body, array('flat')); + } + + public function testMultipartFiles() + { + $fixture = __DIR__ . '/fixtures/upload.txt'; + + $data = array('foo' => 'bar', 'bar' => 'baz'); + $files = array('test' => $fixture); + + $body = Body::Multipart($data, $files); + + // echo $body; + + $this->assertEquals($body, array( + 'foo' => 'bar', + 'bar' => 'baz', + 'test' => Body::File($fixture) + )); + } +} diff --git a/vendor/mashape/unirest-php/tests/Unirest/RequestTest.php b/vendor/mashape/unirest-php/tests/Unirest/RequestTest.php new file mode 100644 index 00000000..d9b56331 --- /dev/null +++ b/vendor/mashape/unirest-php/tests/Unirest/RequestTest.php @@ -0,0 +1,485 @@ +assertTrue(property_exists($response->body->cookies, 'foo')); + + Request::clearCurlOpts(); + } + + /** + * @expectedException \Unirest\Exception + */ + public function testTimeoutFail() + { + Request::timeout(1); + + Request::get('http://mockbin.com/delay/1000'); + + Request::timeout(null); // Cleaning timeout for the other tests + } + + public function testDefaultHeaders() + { + $defaultHeaders = array( + 'header1' => 'Hello', + 'header2' => 'world' + ); + Request::defaultHeaders($defaultHeaders); + + $response = Request::get('http://mockbin.com/request'); + + $this->assertEquals(200, $response->code); + $this->assertObjectHasAttribute('header1', $response->body->headers); + $this->assertEquals('Hello', $response->body->headers->header1); + $this->assertObjectHasAttribute('header2', $response->body->headers); + $this->assertEquals('world', $response->body->headers->header2); + + $response = Request::get('http://mockbin.com/request', ['header1' => 'Custom value']); + + $this->assertEquals(200, $response->code); + $this->assertObjectHasAttribute('header1', $response->body->headers); + $this->assertEquals('Custom value', $response->body->headers->header1); + + Request::clearDefaultHeaders(); + + $response = Request::get('http://mockbin.com/request'); + + $this->assertEquals(200, $response->code); + $this->assertObjectNotHasAttribute('header1', $response->body->headers); + $this->assertObjectNotHasAttribute('header2', $response->body->headers); + } + + public function testDefaultHeader() + { + Request::defaultHeader('Hello', 'custom'); + + $response = Request::get('http://mockbin.com/request'); + + $this->assertEquals(200, $response->code); + $this->assertTrue(property_exists($response->body->headers, 'hello')); + $this->assertEquals('custom', $response->body->headers->hello); + + Request::clearDefaultHeaders(); + + $response = Request::get('http://mockbin.com/request'); + + $this->assertEquals(200, $response->code); + $this->assertFalse(property_exists($response->body->headers, 'hello')); + } + + public function testSetMashapeKey() + { + Request::setMashapeKey('abcd'); + + $response = Request::get('http://mockbin.com/request'); + + $this->assertEquals(200, $response->code); + $this->assertTrue(property_exists($response->body->headers, 'x-mashape-key')); + $this->assertEquals('abcd', $response->body->headers->{'x-mashape-key'}); + + // send another request + $response = Request::get('http://mockbin.com/request'); + + $this->assertEquals(200, $response->code); + $this->assertTrue(property_exists($response->body->headers, 'x-mashape-key')); + $this->assertEquals('abcd', $response->body->headers->{'x-mashape-key'}); + + Request::clearDefaultHeaders(); + + $response = Request::get('http://mockbin.com/request'); + + $this->assertEquals(200, $response->code); + $this->assertFalse(property_exists($response->body->headers, 'x-mashape-key')); + } + + public function testGzip() + { + $response = Request::get('http://mockbin.com/gzip/request'); + + $this->assertEquals('gzip', $response->headers['Content-Encoding']); + } + + public function testBasicAuthenticationDeprecated() + { + $response = Request::get('http://mockbin.com/request', array(), array(), 'user', 'password'); + + $this->assertEquals('Basic dXNlcjpwYXNzd29yZA==', $response->body->headers->authorization); + } + + public function testBasicAuthentication() + { + Request::auth('user', 'password'); + + $response = Request::get('http://mockbin.com/request'); + + $this->assertEquals('Basic dXNlcjpwYXNzd29yZA==', $response->body->headers->authorization); + } + + public function testCustomHeaders() + { + $response = Request::get('http://mockbin.com/request', array( + 'user-agent' => 'unirest-php', + )); + + $this->assertEquals(200, $response->code); + $this->assertEquals('unirest-php', $response->body->headers->{'user-agent'}); + } + + // GET + public function testGet() + { + $response = Request::get('http://mockbin.com/request?name=Mark', array( + 'Accept' => 'application/json' + ), array( + 'nick' => 'thefosk' + )); + + $this->assertEquals(200, $response->code); + $this->assertEquals('GET', $response->body->method); + $this->assertEquals('Mark', $response->body->queryString->name); + $this->assertEquals('thefosk', $response->body->queryString->nick); + } + + public function testGetMultidimensionalArray() + { + $response = Request::get('http://mockbin.com/request', array( + 'Accept' => 'application/json' + ), array( + 'key' => 'value', + 'items' => array( + 'item1', + 'item2' + ) + )); + + $this->assertEquals(200, $response->code); + $this->assertEquals('GET', $response->body->method); + $this->assertEquals('value', $response->body->queryString->key); + $this->assertEquals('item1', $response->body->queryString->items[0]); + $this->assertEquals('item2', $response->body->queryString->items[1]); + } + + public function testGetWithDots() + { + $response = Request::get('http://mockbin.com/request', array( + 'Accept' => 'application/json' + ), array( + 'user.name' => 'Mark', + 'nick' => 'thefosk' + )); + + $this->assertEquals(200, $response->code); + $this->assertEquals('GET', $response->body->method); + $this->assertEquals('Mark', $response->body->queryString->{'user.name'}); + $this->assertEquals('thefosk', $response->body->queryString->nick); + } + + public function testGetWithDotsAlt() + { + $response = Request::get('http://mockbin.com/request', array( + 'Accept' => 'application/json' + ), array( + 'user.name' => 'Mark Bond', + 'nick' => 'thefosk' + )); + + $this->assertEquals(200, $response->code); + $this->assertEquals('GET', $response->body->method); + $this->assertEquals('Mark Bond', $response->body->queryString->{'user.name'}); + $this->assertEquals('thefosk', $response->body->queryString->nick); + } + public function testGetWithEqualSign() + { + $response = Request::get('http://mockbin.com/request', array( + 'Accept' => 'application/json' + ), array( + 'name' => 'Mark=Hello' + )); + + $this->assertEquals(200, $response->code); + $this->assertEquals('GET', $response->body->method); + $this->assertEquals('Mark=Hello', $response->body->queryString->name); + } + + public function testGetWithEqualSignAlt() + { + $response = Request::get('http://mockbin.com/request', array( + 'Accept' => 'application/json' + ), array( + 'name' => 'Mark=Hello=John' + )); + + $this->assertEquals(200, $response->code); + $this->assertEquals('GET', $response->body->method); + $this->assertEquals('Mark=Hello=John', $response->body->queryString->name); + } + + public function testGetWithComplexQuery() + { + $response = Request::get('http://mockbin.com/request?query=[{"type":"/music/album","name":null,"artist":{"id":"/en/bob_dylan"},"limit":3}]&cursor'); + + $this->assertEquals(200, $response->code); + $this->assertEquals('GET', $response->body->method); + $this->assertEquals('', $response->body->queryString->cursor); + $this->assertEquals('[{"type":"/music/album","name":null,"artist":{"id":"/en/bob_dylan"},"limit":3}]', $response->body->queryString->query); + } + + public function testGetArray() + { + $response = Request::get('http://mockbin.com/request', array(), array( + 'name[0]' => 'Mark', + 'name[1]' => 'John' + )); + + $this->assertEquals(200, $response->code); + $this->assertEquals('GET', $response->body->method); + $this->assertEquals('Mark', $response->body->queryString->name[0]); + $this->assertEquals('John', $response->body->queryString->name[1]); + } + + // POST + public function testPost() + { + $response = Request::post('http://mockbin.com/request', array( + 'Accept' => 'application/json' + ), array( + 'name' => 'Mark', + 'nick' => 'thefosk' + )); + + $this->assertEquals(200, $response->code); + $this->assertEquals('POST', $response->body->method); + $this->assertEquals('Mark', $response->body->postData->params->name); + $this->assertEquals('thefosk', $response->body->postData->params->nick); + } + + public function testPostForm() + { + $body = Request\Body::Form(array( + 'name' => 'Mark', + 'nick' => 'thefosk' + )); + + $response = Request::post('http://mockbin.com/request', array( + 'Accept' => 'application/json' + ), $body); + + $this->assertEquals('POST', $response->body->method); + $this->assertEquals('application/x-www-form-urlencoded', $response->body->headers->{'content-type'}); + $this->assertEquals('application/x-www-form-urlencoded', $response->body->postData->mimeType); + $this->assertEquals('Mark', $response->body->postData->params->name); + $this->assertEquals('thefosk', $response->body->postData->params->nick); + } + + public function testPostMultipart() + { + $body = Request\Body::Multipart(array( + 'name' => 'Mark', + 'nick' => 'thefosk' + )); + + $response = Request::post('http://mockbin.com/request', (object) array( + 'Accept' => 'application/json', + ), $body); + + $this->assertEquals('POST', $response->body->method); + $this->assertEquals('multipart/form-data', explode(';', $response->body->headers->{'content-type'})[0]); + $this->assertEquals('multipart/form-data', $response->body->postData->mimeType); + $this->assertEquals('Mark', $response->body->postData->params->name); + $this->assertEquals('thefosk', $response->body->postData->params->nick); + } + + public function testPostWithEqualSign() + { + $body = Request\Body::Form(array( + 'name' => 'Mark=Hello' + )); + + $response = Request::post('http://mockbin.com/request', array( + 'Accept' => 'application/json' + ), $body); + + $this->assertEquals(200, $response->code); + $this->assertEquals('POST', $response->body->method); + $this->assertEquals('Mark=Hello', $response->body->postData->params->name); + } + + public function testPostArray() + { + $response = Request::post('http://mockbin.com/request', array( + 'Accept' => 'application/json' + ), array( + 'name[0]' => 'Mark', + 'name[1]' => 'John' + )); + + $this->assertEquals(200, $response->code); + $this->assertEquals('POST', $response->body->method); + $this->assertEquals('Mark', $response->body->postData->params->{'name[0]'}); + $this->assertEquals('John', $response->body->postData->params->{'name[1]'}); + } + + public function testPostWithDots() + { + $response = Request::post('http://mockbin.com/request', array( + 'Accept' => 'application/json' + ), array( + 'user.name' => 'Mark', + 'nick' => 'thefosk' + )); + + $this->assertEquals(200, $response->code); + $this->assertEquals('POST', $response->body->method); + $this->assertEquals('Mark', $response->body->postData->params->{'user.name'}); + $this->assertEquals('thefosk', $response->body->postData->params->nick); + } + + public function testRawPost() + { + $response = Request::post('http://mockbin.com/request', array( + 'Accept' => 'application/json', + 'Content-Type' => 'application/json' + ), json_encode(array( + 'author' => 'Sam Sullivan' + ))); + + $this->assertEquals(200, $response->code); + $this->assertEquals('POST', $response->body->method); + $this->assertEquals('Sam Sullivan', json_decode($response->body->postData->text)->author); + } + + public function testPostMultidimensionalArray() + { + $body = Request\Body::Form(array( + 'key' => 'value', + 'items' => array( + 'item1', + 'item2' + ) + )); + + $response = Request::post('http://mockbin.com/request', array( + 'Accept' => 'application/json' + ), $body); + + $this->assertEquals(200, $response->code); + $this->assertEquals('POST', $response->body->method); + $this->assertEquals('value', $response->body->postData->params->key); + $this->assertEquals('item1', $response->body->postData->params->{'items[0]'}); + $this->assertEquals('item2', $response->body->postData->params->{'items[1]'}); + } + + // PUT + public function testPut() + { + $response = Request::put('http://mockbin.com/request', array( + 'Accept' => 'application/json' + ), array( + 'name' => 'Mark', + 'nick' => 'thefosk' + )); + + $this->assertEquals(200, $response->code); + $this->assertEquals('PUT', $response->body->method); + $this->assertEquals('Mark', $response->body->postData->params->name); + $this->assertEquals('thefosk', $response->body->postData->params->nick); + } + + // PATCH + public function testPatch() + { + $response = Request::patch('http://mockbin.com/request', array( + 'Accept' => 'application/json' + ), array( + 'name' => 'Mark', + 'nick' => 'thefosk' + )); + + $this->assertEquals(200, $response->code); + $this->assertEquals('PATCH', $response->body->method); + $this->assertEquals('Mark', $response->body->postData->params->name); + $this->assertEquals('thefosk', $response->body->postData->params->nick); + } + + // DELETE + public function testDelete() + { + $response = Request::delete('http://mockbin.com/request', array( + 'Accept' => 'application/json', + 'Content-Type' => 'application/x-www-form-urlencoded' + ), array( + 'name' => 'Mark', + 'nick' => 'thefosk' + )); + + $this->assertEquals(200, $response->code); + $this->assertEquals('DELETE', $response->body->method); + } + + // Upload + public function testUpload() + { + $fixture = __DIR__ . '/../fixtures/upload.txt'; + + $headers = array('Accept' => 'application/json'); + $files = array('file' => $fixture); + $data = array('name' => 'ahmad'); + + $body = Request\Body::Multipart($data, $files); + + $response = Request::post('http://mockbin.com/request', $headers, $body); + + $this->assertEquals(200, $response->code); + $this->assertEquals('POST', $response->body->method); + $this->assertEquals('ahmad', $response->body->postData->params->name); + $this->assertEquals('This is a test', $response->body->postData->params->file); + } + + public function testUploadWithoutHelper() + { + $fixture = __DIR__ . '/../fixtures/upload.txt'; + + $response = Request::post('http://mockbin.com/request', array( + 'Accept' => 'application/json' + ), array( + 'name' => 'Mark', + 'file' => Request\Body::File($fixture) + )); + + $this->assertEquals(200, $response->code); + $this->assertEquals('POST', $response->body->method); + $this->assertEquals('Mark', $response->body->postData->params->name); + $this->assertEquals('This is a test', $response->body->postData->params->file); + } + + public function testUploadIfFilePartOfData() + { + $fixture = __DIR__ . '/../fixtures/upload.txt'; + + $response = Request::post('http://mockbin.com/request', array( + 'Accept' => 'application/json' + ), array( + 'name' => 'Mark', + 'files[owl.gif]' => Request\Body::File($fixture) + )); + + $this->assertEquals(200, $response->code); + $this->assertEquals('POST', $response->body->method); + $this->assertEquals('Mark', $response->body->postData->params->name); + $this->assertEquals('This is a test', $response->body->postData->params->{'files[owl.gif]'}); + } +} diff --git a/vendor/mashape/unirest-php/tests/Unirest/ResponseTest.php b/vendor/mashape/unirest-php/tests/Unirest/ResponseTest.php new file mode 100644 index 00000000..6311f8f1 --- /dev/null +++ b/vendor/mashape/unirest-php/tests/Unirest/ResponseTest.php @@ -0,0 +1,35 @@ +assertEquals($response->body['a'], 1); + } + + public function testJSONAObjects() + { + $opts = Request::jsonOpts(false); + $response = new Response(200, '{"a":1,"b":2,"c":3,"d":4,"e":5}', '', $opts); + + $this->assertEquals($response->body->a, 1); + } + + public function testJSONOpts() + { + $opts = Request::jsonOpts(false, 512, JSON_NUMERIC_CHECK); + $response = new Response(200, '{"number": 1234567890}', '', $opts); + + $this->assertSame($response->body->number, 1234567890); + } +} diff --git a/vendor/mashape/unirest-php/tests/bootstrap.php b/vendor/mashape/unirest-php/tests/bootstrap.php new file mode 100644 index 00000000..7ccbe497 --- /dev/null +++ b/vendor/mashape/unirest-php/tests/bootstrap.php @@ -0,0 +1 @@ + diff --git a/vendor/mashape/unirest-php/tests/fixtures/upload.txt b/vendor/mashape/unirest-php/tests/fixtures/upload.txt new file mode 100644 index 00000000..793aa682 --- /dev/null +++ b/vendor/mashape/unirest-php/tests/fixtures/upload.txt @@ -0,0 +1 @@ +This is a test \ No newline at end of file