Я пытался внедрить платежный шлюз 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'
В разработке. 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для response.token
nil
Так что я думаю, что проблема в response.token nil
есть предложения, почему это происходит?