Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
711 views
in Technique[技术] by (71.8m points)

ruby - error trying to make sandbox paypal to work with rails?

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

 # ActiveMerchant accepts all amounts as Integer values in cents
        amount = 1000  # $10.00

        # The card verification value is also known as CVV2, CVC2, or CID
        credit_card = ActiveMerchant::Billing::CreditCard.new(
                        :brand => 'visa',
                        :first_name         => 'Bob',
                        :last_name          => 'Bobsen',
                        :number             => '4132033791119477',
                        :month              => 3,
                        :year               => 2022,
                        :verification_value => '123')

        # Validating the card automatically detects the card type
        if credit_card.validate.empty?
          # Capture $10 from the credit card
          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 appreciate any help!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It's in their docs:

10548 This transaction cannot be processed. The merchant's account is not able to process transactions. The merchant account attempting the transaction is not a business account at PayPal. Check your account settings.

-

10549 This transaction cannot be processed. The merchant's account is not able to process transactions. The merchant account attempting the transaction is not able to process Direct Payment transactions. Contact PayPal for more information.

I'd check the status of your account and ensure it's definitely switched to business. Have a poke around it there and let me know how you get on!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...