I implemented paypal express checkout and was working fine but I had to change it to website payment pro. I switched to website payment pro and setup everything that needed but always displays "invalid credit card number" as an error message.

My development.rb file has below code

ActiveMerchant::Billing::Base.mode = :test
::GATEWAY = ActiveMerchant::Billing::PaypalGateway.new(
  :login => "seller_1280588868_biz_api1.hotmail.com",
  :password => "1290567879",
  :signature => "AZjEOuZ30SjjtX25uAhHyqYeodXnAi.tdG6i-gpZB1dBn2t876XYhKdE2"
)

I have used below code to generate credit card and validate

def validate_card
    unless credit_card.valid?
      credit_card.errors.full_messages.each do |message|
        errors.add_to_base message
      end
    end
  end

  def credit_card
    @credit_card ||= ActiveMerchant::Billing::CreditCard.new(
      :first_name => first_name,
      :last_name => last_name,
      :type => card_type,
      :number => card_number,
      :verification_value => card_verification,
      :month => card_expires_on.month,
      :year => card_expires_on.year
    )
  end

I really don't understand why this error is coming. I think i did everything correctly. I have entered paypal's sandbox account credit card number.

I am using rails 3.0.0, ruby 1.9.2 and active merchant 1.12.0.

有帮助吗?

解决方案

Finally got after almost spending half day on this. The bug was that I only used last 4 valid digits instead of all 16 digits because paypal displayed only last 4 digits on my credit card list page. Now it is working as I used all 16 digits.

Thank guys for your concerns/inputs.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top