postnl/postnl-magento2

[BUG] PostNL shipment created with invalid product code

memen45 opened this issue · 2 comments

To Reproduce
Steps to reproduce the behavior:

  1. Customer creates order with e.g. Belgian address (probably any non-Dutch address)
  2. Use api to
  • POST /V1/order/:id/ship to create the magento shipment
  • POST /V1/postnl/shipments/:id/createShipment with empty body to create a postnl shipment
  • GET /V1/postnl/shipments/getByFieldWithValue?field=shipment_id&value=:shipment_id to obtain the resulting postnl shipment

Expected result
The postnl shipment product_code attribute has an allowable product code and /V1/postnl/shipments/:shipmentId/generateLabel returns true.

Actual result
The postnl shipment seems to be created always with product_code: 2928 (Letterbox Package) and a label cannot be generated anymore.

Workaround
In the magento admin interface, during shipment creation a list of allowable product codes is given. The label can therefore be generated correctly after creating the shipment through the magento admin interface.

Possible solutions / suggestions

  1. If the createShipment were to fail on a non-allowed product_code, one could retry the shipment with a different product_code. However, after the shipment is created, there is no way to change the product_code, and no way to generate a label.
  2. Where could I find a list with all possible product codes?
  3. Is there a way to know which product codes are allowed for the order? E.g. an API endpoint GET /V1/postnl/shipments/:id/options to expose the logic to api clients? This way the client can make sure the right product code is chosen and provided during createShipment

Software versions

  • Magento version: 2.4.5
  • PHP version: 7.4
  • TIG PostNL version: 1.12.4

Possibly related: #311

Hi @memen45

Does this issue only happen with orders via the API or do you also encounter it when you create an order via the frontend of the webshop?

Greetings

Vincent

When creating a shipment through the magento admin frontend, a dropdown list of allowed shipment types is given. Therefore, after creating the shipment, a label can also be generated. From the rest API however, one can create a shipment with incorrect product code successfully, but then the label generation will fail (both from api and admin frontend).