Laravel integrator for PayPal solutions. Actually this library supports the following solutions:
You need to make sure your server meets the following requirements.
- PHP >= 7.4, PHP >= 8.0
- Laravel 7.x, 8.x
Use following command to install this library:
composer require pleets/laravel-paypalAdd the service provider to your providers[] array in config/app.php file like:
\Pleets\LaravelPayPal\LaravelPaypalProvider::classFinally, publish the vendor files.
php artisan vendor:publish --tag="laravel-paypal"Set up first API credentials for sandbox with the following env vars.
PAYPAL_SANDBOX_CLIENT_ID=
PAYPAL_SANDBOX_SECRET=For live environment set up the following.
PAYPAL_LIVE_CLIENT_ID=
PAYPAL_LIVE_SECRET=You can choose your current environment with the following.
PAYPAL_ENVIRONMENT=sandboxThe only valid values for this are sandbox and live.
Activate paypal checkout with the following env var.
PAYPAL_CHECKOUT_ACTIVATED=trueAdd the PayPal SDK to your blade templates as follows
@include('laravel-paypal::checkout.sdk')💡 You don't have to be worried about when to include this SDK. The component checks for PAYPAL_CHECKOUT_ACTIVATED
and then include the JavaScript SDK in case the value were true.
Then you can add the Smart Payment Button like this
@include('laravel-paypal::checkout.button')<script src="{{ asset('js/paypal/checkout.js') }}" defer></script>The checkout.js file contains values related to the purchase amount and purchase behaviour.
For other values you can check the official documentation.
Activate paypal subscriptions with the following en var.
PAYPAL_SUBSCRIPTION_ACTIVATED=trueYou can interact with subscriptions Api through this PayPal SDK. Add the service provider
to your providers[] array in config/app.php file like:
Pleets\LaravelPayPal\Providers\PayPalServiceProvider::classAdd the PayPal SDK to your blade templates as follows
@include('laravel-paypal::subscriptions.sdk')💡 You don't have to be worried about when to include this SDK. The component checks for PAYPAL_SUBSCRIPTION_ACTIVATED
and then include the JavaScript SDK in case the value were true.
Then you can add the Smart Payment Button like this
@include('laravel-paypal::subscriptions.button')<script src="{{ asset('js/paypal/subscriptions.js') }}" defer></script>The subscriptions.js file contains values related to creating subscriptions and purchase behaviour.
For other values you can check the official documentation.
If you want to mock the PayPal Service for testing purposes, you need to overwrite the paypal testing configuration.
You must create a testing.php file inside config/paypal folder and set up a specific handler like this.
'handler' => [
'class' => PaymentGateway\PayPalApiMock\PayPalApiMock::class,
]Feel free to use your own paypal mock, or you can use this PayPal Api Mock.
Finally, you should set up the following in your testing environment.
PAYPAL_HANDLER_ENABLED=true