Getting the 'order summary' field to populate with paypal

439 views
Skip to first unread message

John McLaughlin

unread,
Jun 17, 2011, 1:38:54 AM6/17/11
to potion...@googlegroups.com
Hi All,

I had a customer recently complain that they were being asked to agree to pay with paypal without knowing the amount -- it took a bit of work to sort out what she meant but the problem was when using paypal the first screen you see asks for username/password and has a 'your order details' screen that was blank!

In reality once logged on it shows the proper amount and then let's you confirm it so it is working, it's just a bit off putting when you have to enter a password without knowing for sure... I've noticed this on lots of other sites also so I knew it wasn't just me.  for instance look at this store https://secure.flyingmeat.com/store/ -- try adding a item and then paying by paypal, you'll see that the purchase sumary on the first paypal screen is blank (I'm not trying to pick on gus, I was testing lots of stores to see if I could sort it out and just happened to remember his was one that didn't do it either)

I tried migrating to the newer version of PotionStore (I'm using a fairly ancient version) but the integration of my custom changes were just too daunting (I'm really not a ruby expert at all -- I know just enough to keep the store running)

Anyway -- I finally sorted out how to fix it -- What you need to do is pass along the 'orderDescription' -- By default it's not passed in -- I thought I would pass it along for other folks.

Change app/contgrollers/store/order_controller in the 'payment' function to add the orderDescription field as so -- this defaults to showing your store name and the amount (e.g. for me it shows 'loghound software: $13.22'
 

      res =  Paypal.express_checkout(:amount => String(@order.total),
                                     :cancelURL => url_for(:action => 'index'),
                                     :returnURL => url_for(:action => 'confirm_paypal'),
                                     :noShipping => 1,
                                     :cpp_header_image => $STORE_PREFS['paypal_express_checkout_header_image'],
    :orderDescription => $STORE_PREFS['company_name'] + ' Software: $'+String(@order.total))



Change vendor/plugins/paypal/lib/paypal.rb to include the orderDescription in the express_checkout_redirect_url

  def Paypal.express_checkout_redirect_url(token)
    live = ENV['RAILS_ENV'] == 'production'
    if live
    else
    end
  end
  
  def Paypal.express_checkout(params)
    details = SetExpressCheckoutRequestDetailsType.new
    #     details.orderTotal = Paypal._usd_amount(params[:amount])
    a = BasicAmountType.new(String(params[:amount]))
    a.xmlattr_currencyID = 'USD'
    details.orderTotal = a

    details.cancelURL = params[:cancelURL]
    details.returnURL = params[:returnURL]
    details.noShipping = params[:noShipping]
    details.cpp_header_image = params[:cpp_header_image]
    details.orderDescription=params[:orderDescription]
 
    reqtype = SetExpressCheckoutRequestType.new
    reqtype.version = '2.0'
    reqtype.setExpressCheckoutRequestDetails = details
    req = SetExpressCheckoutReq.new(reqtype)

    return create_client().setExpressCheckout(req)
  end


That's it!  Restart your store and when you next make a purchase it should show the summary amount for the customer so they know what to expect.  Note that I suspect it's fixed in newer versions of potionstore as they switched to nvp but if you are running an older soap based version this should get you going.

-John

Reply all
Reply to author
Forward
0 new messages