-
Notifications
You must be signed in to change notification settings - Fork 25
Installation guide
composer require nikolag/laravel-square
Note: Due to Laravel Package Discovery, registering service providers and facades manually for this project as of Laravel 5.5 is deprecated and no longer required since the package is adapted to automatically register these stuff for you. But there are still couple of steps to do in order to use this package.
First you have to publish configuration files:
php artisan vendor:publish --tag=nikolag_configCheck configuration files out at config/nikolag.php before continuing.
Important: If for some reason you can't see square driver inside of connections array, you'll have to add it manually. You can find configuration file here and copy everything from inside connections array and append to your connections array inside of published config file (config/nikolag.php)

Figure 1. Config file
After finishing with configuration files, you should run migrations with the following command
php artisan migrateThen add your credentials for Square API inside of .env and also add fully qualified name (namespace) for your classes.
SQUARE_APPLICATION_ID=<YOUR_APPLICATION_ID>
SQUARE_TOKEN=<YOUR_ACCESS_TOKEN>To be able to utilize the customers system for Users, your User class must use HasCustomers trait.
...
use Nikolag\Square\Traits\HasCustomers;
class User extends Model {
use HasCustomers;
...
}You also need to define user namespace
// .env file
SQUARE_USER_NAMESPACE=<USER_NAMESPACE>To be able to utilize the order system for Users, your Order class must use HasProducts trait.
...
use Nikolag\Square\Traits\HasProducts;
class Order extends Model {
use HasProducts;
...
}You also need to define couple of environment variables
// .env file
SQUARE_ORDER_NAMESPACE=<ORDER_NAMESPACE>
SQUARE_ORDER_IDENTIFIER=<ORDER_IDENTIFIER>
SQUARE_PAYMENT_IDENTIFIER=<ORDER_SQUARE_ID_COLUMN>Important: SQUARE_PAYMENT_IDENTIFIER represents name of the column where we will keep unique ID that Square generates once it saves an Order. This means that you will need to add new column to your Orders table which will hold that value.