ruby-on-rails - 尝试通过 PayPal 创建付款时出现内部服务器错误

标签 ruby-on-rails paypal paypal-sandbox

这是一个“现在可以,现在不行”的情况 使用 PayPal 沙盒时一切正常,但现在出现以下错误

Internal Server Error

The server encountered an internal error or misconfiguration and was unable 
to complete your request.

Please contact the server administrator, webmaster@paypal.com and inform 
them of the time the error occurred, and anything you might have done that 
may have caused the error.

More information about this error may be available in the server error log.

这是我的购物车.rb

def paypal_url(return_url,notify_url)
  values = {
    :business => 'seller5@myseelingwebsite.com',
    :cmd => '_cart',
    :upload => 1,
    :return => return_url,
    :invoice => id,
    :notify_url => notify_url,
    :cert_id => "4VA2YEE757V8A"
  }
  shopping_cart_items.each_with_index do |item, index|
    values.merge!({
      "amount_#{index+1}" => (item.price_cents/100),
      "item_name_#{index+1}" => Product.find(item.item_id).name,
      "item_number_#{index+1}" => item.item_id,
      "quantity_#{index+1}" => item.quantity
    })
  end
  encrypt_for_paypal(values)
end

PAYPAL_CERT_PEM = File.read("#{Rails.root}/certs/paypal_cert.pem")
APP_CERT_PEM = File.read("#{Rails.root}/certs/app_cert.pem")
APP_KEY_PEM = File.read("#{Rails.root}/certs/app_key.pem")

def encrypt_for_paypal(values)
  signed = OpenSSL::PKCS7::sign(OpenSSL::X509::Certificate.new(APP_CERT_PEM), 
                                OpenSSL::PKey::RSA.new(APP_KEY_PEM, ''), 
                                values.map { |k, v| "#{k}=#{v}" }.join("\n"), 
                                [], 
                                OpenSSL::PKCS7::BINARY)

  OpenSSL::PKCS7::encrypt([OpenSSL::X509::Certificate.new(PAYPAL_CERT_PEM)], 
                          signed.to_der, 
                          OpenSSL::Cipher::Cipher::new("DES3"), 
                          OpenSSL::PKCS7::BINARY).to_s.gsub("\n", "")
end

我的重定向 View

<%= form_tag "https://www.sandbox.paypal.com/cgi-bin/webscr", :id => 
'checkoutform' do %>
  <%= hidden_field_tag :cmd, "_s-xclick" %>
  <%= hidden_field_tag :encrypted, 
  @cart.paypal_url("http://www.mywebsite.com", 
  payment_notifications_url(:secret => "secretcode")) %>
<% end %>

我一步步经历了一切,却一无所获

最佳答案

我从带有加密按钮的 PayPal 沙箱中收到相同的错误。我也没有更改我的代码,它在两三个星期前就可以工作了。但是现在我得到了和你一样的错误。看起来 PayPal 不太关心修复他们的沙盒。他们把它放在低优先级。我建议你和他们一起开票。如果有足够多的客户提示,他们将解决这个问题的唯一方法。

关于ruby-on-rails - 尝试通过 PayPal 创建付款时出现内部服务器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43323235/

相关文章:

ruby-on-rails - 在 Ransack for rails 上设置默认搜索参数

paypal - 哪种 PayPal 设置最适合市场?

ios - Objective C 中的 Paypal 集成

ruby-on-rails - 在 rails 控制台中查看回滚错误的原因

ruby-on-rails - Rails 资源路由中的默认段名称

ruby-on-rails - 查找具有特定帖子的所有男性用户

Paypal 显示沙盒交易

paypal - 使用 IPN 模拟器测试 PayPal IPN SHA-256 合规性

Paypal 仅在订阅完成后才返回授权码?

image - 支付宝按钮不显示