fullscreeninteractive/silverstripe-xero
Composer 安装命令:
composer require fullscreeninteractive/silverstripe-xero
包简介
关键字:
README 文档
README
Maintainer Contact
- Will Rossiter will@fullscreen.io
Installation
composer require "fullscreeninteractive/silverstripe-xero"
Documentation
Provides a lightweight wrapper around calcinai/xero-php with additional
Silverstripe support for authenication and connecting applications via oauth.
To setup register a Xero Application and define your clientId and clientSecret as environment variables.
XERO_CLIENT_ID='123' XERO_CLIENT_SECRET='123'
Once those API keys are available, a new tab under the Settings admin will
appear for connecting to Xero. Follow the prompts to link the selected account
to your Silverstripe website.
Renewing the Access Token
Access tokens last 30 days, a scheduled queued job (RefreshXeroTokenJob) is
provided which renews the access token on a regular basis.
Setting up the application in Xero
- Head to https://developer.xero.com/app/manage/
- Create a new
Web App - Set the
Redirect URIto behttps://www.yoursite.com/connectXero
Note the connectXero endpoint in Silverstripe is restricted to ADMIN only
users.
Interacting with the API
/** @var \XeroPHP\Application **/ $app = XeroFactory::singleton()->getApplication();
Integrating with the API is done via https://github.com/calcinai/xero-php. Consult that page for further information for creating invoices etc.
Creating a Xero Contact from a Member
<?php use Psr\Log\LoggerInterface; use SilverStripe\ORM\DataExtension; use FullscreenInteractive\SilverStripeXero\XeroFactory; use SilverStripe\Core\Injector\Injector; class XeroMemberExtension extends DataExtension { private static $db = [ 'XeroContactID' => 'Varchar' ]; public function updateCMSFields(FieldList $fields) { $fields->makeFieldReadonly('XeroContactID'); } public function getXeroContact() { try { $xero = XeroFactory::singleton()->getApplication(); } catch (Throwable $e) { $xero = null; } if ($xero) { try { $contact = null; if ($id = $this->owner->XeroContactID) { $contact = $xero->loadByGUID('Accounting\\Contact', $id); } if (!$contact) { $existing = $xero->load('Accounting\\Contact') ->where('EmailAddress!=null AND EmailAddress.Contains("' . trim($this->owner->Email) . '")') ->execute(); if (count($existing) > 1) { $contact = $existing->offsetGet(0); } } if (!$contact) { // create the record $contact = new \XeroPHP\Models\Accounting\Contact(); $contact->setName($this->owner->Name); $contact->setFirstName($this->owner->FirstName); $contact->setLastName($this->owner->Surname); $contact->setEmailAddress($this->owner->Email); try { $xero->save($contact); } catch (Exception $e) { if (strpos($e->getMessage(), 'Already assigned to') !== false) { $contact->setName($this->owner->Name . ' ' . date('Y-m-d')); try { $xero->save($contact); } catch (Exception $e) { Injector::inst()->get(LoggerInterface::class)->warning($e); } } } } return $contact; } catch (Exception $e) { Injector::inst()->get(LoggerInterface::class)->error($e); } } } }
fullscreeninteractive/silverstripe-xero 适用场景与选型建议
fullscreeninteractive/silverstripe-xero 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 110 次下载、GitHub Stars 达 1, 最近一次更新时间为 2021 年 09 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「silverstripe」 「xero」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 fullscreeninteractive/silverstripe-xero 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 fullscreeninteractive/silverstripe-xero 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 fullscreeninteractive/silverstripe-xero 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Laravel wrapper for Xero
An extension for using the Xero API from within Yii2
Symfony bundle wrapping the XeroPHP library
Analytics chooser extensions for site settings.
Send invoices to Xero including contacts, payments and even inventory updates.
统计信息
- 总下载量: 110
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2021-09-16