paytrail / paytrail-for-adobe-commerce

Paytrail payment service for Adobe Commerce (formerly known as Magento 2)
https://www.paytrail.com
MIT License
2 stars 7 forks source link

Having a order item with an SKU longer than 100 characters causes error "Request payload schema validation failed. Validate request against the provided schema.","m (truncated...) #48

Closed oskar-olaussen closed 1 year ago

oskar-olaussen commented 1 year ago

Describe the bug The Paytrail API does not allow product codes longer than 100 characters. This is an issue since in Magento it is possible to have skus longer than 100 characters on the order item. For example having a product with multiple customizable options will cause an error pictured when paying your order on checkout with Paytrail. Screenshot from 2023-06-16 07-58-35

To Reproduce Have a product with an SKU 50 characters long and with two customizable options that both have 50 characters long skus. Add the product and the customizable options to your cart. Checkout with Paytrail.

Expected behavior You are redirected to the payment portal.

Screenshots

Additional context One can work around this issue by truncating the length of the product code here https://github.com/paytrail/paytrail-php-sdk/blob/master/src/Model/Item.php#L198

bartoszkaluzny-solteq commented 1 year ago

@oskar-olaussen By default, Magento 2 allows a maximum of 64 characters for the SKU of a product. This limit includes letters, numbers, and special characters. There is no option to put bigger value into database: image

Paytrail support default Magento. You probably have something customised on your Magento commerce

oskar-olaussen commented 1 year ago

@bartoszkaluzny-solteq Did you try to use the steps I provided? You are correct that a singular product cannot have a SKU longer than 64 characters. But you can have multiple customizable options with SKUs that are for example 50 characters long. If you select multiple of those the SKU on your order item will be longer than 100 characters. The SKU column in the sales_order_item is varchar(255) so it is not limiting it to 100 characters.

bartoszkaluzny-solteq commented 1 year ago

@oskar-olaussen Yes, I tried to create configurable product with two customizable options that has 50 characters each. And I've got this message while saving this product (see screenshot). By default, configurable products with their options are saved as simple products with specific options into database, and there is limit for 64 characters in product table.

oskar-olaussen commented 1 year ago

@bartoszkaluzny-solteq Here are the steps from default Magento 2.4.5-p1.

I have a simple product: Screenshot from 2023-06-28 08-08-43

It has two customizable options with long SKUs: Screenshot from 2023-06-28 08-09-17

When selecting both of those the sales_order_item has a SKU that is 132 characters long: Screenshot from 2023-06-28 08-14-57

bartoszkaluzny-solteq commented 1 year ago

@oskar-olaussen I was able to reproduce this issue. I will provide you more information when fix will be live.

bartoszkaluzny-solteq commented 1 year ago

@oskar-olaussen Issue has been worked out. There is no option to allow SKU over 100 characters due to API limitations. On module version 1.4.1 there is message for this exception.