ActiveMerchant:买方帐户余额不会减少

时间:2012-02-26 02:05:32

标签: ruby-on-rails paypal paypal-sandbox activemerchant

我在Ruby 1.9.3和Rails 3.1中使用ActiveMerchant gem

我已经使用WebPayments Pro在PayPal上设置了买方虚拟账户和卖方虚拟账户。当我运行此脚本并查看我的paypal沙箱时,我的卖家帐户将正确存入10美元资金。

问题是当我查看我的买家帐户的沙箱时,余额不会减少。我的卖家从哪里拿钱?

我的代码在这里:

require "rubygems"
require "active_merchant"

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

gateway = ActiveMerchant::Billing::PaypalGateway.new(
  :login => "seller_1328509472_biz_api1.gmail.com",
  :password => "*******",
  :signature => "******"
)

credit_card ||= ActiveMerchant::Billing::CreditCard.new(
  :type               => "visa",
  :number             => "4193536536887351",
  :verification_value => "123",
  :month              => 2,
  :year               => 2017,
  :first_name         => "TESTING",
  :last_name          => "BUYER"
)

if credit_card.valid?
  response = gateway.authorize(1000, credit_card, :ip => "98.248.144.120", :billing_address => { :name => 'Test User', :company => '', :address1 => '1 Main St', :address2 => '', :city => 'San Jose', :state => 'CA', :zip => '95131'})
  if response.success?
    gateway.capture(1000, response.authorization)
  else
    puts "Response Unsuccessful Error: #{response.message}"
  end
else
  puts "Error: credit card is not valid. #{credit_card.errors.full_messages.join('. ')}"
end

请帮帮我!我多年来一直坚持这个,我很困惑。

1 个答案:

答案 0 :(得分:2)

因为您直接指定了信用卡,所以没有“帐户”可以从中获取资金。 您使用的API方法DoDirectPayment直接向信用卡收费。它没有连接到PayPal帐户,也没有使用PayPal帐户的余额。

如果您想要使用PayPal帐户而非信用卡付费,请使用PayPal Express Checkout:http://railscasts.com/episodes/146-paypal-express-checkout