MultiSafepay / magento2

MultiSafepay plugin for Magento 2
Open Software License 3.0
19 stars 8 forks source link

Duplicate item id error on post payment methods #59

Closed Medeka closed 8 months ago

Medeka commented 10 months ago

Customer can't order two same simple products with different custom options.

Steps to reproduce

  1. Create a simple product and add a custom option with option type 'radio'
  2. Add two labels with both a differrent price Frontend:
  3. Add this product to cart and choose radio option 1
  4. Add the same product to cart and choose radio option 2
  5. Go to checkout and choose Multisafepay Klarna

Result We don't proceed to the Post payment method and get this Error from the Multisafepay API: Error processing checkout data: Invalid or duplicate merchant_item_id (Testproduct met opties) found.

Expected result We proceed to Klarna without this error.

vinodsowdagar commented 10 months ago

Hi @Medeka ,

Thank you for the report.

For the merchant_item_id we are using the SKU of the product. For a Klarna transaction we need different SKU's for each item variation. For custom options in Magento there is already a setting to adjust the SKU accordingly.

For example:

This item's original SKU is '24-MB01'

image

For the custom options we are setting a custom SKU:

image

Magento will then concatenate the SKU with a hyphen in between: 24-MB01-M for the first option, 24-MB01-L for the second option

When implemented in this way, it should work. If there are any other questions related to this, please let us know.

Medeka commented 10 months ago

Thank you @Vinod-MultiSafepay for your quick reply. This means we have to modify thousends of products. Is there a limit on the number of characters in the sku that you transfer to Klarna? It can be a long SKU if we make it dynamic according to the selected custom options.

vinodsowdagar commented 10 months ago

Hi @Medeka ,

The limit for the Klarna item name and reference fields are 255 characters.

Unfortunately i don't see another easy solution, since the feature to customise the SKU alongside the custom option is actually already there in Magento, there is no need to introduce modification to the MultiSafepay plugin for this as well, as it works out of the box with that already.

Medeka commented 10 months ago

Hello @Vinod-MultiSafepay,

Unfortunately for merchant it does not work out of the box;

This custom option field you mention is optional and is never used because there was never a reason. Merchant uses Klarna for years without this field. So we would appreciate a little more cooperation.

vinodsowdagar commented 10 months ago

Hi @Medeka ,

Understood. Since the MultiSafepay API requires unique merchant item ID's, the only thing we could do at the plugin side is force unique merchant item ID's ourselves by concatenating the SKU with something that is unique, for example with some sort of custom increment.

These custom SKU's with increment will then be passed to Klarna, resulting in Klarna having order lines with references that are made up by the MultiSafepay Magento 2 plugin. I'm not sure if that is an ideal situation, because it's not clear for us what effects and implications this will have with Klarna.

We will investigate this a bit more and give you an answer later.

Medeka commented 10 months ago

This sounds like a good solution for us.

vinodsowdagar commented 8 months ago

Hi @Medeka ,

We've updated our module last week where we fixed this issue: https://github.com/MultiSafepay/magento2/releases/tag/3.2.0

I'm closing this one for now. If there are any questions, please feel free to leave a comment and we will reopen this issue if needed.