diff --git a/CHANGELOG.md b/CHANGELOG.md index f74cffb..5d19ee0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,19 @@ All notable changes to `payfast-onsite-subscriptions` will be documented in this file. +## v1.4.1 - 2022-10-15 + +- Remove illuminate contracts as dependency +- Add normal logging back to webhook controller again +- If testmode variable isn't set it will not fail on merchant_id giving the user a bigger clue as to .env variables that haven't been added +- If the model doesn't have a first name or last name then just use name + +## v1.4.0 - 2022-10-13 + +- Bump Nova minimum to version 4 by adding NovaRequest classes to actions +- Update readme to specify Nova 4 +- Fix plural problem with the `Receipt[s]` resource name + ## v1.3.0 - 2022-10-12 - Bump PHP to 8.1 diff --git a/Nova/Actions/CancelSubscription.php b/Nova/Actions/CancelSubscription.php index 7842ce4..23e5921 100644 --- a/Nova/Actions/CancelSubscription.php +++ b/Nova/Actions/CancelSubscription.php @@ -9,6 +9,7 @@ use Illuminate\Queue\InteractsWithQueue; use FintechSystems\PayFast\Facades\PayFast; use Illuminate\Contracts\Queue\ShouldQueue; +use Laravel\Nova\Http\Requests\NovaRequest; class CancelSubscription extends Action { @@ -35,7 +36,7 @@ public function handle(ActionFields $fields, Collection $models) * * @return array */ - public function fields() + public function fields(NovaRequest $request) { return []; } diff --git a/Nova/Actions/ChangeEndsAt.php b/Nova/Actions/ChangeEndsAt.php index 71605c7..adc02ca 100644 --- a/Nova/Actions/ChangeEndsAt.php +++ b/Nova/Actions/ChangeEndsAt.php @@ -11,6 +11,7 @@ use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; use Laravel\Nova\Actions\DestructiveAction; +use Laravel\Nova\Http\Requests\NovaRequest; class ChangeEndsAt extends DestructiveAction { @@ -37,7 +38,7 @@ public function handle(ActionFields $fields, Collection $models) * * @return array */ - public function fields() + public function fields(NovaRequest $request) { return [ Date::make('Ends At') diff --git a/Nova/Actions/EnableBilling.php b/Nova/Actions/EnableBilling.php index 49637ce..122a0e0 100644 --- a/Nova/Actions/EnableBilling.php +++ b/Nova/Actions/EnableBilling.php @@ -9,6 +9,7 @@ use Laravel\Nova\Fields\ActionFields; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; +use Laravel\Nova\Http\Requests\NovaRequest; class EnableBilling extends Action { @@ -35,7 +36,7 @@ public function handle(ActionFields $fields, Collection $models) * * @return array */ - public function fields() + public function fields(NovaRequest $request) { return []; } diff --git a/Nova/Actions/FetchSubscriptionInformation.php b/Nova/Actions/FetchSubscriptionInformation.php index ff1e541..bf6ad3d 100644 --- a/Nova/Actions/FetchSubscriptionInformation.php +++ b/Nova/Actions/FetchSubscriptionInformation.php @@ -11,6 +11,7 @@ use Illuminate\Queue\InteractsWithQueue; use FintechSystems\PayFast\Facades\PayFast; use Illuminate\Contracts\Queue\ShouldQueue; +use Laravel\Nova\Http\Requests\NovaRequest; class FetchSubscriptionInformation extends Action { @@ -37,7 +38,7 @@ public function handle(ActionFields $fields, Collection $models) * * @return array */ - public function fields() + public function fields(NovaRequest $request) { return []; } diff --git a/Nova/Actions/OverridePayFastStatus.php b/Nova/Actions/OverridePayFastStatus.php index 901941b..a33153b 100644 --- a/Nova/Actions/OverridePayFastStatus.php +++ b/Nova/Actions/OverridePayFastStatus.php @@ -12,6 +12,7 @@ use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; use Laravel\Nova\Actions\DestructiveAction; +use Laravel\Nova\Http\Requests\NovaRequest; class OverridePayFastStatus extends DestructiveAction { @@ -54,7 +55,7 @@ public function handle(ActionFields $fields, Collection $models) * * @return array */ - public function fields() + public function fields(NovaRequest $request) { return [ Select::make('Payfast Status') diff --git a/Nova/Receipts.php b/Nova/Receipt.php similarity index 98% rename from Nova/Receipts.php rename to Nova/Receipt.php index 4730d72..ef00d2d 100644 --- a/Nova/Receipts.php +++ b/Nova/Receipt.php @@ -11,7 +11,7 @@ use Laravel\Nova\Fields\DateTime; use Laravel\Nova\Http\Requests\NovaRequest; -class Receipts extends Resource +class Receipt extends Resource { /** * The model the resource corresponds to. diff --git a/README.md b/README.md index 61fed4a..b3f4843 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,12 @@ Requirements: - PHP 8.1 - Laravel 9.x + - A [PayFast Sandbox account](https://sandbox.payfast.co.za/) - A [PayFast account](https://www.payfast.co.za/registration) +If you want to use Laravel Nova, version 4 is required for the `Subscription` and `Receipt` resources. + ## Installation Install the package via composer: diff --git a/composer.json b/composer.json index 0a662a4..b984e93 100644 --- a/composer.json +++ b/composer.json @@ -32,8 +32,7 @@ "guzzlehttp/guzzle": "^7.4.5", "livewire/livewire": "^2.8", "moneyphp/money": "^4.0", - "spatie/ray": "^1.34", - "illuminate/contracts": "^9.35", + "spatie/ray": "^1.34", "nunomaduro/collision": "^6.3" }, "require-dev": { diff --git a/composer.lock b/composer.lock index b7a55ba..0f9fa6d 100644 --- 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": "cbde67f8c5851016e3b286aa1b13c5bf", + "content-hash": "1e6f0605efa6080e7f948f5ba2e00a80", "packages": [ { "name": "brick/math", @@ -1404,16 +1404,16 @@ }, { "name": "league/flysystem", - "version": "3.5.2", + "version": "3.6.0", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem.git", - "reference": "c73c4eb31f2e883b3897ab5591aa2dbc48112433" + "reference": "8eded334b9894dc90ebdcb7be81e3a1c9413f709" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/c73c4eb31f2e883b3897ab5591aa2dbc48112433", - "reference": "c73c4eb31f2e883b3897ab5591aa2dbc48112433", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/8eded334b9894dc90ebdcb7be81e3a1c9413f709", + "reference": "8eded334b9894dc90ebdcb7be81e3a1c9413f709", "shasum": "" }, "require": { @@ -1475,7 +1475,7 @@ ], "support": { "issues": "https://github.com/thephpleague/flysystem/issues", - "source": "https://github.com/thephpleague/flysystem/tree/3.5.2" + "source": "https://github.com/thephpleague/flysystem/tree/3.6.0" }, "funding": [ { @@ -1491,7 +1491,7 @@ "type": "tidelift" } ], - "time": "2022-09-23T18:59:16+00:00" + "time": "2022-10-13T20:05:14+00:00" }, { "name": "league/mime-type-detection", @@ -6815,23 +6815,23 @@ }, { "name": "orchestra/testbench", - "version": "v7.10.1", + "version": "v7.10.2", "source": { "type": "git", "url": "https://github.com/orchestral/testbench.git", - "reference": "17c8b82bb42f26a0131559aaebabb0e875f28a79" + "reference": "713f811ebba7524eb5891ac102a3f270578e078a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/orchestral/testbench/zipball/17c8b82bb42f26a0131559aaebabb0e875f28a79", - "reference": "17c8b82bb42f26a0131559aaebabb0e875f28a79", + "url": "https://api.github.com/repos/orchestral/testbench/zipball/713f811ebba7524eb5891ac102a3f270578e078a", + "reference": "713f811ebba7524eb5891ac102a3f270578e078a", "shasum": "" }, "require": { "fakerphp/faker": "^1.9.2", "laravel/framework": "^9.34", "mockery/mockery": "^1.5.1", - "orchestra/testbench-core": "^7.10.1", + "orchestra/testbench-core": "^7.10.2", "php": "^8.0", "phpunit/phpunit": "^9.5.10", "spatie/laravel-ray": "^1.28", @@ -6868,7 +6868,7 @@ ], "support": { "issues": "https://github.com/orchestral/testbench/issues", - "source": "https://github.com/orchestral/testbench/tree/v7.10.1" + "source": "https://github.com/orchestral/testbench/tree/v7.10.2" }, "funding": [ { @@ -6880,20 +6880,20 @@ "type": "liberapay" } ], - "time": "2022-10-11T14:07:11+00:00" + "time": "2022-10-14T11:29:27+00:00" }, { "name": "orchestra/testbench-core", - "version": "v7.10.1", + "version": "v7.10.2", "source": { "type": "git", "url": "https://github.com/orchestral/testbench-core.git", - "reference": "e4065bc5085aa0e643b901171cdb7fd95c0e8f3c" + "reference": "ef1c1bfe5f05f96151a5bd9a9ccd7c10650bc5d1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/orchestral/testbench-core/zipball/e4065bc5085aa0e643b901171cdb7fd95c0e8f3c", - "reference": "e4065bc5085aa0e643b901171cdb7fd95c0e8f3c", + "url": "https://api.github.com/repos/orchestral/testbench-core/zipball/ef1c1bfe5f05f96151a5bd9a9ccd7c10650bc5d1", + "reference": "ef1c1bfe5f05f96151a5bd9a9ccd7c10650bc5d1", "shasum": "" }, "require": { @@ -6975,7 +6975,7 @@ "type": "liberapay" } ], - "time": "2022-10-11T12:29:15+00:00" + "time": "2022-10-14T11:20:52+00:00" }, { "name": "phar-io/manifest", @@ -7200,25 +7200,30 @@ }, { "name": "phpdocumentor/type-resolver", - "version": "1.6.1", + "version": "1.6.2", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "77a32518733312af16a44300404e945338981de3" + "reference": "48f445a408c131e38cab1c235aa6d2bb7a0bb20d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/77a32518733312af16a44300404e945338981de3", - "reference": "77a32518733312af16a44300404e945338981de3", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/48f445a408c131e38cab1c235aa6d2bb7a0bb20d", + "reference": "48f445a408c131e38cab1c235aa6d2bb7a0bb20d", "shasum": "" }, "require": { - "php": "^7.2 || ^8.0", + "php": "^7.4 || ^8.0", "phpdocumentor/reflection-common": "^2.0" }, "require-dev": { "ext-tokenizer": "*", - "psalm/phar": "^4.8" + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-phpunit": "^1.1", + "phpunit/phpunit": "^9.5", + "rector/rector": "^0.13.9", + "vimeo/psalm": "^4.25" }, "type": "library", "extra": { @@ -7244,9 +7249,9 @@ "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", "support": { "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.1" + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.2" }, - "time": "2022-03-15T21:29:03+00:00" + "time": "2022-10-14T12:47:21+00:00" }, { "name": "phpunit/php-code-coverage", diff --git a/resources/views/components/billing.blade.php b/resources/views/components/billing.blade.php index 689ebac..285cb0a 100644 --- a/resources/views/components/billing.blade.php +++ b/resources/views/components/billing.blade.php @@ -11,8 +11,8 @@
@livewire('subscriptions', ['mergeFields' => [ - 'name_first' => Auth()->user()->first_name, - 'name_last' => Auth()->user()->last_name, + 'name_first' => Auth()->user()->first_name ?? Auth()->user()->name, + 'name_last' => Auth()->user()->last_name ?? Auth()->user()->name, 'item_description' => config('app.name') . " Subscription", ]] )
diff --git a/src/Http/Controllers/WebhookController.php b/src/Http/Controllers/WebhookController.php index 2861e05..52e4940 100644 --- a/src/Http/Controllers/WebhookController.php +++ b/src/Http/Controllers/WebhookController.php @@ -31,10 +31,13 @@ class WebhookController extends Controller */ public function __invoke(Request $request) { - ray('Incoming Webhook from PayFast')->blue(); + $message = 'Incoming Webhook from PayFast'; + Log::info($message); + ray($message)->blue(); $payload = $request->all(); + Log::debug($payload); ray($payload)->green(); if (isset($payload['ping'])) { diff --git a/src/PayFast.php b/src/PayFast.php index 036b42a..1d13873 100644 --- a/src/PayFast.php +++ b/src/PayFast.php @@ -22,7 +22,7 @@ class PayFast implements BillingProvider public function __construct($client) { - $this->testmode = $client['testmode']; + $this->testmode = $client['testmode'] ?? false; if ($this->testmode == true) { $this->merchant_id = $client['merchant_id_test'];