0

I'm following this guide for implementing the PayPal REST API in my Rails app, and it gives an error that's said in the title, specifically pointing to this line in the code under create_order.

response = @client.execute request

I'm sure I have my client id and secret copy pasted and I also copy pasted most of the code to avoid any errors. What's causing this problem and how do I fix it? I appreciate the help.

Edit:

Command line output:

Started POST "/create_order" for ::1 at 2021-11-16 21:21:07 +0800
Processing by BookingsController#create_order as */*
Completed 500 Internal Server Error in 2ms (ActiveRecord: 0.0ms | Allocations: 1603)



NoMethodError (undefined method `escape' for URI:Module):

app/controllers/bookings_controller.rb:35:in `create_order'
teduniq
  • 57
  • 7

2 Answers2

0

Probably best to just do a monkey patch with future expectation of moving away from paypal-checkout-sdk (it's deprecated)

monkey patch option can be found at: paypal-checkout-sdk breaks in ruby 3.0.1

  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/33724456) – DJSDev Feb 03 '23 at 03:32
-1

you are missing gem files which are required to use the URI.escape

add these gems in you gemfile

  • gem 'uri'
  • gem 'net-http'
  • gem 'http'

after that run command => "bundle install" in the terminal

and then try to run you application via rails s

hope this will fix your error

Since "URI.escape" is depriciated by the ruby community but "paypal-checkout-sdk" uses it while requesting from client. which is like this: @client.execute request