Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8266609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:13:27+00:00 2026-06-08T05:13:27+00:00

I need to pass user_id, not logged in user, but user_id from view. I

  • 0

I need to pass user_id, not logged in user, but user_id from view.

I am writing admin part.

I’m making post request using user email and redirect to appropriate page. so I want to make route something like:

     /:user_id/pay

to call pay action for appropriate user.

In my view I want to show email and link to this action:

<% @users.each do |user| %>
 <li>
  <%= user.email %>
  <%= link_to "Pay", some_controller_pay(user.id) %>
 </li>

EDIT

    def pay
    require 'httpclient'
    require 'xmlsimple'
    clnt = HTTPClient.new
    user = User.find(params[:user_id])
    credentials = {
        'USER' => 'payer_1342623102_biz_api1.gmail.com',
       'PWD' => '1342623141',
       'SIGNATURE' => 'Ay2zwWYEoiRoHTTVv365EK8U1lNzAESedJw09MPnj0SEIENMKd6jvnKL '
     }

    header =  {"X-PAYPAL-SECURITY-USERID" => "payer_1342623102_biz_api1.gmail.com",
                   "X-PAYPAL-SECURITY-PASSWORD" => "1342623141",
                   "X-PAYPAL-SECURITY-SIGNATURE" => "Ay2zwWYEoiRoHTTVv365EK8U1lNzAESedJw09MPnj0SEIENMKd6jvnKL ",
                   "X-PAYPAL-REQUEST-DATA-FORMAT" => "NV",
                   "X-PAYPAL-RESPONSE-DATA-FORMAT" => "XML",
                   "X-PAYPAL-APPLICATION-ID" =>  "APP-80W284485P519543T"
                    }
    data = {"actionType" => "PAY",
               "receiverList.receiver(0).email"=> user.email,
               "receiverList.receiver(0).amount" => "10",
               "currencyCode" => "USD",
               "cancelUrl" => root_path,
               "returnUrl" => root_path,
               "requestEnvelope.errorLanguage" => "en_US"}
    uri = "https://svcs.sandbox.paypal.com/AdaptivePayments/Pay"
    res = clnt.post(uri, data, header)
    @xml = XmlSimple.xml_in(res.content)
    @payKey = @xml["payKey"].to_s()
    @payKey = @payKey.tr("[]", "")
    @payKey = @payKey[1..20]
    redirect_to "https://sandbox.paypal.com/webscr?cmd=_ap-payment&paykey=#{@payKey}"

end

PayPal say that some error occured.

I try to inspect variables, so I should put in view:

 <%= @xml%>
 <%= payKey%>

but id din’t work, how I can inpect them ?

In development log:

  Redirected to https://sandbox.paypal.com/webscr?cmd=_ap-payment&paykey=
  Completed 302 Found in 1193ms (ActiveRecord: 1.0ms)

So it doesn’t insert link, yes ? How I can get ALL RESPONS info

How I can manage to do this ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T05:13:29+00:00Added an answer on June 8, 2026 at 5:13 am

    Since you already have a User model, you can add pay as another RESTful action:

    resources :users do
      member do
        get 'pay' # or post/put, whatever is appropriate
      end
    end
    

    This automatically sets up a named route pay_user:

    pay_user GET    /users/:id/pay(.:format)  users#pay
    

    Including a pay_user_path helper for your views:

    <%= link_to "Pay", pay_user_path(user.id) %>
    

    In your UserController this works like any other action:

    def pay
      @user = User.find(params[:id])
      # do something with @user
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a web application where I need to pass some user data to
When a user searches post by date, I need to pass the date as
I need to pass an extra parameter :mobilejs => true from jQuery to a
I need to pass a variable which is captured from client side via jquery
I need to pass a parameter from an EditText and when I click the
I'm having a problem accessing a Django Form POST data. I need to pass
Rails 3.2.3 I need to pass a class variable to a view. For some
I need to pass this filepath over via route to my actionmethod: <p><a href=/Cars/@Model.CarId/@car.ContainerPath/@Model.UserId/Url>@car.Name</a></p>
I need to pass argument to JNLP dynamically for which I tried using a
I need to pass Cursor object to another activity, what is the best way

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.