Larapal
A modern, easy and fluent way to allow your clients to pay with PayPal.
Installation
Via Composer
$ composer require hypnodev/larapal
Publish the configuration with command:
$ php artisan vendor:publish --provider="hypnodev\Larapal\LarapalServiceProvider"
Add these keys in your .env:
PAYPAL_MODE=sandbox
PAYPAL_SANDBOX_ID=
PAYPAL_SANDBOX_SECRET=
PAYPAL_PRODUCTION_ID=
PAYPAL_PRODUCTION_SECRET=
If you don't have yet credentials for PayPal API, please refer to Get Started - PayPal Developer
Usage
Add BillableWithPaypal
trait to your User model
<?php
namespace App;
use hypnodev\Larapal\Traits\BillableWithPaypal;
// ...
class User extends Authenticatable
{
use Notifiable, BillableWithPaypal;
// ...
}
This will add chargeWithPaypal
, subscribeWithPaypal
, getPaypalCurrency
, getShippingFields
to your user.
Then you can charge your user with method:
<?php
auth()->user()->chargeWithPaypal('Charge description', [ // Array of items
['name' => 'pkg base', 'description' => 'base package', 'price' => 10.00, 'tax'
…