Reputation: 2662
Can't get my head around PayPal payment response errors or at least warnings. I am Australian developer (at least I am located in Australia and using AUD as a currency).
Could you please tell me why if the sandbox user has insufficient funds the transaction has a positive (valid) response on the request for payment?
So I have user_A who is buyer and a seller_user. user_A has 0AUD and makes a transaction of 20AUD of recurring payments and the response is successful??? Why?
What is the way to get to know that user doesn't have sufficient funds for the transaction?
gem: paypal-recurring
rails: 3.2.14
location: Australia
====== Controller action for redirecting to checkout url
ppl = PayPal::Recurring.new(
return_url: paypal_confirm_url(:plan_id => params[:plan_id], :user_id => current_user.id),
cancel_url: paypal_no_checkout_url,
description: "Starter",
amount: 15,
currency: "AUD"
)
response = ppl.checkout
if response.valid?
redirect_to response.checkout_url
else
redirect_to :back
end
==== Controller action after confirmation
ppr = PayPal::Recurring.new(
token: params[:token],
payer_id: params[:PayerID],
description: plan.name,
amount: plan.value,
currency: "AUD",
period: :monthly,
start_at: Time.zone.now,
frequency: 1
)
response = ppr.request_payment
if response.errors.any?
flash.keep[:error] = "Something went wrong please contact paypal or ask our development team: [email protected]"
return false
end
response = ppr.create_recurring_profile
paypal_recurring_profile_token = response.profile_id # response.profile_id = nil????
save!
Upvotes: 4
Views: 423
Reputation: 30477
All PayPal sandbox accounts have a dummy bank account attached with unlimited funds. So when the PayPal account has $0, it just pulls from that "bank". For an insufficient funds error to occur, you would need to turn on negative testing somehow, though I think that produces errors based on trigger AMT variables. For classic APIs, I recommend just having your code look for an ACK response containing Success and treating the rest as an exception (perhaps printing out RESPMSG as a customer notice, though sometimes you'll want to replace that with your own error messaging)
Upvotes: 1