PayPal错误:此交易无效。请返回收件人的网站,使用他们的常规结帐流程完成您的交易

时间:2011-12-17 21:43:28

标签: ruby-on-rails ruby-on-rails-3 paypal activemerchant

我试图实现paypal支付网关。

但是我收到了一个错误:

This transaction is invalid. Please return to the recipient's website to complete your transaction using their regular checkout flow.

在Gem文件中

gem 'activemerchant', :require => 'active_merchant'

在development.rb

 config.after_initialize do
    ActiveMerchant::Billing::Base.mode = :test
    paypal_options = {
      :login => "************",
      :password => "************",
      :signature => "************",
    }
    ::STANDARD_GATEWAY = ActiveMerchant::Billing::PaypalGateway.new(paypal_options)
    ::EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalExpressGateway.new(paypal_options)
  end

我在控制器中使用的示例代码

  response = EXPRESS_GATEWAY.setup_purchase(10000,
    :ip                => request.remote_ip,
    :return_url        => new_order_url,
    :cancel_return_url => orders_url
  )
  p response
  p response.token
  redirect_to EXPRESS_GATEWAY.redirect_url_for(response.token)

回复的O / p:

#<ActiveMerchant::Billing::PaypalExpressResponse:0x007f90bbababa0 @params={"timestamp"=>"2011-12-17T21:41:21Z", "ack"=>"Failure", "correlation_id"=>"c152e1862f475", "version"=>"62.0", "build"=>"2271164", "message"=>"Security header is not valid", "error_codes"=>"10002", "Timestamp"=>"2011-12-17T21:41:21Z", "Ack"=>"Failure", "CorrelationID"=>"c152e1862f475", "Errors"=>{"ShortMessage"=>"Security error", "LongMessage"=>"Security header is not valid", "ErrorCode"=>"10002", "SeverityCode"=>"Error"}, "Version"=>"62.0", "Build"=>"2271164"}, @message="Security header is not valid", @success=false, @test=true, @authorization=nil, @fraud_review=false, @avs_result={"code"=>nil, "message"=>nil, "street_match"=>nil, "postal_match"=>nil}, @cvv_result={"code"=>nil, "message"=>nil}>

o / p for response.token

  nil

所以我认为问题是response.token是nil

为什么会发生这种情况的任何建议?

1 个答案:

答案 0 :(得分:11)

您检查的第一件事可能是沙盒用户的登录名,密码和签名,而不是您自己登录沙箱的登录名,密码和签名。您需要登录沙盒用户帐户并从中获取签名。

因此,当您登录sandbox.paypal.com然后转到“测试帐户”时,选择您想要详细信息的帐户,然后按Enter Sandbox Test Site。在新窗口中输入假用户的详细信息(电子邮件应预先填写)。登录后转到个人资料 - &gt; API访问并请求或查看API签名。

很抱歉,如果你已经尝试过这个,但我无法发表评论要求;)