Downloads
Stars
Version
By using this plugin you can process or refund payments and handle IPN (Instant Payment Notification) from PayPal in your Laravel application.
This plugin supports the new paypal rest api.
This package uses the new paypal rest api. Refer to this link on how to create API credentials:
https://developer.paypal.com/docs/api/overview/
composer require bgaetealvear/paypal-laravel-58
Perform the following steps if you are using Laravel 5.4 or less.
providers[]
array in config/app.php
file like:BGaeteAlvear\PayPal\Providers\PayPalServiceProvider::class
aliases[]
array in config/app.php
file like:'PayPal' => BGaeteAlvear\PayPal\Facades\PayPal::class
php artisan vendor:publish --provider "BGaeteAlvear\PayPal\Providers\PayPalServiceProvider"
return [
'mode' => env('PAYPAL_MODE', 'sandbox'), // Can only be 'sandbox' Or 'live'. If empty or invalid, 'live' will be used.
'sandbox' => [
'client_id' => env('PAYPAL_SANDBOX_CLIENT_ID', ''),
'client_secret' => env('PAYPAL_SANDBOX_CLIENT_SECRET', ''),
'app_id' => 'APP-80W284485P519543T',
],
'live' => [
'client_id' => env('PAYPAL_LIVE_CLIENT_ID', ''),
'client_secret' => env('PAYPAL_LIVE_CLIENT_SECRET', ''),
'app_id' => '',
],
'payment_action' => env('PAYPAL_PAYMENT_ACTION', 'Sale'), // Can only be 'Sale', 'Authorization' or 'Order'
'currency' => env('PAYPAL_CURRENCY', 'USD'),
'notify_url' => env('PAYPAL_NOTIFY_URL', ''), // Change this accordingly for your application.
'locale' => env('PAYPAL_LOCALE', 'en_US'), // force gateway language i.e. it_IT, es_ES, en_US ... (for express checkout only)
'validate_ssl' => env('PAYPAL_VALIDATE_SSL', true), // Validate SSL when creating api client.
];
.env.example
and .env
#PayPal Setting & API Credentials - sandbox
PAYPAL_SANDBOX_CLIENT_ID=
PAYPAL_SANDBOX_CLIENT_SECRET=
#PayPal Setting & API Credentials - live
PAYPAL_LIVE_CLIENT_ID=
PAYPAL_LIVE_CLIENT_SECRET=
Following are some ways through which you can access the paypal provider:
// Import the class namespaces first, before using it directly
use BGaeteAlvear\PayPal\Services\PayPal as PayPalClient;
$provider = new PayPalClient;
// Through facade. No need to import namespaces
$provider = PayPal::setProvider();
You can override PayPal API configuration by calling setApiCredentials
method:
$provider->setApiCredentials($config);
After setting the PayPal API configuration by calling setApiCredentials
method. You need to get access token before performing any API calls
$provider->getAccessToken();
By default the currency used is USD
. If you wish to change it, you may call setCurrency
method to set a different currency before calling any respective API methods:
$provider->setCurrency('EUR');
This plugin only supports Laravel 5.1 to 5.8.