2012-02-26 107 views
0

我使用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 

請幫幫我!我一直被困在這個問題上,而且我很困惑。

回答

2

由於您直接指定信用卡,因此沒有「帳戶」,因此需要資金。 您使用的API方法DoDirectPayment直接向信用卡收費。它沒有連接到PayPal賬戶,也沒有使用PayPal賬戶的餘額。

如果您想要通過PayPal賬戶而非信用卡收費,請使用PayPal Express Checkout:http://railscasts.com/episodes/146-paypal-express-checkout