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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:19:06+00:00 2026-06-07T01:19:06+00:00

This issue is about: ActiveMerchant + PaypalExpressCheckout + Rails 3.2 I’ve been trying to

  • 0

This issue is about: ActiveMerchant + PaypalExpressCheckout + Rails 3.2

I’ve been trying to build a Paypal Express Checkout on my Rails 3.2 app. Most of the tutorials out there are outdated so I followed a few then read the Paypal Express Checkout integration guide. I’ve already set up my Sandobx and my paypal informations.

When I try to process the payment by clicking on my “Buy now” link from my view:

<%= link_to image_tag('http://img36.imageshack.us/img36/249/buttonpaypal.png'),
action: 'checkout', controller: 'orders'%>

I am getting the following error:

This transaction is invalid. Please return to the recipient's website to complete
you transaction using their regular checkout flow.

Return to merchant
At this time, we are unable to process your request. Please return to and try
another option.

— My Controller:

class OrdersController < ApplicationController
  include ActiveMerchant::Billing 
  def checkout
   setup_response = ::GATEWAY.setup_purchase(2000,
        :ip                => request.remote_ip,
        :return_url        => url_for('confirm'),
        :cancel_return_url => url_for(root_path)
   ) 
  redirect_to ::GATEWAY.redirect_url_for(setup_response.token)
 end
end

— My Initializer ActiveMerchant.rb:

 ActiveMerchant::Billing::Base.mode = :test
  ::GATEWAY = ActiveMerchant::Billing::PaypalExpressGateway.new(
  :login => "I_PUT_MY_EMAIL_HERE",
  :password => "I_PUT_MY_PASS_HERE",
  :signature => "I_PUT_MY_SIGNATURE_HERE",
  :allow_guest_checkout => true
 )

— My routes: routes.rb:

 resources :orders do
   # Im not sure why 'get :checkout' by itself doesn't work.
   get :checkout, :on => :new
   get :confirm
   get :complete
 end

get “pages/index”

This is the gist: https://gist.github.com/11be6cef6a97632343b9

Can anyone point me to a ‘recent’ tutorial or help me figure out what I am doing wrong here?

  • 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-07T01:19:09+00:00Added an answer on June 7, 2026 at 1:19 am

    The easiest way is to do as follow:

    1.) You must create a paypal test account.

    2.) Create a Cart Model:

    $ rails g model Cart purchased_at:datetime
    

    3.) In your Cart Model Type:

    class Cart < ActiveRecord::Base
    
      def paypal_url(return_url)
    
        values = {
          # get it form your http://sandbox.paypal.com account
          :business => 'ENTER_THE_SELLER_PAYPAL_EMAIL_ADDRESS',
          :cmd => '_cart',
          :upload => 1,
          :return => return_url,
          :invoice => id
        }
        # These values set up the details for the item on paypal.
           values.merge!({
            # The amount is in cents
            "amount_1" => ENTER_AN_AMOUNT_HERE,
            "item_name_1" => ENTER_THE_ITEM_NAME_HERE,
            "item_number_1" => 1,
            "quantity_1" => 1
          })
    
        "https://www.sandbox.paypal.com/cgi-bin/webscr?" + values.to_query
    
      end
    end
    

    4.) On the appllication_controller.rb file add this

      def current_cart
         session[:cart_id] ||= Cart.create!.id
         @current_cart ||= Cart.find(session[:cart_id])
       end
    

    5.) On your the view where you want the checkout button add this:

    # 'products_url' is just the url where you would like to redirect
    # the user after the transaction
    <%= link_to 'Buy with PAYPAL', @cart.paypal_url(products_url) %>
    

    6.) On the controller show action of the view where you want the checkout add this:

    def show
      ...
      @cart = current_cart
    end
    

    Thats it! This is a PaypalExpressCheckout without a ‘real’ Cart since I built this Cart without using a Line Item. But you could add a Line Item to it following the Railscast #141 Paypal Basics http://railscasts.com/episodes/141-paypal-basics

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

Sidebar

Related Questions

I have been googling about this issue for hours, and I'm stumped. Im trying
I've been trying to get my own opinion about this issue but could not,
I have been thinking about this issue and I can't figure it out. Perhaps
I've been reading several threads and questions about this issue but I didn't find
I've been banging my head over this issue for about 5 hours now, I'm
i need your help about this issue badly. i am trying to model a
I have been struggling with this issue for about 10 hours straight. I really
Please help me about this issue... In my application i have calender where user
I've read every post about this issue, but nothing solved the problem. I'll be
I have read a lot about this issue but mine still seems to be

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.