Redsys: Properly escape special characters in 3DS requests #3537
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In some Redsys 3DS requests, the API will return
SIS0042
, whichsignifies an error calculating the signature. After some testing,
this appears to be caused by special characters in various fields
of the request (in particular the
DS_MERCHANT_TITULAR
field).Non-3DS requests escape the entire xml_request_from response, but
after testing the same approach for 3DS, that doesn't quite work
(you'll still end up with an encoding error after the first round of
3ds-related api requests). This PR updates to escape the cardholder
name when the transaction calls for 3DS to prevent such errors. It
also does the same thing for the description field as that seemed
like the most likely other place where a special character could
end up. I feel like there's probably a better way to do this, so if
you have another idea, please feel free to suggest!
If you'd like to manually test, try issuing a 3ds purchase request
against this branch, using a name or description that includes a
special character - the transaction should succeed. Then try issuing
a request using a special character against the active merchant master
branch, and it should fail.
Unit:
38 tests, 122 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
22 tests, 70 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed