Download the PHP package mijora/itella-api without Composer
On this page you can find all versions of the php package mijora/itella-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package itella-api
Itella-API
Its a wrapper library for Pakettikauppa API library.
Installing Itella-API using composer
Using Itella-API library
__PATH_TO_LIB__
is path to where itella-api is placed. This will load Mijora\Itella namespace
Validations, checks, etc. throws ItellaException and calls to library classes should be wrapped in: blocks
Any function starting with add
or set
returns its class so functions can be chained.
Authentication
Uses supplied user
and secret
. It is called during Shipment creation.
Creating Sender
Party::ROLE_SENDER
is used to identify sender.
Minimum required setup:
- Contract must be set for sender!
- Phone number must be in international format, library will try to fix given number or throw ItellaException.
Creating Receiver
Party::ROLE_RECEIVER
is used to identify sender.
Minimum required setup:
- Phone number must be in international format, library will try to fix given number or throw ItellaException.
Disabling phone checking / fixing
By default Party class checks that supplied phone matches set country format (if country is Lithuania it exxpects to see Lithuanian phone number) and tries to fix phone number to conform to international standart if needed. In case where such check / fixing is not desired (phone number is of different country than the one set) it can be disabled using disablePhoneCheck function on Party class.
NOTE: Even if checking / fixing is disabled Party class will still check that supplied number is in international format.
Example:
Notice how country code is set as LT (Lithuania) while contact mobile number is Latvian.
Creating Order Items
- If using multiparcel additional service simply create multiple GoodsItem and register them to Shipment.
Creating Additional Services
Shipment::PRODUCT_COURIER available additional services:
- Must be set manualy
- 3101 - Cash On Delivery (only by credit card).
Requires array with this information:
amount
=> amount to be payed in EUR,account
=> bank account (IBAN),codbic
=> bank BIC,reference
=> COD Reference, can be usedHelper::generateCODReference($id)
where$id
can be Order ID.
- 3104 - Fragile
- 3166 - Call before Delivery
- 3174 - Oversized
- 3101 - Cash On Delivery (only by credit card).
Requires array with this information:
- Will be set automatically
- 3102 - Multi Parcel, will be set automatically if Shipment has more than 1 and up to 10 GoodsItem.
Requires array with this information:
count
=> Total of registered GoodsItem.
- 3102 - Multi Parcel, will be set automatically if Shipment has more than 1 and up to 10 GoodsItem.
Requires array with this information:
Shipment::PRODUCT_PICKUP available additional services:
- Must be set manualy
- 3101 - Cash On Delivery (only by credit card).
Requires array with this information:
amount
=> amount to be payed in EUR,account
=> bank account (IBAN),codbic
=> bank BIC,reference
=> COD Reference, can be usedHelper::generateCODReference($id)
where$id
can be Order ID.
- 3101 - Cash On Delivery (only by credit card).
Requires array with this information:
- Will be set automatically
- 3201 - Pickup Point, is set automatically when pick up point ID (pupCode from Locations API) is registered into Shipment.
Requires array with this information:
pickup_point_id
=> Pickup point pupCode.
- 3201 - Pickup Point, is set automatically when pick up point ID (pupCode from Locations API) is registered into Shipment.
Requires array with this information:
Trying to set additional service that is not available for set product code will throw ItellaException.
Creating additional service that does not need extra information (eg. with Fragile):
Creating COD additional service:
Create Shipment
Available product codes:
- Shipment::PRODUCT_COURIER = 2317
- Shipment::PRODUCT_PICKUP = 2711
Shipment can be either one, but never both. See Additional Services for what services is available to each product code.
Shipment product code should always be set first.
When registering GoodsItem its possible to register one at a time using
$shipment->addGoodsItem(GoodsItem)
or multiple passing them in array to
$shipment->addGoodsItems(array(GoodsItem, GoodsItem))
When registering AdditionalService its possible to register one at a time using
$shipment->addAdditionalService(AdditionalService)
or multiple passing them in array to
$shipment->addAdditionalServices(array(AdditionalService, AdditionalService))
Courier Shipment example (uses variables from above examples):
Pickup point Shipment example (uses variables from above examples):
Once all information is supplied - shipment can be registered. If registration is successfull, tracking number will be returned. In this example returned tracking number is displayed, normaly it would be saved to order for later use to request shipment label PDF.
If there is need to check request XML it can be done using asXML()
Printing Label
Available label sizes:
- Shipment::LABEL_SIZE_A5 = A5
- Shipment::LABEL_SIZE_107X225 = 107x225
It is advised to always download label when it is needed. For that Shipment class is used.
result will be base64 encoded pdf file. If multiple tracking numbers (in array) is passed pdf will contain all those labels. For getting and merging labels pdf from two different users please refer to get-merge-labels.php
example
$shipment->downloadLabels($track, $size = null)
secondary parameter $size
is optional and will work once posti/itella enviroment has it implemented on pakettikauppa side.
Important: If tracking number is from different user it will be ignored.
Above example checks that response isnt empty (if tracking number is wrong it still returns empty response), saves to file and loads into browser.
Locations API
When using Pickup Point option it is important to have correct list of pickup points. Also when creating Shipment to send to pickup point it will require that pickup point ID.
Manifest generating
When generating manifest by default it uses english strings - it is possible to pass translation.
Manifest constructor accepts additional arguments
$timestamp
=> defaultfalse
and will assign current system time. Unixtimestamp can be passed here to show particular date in manifest above logo.$dateFormat
=> default'Y-m-d'
. Date format as string, can be used anything that is supported by PHP date() https://www.php.net/manual/en/function.date
Requires array of arrays with this information:
track_num
=> tracking number (string),weight
=> weight (if any) (float),delivery_address
=> Delivery address (string).
for other options see example below:
Call Courier
To call courrier manifest must be generated (works well with base64 encoded pdf). CallCourier is using mail() php function. That means - even if mail reports success on sending email, it is not guaranteed to be sent.
Call Courier - in development
To call courrier manifest must be generated (works well with base64 encoded pdf). CallCourier is using mail() php function. That means - even if mail reports success on sending email, it is not guaranteed to be sent.
All versions of itella-api with dependencies
setasign/fpdi Version ^2.3
tecnickcom/tcpdf Version ^6.4