You mean partially encode. Because that http:// is still not encoded. And encoding only part of a URL is weird and clunky. Because I want to just do this:
returnSettingsJSON.put("url", URLEncoder.encode( submitOrderURL, StandardCharsets.ISO_8859_1 ) );
returnSettingsJSON.put("cancelUrl", URLEncoder.encode( cancelURL, StandardCharsets.ISO_8859_1 ) );
Encode everything is one simple call and be done. But now I need to extract the http:// portion and only encode the back half and then put the URL back together again?
Because when I try to encode the entire thing I get this error:
[2021-02-22 10:24:20,385] [ERROR] Failed to retrieve Nonce token for building AuthorizeNet Payment Form:
Response Code: [E00013]
Response Text: [Failed to add Option hostedPaymentReturnOptions
String 'http%3A%2F%2F1.1.1.1%3ForderID%3D2548%26orderAmount%3D540.0%26submitToken%3D011a7a33-bcea-4de9-9c8b-d0ceb9246c3d' does not match regex pattern '(http|https)://.*'. Line 1, position 160.]
Your regex validation should account for the encoding. Or simply do the validation after you decode the URL I give you.