2009-12-11 75 views
1

我知道有各种方法可以使用PayPal的API(SOAP等),但我对它们一无所知,所以为了扩大我对这个主题的知识,请告诉我使用什么在这个例子中来自railscasts:这里使用什么样的协议与PayPal进行通信?

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 

谢谢!

回答

1

如前所述,这是一个GET请求到PayPal的服务器。

具体它是一个购物车的上传命令 - 你可以看到这个位置:https://www.x.com/community/ppx/wps。如果感兴趣,请查看该页面右侧的html变量引用。这些变量是通过提供的代码发送给PayPal的。

-2

HTTP是互联网协议

+0

实际上HTTP是万维网协议(因此称为“超文本”)。 Internet协议是TCP/IP。 – 2009-12-11 10:31:50