lib

The Instore API's enables cash registers to create Svea orders that the customer can checkout by following a link sent to them by SMS

This PHP package is automatically generated by the Swagger Codegen project:

  • API version: v1
  • Build package: io.swagger.codegen.v3.generators.php.PhpClientCodegen

Requirements

PHP 5.5 and later

Installation & Usage

Composer

To install the bindings via Composer, add the following to composer.json:

{
  "repositories": [
    {
      "type": "git",
      "url": "https://github.com/sveaekonomi/php-instore.git"
    }
  ],
  "require": {
    "sveaekonomi/php-instore": "*@dev"
  }
}

Then run composer install

Manual Installation

Download the files and include autoload.php:

    require_once('/path/to/lib/vendor/autoload.php');

Tests

To run the unit tests:

composer install
./vendor/bin/phpunit

Getting Started

Please follow the installation procedure and then run the following:

<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure HTTP basic authorization: basic
$config = Svea\Instore\Configuration::getDefaultConfiguration()
    ->setUsername('YOUR_USERNAME')
    ->setPassword('YOUR_PASSWORD');

$apiInstance = new Svea\Instore\Api\OrderApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$merchantOrderNumber = "merchantOrderNumber_example"; // string | The unique merchant order number used when creating the order

try {
    $result = $apiInstance->cancelOrder($merchantOrderNumber);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling OrderApi->cancelOrder: ', $e->getMessage(), PHP_EOL;
}
// Configure HTTP basic authorization: basic
$config = Svea\Instore\Configuration::getDefaultConfiguration()
    ->setUsername('YOUR_USERNAME')
    ->setPassword('YOUR_PASSWORD');

$apiInstance = new Svea\Instore\Api\OrderApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$body = new \Svea\Instore\Model\CreateOrderRequest(); // \Svea\Instore\Model\CreateOrderRequest | 

try {
    $result = $apiInstance->createOrder($body);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling OrderApi->createOrder: ', $e->getMessage(), PHP_EOL;
}
// Configure HTTP basic authorization: basic
$config = Svea\Instore\Configuration::getDefaultConfiguration()
    ->setUsername('YOUR_USERNAME')
    ->setPassword('YOUR_PASSWORD');

$apiInstance = new Svea\Instore\Api\OrderApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$merchantOrderNumber = "merchantOrderNumber_example"; // string | The unique merchant order number used when creating the order

try {
    $result = $apiInstance->getOrderStatus($merchantOrderNumber);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling OrderApi->getOrderStatus: ', $e->getMessage(), PHP_EOL;
}
// Configure HTTP basic authorization: basic
$config = Svea\Instore\Configuration::getDefaultConfiguration()
    ->setUsername('YOUR_USERNAME')
    ->setPassword('YOUR_PASSWORD');

$apiInstance = new Svea\Instore\Api\OrderApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);
$merchantOrderNumber = "merchantOrderNumber_example"; // string | The unique merchant order number used when creating the order
$body = new \Svea\Instore\Model\RevokeOrderRequest(); // \Svea\Instore\Model\RevokeOrderRequest | Order rows to credit. Doesn't have to match the order rows on the invoice.

try {
    $result = $apiInstance->returnOrder($merchantOrderNumber, $body);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling OrderApi->returnOrder: ', $e->getMessage(), PHP_EOL;
}
?>

Documentation for API Endpoints

All URIs are relative to https://webpayinstoreapi.svea.com

Class Method HTTP request Description
OrderApi cancelOrder POST /api/v1/orders/{merchantOrderNumber}/cancel Cancel the entire order. If the order has been delivered the invoice will be credited.
OrderApi createOrder POST /api/v1/orders Creates an order. A SMS message will be sent to the provided mobile phone number where the checkout can be completed.
OrderApi getOrderStatus GET /api/v1/orders/{merchantOrderNumber}/status Gets order status for a created order. When the order has been finalized customer information is added to the order status response.
OrderApi returnOrder POST /api/v1/orders/{merchantOrderNumber}/return

Documentation For Models

Documentation For Authorization

basic

  • Type: HTTP basic authentication

Author