{"id":25834355,"url":"https://github.com/fintech-systems/payfast-onsite-subscriptions","last_synced_at":"2026-04-08T13:32:22.210Z","repository":{"id":57698199,"uuid":"499134638","full_name":"fintech-systems/payfast-onsite-subscriptions","owner":"fintech-systems","description":"A Payfast Onsite Payments implementation for Laravel designed to ease subscription billing. Livewire views included.","archived":false,"fork":false,"pushed_at":"2025-11-10T20:32:27.000Z","size":527,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-11-10T22:18:25.253Z","etag":null,"topics":["laravel","laravel-livewire","laravel-nova","payfast"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fintech-systems.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"FintechSystems"}},"created_at":"2022-06-02T12:54:07.000Z","updated_at":"2025-11-10T20:31:56.000Z","dependencies_parsed_at":"2023-11-19T10:20:16.618Z","dependency_job_id":"ccbc4782-4802-42c6-9ee1-dc3097b6129e","html_url":"https://github.com/fintech-systems/payfast-onsite-subscriptions","commit_stats":{"total_commits":123,"total_committers":5,"mean_commits":24.6,"dds":0.3252032520325203,"last_synced_commit":"d817cfcb3b57a7dea1dc8611051df7cd533f9cec"},"previous_names":["eugenefvdm/payfast-onsite-subscriptions","fintech-systems/payfast-onsite-subscriptions"],"tags_count":37,"template":false,"template_full_name":"fintech-systems/packagist-boilerplate","purl":"pkg:github/fintech-systems/payfast-onsite-subscriptions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fintech-systems%2Fpayfast-onsite-subscriptions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fintech-systems%2Fpayfast-onsite-subscriptions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fintech-systems%2Fpayfast-onsite-subscriptions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fintech-systems%2Fpayfast-onsite-subscriptions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fintech-systems","download_url":"https://codeload.github.com/fintech-systems/payfast-onsite-subscriptions/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fintech-systems%2Fpayfast-onsite-subscriptions/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31558381,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T10:21:54.569Z","status":"ssl_error","status_checked_at":"2026-04-08T10:21:38.171Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel","laravel-livewire","laravel-nova","payfast"],"created_at":"2025-03-01T00:37:24.538Z","updated_at":"2026-04-08T13:32:22.202Z","avatar_url":"https://github.com/fintech-systems.png","language":"PHP","funding_links":["https://github.com/sponsors/FintechSystems"],"categories":[],"sub_categories":[],"readme":"## About Payfast Onsite Subscriptions\n![GitHub release (latest by date)](https://img.shields.io/github/v/release/fintech-systems/payfast-onsite-subscriptions) ![Tests](https://github.com/fintech-systems/payfast-onsite-subscriptions/actions/workflows/tests.yml/badge.svg)\n ![GitHub](https://img.shields.io/github/license/fintech-systems/payfast-onsite-subscriptions)\n [![Downloads](https://img.shields.io/packagist/dt/fintechsystems/payfast-onsite-subscriptions.svg)](https://packagist.org/packages/fintechsystems/payfast-onsite-subscriptions)\n\nA [Payfast Onsite Payments](https://developers.payfast.co.za/docs#onsite_payments) implementation for Laravel designed to ease subscription billing. [Livewire](https://laravel-livewire.com/) views are included.\n\nRequirements:\n\n- PHP 8.3\n- Laravel 11.x or higher\n- A [Payfast Sandbox account](https://sandbox.payfast.co.za/)\n- A [Payfast account](https://www.payfast.co.za/registration)\n- Sanctum\n\nIf you want to use Laravel Nova, version 4 is required for the `Subscription` and `Receipt` resources.\n\n## Installation\n\nInstall the package via composer:\n\n```bash\ncomposer require fintechsystems/payfast-onsite-subscriptions\n```\n\nIf you don't have Sanctum already:\n\n```bash\nphp artisan install:api\n```\n\n## Publish Configuration and Views\n\nPublish the config file with:\n```bash\nphp artisan vendor:publish --provider=\"FintechSystems\\Payfast\\PayfastServiceProvider\" --tag=\"config\"\n```\n\nPublish the Success and Cancelled views and the Livewire components for subscriptions and receipts.\n```bash\nphp artisan vendor:publish --provider=\"FintechSystems\\Payfast\\PayfastServiceProvider\" --tag=\"views\"\n```\n\nThese files are:\n```bash\nbanner.blade.php\nbilling.blade.php\ncancel.blade.php\npricing.blade.php\nreceipts.blade.php\nsubscriptions.blade.php\nsuccess.blade.php\n```\n\n## Setup\n\nAdd the `Billable()` trait to your user model.\n\n```php\nuse FintechSystems\\Payfast\\Billable;\n\nclass User extends Authenticatable\n{\n    /** @use HasFactory\u003c\\Database\\Factories\\UserFactory\u003e */\n    use HasFactory, Notifiable;\n    use Billable;\n```\n\n## In your header\n\n```php\n@if (config('payfast.test_mode'))\n    \u003c!-- Payfast Test Mode --\u003e\n    \u003cscript src=\"https://sandbox.payfast.co.za/onsite/engine.js\" defer\u003e\u003c/script\u003e\n@else\n    \u003cscript src=\"https://www.payfast.co.za/onsite/engine.js\" defer\u003e\u003c/script\u003e\n@endif\n\n@stack('payfast-event-listener')\n```\n\nTo include the pricing component on a page, do this:\n\nIn your header:\n```php\n@vite(['resources/css/app.css', 'resources/js/app.js'])\n```\n\nIn your view:\n\n```php\n@include('payfast::components.pricing')\n```\n\n### Nova Integration\n\nOptionally publish Laravel Nova Subscription and Receipts Resources and Actions\n\n```bash\nphp artisan vendor:publish --provider=\"FintechSystems\\Payfast\\PayfastServiceProvider\" --tag=\"nova-resources\"\n```\n\n## Migrations\n\nA migration is needed to create Customers, Orders, Receipts and Subscriptions tables:\n\n```bash\nphp artisan migrate\n```\n\n## Example Configuration\n\n`config/payfast.php`:\n\n```php\n\u003c?php\n\nreturn [\n    'merchant_id' =\u003e env('PAYFAST_MERCHANT_ID'),\n    'merchant_key' =\u003e env('PAYFAST_MERCHANT_KEY'),\n    'passphrase' =\u003e env('PAYFAST_PASSPHRASE'),    \n    'test_mode' =\u003e env('PAYFAST_TEST_MODE'),\n    'test_mode_callback_url' =\u003e env('PAYFAST_TEST_MODE_CALLBACK_URL',config('app.url')),\n    'trial_days' =\u003e env('PAYFAST_TRIAL_DAYS', 30),\n    'merchant_id_test' =\u003e env('PAYFAST_MERCHANT_ID_TEST'),\n    'merchant_key_test' =\u003e env('PAYFAST_MERCHANT_KEY_TEST'),\n    'passphrase_test' =\u003e env('PAYFAST_PASSPHRASE_TEST'),\n    'debug' =\u003e env('PAYFAST_DEBUG', false),\n    'return_url' =\u003e env('PAYFAST_RETURN_URL', '/payfast/return'),\n    'cancel_url' =\u003e env('PAYFAST_CANCEL_URL', '/payfast/cancel'),\n    'notify_url' =\u003e env('PAYFAST_NOTIFY_URL', '/payfast/notify'),\n    'callback_url' =\u003e env('PAYFAST_CALLBACK_URL', config('app.url')),\n    'callback_url_test' =\u003e env('PAYFAST_CALLBACK_URL_TEST', ''),\n    'billables' =\u003e [\n        'user' =\u003e [\n            'model' =\u003e User::class,\n            'trial_days' =\u003e 30,\n            'default_interval' =\u003e 'monthly',\n            'currency_prefix' =\u003e 'R ',\n            'plans' =\u003e [\n                [\n                    'name' =\u003e 'Startup',\n                    'short_description' =\u003e \"\",\n                    'monthly' =\u003e [\n                        'setup_amount' =\u003e 69000,\n                        'recurring_amount' =\u003e 69000,\n                    ],\n                    'yearly' =\u003e [\n                        'setup_amount' =\u003e 700000,\n                        'recurring_amount' =\u003e 700000,\n                    ],\n                    'features' =\u003e [\n                        'Feature 1',\n                        'Feature 2',\n                        'Feature 3',\n                    ],\n                    'archived' =\u003e false,\n                    'cta' =\u003e '30 DAY FREE TRIAL',\n                    'mostPopular' =\u003e false,\n                ],\n                [\n                    'name' =\u003e 'Business',\n                    'short_description' =\u003e \"\",                    \n                    'monthly' =\u003e [\n                        'setup_amount' =\u003e 199000,\n                        'recurring_amount' =\u003e 199000,\n                    ],\n                    'yearly' =\u003e [\n                        'setup_amount' =\u003e 2189000,\n                        'recurring_amount' =\u003e 2189000,\n                    ],\n                    'features' =\u003e [\n                        'Feature 1',\n                        'Feature 2',\n                        'Feature 3',\n                    ],\n                    'archived' =\u003e false,\n                    'cta' =\u003e '30 DAY FREE TRIAL',\n                    'mostPopular' =\u003e true,\n                ],                \n            ],\n        ],\n    ],\n];\n```\n\n## Livewire setup\n\n### Views\n\nThe Livewire views are modelled to blend into a [Laravel Jetstream](https://jetstream.laravel.com) user profile page.\n\n#### Adding a billing menu\n\nIn `app.blade.php` below in the Account Management sections (e.g., below profile):\n\n```html\n\u003cx-dropdown-link href=\"/user/billing\"\u003e\n    Billing\n\u003c/x-dropdown-link\u003e\n```\n\nAlso look for the responsive part and add this:\n\n```html\n\u003cx-responsive-nav-link href=\"/user/billing\" :active=\"request()-\u003erouteIs('profile.billing')\"\u003e\n    Billing\n\u003c/x-responsive-nav-link\u003e\n```\n\n#### Adding the subscriptions and receipts views\n\nWhen calling the Livewire component, you can override any [Payfast form field](https://developers.payfast.co.za/docs#step_1_form_fields) by specifying a `mergeFields` array.\n\nExample modification Jetstream Livewire's `resources/views/profiles/show.php`:\n\nReplace `$user-\u003ename` with your first name and last name fields.\n\n```php\n\u003c!-- Subscriptions --\u003e\n\u003cdiv class=\"mt-10 sm:mt-0\"\u003e    \n    @livewire('subscriptions', ['mergeFields' =\u003e [\n            'name_first' =\u003e $user-\u003ename,\n            'name_last' =\u003e $user-\u003ename,\n            'item_description' =\u003e 'Subscription to Online Service'\n        ]] )        \n\u003c/div\u003e\n\n\u003cx-payfast::section-border /\u003e\n\u003c!-- End Subscriptions --\u003e\n\n\u003c!-- Receipts --\u003e\n    \u003cdiv class=\"mt-10 sm:mt-0\"\u003e\n        @livewire('receipts')\n    \u003c/div\u003e\n\n\u003cx-payfast::section-border /\u003e\n\u003c!-- End Receipts --\u003e\n```\n\n## Usage\n\n### Examples\n\n- Generate a payment link\n- Create an adhoc token optionally specifying the amount\n- Cancel a subscription\n- Update a card\n\n```php\nuse FintechSystems\\Payfast\\Facades\\Payfast;\n\nRoute::get('/payment', function() {\n    return Payfast::payment(5,'Order #1');\n});\n\nRoute::get('/cancel-subscription', function() {\n    return Payfast::cancelSubscription('73d2a218-695e-4bb5-9f62-383e53bef68f');\n});\n\nRoute::get('/create-subscription', function() {\n    return Payfast::createSubscription(\n        Carbon::now()-\u003eaddDay()-\u003eformat('Y-m-d'),\n        5, // Amount\n        6 // Frequency (6 = annual, 3 = monthly)\n    );\n});\n\nRoute::get('/create-adhoc-token', function() {\n    return Payfast::createAdhocToken(5);\n});\n\nRoute::get('/fetch-subscription', function() {\n    return Payfast::fetchSubscription('21189d52-12eb-4108-9c0e-53343c7ac692');\n});\n\nRoute::get('/update-card', function() {\n    return Payfast::updateCardLink('40ab3194-20f0-4814-8c89-4d2a6b5462ed');\n});\n```\n\n## Testing\n\n### How to determine when a user's subscription ends\n\n$user-\u003esubscription('default')-\u003eends_at = [date in the past]\n\n```bash\ncomposer test\n```\n\nIn your main project, add this:\n\n```\n\"repositories\": [\n        {\n            \"type\": \"path\",\n            \"url\": \"../payfast-onsite-subscriptions\"\n        }\n],\n```\n\nThen do this to symlink the library:\n\n```\ncomposer require fintechsystems/payfast-onsite-subscriptions:dev-main\n```\n\nIf you want to test trials, use this one-liner to activate a billable user and a trial using Tinker:\n\n```php\n$user = User::find(x)-\u003ecreateAsCustomer(['trial_ends_at' =\u003e now()-\u003eaddDays(30)]);\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Credits\n\n- [Eugene van der Merwe](https://github.com/eugenevdm)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffintech-systems%2Fpayfast-onsite-subscriptions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffintech-systems%2Fpayfast-onsite-subscriptions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffintech-systems%2Fpayfast-onsite-subscriptions/lists"}