Skip to content

andyredfern/iZettleApi

 
 

Repository files navigation

iZettle Api

The iZettle Api provides a simple integration of the iZettle Api for your PHP project.

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version License

Installation

With composer, add:

$ composer require laulamanapps/izettle-api

Run Tests

To make sure everyting works you can run tests:

$ make unit-tests 
$ make integration-tests 

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();

Make call with an admin created Assertion

For a single merchant account access, create a token in the Inetgrations > Api section and use that as the supplied Assertion to access permitted end points.

use GuzzleHttp\Client;
use LauLamanApps\IzettleApi\GuzzleIzettleClient;
use LauLamanApps\IzettleApi\IzettleClientFactory;

$iZettleClient = new GuzzleIzettleClient(new Client(), 'clientId','clientSecret');

$accessToken = $iZettleClient->getAccessTokenFromApiTokenAssertion('SECRET_API_KEY');

$purchaseClient = IzettleClientFactory::getPurchaseClient($iZettleClient);

$library = $purchaseClient->getPurchaseHistory();

Credits

iZettle Api has been developed by LauLaman.

About

iZettle Api php intergration

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 99.8%
  • Makefile 0.2%