【问题标题】:getting error with paypal, activemerchant -- A field was longer or shorter than the server allowspaypal、activemerchant 出错——字段比服务器允许的长或短
【发布时间】:2016-12-09 14:27:21
【问题描述】:

我正在尝试使用 activemerchet 实现 paypal 支付网关,但出现错误 - A 字段比服务器允许的长或短

我正在使用专业帐户的凭据。我看到了其他 SO 问题,但没有帮助

    require 'rubygems'
    require 'active_merchant'
    ActiveMerchant::Billing::Base.mode = :test

    gateway = ActiveMerchant::Billing::TrustCommerceGateway.new(
                :login => 'XXX@gmail.com',
                :password => 'my_password',
                :signature => 'my_signature')

    credit_card = ActiveMerchant::Billing::CreditCard.new(
                    :first_name         => 'f_name',
                    :last_name          => 'l_name',
                    :number             => '4032034467080704',
                    :month              => '9',
                    :year               => '2021',
                    :verification_value => '123',
                    :brand => 'VISA'
                    )

    AMOUNT = 1000
      def purchase_options
        {
            ip: "127.0.0.1",
            billing_address: {
                name:      "Flaying Cakes",
                address1:  "123 5th Av.",
                city:      "New York",
                state:     "NY",
                country:   "US",
                zip:       "10001"
            }
        }
      end

if credit_card.validate.empty?
    response = gateway.purchase(AMOUNT, credit_card, purchase_options)
    if response.success?
      puts "Successfully charged to the credit card #{credit_card.display_number}"
    else
       raise StandardError, response.message
    end
else
    puts "credit card is not valid #{credit_card.errors.full_messages.join(". ")}"
end

【问题讨论】:

    标签: ruby-on-rails ruby paypal activemerchant


    【解决方案1】:

    我变了
    gateway = ActiveMerchant::Billing::TrustCommerceGateway.new

    gateway = ActiveMerchant::Billing::PaypalGateway.new
    

    效果很好。

    【讨论】:

      猜你喜欢
      • 2011-11-18
      • 2013-05-31
      • 1970-01-01
      • 1970-01-01
      • 2012-03-14
      • 2013-12-07
      • 1970-01-01
      • 2012-06-30
      相关资源
      最近更新 更多