Skip to main content

Integration with a Library

Paysera provides an open-source PHP library for integrating the Delivery API into your website. The library simplifies API communication and handles security parameter verification for data transfer and receipt.

Service Availability

Delivery API is currently available only in Lithuania (LT), Latvia (LV), and Estonia (EE).

Library Overview​

Repository: lib-delivery-api-merchant-client

The library provides a convenient PHP interface for:

  • Creating shipping orders
  • Retrieving shipment gateways and methods
  • Managing post offices and parcel machines
  • Accessing package size information

Installation​

Clone the library from GitHub:

git clone https://github.com/paysera/lib-delivery-api-merchant-client

Alternatively, install via Composer:

composer require paysera/lib-delivery-api-merchant-client

ClientFactory Setup​

Initialize the API client using the ClientFactory class with your project credentials:

use Paysera\DeliveryApi\MerchantClient\ClientFactory;

$clientFactory = new ClientFactory([
'base_url' => 'https://delivery-api.paysera.com/rest/v1/',
'mac' => [
'mac_id' => 'project_id', // Your project ID
'mac_secret' => 'project_password', // Your project password
],
]);

$merchantClient = $clientFactory->getMerchantClient();

Core Methods​

Get Shipment Gateways​

Retrieve available shipment gateways filtered by project, country codes, and shipment details:

use Paysera\DeliveryApi\MerchantClient\Entity\GatewaysFilter;

$gatewaysFilter = (new GatewaysFilter())
->setProjectId($projectId)
->setFromCountryCode($fromCountryCode)
->setToCountryCode($toCountryCode)
->setShipments($shipments)
->setShipmentMethodCode($shipmentMethodCode);

$result = $merchantClient->updateGateway($gatewaysFilter);

Returns: Unique identifiers for available shipment options based on your filters.

Create Shipping Order​

Create a new shipping order with complete sender and receiver information:

use Paysera\DeliveryApi\MerchantClient\Entity\OrderCreate;

$orderCreate = new OrderCreate()
->setProjectId($projectId)
->setShipmentGatewayCode($shipmentGatewayCode)
->setShipmentMethodCode($shipmentMethodCode)
->setShipments($shipments)
->setSenderId($senderId)
->setSender($sender)
->setReceiverId($receiverId)
->setReceiver($receiver)
->setNotes($notes);

$result = $merchantClient->createOrder($orderCreate);

Parameters:

  • projectId - Your project identifier
  • shipmentGatewayCode - Selected gateway code
  • shipmentMethodCode - Selected shipping method
  • shipments - Array of shipment details (weight, dimensions)
  • senderId / sender - Sender identification or full sender object
  • receiverId / receiver - Receiver identification or full receiver object
  • notes - Optional notes for the shipment

Get Shipment Methods​

Retrieve available shipping methods based on origin/destination countries and shipment specifications:

use Paysera\DeliveryApi\MerchantClient\Entity as Entities;

$methodsFilter = new Entities\MethodsFilter();
$methodsFilter->setProjectId($projectId);
$methodsFilter->setFromCountryCode($fromCountryCode);
$methodsFilter->setToCountryCode($toCountryCode);
$methodsFilter->setShipments($shipments);

$result = $merchantClient->updateMethod($methodsFilter);

Returns: Method identifiers (e.g., courier codes, service levels) matching your criteria.

Get Default Package Sizes​

Retrieve standard package dimensions with pagination support:

use Paysera\DeliveryApi\MerchantClient\Entity as Entities;

$filter = new PayseraComponentRestClientCommonEntityFilter();
$filter->setLimit($limit);
$filter->setOffset($offset);
$filter->setOrderBy($orderBy);
$filter->setOrderDirection($orderDirection);
$filter->setAfter($after);
$filter->setBefore($before);

$result = $merchantClient->getDefaultPackageSizes($filter);

Parameters:

  • limit - Number of items to retrieve
  • offset - Pagination offset
  • orderBy - Field to sort by
  • orderDirection - Sort direction ('asc' or 'desc')
  • after / before - Date filters

