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

Moh*_*ain 5 paypal ruby-on-rails activemerchant ruby-on-rails-3

我试图实现paypal支付网关.

但我收到一个错误:

This transaction is invalid. Please return to the recipient's website to complete your transaction using their regular checkout flow.
Run Code Online (Sandbox Code Playgroud)

在宝石文件中

gem 'activemerchant', :require => 'active_merchant'
Run Code Online (Sandbox Code Playgroud)

在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
Run Code Online (Sandbox Code Playgroud)

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

  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)
Run Code Online (Sandbox Code Playgroud)

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}>
Run Code Online (Sandbox Code Playgroud)

o/p for response.token

  nil
Run Code Online (Sandbox Code Playgroud)

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

任何建议为什么会这样?

小智 11

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

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

对不起,如果您已经尝试过此但我无法发表评论询问;)