PayFast Onsite Payments

Learn how to install PayFast Onsite Payments into a Laravel Jetstream compatible project.

Blog Featured Image Placeholder

Installation

Do the following to install PayFast Onsite Payments into a Laravel project:

composer install fintechsytems/payfast-onsite-payments
lang-bash

Publish the configuration file:

php artisan vendor:publish --provider="FintechSystems\PayFast\PayFastServiceProvider" --tag="config"
lang-bash

Public the Livewire Jetstream compatible views:

php artisan vendor:publish --provider="FintechSystems\PayFast\PayFastServiceProvider" --tag="views"
lang-bash

In your layout file's HTML header, ensure the following code is present:

@if (config('payfast.testmode') == false)
    <script src="https://www.payfast.co.za/onsite/engine.js" defer></script>
@else
    <!-- PayFast Test Mode -->
    <script src="https://sandbox.payfast.co.za/onsite/engine.js" defer></script>
@endif
@stack('payfast-event-listener')
lang-blade

Copy the .env file variables to your .env. file:

PAYFAST_MERCHANT_ID=10004002
PAYFAST_MERCHANT_KEY=q1cd2rdny4a53
PAYFAST_PASSPHRASE=payfast
PAYFAST_TESTMODE=true
PAYFAST_MERCHANT_ID_TEST=
PAYFAST_MERCHANT_KEY_TEST=
PAYFAST_PASSPHRASE_TEST=
PAYFAST_CALLBACK_URL_TEST=https://your-local-app.eu-1.sharedwithexpose.com
PAYFAST_DEBUG=true
PAYFAST_TRIAL_DAYS=30
lang-bash

On your User model, add the following trait:

use FintechSystems\PayFast\Billable;

use Billable;
lang-php

Typically you'll want the navigation menu for authenticated users. Copy this to your navigation-menu.blade.php file:

<x-jet-dropdown-link href="{{ route('profile.billing') }}">
    {{ __('Billing') }}
</x-jet-dropdown-link>
lang-blade

Testing

If you're doing local payments and transactions testing, the PAYFAST_CALLBACK_URL_TEST should be a local Expose or NGrok endpoint:

PAYFAST_CALLBACK_URL_TEST=https://your-local-app.eu-1.sharedwithexpose.com
lang-bash

Local Development

Add the  following to your local project:

"repositories": [
    {
        "type": "path",
        "url": "../payfast-onsite-subscriptions"
    }
],
lang-json




Updated: 1 year ago

© 2022 Eugene's Blog