ruby - 活跃的 ruby 商人

标签 ruby ruby-on-rails-3 activemerchant

<分区>

Possible Duplicate:
An invalid merchant configuration in Paypal with rails

我正在玩 Active Merchant gem。我用了Rails cast(144)我创建了一个 ruby​​ 文件 (credit_card.rb):

require "rubygems"
require "active_merchant"

ActiveMerchant::Billing::Base.mode = :test

gateway = ActiveMerchant::Billing::PaypalGateway.new(
  :login => "seller_1316503855_biz_api1.agileblaze111.com",
  :password => "********",
  :signature => "A5llddES-nIiDc8WBuZMOtm6yM2oANQrerVY20ty0ZxeN-izmKjwDtR0"
)

credit_card = ActiveMerchant::Billing::CreditCard.new(
  :type               => "visa",
  :number             => "4234609806354393",
  :verification_value => "123",
  :month              =>  '9',
  :year               =>  '2016',
  :first_name         => "shamith",
  :last_name          => "c"
)

billing_address = { 
    :name     => "John Smith",
    :address1 => '123 First St.',
    :address2 => '33333',
    :city     => 'Los Angeles',
    :state    => 'CA',
    :country  => 'US',
    :zip      => '90068',
    :phone    => '310-555-1234'
}

 billing_address1 = {
    :name => 'Test User',
    :company => '',
    :address1 => '123 S Main St',
    :address2 => '',
    :city => 'Akron',
    :state => 'OH',
    :country => 'US',
    :zip => '44333',
    :phone => '(310)555-5555'
  } 


if credit_card.valid?
  puts "Credit Card is valid"
  response=gateway.purchase(1000,credit_card,:ip=>"127.0.0.1",:billing_address=>billing_address1)
  if response.success?
     puts "Purchased"
  else
     puts "Error:#{response.message}"
  end
else
  puts "Error: credit card is not valid. #{credit_card.errors.full_messages.join('. ')}"end

我执行 $ ruby​​ credit_card.rb 并得到以下错误:

Error: This transaction cannot be processed due to an invalid merchant configuration.

最佳答案

您的 ActiveMerchant::Billing::PaypalGateway 行有问题。我最近也经历了这个,并遇到了那个问题。

我发布了 this link到该集评论中的 Paypal 文档。他们在那里描述了获取您需要的 API 凭据的当前过程,因为 Rails cast 已经有大约两年的历史了,而且有点过时了。

我的沙盒帐户类型不正确且没有正确的凭据时遇到了多个问题。

我最终发现的一个有用的东西是,在开发人员网站上,您可以在其中创建新的沙盒帐户等,左侧有一个链接,您可以在其中查看您的沙盒帐户生成的任何 API 凭据。当我找到该链接时,我的页面是空白的,这导致我创建一个新的沙盒帐户并按照 Paypal 文档方法获取凭据。

如果这有帮助或没有帮助,请发帖,因为我仍在学习如何使用 active_merchant 和 Paypal 沙箱,并且需要我能得到的所有练习。

关于ruby - 活跃的 ruby 商人,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7486032/

相关文章:

ruby - 在 Ruby FFI 中分配给嵌套结构成员

ruby - 从 Linux 上的 Ruby 和 Resque 捕获段错误回溯

ruby - 使用适当的参数转义从 ruby​​ 在后台执行 shell 命令

ruby-on-rails-3 - Bootstrap-datetimepicker-rails

ruby-on-rails - after_save 回调将 updated_by 列设置为 current_user

ruby-on-rails - 通过 ActiveMerchant 退款(Paypal 结帐 Express)

ruby-on-rails - 美国以外的 Ruby on Rails 和 Paypal

ruby - rufus-scheduler 和 cron 有什么区别?

ruby-on-rails - 使用 Moneris Canada 在活跃商家中定期计费

ruby-on-rails - Rails 是否有可能有一个模型可以包含两种类型的模型 : Tree of multiple models