【问题标题】:Rails Activermerchant Truscommerce Capture Transid Invalid Octal DigitRails Activemerchant Truscommerce 捕获 Transid 无效的八进制数字
【发布时间】:2011-08-21 09:47:26
【问题描述】:

我有一个名为 purchase.rb 的文件,我用它来测试带有 Trustcommerce 的 Activemerchant:

需要“红宝石” 需要“active_merchant”

使用 TrustCommerce 测试服务器

ActiveMerchant::Billing::Base.mode = :test 金额 = 1000

credit_card = ActiveMerchant::Billing::CreditCard.new(
             :first_name         => 'againchangeD',
             :last_name          => 'Tessdsdst',
             :number             => '4242424242424242',
             :month              => '8',
             :year               => '2012',
             :verification_value => '123'

           )


billing_address = { :address1 => '9909 Down the Road',
    :city => 'San Francisco', :state => 'CA',
    :country => 'US', :zip => '23456', :phone => '(555)555-5555'}


options = {:billing_address => billing_address}

#验证卡自动检测卡类型

if credit_card.valid?

# 为 TrustCommerce 服务创建网关对象

gateway = ActiveMerchant::Billing::TrustCommerceGateway.new(
           :login => "xxxxxx",
           :password => "xxxxxx"
         )

# response = gateway.authorize(amount, credit_card)

# 这是从沙盒接收到的 transid,之前运行了 authorize()

   trans_id = 027-0004842047
   response = gateway.capture(amount,trans_id)


   if response.success?
       good = 'yes'
   puts "Successful #{good}"
   else
       puts "NO"
       raise StandardError, response.message
   end

结束

我在终端上运行 ruby​​ purchase.rb 得到:八进制数无效,因为 027-0004842047。有人知道如何解决这个问题吗?如果我实际构建一个 Rails 应用程序而不是使用 ruby​​ 命令运行这样的文件,会有什么不同吗?谢谢

【问题讨论】:

    标签: ruby-on-rails activemerchant octal


    【解决方案1】:

    愚蠢的我......

    这解决了问题: trans_id = '027-0004842047'

    我不得不把它当作一个字符串来处理

    【讨论】:

      猜你喜欢
      • 2012-06-25
      • 1970-01-01
      • 2019-07-20
      • 2010-12-22
      • 2013-09-10
      • 2012-04-18
      • 2013-02-18
      • 1970-01-01
      • 2012-01-17
      相关资源
      最近更新 更多