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
- PHP 8.0 and later
- A valid API Key, that can be generated in your Gifty dashboard
The SDK is published on Packagist and can be installed using Composer.
composer require gifty/gifty-php
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');
$locations = $gifty->locations->all();
$packages = $gifty->packages->all();
$package = $gifty->packages->get('gp_ABCDABCD');
$giftCard = $gifty->giftCards->get('ABCDABCDABCDABCD');
$transaction = $gifty->giftCards->issue(
'ABCDABCDABCDABCD',
[
"amount" => 1250,
"currency" => "EUR",
"promotional" => false
]
);
$transaction = $gifty->giftCards->redeem(
'ABCDABCDABCDABCD',
[
"amount" => 1250,
"currency" => "EUR",
"capture" => false
]
);
$transaction = $gifty->giftCards->extend(
'ABCDABCDABCDABCD',
[
"expires_at" => "2027-09-15T12:42:42+00:00"
]
);
$transactions = $gifty->transactions->all(['limit' => 5]);
$transactions = $gifty->transactions->all(['giftcard' => 'gc_123456789']);
$transaction = $gifty->transactions->get('tr_BV94pGgqRvgobxvrLX28jEl0');
$transaction = $gifty->transactions->capture('tr_BV94pGgqRvgobxvrLX28jEl0');
$transaction = $gifty->transactions->release('tr_BV94pGgqRvgobxvrLX28jEl0');
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