ActiveMerchant:买方账户余额不减少

ActiveMerchant:买方账户余额不减少

问题描述:

我使用ActiveMerchant宝石使用Ruby 1.9.3和Rails 3.1ActiveMerchant:买方账户余额不减少

我已经成立了一个买家的虚拟帐户,并使用WebPayments临上贝宝卖家的虚拟帐户。当我运行这个脚本并查看我的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 

请帮帮我!我一直被困在这个问题上,而且我很困惑。

由于您直接指定信用卡,因此没有“帐户”,因此需要资金。 您使用的API方法DoDirectPayment直接向信用卡收费。它没有连接到PayPal账户,也没有使用PayPal账户的余额。

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