postnl / postnl-magento2

This is the official Magento 2 extension for the logistics company PostNL. Add shipping options and parcelshops to your checkout. Create labels with track and trace functionality from the backend.
59 stars 60 forks source link

[BUG] PostNL shipment created with invalid product code #359

Closed memen45 closed 1 year ago

memen45 commented 1 year ago

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

Possibly related: #311

tig-vincentthart commented 1 year ago

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

memen45 commented 1 year ago

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).