Integration with a library
Do you create a libraries?
We will pay from 100 to 200 EUR for an accurate and working programming code. If you’d like to cooperate in the future and receive orders for maintenance of a specific system version, the code and your contact data will be published for open use.
Contact us via email to support@paysera.com
You can integrate Paysera system into your website by downloading our open source software library lib_deliver_api. The library can be used to check all the necessary security parameters of transferred and received data.
- 
            lib-delivery-api-merchant-client
            for PHP from
            GitHub.
            
$ git clone https://github.com/paysera/lib-delivery-api-merchant-client
 
Library usage
This library provides ClientFactory class, which you should use to get the API client itself:
use Paysera\DeliveryApi\MerchantClient\ClientFactory;
$clientFactory = new ClientFactory([
    'base_url' => 'https://delivery-api.paysera.com/rest/v1/',
    'mac' => [
        'mac_id' => 'project_id',
        'mac_secret' => 'project_password',
    ],
]);
$merchantClient = $clientFactory->getMerchantClient();
    Library methods
First of all, you need to obtain essential information without which you will not be able to place an order. You can use the following methods:
Get shipment gateways
The Gateway ID is a unique identifier assigned to each available shipment gateway. To retrieve shipment gateway information, you can use the `getShipmentGateway` method:
use Paysera\DeliveryApi\MerchantClient\Entity\GatewaysFilter;
$gatewaysFilter = (new GatewaysFilter())
    ->setProjectId($projectId)
    ->setFromCountryCode($fromCountryCode)
    ->setToCountryCode($toCountryCode)
    ->setShipments($shipments)
    ->setShipmentMethodCode($shipmentMethodCode)
;
$result = $merchantClient->updateGateway($gatewaysFilter);
    Create shipping order
Now that you have all the necessary information, you can proceed to create your order.
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);
    Get shipment methods
The Method ID is a unique identifier assigned to each available shipment method. To retrieve shipment methods, you can use the `getShipmentMethods` method.
use Paysera\DeliveryApi\MerchantClient\Entity as Entities; $methodsFilter = new EntitiesMethodsFilter(); $methodsFilter->setProjectId($projectId); $methodsFilter->setFromCountryCode($fromCountryCode); $methodsFilter->setToCountryCode($toCountryCode); $methodsFilter->setShipments($shipments); $result = $merchantClient->updateMethod($methodsFilter);
Get default package size
Shipment size information is crucial for accurate logistics and delivery management. Retrieve default package sizes using the `getDefaultPackageSizes` method:
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);
Get post office
Knowing the available Post Offices is essential for choosing suitable shipping options based on your location. To retrieve Post Office information, you can use the `getPostOffice` method:
use Paysera\DeliveryApi\MerchantClient\Entity as Entities; $postOfficeFilter = new EntitiesPostOfficeFilter(); $postOfficeFilter->setCity($city); $postOfficeFilter->setCountry($country); $postOfficeFilter->setShipmentGatewayCode($shipmentGatewayCode); $result = $merchantClient->getPostOffices($postOfficeFilter);
delivery.integration_library.get_parcel_machine
delivery.integration_library.parcel_machine
use Paysera\DeliveryApi\MerchantClient\Entity as Entities; $parcelMachineFilter = new EntitiesParcelMachineFilter(); $parcelMachineFilter->setCity($city); $parcelMachineFilter->setCountry($country); $parcelMachineFilter->setShipmentGatewayCode($shipmentGatewayCode); $result = $merchantClient->getParcelMachines($parcelMachineFilter);