#146 PayPal Express Checkout
PayPal Express Checkout is easy to add to an existing ordering system. See how in this episode.
- source codeProject Files in Zip (108 KB)
- mp4Full Size H.264 Video (28.9 MB)
- m4vSmaller H.264 Video (17.9 MB)
- webmFull Size VP8 Video (46.3 MB)
- ogvFull Size Theora Video (38.9 MB)
When overriding the express_token= method, you set the express_token "attribute" via the self method. This is not the best way.
According to the Rails manuals it is better to use write_attribute when overriding an attribute setter (and read_attribute when overriding the getter)
Great cast otherwise ;)
thank you very much for another useful and interesting Railscast!
Keep up the good work.
Greetings from Austria,
Thanks for your work. Can't wait the end of work day to watch it ;)
However it's 6 screen casts regarding payment gateways. How much more you planning to spend on it, when we will see your screencasts with another rails tips?
@Bertg, thanks for the correction, I'll update the code in the show notes.
@Igor, This is the last cast on e-commerce for a little while. Expect some more regular episodes over the next few weeks.
Thanks again for the screen cast - very useful.
Still new to Ruby and Rails and had a quick question. If the purchase fails it goes to a failure page rather than rendering the new action again. Should this be changed? I'm not sure if this is a bad practice or if it was just to simplify it for the screencast.
No screencast on recurring billing? That's too bad. Anyway, love the series. Thanks a lot!
+1 for Recurring Billing!
@ron and @Scott,
Ryan said that he would that in previous episodes! =D
It is my understanding that (like mentioned in episode 145) informations (even more so for sensitive ones) should be gathered in HTTPS... I'm not sure if i missed an episode where the process of doing just that is explained but wouldn't it be a good episode subject otherwise ?
Great screencasts, btw ! keep up the great work !
Ryan, Just wanted to thank you for all the recent merchant casts, have been very helpful for setting up my shop. Keep up the good work :)
I'm missing the boat on something. How do I add the shipping information into my orders table when using the express pay. I have the first and last name just like the screen cast. But when I try and add the shipping address or any of the shipping information, its not updating the orders table.
Ryan. Thanks for the great series on Active Merchant and PayPal.
You use current_cart.build_order.price_in_cents in the controller to setup your response. And then the request cycle goes to paypal and then returns and then im losing the cart_id for the order.
Could someone check that?
Great series of casts Ryan! VERY helpful!
Thanks a lot Ryan! But why not ending in great style with a recurring bill episode? :(
Was one of the most important features!
Thanks aniway :)
I found a handy pdf to get you started with credit card processing:
Most of the things were already mentiond by ryan, but its a nice overview.
There have been a lot of ecommerce related Railscasts lately, but I think that is because it is a complex topic. I'll throw in a +1 for recurring billing.
Thanks for all of your work. Railscasts are one of the best resources for the community and they are free. Thanks again.
I had to do PayPal recurring payment before the Railscast becomes available. So I put together an extention and wrote a blog post about it.
I hope it works out you all who need to do similar things. There are stuff you can configure. ActiveMerchant is real nice.
Feedback will be appreciated.
I'm trying to get this code to work from the git repo but its complaining about current_cart in line_items_controller.rb the create on line 4. any ideas?
Any plans for authorize.net processing ryan? I'm trying to get it work but just can't was hoping you might give some insight.
great screencast, got me most of the way. i still have questions about integrating a list of ordered products on the confirmation page (after going to paypal).
i can't seem to get the cart line items to list on the confirm page. (this is the Orders -> new.html.erb page).
specifically i thought i would be able to access the cart thru @orders.cart.line_items, but i'm obviously missing something. in fact the @orders.cart_id seems nil.
does this get lost in the Express situation?
if i'm understanding this correctly, i can get all the order details (and items) thru the returned express_token. (since i'm actually sending PaymentDetailItems in my purchase).
question: can i access the token details directly on my orders new ERB? or is there a better way to do this?
oh, i just included the current cart as in the new method of the OrderController. silly me...
+ eight gazzilion billon for recurring billing, Ryan this !#*$ is the bomb.
Looking forward to the recurring billing episode. Many thanks for the series on Paypal.
I got the following error, when i followed your code, please assist me..
NameError in OrdersController#express
undefined local variable or method `products_url' for #<OrdersController:0xb6933454>
Application Trace | Framework Trace | Full Trace
How can I use Active Merchant to set Express Checkout's taxamt field? I need to set tax on orders shipping to my state.
Thank you so much for this series! It helped me out an incredible amount. This saved me days of researching and learning. Thank you! :)
Before considering PayPal, consider this:
There is one issue.
When you are redirecting to PayPal sandbox for Payment, you are not showing the amount which User is going to PAY ?
How can we show the AMOUNT on PayPal site which user is going to PAY ?
You can show the AMOUNT the user is going to PAY by fetching the TOTAL PRICE on the CART in Orders#new
+1,210,000,000 for recurring billing. Killer screencast.
These 6 screencasts really helped to sort things out, thanks a lot for that. Are you still planning to cover recurring payments?
I think the routes.rb code needs to change for Rails 3 apps to something like this:
resources :orders do
get 'express', :on => :collection
and then use the express_orders_path rather than express_new_order_path
I am new to rails. In my application i integrate the paypal by following episode 146. In that i didn't get the order summary. For that what can i do??? Can u help me out. Thanks.
Great series of casts Ryan! VERY helpful!
Thank you very much :)
Just wanted to ask, cast is from 2009, is there any major changes to this today, or i can go to production with this solution without problems?
Srdan I've put it working without much problems few days ago. I've wondering how to show the amount the user is going to pay on sandbox. Thanks!!
I have upgraded this episode to use Ruby 2.2.2, Rails 4.2.3 and ActiveMerchant 1.52.0. Here is the source code : Paypal Express
Two points to fix, I think.
One is that you create a new Cart object every time if it is not in the session. So imagine that your payment via PayPal fails for whatever reason you want. In this case you will finish to have multiple Cart records with
purchased_atset to nil what is not ideal.
Another one is that you will assign first name and last name of the payer and display their values in the
orders#newpage. But what for, just to display, because the values will not be submitted with the form in
OrdersController#createand will be lost when saving the order. Any tips for that ?