pulkitjalan / paypal-laravel
A Laravel 5 wrapper for PayPal
Installs: 2 297
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 2
Open Issues: 0
Requires
- php: >=5.5
- illuminate/support: ~5.0
- paypal/rest-api-sdk-php: *
This package is auto-updated.
Last update: 2023-05-10 20:24:29 UTC
README
A Laravel 5 wrapper for PayPal
Requirements
- PHP >= 5.5
This package wraps paypal/rest-api-sdk-php package.
Installation
Require the package
composer require pulkitjalan/paypal-laravel
Laravel 5.5 uses Package Auto-Discovery, so you don't need to manually add the ServiceProvider.
If you don't use auto-discovery, add the following to the providers
array in your config/app.php
PulkitJalan\PayPal\PayPalServiceProvider::class,
Next add the following to the aliases
array in your config/app.php
. Pick and choose if you want or add all 3.
'PayPal' => PulkitJalan\PayPal\Facades\PayPal::class,
Configuration
The config is set in config/services.php
'paypal' => [ 'client_id' => env('PAYPAL_CLIENT_ID'), 'client_secret' => env('PAYPAL_CLIENT_SECRET'), 'mode' => env('PAYPAL_MODE'), // default is sandbox // 'log' => [ // 'enabled' => true // default is false // 'file' => 'paypal.log' // default is laravel.log // 'level' => 'DEBUG' // default is DEBUG // ], ],
Usage
Main use is to get one of the PayPal api classes.
use PulkitJalan\PayPal\PayPal class App { protected $paypal; public function __construct(PayPal $paypal) { $this->paypal = $paypal; } public function payout() { $payouts = $this->paypal->payout(); // returns PayPal\Api\Payout $senderBatchHeader = $this->paypal->payoutSenderBatchHeader(); // returns PayPal\Api\PayoutSenderBatchHeader ... $senderItem = $this->paypal->payoutItem(); // returns PayPal\Api\PayoutItem ... $payouts->setSenderBatchHeader($senderBatchHeader) ->addItem($senderItem); ... $payout->create([], $this->paypal->getApiContext()); } }