As @zeyu says, you cannot do this directly. Another service you can use to achieve this is https://ngrok.com/ . Hope this is helpful to someone!
It will give you a link something like this: http://75z929f4.ngrok.io , which I set to the APP_HOST development ENV variable.
And popped into the webhook as such:
def generate_url values = { business: ENV["PAYPAL_ACCOUNT"], cmd: '_xclick', return: ENV["APP_HOST"] + @return_path, custom: @user.id, upload: 1, invoice: Time.now, currency_code: 'GBP', amount: @price, no_shipping: 1, item_name: self.purchase_name, item_number: @product_id, quantity: 1, notify_url: ENV["APP_HOST"] + @notify_path, on0: ('Coupon Code' if @coupon_code.present?), os0: @coupon_code } "#{ENV["PAYPAL_URL"]}/cgi-bin/websr?" + values.to_query end
Final note, you need to update APP_HOST every time you restart ngrok, since you will get a new identifier from them. This will bind everything so you can send this request to localhost and successfully return the response.
source share