You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SyliusPayPalPlugin version affected: ^1.6 potentially *
Description
When the name of a product is too long and exceeds the length allowed by paypal, the request sent to paypal in Sylius\PayPalPlugin\Api\CreateOrderApi which is called by Sylius\PayPalPlugin\Payum\Action\CaptureAction fails and the error is not handled in any way which causes the request to fail with a cryptic error in CaptureAction line 58 when trying to access offset status on $content with Warning: Undefined array key "status" (and Warning: Undefined array key "paypal_order_id" in some cases).
Part of the error returned by PayPal :
{"name":"INVALID_REQUEST","message":"Request is not well-formed, syntactically incorrect, or violates schema.","d
ebug_id":"XXXXXX","details":[{"field":"\/purchase_units\/@reference_id==XXXXXX'\/items\/1\/name","value":"thewaytoolongname","location":"body","issue":"INVALI
D_STRING_LENGTH","description":"The value of a field is either too short or too long."},{"field":"\/purchase_units\/@reference_id=='XXXXXX'\/items\/0\/name","value":"thewaytoolongname","location":"body","issue":"INVALID_STRING_LENGTH","description":"The value of a field is either too short or too long."}]
When trying to pay, the PayPal pop-up will open and close instantly with the error Expected an order id to be passed in console because the request to PayPal failed
Steps to reproduce
Create a product with a long name
Add the product to your cart
Try to checkout and pay with PayPal
Possible Solution
Truncate the name before sending it to PayPal (which length ?)
Make sure the data returned by PayPal is somewhat valid and throw an exception if need be in order to simplify debugging of similar potential future bugs
Temporary fix
Should probably not have such long product names in the first place, so truncate them, but just in case or if there is a legitimate reason to have long product names : if your project uses cweagans/composer-patches, add the following patch to your project :
SyliusPayPalPlugin version affected: ^1.6 potentially *
Description
When the name of a product is too long and exceeds the length allowed by paypal, the request sent to paypal in
Sylius\PayPalPlugin\Api\CreateOrderApi
which is called bySylius\PayPalPlugin\Payum\Action\CaptureAction
fails and the error is not handled in any way which causes the request to fail with a cryptic error inCaptureAction
line 58 when trying to access offsetstatus
on$content
withWarning: Undefined array key "status"
(andWarning: Undefined array key "paypal_order_id"
in some cases).Part of the error returned by PayPal :
When trying to pay, the PayPal pop-up will open and close instantly with the error
Expected an order id to be passed
in console because the request to PayPal failedSteps to reproduce
Possible Solution
Temporary fix
Should probably not have such long product names in the first place, so truncate them, but just in case or if there is a legitimate reason to have long product names : if your project uses
cweagans/composer-patches
, add the following patch to your project :64 is arbitrary I did not check PayPal docs
The text was updated successfully, but these errors were encountered: