2012-06-28 115 views
1

我在調用此代碼時遇到此錯誤。Rails ActiveMerchant - Paypal Express Checkout Error

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

檢查響應VAR後,這是我得到的。

#<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,所以我固定的和急!

謝謝。

回答

0

當您沒有正確登錄到貝寶網站上的沙箱帳戶時顯示此錯誤。

  1. 登錄到http://sandbox.paypal.com/
  2. 打開你的網站,結帳
  3. 當發送到貝寶,登錄爲您的買家的測試帳戶之一
+0

我沒有創建一個買方帳戶。讓我測試一下,看看是否能解決這個問題。 –

+0

不...還是給出了這個錯誤。 –