gifty/gifty-php
Composer 安装命令:
composer require gifty/gifty-php
包简介
PHP library for interacting with the Gifty API.
README 文档
README
PHP library for interacting with the Gifty API. This SDK is using the public Gifty API and enables you to:
- Accept gift cards in your webshop
- Redeem and issue gift cards in your POS-system
- Retrieve gift card packages
- Retrieve store locations
Requirements
- PHP 8.1 and later
- A valid API Key, that can be generated in your Gifty dashboard
Installation
The SDK is published on Packagist and can be installed using Composer.
composer require gifty/gifty-php
Getting Started
Before starting, it is recommended to read the documentation of the underlying Gifty API where all possible options to include are described.
Initializing the client and performing an API call is done as follows.
$gifty = new \Gifty\Client\GiftyClient('eyJ0eXAi....'); $giftCard = $gifty->giftCards->get('ABCDABCDABCDABCD');
You can also pass additional headers to the client.
$gifty = new \Gifty\Client\GiftyClient('eyJ0eXAi....', ['api_headers' => [ 'Accept-Language' => 'en', 'X-Gifty-Location' => 'lc_123456789' ]]); $giftCard = $gifty->giftCards->get('ABCDABCDABCDABCD');
Retrieve Locations
$locations = $gifty->locations->all();
Retrieve Packages
$packages = $gifty->packages->all();
Retrieve a Package
$package = $gifty->packages->get('gp_ABCDABCD');
Retrieve a Gift Card
$giftCard = $gifty->giftCards->get('ABCDABCDABCDABCD');
Issue a Gift Card
$transaction = $gifty->giftCards->issue( 'ABCDABCDABCDABCD', [ "amount" => 1250, "currency" => "EUR", "promotional" => false ] );
Redeem a Gift Card
$transaction = $gifty->giftCards->redeem( 'ABCDABCDABCDABCD', [ "amount" => 1250, "currency" => "EUR", "capture" => false ] );
Extend a Gift Card
$transaction = $gifty->giftCards->extend( 'ABCDABCDABCDABCD', [ "expires_at" => "2027-09-15T12:42:42+00:00" ] );
Retrieve all Transactions
$transactions = $gifty->transactions->all(['limit' => 5]);
Retrieve all Transactions filtered by gift card ID
$transactions = $gifty->transactions->all(['giftcard' => 'gc_123456789']);
Retrieve a Transaction
$transaction = $gifty->transactions->get('tr_BV94pGgqRvgobxvrLX28jEl0');
Capture a Transaction
$transaction = $gifty->transactions->capture('tr_BV94pGgqRvgobxvrLX28jEl0');
Release a Transaction
$transaction = $gifty->transactions->release('tr_BV94pGgqRvgobxvrLX28jEl0');
Refund a Transaction
$transaction = $gifty->transactions->refund( 'tr_BV94pGgqRvgobxvrLX28jEl0', [ "amount" => 1250, "currency" => "EUR", "reason" => "CUSTOMER_REQUEST", "reason_description" => "Customer returned one item from the order" ] );
Development
Clone the Git repository, so you have a local working copy.
git clone https://github.com/giftyhq/gifty-php
Install required (developing) dependencies using Composer.
composer install
Run and create PHPUnit tests for your modifications.
composer test
Make sure you follow the PSR12 coding standards.
composer phpstan & composer phpcs
gifty/gifty-php 适用场景与选型建议
gifty/gifty-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.43k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2020 年 08 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「gifty」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 gifty/gifty-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gifty/gifty-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 gifty/gifty-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A PSR-7 compatible library for making CRUD API endpoints
An easy-to-use wrapper to check the balance of Gifty.nl vouchers.
A lightweight plain-PHP framework for database-backed CRUD APIs.
Modern, strongly-typed, PSR-compliant PHP client for the WeFact v2 API.
PHP SDK for the Enconvert file conversion API
支付宝开放平台v3协议文档,支持最新版PHP8+
统计信息
- 总下载量: 2.43k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-08-28