### Install and Configure Russian Post SDK Source: https://context7.com/lapaygroup/russianpost/llms.txt Install the SDK using Composer and configure authentication credentials for the Russian Post API. Configuration can be done directly in PHP or by parsing a YAML file. ```php [ 'otpravka' => [ 'token' => 'ваш_access_token', 'key' => 'ваш_base64_ключ' ], 'tracking' => [ 'login' => 'ваш_логин_трекинга', 'password' => 'ваш_пароль_трекинга' ] ] ]; // Или через YAML файл use Symfony\Component\Yaml\Yaml; $config = Yaml::parse(file_get_contents('config.yaml')); ``` -------------------------------- ### GET /settings Source: https://github.com/lapaygroup/russianpost/blob/master/README.md Retrieves the current user settings. ```APIDOC ## GET /settings ### Description Returns the current configuration settings for the authenticated user. ### Method GET ### Endpoint /settings ``` -------------------------------- ### GET /generateDocF7p Source: https://github.com/lapaygroup/russianpost/blob/master/README.md Generates a PDF file with the F7p form for a specific order. ```APIDOC ## GET /generateDocF7p ### Description Generates and returns a PDF file with the F7p form for a specific order. Optionally includes the F22 form. ### Parameters #### Query Parameters - **order_id** (int) - Required - The ID of the order. - **action** (string) - Required - Defines output format: 'DOWNLOAD_FILE' or 'PRINT_FILE'. - **sending_date** (DateTime) - Optional - The date of sending. Defaults to current date if not provided. ``` -------------------------------- ### Create Order with Russian Post API Source: https://github.com/lapaygroup/russianpost/blob/master/README.md This example shows how to create a new order using the Russian Post API. It includes setting order details, calculating shipping costs, and handling potential validation or API errors. Ensure correct index types (numeric for domestic, string for international) are used. ```php setIndexTo(115551); $order->setPostOfficeCode(109012); $order->setGivenName('Иван'); $order->setHouseTo('92'); $order->setCorpusTo('3'); $order->setMass(1000); $order->setOrderNum('2'); $order->setPlaceTo('Москва'); $order->setRecipientName('Иванов Иван'); $order->setRegionTo('Москва'); $order->setStreetTo('Каширское шоссе'); $order->setRoomTo('1'); $order->setSurname('Иванов'); $orders[] = $order->asArr(); $result = $otpravkaApi->createOrders($orders); // Успешный ответ /*Array ( [result-ids] => Array ( [0] => 115322331 ) ) */ // Ответ с ошибкой /*Array ( [errors] => Array ( [0] => Array ( [error-codes] => Array ( [0] => Array ( [code] => EMPTY_INDEX_TO [description] => Почтовый индекс не указан ) ) [position] => 0 ) ) )*/ } catch (InvalidArgumentException $e) { // Обработка ошибки заполнения параметров } catch (LapayGroup\RussianPost\Exceptions\RussianPostException $e) { // Обработка ошибочного ответа от API ПРФ } catch (Exception $e) { // Обработка нештатной ситуации } ?> ``` -------------------------------- ### GET /generateDocPackage Source: https://github.com/lapaygroup/russianpost/blob/master/README.md Generates a ZIP archive containing essential shipment documents for a batch. ```APIDOC ## GET /generateDocPackage ### Description Generates and returns a ZIP archive containing Export.xls, Export.csv, F103.pdf, and other relevant forms (f7, f112, f22) based on shipment type. ### Parameters #### Query Parameters - **shipment_id** (int) - Required - The ID of the shipment batch. - **action** (string) - Required - Defines output format: 'DOWNLOAD_FILE' for browser download or 'PRINT_FILE' for object return. ``` -------------------------------- ### Track Shipments by RPO with Russian Post API Source: https://context7.com/lapaygroup/russianpost/llms.txt Retrieves detailed operation history for a shipment using its RPO (barcode). This example also shows how to fetch information about cash-on-delivery payments. Ensure your config.yaml is set up. ```php getOperationsByRpo('10944022440321'); foreach ($operations as $operation) { echo "Дата: " . $operation->DateOper . "\n"; echo "Операция: " . $operation->OperType->Name . "\n"; echo "Атрибут: " . $operation->OperAttr->Name . "\n"; echo "Индекс ОПС: " . $operation->AddressParameters->OperationAddress->Index . "\n\n"; } // Информация о наложенном платеже $npayInfo = $tracking->getNpayInfo('10944022440321'); print_r($npayInfo); } catch ( SoapFault $e) { echo "Ошибка SOAP: " . $e->getMessage(); } ?> ``` -------------------------------- ### Calculate Tariff via Sending API Source: https://context7.com/lapaygroup/russianpost/llms.txt Calculate shipping costs using the Russian Post Sending API, which offers advanced features for ECOM shipments. This example demonstrates retrieving shipping points and calculating tariffs for both standard and ECOM parcels. ```php shippingPoints(); $parcelInfo = new ParcelInfo(); $parcelInfo->setIndexFrom($shippingPoints[0]['operator-postcode']); $parcelInfo->setIndexTo(644015); $parcelInfo->setMailCategory('ORDINARY'); $parcelInfo->setMailType('POSTAL_PARCEL'); $parcelInfo->setWeight(1000); $parcelInfo->setFragile(true); $tariffInfo = $otpravkaApi->getDeliveryTariff($parcelInfo); echo "Стоимость: " . ($tariffInfo->getTotalRate() / 100) . " руб.\n"; echo "Срок доставки: " . $tariffInfo->getDeliveryMinDays() . "-" . $tariffInfo->getDeliveryMaxDays() . " дней\n"; // Расчет для ЕКОМ $parcelInfo->setMailType('ECOM'); $parcelInfo->setDeliveryPointindex(644015); $parcelInfo->setEntriesType('SALE_OF_GOODS'); $parcelInfo->setFunctionalityChecking(true); $parcelInfo->setGoodsValue(1588000); $parcelInfo->setWithFitting(true); $ecomTariff = $otpravkaApi->getDeliveryTariff($parcelInfo); } catch ( LapayGroup\RussianPost\Exceptions\RussianPostException $e) { echo "Ошибка: " . $e->getMessage(); } ``` -------------------------------- ### Retrieve Account Settings and Balance with PHP Source: https://context7.com/lapaygroup/russianpost/llms.txt Fetch user settings, shipping points, and current account balance. ```php settings(); print_r($settings); // Точки сдачи отправлений $shippingPoints = $otpravkaApi->shippingPoints(); foreach ($shippingPoints as $point) { echo "Индекс: " . $point['operator-postcode'] . "\n"; echo "Адрес: " . $point['address']['address-str'] . "\n\n"; } // Баланс расчетного счета (в копейках) $balance = $otpravkaApi->getBalance(); echo "Баланс: " . ($balance['balance'] / 100) . " руб.\n"; echo "Дата: " . $balance['balance-date'] . "\n"; } catch (\LapayGroup\RussianPost\Exceptions\RussianPostException $e) { echo "Ошибка: " . $e->getMessage(); } ``` -------------------------------- ### GET /shipping-points Source: https://github.com/lapaygroup/russianpost/blob/master/README.md Retrieves a list of current shipping points. ```APIDOC ## GET /shipping-points ### Description Returns a list of current shipping points configured for the user. ### Method GET ### Endpoint /shipping-points ``` -------------------------------- ### Manage Easy Returns with PHP Source: https://context7.com/lapaygroup/russianpost/llms.txt Create, delete, and generate labels for return shipments using the Easy Return service. ```php returnShipment('80083740712514', MailType::UNDEFINED); echo "ШПИ возврата: " . $result['return-barcode'] . "\n"; // Создание отдельного возвратного отправления $addressFrom = new AddressReturn(); $addressFrom->setAddressType(AddressType::DEFAULT); $addressFrom->setIndex(125009); $addressFrom->setPlace('Москва'); $addressFrom->setRegion('Москва'); $addressTo = new AddressReturn(); $addressTo->setAddressType(AddressType::DEFAULT); $addressTo->setIndex(115551); $addressTo->setPlace('Москва'); $addressTo->setRegion('Москва'); $returnShipment = new ReturnShipment(); $returnShipment->setMailType(MailType::UNDEFINED); $returnShipment->setSenderName('Иванов Иван'); $returnShipment->setRecipientName('Петров Петр'); $returnShipment->setOrderNum(1234); $returnShipment->setAddressFrom($addressFrom); $returnShipment->setAddressTo($addressTo); $createResult = $otpravkaApi->createReturnShipment([$returnShipment->asArr()]); // Удаление возвратного отправления $deleteResult = $otpravkaApi->deleteReturnShipment('80083740712514'); // Генерация возвратного ярлыка $label = $otpravkaApi->generateReturnLabel('80083740712514', OtpravkaApi::PRINT_FILE, OtpravkaApi::PRINT_TYPE_PAPER); file_put_contents('return_label.pdf', $label->getStream()->getContents()); } catch (\LapayGroup\RussianPost\Exceptions\RussianPostException $e) { echo "Ошибка: " . $e->getMessage(); } ``` -------------------------------- ### Manage Batches with OtpravkaApi Source: https://context7.com/lapaygroup/russianpost/llms.txt Create, modify, and query batches of shipments. Requires an initialized OtpravkaApi instance. ```php createBatch($orderIds, $sendingDate); $batchName = $result['batches'][0]['batch-name']; echo "Создана партия: $batchName\n"; echo "Присвоенные ШПИ: " . implode(', ', $result['result-ids']) . "\n"; // Перенос заказов в существующую партию $moveResult = $otpravkaApi->moveOrdersToBatch($batchName, [115685149]); // Поиск партии по имени $batch = $otpravkaApi->findBatchByName($batchName); echo "Статус партии: " . $batch['batch-status'] . "\n"; echo "Количество отправлений: " . $batch['shipment-count'] . "\n"; // Получение заказов в партии $ordersInBatch = $otpravkaApi->getOrdersInBatch($batchName); foreach ($ordersInBatch as $order) { echo "ШПИ: " . $order['barcode'] . " - " . $order['recipient-name'] . "\n"; } // Изменение даты отправки $newDate = new DateTimeImmutable('2024-01-25'); $otpravkaApi->changeBatchSendingDay($batchName, $newDate); // Удаление заказов из партии $otpravkaApi->deleteOrdersInBatch([115527611]); // Поиск всех партий $allBatches = $otpravkaApi->getAllBatches(); foreach ($allBatches as $b) { echo $b['batch-name'] . ": " . $b['batch-status'] . "\n"; } } catch (\LapayGroup\RussianPost\Exceptions\RussianPostException $e) { echo "Ошибка: " . $e->getMessage(); } ``` -------------------------------- ### Get Archived Batches Source: https://github.com/lapaygroup/russianpost/blob/master/README.md Retrieves a list of batches that are currently in the archive. ```APIDOC ## Get Archived Batches ### Description Retrieves a list of batches that are currently in the archive. ### Method GET ### Endpoint /getArchivedBatches ### Response #### Success Response (200) - **batch-name** (string) - The name of the batch. - **batch-status** (string) - The current status of the batch (e.g., ARCHIVED). - **batch-status-date** (string) - The date and time when the batch status was updated. - **combined-batch-mail-types** (array) - An array of mail types included in the batch. - **courier-order-statuses** (array) - Statuses of courier orders associated with the batch. - **international** (string) - Indicates if the batch is international. - **list-number-date** (string) - The date of the list number. - **mail-category** (string) - The mail category (e.g., COMBINED). - **mail-category-text** (string) - A human-readable description of the mail category. - **mail-rank** (string) - The mail rank. - **mail-type** (string) - The type of mail (e.g., COMBINED). - **mail-type-text** (string) - A human-readable description of the mail type. - **payment-method** (string) - The payment method used for the batch. - **postmarks** (array) - Postmarks applied to the batch. - **postoffice-address** (string) - The address of the post office. - **postoffice-code** (string) - The code of the post office. - **postoffice-name** (string) - The name of the post office. - **shipment-avia-rate-sum** (string) - The sum ofavia shipping rates. - **shipment-avia-rate-vat-sum** (string) - The VAT sum foravia shipping rates. - **shipment-completeness-checking-rate-sum** (string) - The sum for completeness checking rates. - **shipment-completeness-checking-rate-vat-sum** (string) - The VAT sum for completeness checking rates. - **shipment-contents-checking-rate-sum** (string) - The sum for contents checking rates. - **shipment-contents-checking-rate-vat-sum** (string) - The VAT sum for contents checking rates. - **shipment-count** (string) - The number of shipments in the batch. - **shipment-ground-rate-sum** (string) - The sum of ground shipping rates. - **shipment-ground-rate-vat-sum** (string) - The VAT sum for ground shipping rates. - **shipment-insure-rate-sum** (string) - The sum of insurance rates. - **shipment-insure-rate-vat-sum** (string) - The VAT sum for insurance rates. - **shipment-inventory-rate-sum** (string) - The sum of inventory rates. - **shipment-inventory-rate-vat-sum** (string) - The VAT sum for inventory rates. - **shipment-mass** (string) - The total mass of shipments. - **shipment-mass-rate-sum** (string) - The sum of mass-based shipping rates. - **shipment-mass-rate-vat-sum** (string) - The VAT sum for mass-based shipping rates. - **shipment-notice-rate-sum** (string) - The sum of notice rates. - **shipment-notice-rate-vat-sum** (string) - The VAT sum for notice rates. - **shipment-sms-notice-rate-sum** (string) - The sum of SMS notice rates. - **shipment-sms-notice-rate-vat-sum** (string) - The VAT sum for SMS notice rates. - **shipping-notice-type** (string) - The type of shipping notice. - **transport-type** (string) - The type of transport used. - **use-online-balance** (string) - Indicates if online balance is used. - **wo-mass** (string) - Weight of the shipment. #### Response Example ```json { "0": { "batch-name": "25", "batch-status": "ARCHIVED", "batch-status-date": "2019-09-03T13:17:59.237Z", "combined-batch-mail-types": [ "POSTAL_PARCEL" ], "courier-order-statuses": [ "NOT_REQUIRED" ], "international": null, "list-number-date": "2019-09-08", "mail-category": "COMBINED", "mail-category-text": "Комбинированно", "mail-rank": "WO_RANK", "mail-type": "COMBINED", "mail-type-text": "Комбинированно", "payment-method": "CASHLESS", "postmarks": [ "NONSTANDARD" ], "postoffice-address": "ул Никольская, д.7-9, стр.3, г Москва", "postoffice-code": "109012", "postoffice-name": "ОПС 109012", "shipment-avia-rate-sum": "0", "shipment-avia-rate-vat-sum": "0", "shipment-completeness-checking-rate-sum": "0", "shipment-completeness-checking-rate-vat-sum": "0", "shipment-contents-checking-rate-sum": "0", "shipment-contents-checking-rate-vat-sum": "0", "shipment-count": "1", "shipment-ground-rate-sum": "16500", "shipment-ground-rate-vat-sum": "3300", "shipment-insure-rate-sum": "0", "shipment-insure-rate-vat-sum": "0", "shipment-inventory-rate-sum": "0", "shipment-inventory-rate-vat-sum": "0", "shipment-mass": "1000", "shipment-mass-rate-sum": "16500", "shipment-mass-rate-vat-sum": "3300", "shipment-notice-rate-sum": "0", "shipment-notice-rate-vat-sum": "0", "shipment-sms-notice-rate-sum": "0", "shipment-sms-notice-rate-vat-sum": "0", "shipping-notice-type": "SIMPLE", "transport-type": "SURFACE", "use-online-balance": null, "wo-mass": null } } ``` ``` -------------------------------- ### GET /postal-codes-in-locality Source: https://github.com/lapaygroup/russianpost/blob/master/README.md Retrieves a list of postal codes for a given locality name. ```APIDOC ## GET /postal-codes-in-locality ### Description Retrieves a list of postal codes for a given locality name. ### Parameters #### Query Parameters - **locality** (string) - Required - The name of the city or locality. ``` -------------------------------- ### Creating Orders in PHP Source: https://context7.com/lapaygroup/russianpost/llms.txt Configures order details and submits them to the API using either V1 or V2 methods. V2 is recommended for retrieving the barcode (ШПИ) immediately upon creation. ```php setOrderNum('12345'); // Внутренний номер заказа $order->setIndexTo(115551); // Индекс получателя $order->setPostOfficeCode(109012); // Индекс точки сдачи $order->setRegionTo('Москва'); $order->setPlaceTo('Москва'); $order->setStreetTo('Каширское шоссе'); $order->setHouseTo('92'); $order->setCorpusTo('3'); $order->setRoomTo('1'); $order->setRecipientName('Иванов Иван Петрович'); $order->setSurname('Иванов'); $order->setGivenName('Иван'); $order->setMiddleName('Петрович'); $order->setMass(1000); // Вес в граммах $order->setMailCategory('ORDINARY'); // Категория РПО $order->setMailType('POSTAL_PARCEL'); // Вид РПО $order->setFragile(true); // Хрупкое $order->setTelAddress(79260120935); // Телефон получателя $order->setComment('Позвонить перед доставкой'); // Создание заказа V1 (без возврата ШПИ) $result = $otpravkaApi->createOrders([$order->asArr()]); if (!empty($result['result-ids'])) { echo "Заказ создан, ID: " . $result['result-ids'][0] . "\n"; } // Создание заказа V2 (с возвратом ШПИ) $resultV2 = $otpravkaApi->createOrdersV2([$order->asArr()]); if (!empty($resultV2['orders'])) { echo "ШПИ: " . $resultV2['orders']['barcode'] . "\n"; echo "ID: " . $resultV2['orders']['result-id'] . "\n"; } } catch (\InvalidArgumentException $e) { echo "Ошибка валидации: " . $e->getMessage(); } catch (\LapayGroup\RussianPost\Exceptions\RussianPostException $e) { echo "Ошибка API: " . $e->getMessage(); } ``` -------------------------------- ### GET /search-post-office-by-coordinates Source: https://github.com/lapaygroup/russianpost/blob/master/README.md Searches for post offices based on provided geographical coordinates. ```APIDOC ## GET /search-post-office-by-coordinates ### Description Searches for post offices based on provided geographical coordinates. ### Parameters #### Request Body - **params** (array) - Required - Array of search parameters as defined in the official Russian Post API documentation. ``` -------------------------------- ### Configure PSR-3 Logging Source: https://context7.com/lapaygroup/russianpost/llms.txt Attach a Monolog instance to the TariffCalculation, OtpravkaApi, and Tracking providers to capture request and response logs. ```php pushHandler(new StreamHandler('russianpost.log', Logger::INFO)); // Логирование тарификатора $tariffCalculation = new TariffCalculation(); $tariffCalculation->setLogger($log); $result = $tariffCalculation->calculate(23030, ['from' => 101000, 'to' => 115551, 'weight' => 100, 'sumoc' => 0]); // Логирование API отправки $otpravkaApi = new OtpravkaApi(Yaml::parse(file_get_contents('config.yaml'))); $otpravkaApi->setLogger($log); $balance = $otpravkaApi->getBalance(); // Логирование трекинга $config = Yaml::parse(file_get_contents('config.yaml')); $tracking = new Tracking('single', $config); $tracking->setLogger($log); $operations = $tracking->getOperationsByRpo('10944022440321'); // Пример записи в лог: // [2024-01-15 12:00:00] russianpost.INFO: Russian Post Otpravka API GET request /1.0/counterpart/balance // [2024-01-15 12:00:01] russianpost.INFO: Russian Post Otpravka API GET response /1.0/counterpart/balance: {"balance":0,"balance-date":"2024-01-15"} ``` -------------------------------- ### POST /create_batch Source: https://github.com/lapaygroup/russianpost/blob/master/README.md Automatically creates a batch and moves specified prepared orders into it. If orders belong to different types and categories, multiple batches are created. Orders are distributed into the appropriate batches. Each moved order is automatically assigned a tracking number (ШПИ). ```APIDOC ## POST /create_batch ### Description Automatically creates a batch and moves specified prepared orders into it. If orders belong to different types and categories, multiple batches are created. Orders are distributed into the appropriate batches. Each moved order is automatically assigned a tracking number (ШПИ). ### Method POST ### Endpoint /create_batch ### Parameters #### Query Parameters - **orders** (array) - Required - An array of order IDs to be included in the batch. - **sending_day** (DateTimeImmutable) - Required - The desired sending day for the batch. ### Request Example ```php createBatch([115527611], new DateTimeImmutable('2019-09-20')); // Process successful response } catch (LapayGroup\RussianPost\Exceptions\RussianPostException $e) { // Handle Russian Post API errors } catch (Exception $e) { // Handle general exceptions } ``` ### Response #### Success Response (200) - **batches** (array) - An array of created batches, each containing details like batch name, status, mail types, and shipment information. - **result-ids** (array) - An array of IDs of the orders successfully added to batches. #### Response Example ```json { "batches": [ { "batch-name": "24", "batch-status": "CREATED", "batch-status-date": "2019-09-03T11:37:17.589Z", "combined-batch-mail-types": [ "POSTAL_PARCEL" ], "courier-order-statuses": [ "NOT_REQUIRED" ], "international": null, "list-number-date": "2019-09-20", "mail-category": "COMBINED", "mail-category-text": "Комбинированно", "mail-rank": "WO_RANK", "mail-type": "COMBINED", "mail-type-text": "Комбинированно", "payment-method": "CASHLESS", "postmarks": [ "NONSTANDARD" ], "postoffice-code": "109012", "postoffice-name": "ОПС 109012", "shipment-avia-rate-sum": 0, "shipment-avia-rate-vat-sum": 0, "shipment-completeness-checking-rate-sum": 0, "shipment-completeness-checking-rate-vat-sum": 0, "shipment-contents-checking-rate-sum": 0, "shipment-contents-checking-rate-vat-sum": 0, "shipment-count": 1, "shipment-ground-rate-sum": 16500, "shipment-ground-rate-vat-sum": 3300, "shipment-insure-rate-sum": 0, "shipment-insure-rate-vat-sum": 0, "shipment-inventory-rate-sum": 0, "shipment-inventory-rate-vat-sum": 0, "shipment-mass": 1000, "shipment-mass-rate-sum": 16500, "shipment-mass-rate-vat-sum": 3300, "shipment-notice-rate-sum": 0, "shipment-notice-rate-vat-sum": 0, "shipment-sms-notice-rate-sum": 0, "shipment-sms-notice-rate-vat-sum": 0, "shipping-notice-type": "SIMPLE", "transport-type": "SURFACE", "use-online-balance": null, "wo-mass": null } ], "result-ids": [ 115527611 ] } ``` #### Error Response - **errors** (array) - An array of error objects, each containing an error code, description, and position. #### Error Response Example ```json { "errors": [ { "error-code": "NOT_FOUND", "error-description": "Отправление не найдено", "position": 0 } ] } ``` ``` -------------------------------- ### GET /post-office-services Source: https://github.com/lapaygroup/russianpost/blob/master/README.md Retrieves a list of services available at a specific post office, optionally filtered by group ID. ```APIDOC ## GET /post-office-services ### Description Retrieves a list of services available at a specific post office, optionally filtered by group ID. ### Parameters #### Query Parameters - **postalCode** (int) - Required - The postal code of the office. - **groupId** (int) - Optional - Filter services by group ID. ### Response #### Success Response (200) - **code** (string) - Service code - **group-id** (int) - Group ID - **name** (string) - Service description ``` -------------------------------- ### GET /searchPostOfficeByAddress Source: https://github.com/lapaygroup/russianpost/blob/master/README.md Searches for post offices based on a provided address string and returns matching postal codes. ```APIDOC ## GET /searchPostOfficeByAddress ### Description Searches for post offices based on a provided address string and returns matching postal codes and a flag indicating if the address is an exact match for a post office. ### Method GET ### Parameters #### Query Parameters - **address** (string) - Required - The address string to search for (e.g., 'Санкт-Петербург, улица Победы, 15к1') ### Response #### Success Response (200) - **is-matched** (boolean) - Indicates if the address is an exact match for a post office - **postoffices** (array) - List of matching postal codes ### Response Example { "is-matched": false, "postoffices": ["196070"] } ``` -------------------------------- ### Create Batch of Orders - PHP Source: https://github.com/lapaygroup/russianpost/blob/master/README.md Use this to automatically create a batch and move specified prepared orders into it. If orders have different types or categories, multiple batches will be created. Each moved order will be assigned a tracking number. Handles successful responses and API errors. ```php createBatch([115527611], new DateTimeImmutable('2019-09-20')); /* Array Успешный ответ ( [batches] => Array ( [0] => Array ( [batch-name] => 24 [batch-status] => CREATED [batch-status-date] => 2019-09-03T11:37:17.589Z [combined-batch-mail-types] => Array ( [0] => POSTAL_PARCEL ) [courier-order-statuses] => Array ( [0] => NOT_REQUIRED ) [international] => [list-number-date] => 2019-09-20 [mail-category] => COMBINED [mail-category-text] => Комбинированно [mail-rank] => WO_RANK [mail-type] => COMBINED [mail-type-text] => Комбинированно [payment-method] => CASHLESS [postmarks] => Array ( [0] => NONSTANDARD ) [postoffice-code] => 109012 [postoffice-name] => ОПС 109012 [shipment-avia-rate-sum] => 0 [shipment-avia-rate-vat-sum] => 0 [shipment-completeness-checking-rate-sum] => 0 [shipment-completeness-checking-rate-vat-sum] => 0 [shipment-contents-checking-rate-sum] => 0 [shipment-contents-checking-rate-vat-sum] => 0 [shipment-count] => 1 [shipment-ground-rate-sum] => 16500 [shipment-ground-rate-vat-sum] => 3300 [shipment-insure-rate-sum] => 0 [shipment-insure-rate-vat-sum] => 0 [shipment-inventory-rate-sum] => 0 [shipment-inventory-rate-vat-sum] => 0 [shipment-mass] => 1000 [shipment-mass-rate-sum] => 16500 [shipment-mass-rate-vat-sum] => 3300 [shipment-notice-rate-sum] => 0 [shipment-notice-rate-vat-sum] => 0 [shipment-sms-notice-rate-sum] => 0 [shipment-sms-notice-rate-vat-sum] => 0 [shipping-notice-type] => SIMPLE [transport-type] => SURFACE [use-online-balance] => [wo-mass] => ) ) [result-ids] => Array ( [0] => 115527611 ) ) Array Ответ с ошибкой ( [errors] => Array ( [0] => Array ( [error-code] => NOT_FOUND [error-description] => Отправление не найдено [position] => 0 ) ) ) */ } catch (\LapayGroup\RussianPost\Exceptions\RussianPostException $e) { // Обработка ошибочного ответа от API ПРФ } catch (\Exception $e) { // Обработка нештатной ситуации } ``` -------------------------------- ### Retrieve user settings Source: https://github.com/lapaygroup/russianpost/blob/master/README.md Fetches the current configuration settings for the authenticated user. ```php settings(); ``` -------------------------------- ### Get Archived Batches with RussianPost SDK Source: https://github.com/lapaygroup/russianpost/blob/master/README.md Retrieve a list of all batches currently in the archive. This method does not require any parameters. ```php getArchivedBatches(); /* Array ( [0] => Array ( [batch-name] => 25 [batch-status] => ARCHIVED [batch-status-date] => 2019-09-03T13:17:59.237Z [combined-batch-mail-types] => Array ( [0] => POSTAL_PARCEL ) [courier-order-statuses] => Array ( [0] => NOT_REQUIRED ) [international] => [list-number-date] => 2019-09-08 [mail-category] => COMBINED [mail-category-text] => Комбинированно [mail-rank] => WO_RANK [mail-type] => COMBINED [mail-type-text] => Комбинированно [payment-method] => CASHLESS [postmarks] => Array ( [0] => NONSTANDARD ) [postoffice-address] => ул Никольская, д.7-9, стр.3, г Москва [postoffice-code] => 109012 [postoffice-name] => ОПС 109012 [shipment-avia-rate-sum] => 0 [shipment-avia-rate-vat-sum] => 0 [shipment-completeness-checking-rate-sum] => 0 [shipment-completeness-checking-rate-vat-sum] => 0 [shipment-contents-checking-rate-sum] => 0 [shipment-contents-checking-rate-vat-sum] => 0 [shipment-count] => 1 [shipment-ground-rate-sum] => 16500 [shipment-ground-rate-vat-sum] => 3300 [shipment-insure-rate-sum] => 0 [shipment-insure-rate-vat-sum] => 0 [shipment-inventory-rate-sum] => 0 [shipment-inventory-rate-vat-sum] => 0 [shipment-mass] => 1000 [shipment-mass-rate-sum] => 16500 [shipment-mass-rate-vat-sum] => 3300 [shipment-notice-rate-sum] => 0 [shipment-notice-rate-vat-sum] => 0 [shipment-sms-notice-rate-sum] => 0 [shipment-sms-notice-rate-vat-sum] => 0 [shipping-notice-type] => SIMPLE [transport-type] => SURFACE [use-online-balance] => [wo-mass] => ) ) */ } catch (\LapayGroup\RussianPost\Exceptions\RussianPostException $e) { // Обработка ошибочного ответа от API ПРФ } catch (\Exception $e) { // Обработка нештатной ситуации } ``` -------------------------------- ### Generate Document Package Source: https://github.com/lapaygroup/russianpost/blob/master/README.md Generates a zip archive containing various documents for a given order, including export lists and PDF forms. The second parameter determines the output format. ```php generateDocPackage(28, OtpravkaApi::PRINT_FILE); /* GuzzleHttp\Psr7\UploadedFile Object ( [clientFilename:GuzzleHttp\Psr7\UploadedFile:private] => all-pdf.zip [clientMediaType:GuzzleHttp\Psr7\UploadedFile:private] => application/zip; charset=UTF-8 [error:GuzzleHttp\Psr7\UploadedFile:private] => 0 [file:GuzzleHttp\Psr7\UploadedFile:private] => [moved:GuzzleHttp\Psr7\UploadedFile:private] => [size:GuzzleHttp\Psr7\UploadedFile:private] => 290398 [stream:GuzzleHttp\Psr7\Stream:private] => GuzzleHttp\Psr7\Stream Object ( [stream:GuzzleHttp\Psr7\Stream:private] => Resource id #56 [size:GuzzleHttp\Psr7\Stream:private] => 290398 [seekable:GuzzleHttp\Psr7\Stream:private] => 1 [readable:GuzzleHttp\Psr7\Stream:private] => 1 [writable:GuzzleHttp\Psr7\Stream:private] => 1 [uri:GuzzleHttp\Psr7\Stream:private] => php://temp [customMetadata:GuzzleHttp\Psr7\Stream:private] => Array ( ) ) )*/ } catch (\LapayGroup\RussianPost\Exceptions\RussianPostException $e) { // Обработка ошибочного ответа от API ПРФ } catch (\Exception $e) { // Обработка нештатной ситуации } ``` -------------------------------- ### Tracking - Get Operations by Ticket Source: https://github.com/lapaygroup/russianpost/blob/master/README.md Retrieves detailed information about shipments using a previously created request ticket. ```APIDOC ## GET /api/tracking/getOperationsByTicket ### Description Retrieves an array of shipment information based on a previously created request ticket. ### Method GET ### Endpoint /api/tracking/getOperationsByTicket ### Parameters #### Path Parameters None #### Query Parameters - **ticket** (string) - Required - The ticket ID obtained from the getTickets method. #### Request Body None ### Request Example ```php getOperationsByTicket('20180506151902355WANVOUGROWKXUN'); ?> ``` ### Response #### Success Response (200) - The response is an associative array where keys are shipment IDs and values are arrays of operation objects. - **OperCtgName** (string) - The text name of the operation subtype. - **isFinal** (boolean) - Indicates if this is the final status for the shipment. #### Response Example ```json { "10944022440321": [ { "OperTypeID": 1, "OperCtgID": 2, "OperName": "Прием", "DateOper": "28.04.2018 19:48:47", "IndexOper": "109440", "OperCtgName": "Партионный", "isFinal": false } ] } ``` ```