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 8332687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:47:42+00:00 2026-06-09T02:47:42+00:00

This is my controller: setup_purchase method does works fine for me with my data

  • 0

This is my controller:

setup_purchase method does works fine for me with my data api, but preapprove_payment method does not works.

def pay
 gateway =  ActiveMerchant::Billing::PaypalAdaptivePayment.new(
  :login => "email",
  :password => "pass",
  :signature => "signature",
  :appid => "APP-80W284485P519543T" )
  response = gateway.preapprove_payment( 
  :return_url => user_orders_url(current_user),
  :cancel_url => user_orders_url(current_user),
  :sender_email =>"email",
  :start_date => Time.now,
  :end_date => Time.now,
  :currency_code =>"USD",
  :max_amount => "20",
  :maxNumberOfPayments => "2")
  puts response.preapproval_key
  puts gateway.debug
  # for redirecting the customer to the actual paypal site to finish the payment.
  redirect_to (gateway.redirect_url_for(response["preapproval_key"]))
end

I get in log:

PA-8K9332086D720151L
{:url=>#<URI::HTTPS:0xdf9bd18 URL:https://svcs.sandbox.paypal.com/AdaptivePayments/Preapproval>, :request=>"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<PreapprovalRequest>\n  <requestEnvelope>\n    <detailLevel>ReturnAll</detailLevel>\n    <errorLanguage>en_US</errorLanguage>\n    <senderEmail>email</senderEmail>\n  </requestEnvelope>\n  <endingDate>2012-07-20T19:09:20</endingDate>\n  <startingDate>2012-07-20T19:09:20</startingDate>\n  <maxTotalAmountOfAllPayments>20</maxTotalAmountOfAllPayments>\n  <maxNumberOfPayments>2</maxNumberOfPayments>\n  <currencyCode>USD</currencyCode>\n  <cancelUrl>http://localhost:3000/en/u/maserranocaceres/orders</cancelUrl>\n  <returnUrl>http://localhost:3000/en/u/maserranocaceres/orders</returnUrl>\n</PreapprovalRequest>\n", :response=>"{\"responseEnvelope\":{\"timestamp\":\"2012-07-20T10:09:22.459-07:00\",\"ack\":\"Success\",\"correlationId\":\"ada6a3e7da93d\",\"build\":\"DEV\"},\"preapprovalKey\":\"PA-8K9332086D720151L\"}"}

Full response:

#<ActiveMerchant::Billing::AdaptivePaymentResponse:0xc817278 @json="{\"responseEnvelope\":{\"timestamp\":\"2012-07-23T07:43:56.603-07:00\",\"ack\":\"Success\",\"correlationId\":\"7f759c5da73ad\",\"build\":\"DEV\"},\"preapprovalKey\":\"PA-1M101813XU7801314\"}", @response=#<Hashie::Rash preapproval_key="PA-1M101813XU7801314" response_envelope=#<Hashie::Rash ack="Success" build="DEV" correlation_id="7f759c5da73ad" timestamp="2012-07-23T07:43:56.603-07:00">>, @xml_request="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<PreapprovalRequest>\n  <requestEnvelope>\n    <detailLevel>ReturnAll</detailLevel>\n    <errorLanguage>en_US</errorLanguage>\n    <senderEmail>microf_1342709161_per@gmail.com</senderEmail>\n  </requestEnvelope>\n  <endingDate>2012-08-22T16:43:54</endingDate>\n  <startingDate>2012-07-23T16:43:54</startingDate>\n  <maxTotalAmountOfAllPayments>20</maxTotalAmountOfAllPayments>\n  <maxNumberOfPayments>1</maxNumberOfPayments>\n  <currencyCode>USD</currencyCode>\n  <cancelUrl>http://localhost:3000/en/u/maserranocaceres/orders</cancelUrl>\n  <returnUrl>http://localhost:3000/en/u/maserranocaceres/orders</returnUrl>\n</PreapprovalRequest>\n", @request={"PreapprovalRequest"=>{"requestEnvelope"=>{"detailLevel"=>"ReturnAll", "errorLanguage"=>"en_US", "senderEmail"=>"email"}, "endingDate"=>"2012-08-22T16:43:54", "startingDate"=>"2012-07-23T16:43:54", "maxTotalAmountOfAllPayments"=>"20", "maxNumberOfPayments"=>"1", "currencyCode"=>"USD", "cancelUrl"=>"http://localhost:3000/en/u/maserranocaceres/orders", "returnUrl"=>"http://localhost:3000/en/u/maserranocaceres/orders"}}, @action="Preapproval">

What am I doing wrong?

  • 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-09T02:47:43+00:00Added an answer on June 9, 2026 at 2:47 am

    The problem was fixed.

    Change

    gateway.redirect_url_for(response["preapprovalKey"])

    to

    gateway.redirect_pre_approval_url_for(response["preapprovalKey"])

    The correct method is redirect_pre_approval_url_for

    You can see the fix in this post:

    preapproved payments with paypal in rails 3.2

    Thank you very much!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

With this controller method: - [AcceptVerbs(HttpVerbs.Post)] public ViewResult Contact(Contact contactMessage) { return View(); }
I have this controller: public class StandingsController : Controller { public ViewResult Index(int id)
I've this controller public class AdminController : Controller { private IAdministratorService _administratorService; public AdminController(IAdministratorService
I have this controller in Code Igniter application. A value is initialized in the
I have this controller in Code Igniter that begins with class MyController extends CI_Controller
I have controller users . In this controller I have action account which is
I have a simple Controller that looks like this:- @Controller @RequestMapping(value = /groups) public
I am getting some unexpected behavior from Html.EditorFor(). I have this controller: [HandleError] public
I need to ignore routes matching this schema /{controller}/edit/undefined {controller} - could be any
In an Apple example I've seen this: myController *controller = [viewControllers objectAtIndex:page]; if ((NSNull

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.