laulamanapps / izettle-api
Zettle by PayPal API PHP Client
Installs: 3 009
Dependents: 0
Suggesters: 0
Security: 0
Stars: 12
Watchers: 7
Forks: 15
Open Issues: 8
Requires
- php: >=7.3
- ext-json: *
- guzzlehttp/guzzle: ^6.3
- moneyphp/money: ^3.0
- ramsey/uuid: ^3.7
- werkspot/enum: ^3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.7
- mockery/mockery: ^1.0
- phpunit/phpunit: ^6.3
This package is auto-updated.
Last update: 2024-10-17 13:38:05 UTC
README
The Zettle by PayPal API provides a simple integration of the Zettle by PayPal API for your PHP project.
Installation
With composer, add:
$ composer require laulamanapps/izettle-api
Run Tests
To make sure everyting works you can run tests:
$ composer test
Usage
Get yourself an access token. you'll need an clientId
and clientSecret
for this (to get one apply here)
for performance benefits, it might be wise to store the access token in a cache like Redis.
use GuzzleHttp\Client; use LauLamanApps\IzettleApi\GuzzleIzettleClient; use LauLamanApps\IzettleApi\IzettleClientFactory; $izettleClient = new GuzzleIzettleClient(new Client(), 'clientId', 'clientSecret'); $accessToken = $izettleClient->getAccessTokenFromUserLogin('john.doe@example.com', 'password'); //-- store $accessToken in cache $productClient = IzettleClientFactory::getProductClient($iZettleClient); $library = $productClient->getLibrary();
Make call with existing AccessToken
use GuzzleHttp\Client; use LauLamanApps\IzettleApi\GuzzleIzettleClient; use LauLamanApps\IzettleApi\IzettleClientFactory; $accessToken = ...; //-- Get from cache $izettleClient = new GuzzleIzettleClient(new Client(), 'clientId', 'clientSecret'); $izettleClient->setAccessToken($accessToken); $purchaseClient = IzettleClientFactory::getPurchaseClient($iZettleClient); $library = $purchaseClient->getPurchaseHistory();
Upgrading
From v0.9 to v1.0
Version 1.0 requires PHP 8.1 and uses first-class Enums. This is a breaking change.
If you're using the enums, make sure you replace calls to get
with an instance reference:
-if ($payout->getPeriodicity() === Periodicity::get(Periodicity::DAILY)) { +if ($payout->getPeriodicity() === Periodicity::DAILY) {
Credits
iZettle Api has been developed by LauLaman.