如何通过 Ruby 使用 Paypal 的自适应支付 API 来避免身份验证和时间问题? [英] How can I avoid auth and time issues using Paypal's Adaptive Payments API with Ruby?

查看:33
本文介绍了如何通过 Ruby 使用 Paypal 的自适应支付 API 来避免身份验证和时间问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试从 Ruby 访问 Paypal 的自适应支付 API 时遇到多个问题.

I'm running into multiple issues trying to access Paypal's Adaptive Payment API from Ruby.

我最初遇到的主要问题是 Paypal 要求他们的 HTTP 标头全部大写,但 Net::HTTP 不保留 HTTP 标头的大小写(它存储它们小写",然后输出大写"-- 因此,如果您设置标题X-PAYPAL-SECURITY-USERID",它将存储为x-paypal-security-userid"并输出为X-Paypal-Security-Userid").

The main issue I ran into initially was that Paypal requires their HTTP headers to be in all caps but Net::HTTP does not preserve the case of HTTP headers (it stores them 'downcased' and then outputs them 'capitalized' -- so if you set the header 'X-PAYPAL-SECURITY-USERID' it is stored as 'x-paypal-security-userid' and output as 'X-Paypal-Security-Userid').

当我尝试将 API 与这些大小写错误的标头一起使用时,我收到了500000 Internal Server"错误.

I was getting "500000 Internal Server" errors when I tried to use the API with these mis-cased headers.

所以我对 Net::HTTP 进行了猴子补丁以保留标头的大小写.但现在我收到超时异常:

So I monkeypatched Net::HTTP to preserve the case of the headers. But now I am getting timeout exceptions:

Timeout::Error (execution expired):
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/timeout.rb:60:in `rbuf_fill'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/protocol.rb:132:in `rbuf_fill'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/protocol.rb:104:in `read_all'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/http.rb:2220:in `read_body_0'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/http.rb:2173:in `read_body'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/http.rb:2198:in `body'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/http.rb:2137:in `reading_body'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/http.rb:1052:in `request'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/http.rb:543:in `start'

那么,回到我最初的问题:是否有人使用 Ruby 成功访问了自适应支付 API?如果是这样,你的秘密是什么?

So, back to my original question: Is anyone successfully accessing the adaptive payments API using Ruby? If so, what's your secret?

推荐答案

我为 ruby​​ 创建了一个 paypal 自适应支付 gem.我在 nextsprocket.com 成功使用它

I created a paypal adaptive payments gem for ruby. I'm using it successfully at nextsprocket.com

这是一篇关于它的博客文章:http://tommy.chheng.com/index.php/2009/12/paypal-adaptive-ruby-gem-released/

Here's a blog post about it: http://tommy.chheng.com/index.php/2009/12/paypal-adaptive-ruby-gem-released/

试一试,看看它是否对你有帮助.

Give it a shot and see if it will help you.

这篇关于如何通过 Ruby 使用 Paypal 的自适应支付 API 来避免身份验证和时间问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