skip to Main Content

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'

2

Answers


  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

    Login or Signup to reply.
  2. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search