这里使用什么类型的协议与 PayPal 进行通信?
我知道有多种方法可以使用 PayPal 的 API(SOAP 等),但我对它们一无所知,因此为了扩大我在该主题上的知识,请您告诉我其中使用了什么来自 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
谢谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是一个通过 HTTP 的简单 get 请求。最终请求如下所示:
https://www.sandbox.paypal.com/cgi-bin/[电子邮件受保护]&< /a> cmd=_cart&upload=1...
等等,看起来应该有些熟悉。
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.
Http 是互联网协议
Http is the Internet protocol
如前所述,这是对 PayPal 服务器的获取请求。
具体来说,它是一个购物车上传命令 - 您可以在这里阅读:https://www.x .com/community/ppx/wps。如果有兴趣,请查看该页面右侧的 html 变量参考。这些变量将随所提供的代码一起发送至 PayPal。
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.