Get Post Offices​

Locate available post offices filtered by city, country, and gateway:

use Paysera\DeliveryApi\MerchantClient\Entity as Entities;

$postOfficeFilter = new Entities\PostOfficeFilter();
$postOfficeFilter->setCity($city);
$postOfficeFilter->setCountry($country);
$postOfficeFilter->setShipmentGatewayCode($shipmentGatewayCode);

$result = $merchantClient->getPostOffices($postOfficeFilter);

Parameters:

  • city - City name (e.g., "Vilnius")
  • country - ISO country code (e.g., "LT")
  • shipmentGatewayCode - Gateway identifier

Get Parcel Machines​

Find automated parcel delivery points using location and gateway filters:

use Paysera\DeliveryApi\MerchantClient\Entity as Entities;

$parcelMachineFilter = new Entities\ParcelMachineFilter();
$parcelMachineFilter->setCity($city);
$parcelMachineFilter->setCountry($country);
$parcelMachineFilter->setShipmentGatewayCode($shipmentGatewayCode);

$result = $merchantClient->getParcelMachines($parcelMachineFilter);

Parameters: Same as getPostOffices method.

Complete Integration Example​

<?php

use Paysera\DeliveryApi\MerchantClient\ClientFactory;
use Paysera\DeliveryApi\MerchantClient\Entity\OrderCreate;

// Initialize client
$clientFactory = new ClientFactory([
'base_url' => 'https://delivery-api.paysera.com/rest/v1/',
'mac' => [
'mac_id' => 'your_project_id',
'mac_secret' => 'your_project_password',
],
]);

$merchantClient = $clientFactory->getMerchantClient();

// Define shipment details
$shipments = [
[
'weight' => 1500, // grams
'width' => 300, // millimeters
'length' => 400,
'height' => 200,
]
];

// Create sender information
$sender = [
'contact' => [
'party' => [
'title' => 'My Company',
'email' => 'shipping@mycompany.com',
'phone' => '+37060000001',
],
'address' => [
'country' => 'LT',
'city' => 'Vilnius',
'street' => 'Warehouse St.',
'house_number' => '1',
'postal_code' => '01001',
],
],
];

// Create receiver information
$receiver = [
'contact' => [
'party' => [
'title' => 'John Doe',
'email' => 'john@example.com',
'phone' => '+37060000002',
],
'address' => [
'country' => 'LT',
'city' => 'Kaunas',
'street' => 'Customer St.',
'house_number' => '10',
'postal_code' => '44001',
],
],
];

// Create order
$orderCreate = (new OrderCreate())
->setProjectId('your_project_id')
->setShipmentGatewayCode('dpd')
->setShipmentMethodCode('standard')
->setShipments($shipments)
->setSender($sender)
->setReceiver($receiver)
->setNotes('Handle with care');

try {
$result = $merchantClient->createOrder($orderCreate);
echo "Order created successfully! Order ID: " . $result->getId();
} catch (Exception $e) {
echo "Error: " . $e->getMessage();
}

Delivery Pricing​

Before implementing your integration, review delivery rates:

Supported Couriers​

  • Omniva - Parcel lockers and courier (LT, LV, EE)
  • LP Express - Parcel machines and courier (LT)
  • Venipak - Courier delivery (LT, LV, EE)
  • SmartPosti - Including remote areas (LT)

Rate Examples​

  • Parcel Lockers: From €1.50 (Small, Medium, Large)
  • Courier (major cities): From €6.90
  • Cross-Border: From €4.60 (locker) / €8.20 (courier)

View Complete Pricing Table →

Prices exclude VAT. Final rates depend on package weight, volume, and destination.

Developer Opportunity​

Paysera offers compensation of €100-200 for developers who contribute functional, accurate library code.

Future maintenance opportunities and ongoing collaboration are available. Paysera may publish both the code and developer contact information for quality contributions.

If you're interested in contributing or have developed useful integration code, contact the support team.

Next Steps​

Support​

Need help with complex integrations?

Contact: