error trying to make sandbox paypal to work with rails?

kofhearts
Contributor
Contributor

I am having problems integrating paypal payment gateway with rails. I will explain below the steps i did.

I first went to developer.paypal.com

I created two sandbox accounts one for buyer and one for business account.

I changed business account to Business-Pro

I then installed activemerchant gem in rails.

In config/environments/development.rb i pasted the following chunk

  config.after_initialize do
    ActiveMerchant::Billing::Base.mode = :test
    paypal_options = {      login: "aGthYkgkYXVA_api1.gmail.com",      password: "DH2RB21WR2EWNSTM",      signature: "ApBHX2qbpxJW-Ll3oP22LSao0WeuAT.A.uNyDDqIArQeMLYzMTqsZnCW"
    }
    ::GATEWAY = ActiveMerchant::Billing::PaypalGateway.new(paypal_options)
end

Then in controller i created a test method and pasted code to do checkout

         amount = 1000  # $10.00

            credit_card = ActiveMerchant::Billing::CreditCard.new(
                        :brand => 'visa',
                        :first_name         => 'Bob',
                        :last_name          => 'Bobsen',
                        :number             => '413203319477',
                        :month              => 3,
                        :year               => 2022,
                        :verification_value => '123')

        # Validating the card automatically detects the card type
        if credit_card.validate.empty?
                 response = GATEWAY.purchase(amount, credit_card, :ip => '128.1.1.1')

          if response.success?            puts "Successfully charged $#{sprintf("%.2f", amount / 100)} to the credit card #{credit_card.display_number}"
          else            raise StandardError, response.message
          end
        end

when i execute the controller method i get the following error

This transaction cannot be processed. The merchant's account is not able to process transactions.

I am wondering the reason for this error.

I used credit card number and exp date from the buyer sandbox account i created above.

I am guessing the problem is with the sandbox account and not the application. Also i had problems deleting sandbox accounts. I appreciate any help!

Login to Me Too
0 REPLIES 0

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.