Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I was trying to implement paypal payment gateway.

But I am getting an error:

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

In Gem File

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

In 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

Sample code I am using in my controller

  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 for response:

#<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

So I think the problem is response.token is nil

any suggestions why this is happening?

like image 237
Mohit Jain Avatar asked Dec 17 '11 21:12

Mohit Jain


1 Answers

Probably the first thing you checked but are the login, password and signature the ones for the sandboxed user and not your own login to the sandbox. You need to log in to the sandboxed users account and the get the signature from in there.

So when you log into sandbox.paypal.com and then go to Test Accounts, select the one you want the details for and press Enter Sandbox Test Site. In the new window enter the details for the fake user (email should be prefilled). Once logged in go to Profile -> API Access and request or view the API signature.

Sorry if you've already tried this but I couldn't post a comment to ask ;)

like image 109
slarti42uk Avatar answered Sep 19 '22 04:09

slarti42uk