调用此代码时出现此错误。
response = EXPRESS_GATEWAY.setup_purchase(order.price_in_cents,
:ip => request.remote_ip,
:return_url => url_for(:action => :create, :only_path => false),
:cancel_return_url => root_path
)
redirect_to EXPRESS_GATEWAY.redirect_url_for(response.token)
错误:
This transaction is invalid. Please return to the recipient's website to complete your transaction using their regular checkout flow.
为了显示我正确设置了 EXPRESS_GATEWAY。代码 development.rb 文件。
config.after_initialize do
ActiveMerchant::Billing::Base.mode = :test
paypal_options = {
:login => '*****************************',
:password => '*************',
:signature => '*******************************************************'
}
::EXPRESS_GATEWAY = ActiveMerchant::Billing::PaypalExpressGateway.new(paypal_options)
end
宝石文件
gem 'activemerchant', :require => 'active_merchant'
所以登录名,密码和签名。在沙箱中创建的都是贝宝。所以他们应该工作。
我应该怎么做才能修复这个错误。或者这是 Paypal 的一方?ActiveMerchant gem 有什么问题吗?
更新 1
检查响应变量后,这就是我得到的。
#<ActiveMerchant::Billing::PaypalExpressResponse:0x00000102402790 @params={"timestamp"=>"2012-06-29T01:30:18Z", "ack"=>"Failure", "correlation_id"=>"d1cb5dbb30425", "version"=>"72", "build"=>"3067390", "message"=>"CancelURL is invalid.", "error_codes"=>"10472", "Timestamp"=>"2012-06-29T01:30:18Z", "Ack"=>"Failure", "CorrelationID"=>"d1cb5dbb30425", "Errors"=>{"ShortMessage"=>"Transaction refused because of an invalid argument. See additional error messages for details.", "LongMessage"=>"CancelURL is invalid.", "ErrorCode"=>"10472", "SeverityCode"=>"Error"}, "Version"=>"72", "Build"=>"3067390"}, @message="CancelURL is invalid.", @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}>
任何反馈表示赞赏。
UDPATE 2
看了上面的那条消息后发现,cancelURL 是无效的,所以我修复了它并立即修复!
谢谢。