Closed alg closed 2 years ago
Any chance we can merge this? PayPal SDK breaks with Ruby 3.0.0. This fixes it.
Can this be merged? it's broken in ruby 3.0
Running into this issue as well, causing a lot of warnings on Ruby 2.7 and blocking upgrade to 3.0.
Merge please
can this be merged please?
This is blocking us from upgrading to Ruby 3.0, can you please merge it?
Please merge this. I've been forced to downgrade to ruby 2.7.3 because of this bug
Another vote to please merge this so we can upgrade to Ruby 3! Thank you!
I hit this with the paypal payout api as well.
Please merge this, it's very annoying. Do anyone solved this in any other way?
@HDLahlou Please address one of the PRs on this issue, it is blocking everyone from having the ability to use ruby 3.0.
Please merge! Our business cannot operate without this, we process our payments through paypal!
Merge, please!
Wow. This is a simple fix that could have been done in 2020.
@HDLahlou Can this be merged please?
I did some more digging on this, and this solution doesn't actually work for all use cases. This encodes URLs as
http%3A%2F%2Flocalhost%3A3001%2F
instead of
http://localhost:3001/
as it did previously which breaks the RETURNURL
in Paypal Payflow. I ended up monkeypatching with:
encoded_params = []
p = URI::Parser.new
request.body.each do |k, v|
encoded_params.push("#{p.escape(k.to_s)}=#{p.escape(v.to_s)}")
end
in order to unblock the upgrade to Ruby 3.1.
The most wanted PR to be merge is right here!!!
When can we expect to merge?
When can we expect to merge?
we know for sure it's going to be 20xx :(
This monkey patch works:
module URI
def self.escape(*args)
URI.encode_www_form_component(*args)
end
end
@JulienSansot Wouldn't recommend monkey patching URI
. Instead, just put this PR's code on an initializer and be done with it 🤷🏼♂️ :
# config/initializers/paypal.rb
# Monkeypatch to work with Ruby 3.0
#
# https://github.com/paypal/paypalhttp_ruby/pull/4
require "uri"
module PayPalHttp
class FormEncoded
def encode(request)
encoded_params = []
request.body.each do |k, v|
encoded_params.push("#{encode_part(k)}=#{encode_part(v)}")
end
encoded_params.join("&")
end
def decode(body)
raise UnsupportedEncodingError.new("FormEncoded does not support deserialization")
end
def content_type
/^application\/x-www-form-urlencoded/
end
private
def encode_part(part)
URI.encode_www_form_component(part.to_s)
end
end
end
@JulienSansot Wouldn't recommend monkey patching
URI
.
I actually think this is a perfect candidate for a global monkeypatch considering Ruby deprecated the method and explicitly recommend using URI.encode_www_form_component
.
https://ruby-doc.org/stdlib-2.7.3/libdoc/uri/rdoc/URI/Escape.html#method-i-escape
@HDLahlou Is this repo actively maintained?
This is fixed in v2.0.0, which was just released.
@crookedneighbor but the PayPal Ruby SDK has been deprecated and archived, and is locked on PayPal HTTP v1. So this PR can't be used.
@sedubois you are welcome to fork the Ruby Checkout SDK and update it.
Using URI.encode_www_form_component instead.