nikolag/laravel-square
Composer 安装命令:
composer require nikolag/laravel-square
包简介
Square API integration with Laravel built on nikolag/core
关键字:
README 文档
README
Square integration with Laravel/Lumen >=5.5 built on nikolag/core
- Version Compatibility
- Installation guide
- Customer System
- Order System
- Examples
- Available methods
- Contributing
- License
Version Compatibility
Old square connect api
| Library Version | Laravel Version | Square Connect Version |
|---|---|---|
| 2.3.x | >= 5.5 | 2.20190814 (Square Connect V1) |
| 2.4.x | >= 6.x | 2.20190925.0 (Square Connect V2) |
| 2.5.x | >= 7.x | 2.20190925.0 (Square Connect V2) |
| 2.6.x | >= 8.x | 3.20200528.1 (Square Connect V2) |
New square sdk
| Library Version | Laravel Version | Square SDK Version |
|---|---|---|
| 3.0.x | >= 8.x | 17.0.0.20211215 |
| 3.1.x | >= 9.x | 25.1.0.20230119 |
| 3.2.0 | >= 10.x | 25.1.0.20230119 |
| 3.2.x | >= 10.x | 29.0.0.20230720 |
| 3.3.x | >= 10.x | 29.0.0.20230720 |
| 3.4.0 | >= 11.x | 29.0.0.20230720 |
| 3.4.x | >= 11.x | 40.0.0.20250123 |
| 3.5.x | >= 12.x | 40.0.0.20250123 |
If you are updating from versions below 3.0 then you need to execute: php artisan migrate. This will add some columns required by the library into the tables created by the library, your own tables won't be affected.
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_config
Check 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)
After finishing with configuration files, you should run migrations with the following command
php artisan migrate
Then 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>
Customers system
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>
Orders system
To be able to utilize the order system for Users, your Order class must use HasProducts trait and define $table property.
... use Nikolag\Square\Traits\HasProducts; class Order extends Model { use HasProducts; ... /** * The table associated with the model. * * @var string */ protected $table = '<TABLE_NAME>'; ... }
You also need to define a 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 the name of the column where we will keep the unique ID that Square generates once it saves an Order. This means that you will need to add a new column to your Orders table which will hold that value.
Examples
Simple examples
Simple examples are moved to wiki pages to avoid unnecessary scrolling of README.md.
Examples with customers
Examples with customers are moved to wiki pages to avoid unnecessary scrolling of README.md.
Examples with order
Examples with orders are moved to the wiki pages to avoid unnecessary scrolling of README.md.
All traits and their methods
HasProducts
All methods for this trait are moved to the wiki pages to avoid unnecessary scrolling of README.md.
HasCustomers
All methods for this trait are moved to the wiki pages to avoid unnecessary scrolling of README.md.
All facades and their methods
Square
All methods for this facade are moved to the wiki pages to avoid unnecessary scrolling of README.md.
Contributing
Everyone is welcome to contribute to this repository, simply open up an issue and label the request, whether it is an issue, bug or a feature. For any other inquiries send an email to nikola.gavric94@gmail.com
Contributors
| Name | Changes | Date |
|---|---|---|
| @Godlikehobbit | Add optional currency parameter to charge function pull request #6 | 2017-09-12 |
| @PaulJulio | Cap square/connect version to resolve deprecation exceptions pull request #27 | 2019-09-20 |
| @Alex Oleynik | Fixes TypeError when updating customers pull request #71 | 2022-06-28 |
| @qooplmao | Adds support for 3DS/SCA pull request #74 | 2023-01-13 |
| @Mrkbingham | For his continous support over the years and helping tremendously in keeping this library afloat | ~ |
Special thanks to all of the contributors!
License
MIT License
Copyright (c) Nikola Gavrić nikola.gavric94@gmail.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
nikolag/laravel-square 适用场景与选型建议
nikolag/laravel-square 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 29.13k 次下载、GitHub Stars 达 38, 最近一次更新时间为 2018 年 06 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「package」 「library」 「laravel」 「square」 「square laravel integration」 「laravel square」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 nikolag/laravel-square 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nikolag/laravel-square 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 nikolag/laravel-square 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Inbox pattern process implementation for your Laravel Applications
Simple ASCII output of array data
Core library that defines common interfaces used by the rest of the intahwebz..
Amqp classes
Provides command to manage a web library directory
统计信息
- 总下载量: 29.13k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 38
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-06-17