I'm using ActiveMerchant gem with Ruby 1.9.3 and Rails 3.1
I already set up a buyer dummy account and a seller dummy account on PayPal using WebPayments Pro. When I run this script and look in my paypal sandbox, my seller account is deposited $10 in funds correctly.
The problem is that when I look at the sandbox for my buyer account, the balance does not decrease. Where is my seller getting the money from?
My code is here:
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
Please help me! I have been stuck on this for ages, and I am very confused.
Because you're specifying a credit card directly, there is no 'account' as such that it takes the funds from. The API method you're using, DoDirectPayment, charges a credit card directly. It is not connected to a PayPal account, nor does it use the balance of a PayPal account.
If you want to charge a PayPal account rather than a credit card, use PayPal Express Checkout: http://railscasts.com/episodes/146-paypal-express-checkout