views:

153

answers:

3

I know that there are various ways to use PayPal's API (SOAP, etc), but I don't know anything about them, so in an attempt to broaden my knowledge on the subject, would you please tell me what is being used in this example from railscasts:

   1. def paypal_url(return_url)  
   2.     values = {  
   3.       :business => ’[email protected]’,  
   4.       :cmd => ’_cart’,  
   5.       :upload => 1,  
   6.       :return => return_url,  
   7.       :invoice => id  
   8.     }  
   9.       
   10.     line_items.each_with_index do |item, index|  
   11.       values.merge!({  
   12.         "amount_#{index + 1}" => item.unit_price,  
   13.         "item_name_#{index + 1}" => item.product.name,  
   14.         "item_number_#{index + 1}" => item.product.identifier,  
   15.         "quantity_#{index + 1}" => item.quantity  
   16.       })  
   17.     end  
   18.     "https://www.sandbox.paypal.com/cgi-bin/webscr?" + values.map { |k,v|     "#{k}=#{v}"  }.join("&")  
   19.   end

Thank you!

A: 

Http is the Internet protocol

Pierreten
Actually HTTP is the World Wide Web protocol (hence "HyperText"). The Internet protocol is TCP/IP.
John Topley
A: 

This is a simple get request over HTTP. The final request would look something like:

https://www.sandbox.paypal.com/cgi-bin/[email protected]& cmd=_cart&upload=1...

and so on, which should look somewhat familiar.

Kyle
+1  A: 

As mentioned this is a get request to PayPal's servers.

Specifically it is a cart upload command - you can read about this here: https://www.x.com/community/ppx/wps. If interested check out the html variables reference on the right hand side of that page. It is those variables that are being sent to PayPal with the code provided.

ezimerchant