Paypal doVoid problems

38 views
Skip to first unread message

Alex Chee

unread,
Oct 30, 2009, 5:19:04 PM10/30/09
to Active Merchant
I'm trying to do refunds through the PayPal sandbox using void()
method, but I keep getting errors about the transaction_id being
wrong. I've tried using the response's authorization and params
["transaction_id"], but it still gives the same error.

Is there anything wrong with what I'm doing here?

>>response = GATEWAY.purchase(1.00,credit_card, options)
=> #<ActiveMerchant::Billing::Response:0x3934024 @test=true, @params=
{"timestamp"=>"2009-10-30T17:02:45Z",
"correlation_id"=>"79efbdc39d41f", "amount_currency_id"=>"USD",
"transaction_id"=>"3E050285AD3361601", "amount"=>"0.01",
"build"=>"1093451", "version"=>"52.0", "avs_code"=>"X",
"cvv2_code"=>"S", "ack"=>"Success"},
@authorization="3E050285AD3361601", @message="Success", @success=true,
@cvv_result={"code"=>"S", "message"=>"Should have been present"},
@fraud_review=false, @avs_result={"code"=>"X", "postal_match"=>"Y",
"street_match"=>"Y", "message"=>"Street address and 9-digit postal
code match."}>

>>v_res=GATEWAY.void(response.authorization)
=> #<ActiveMerchant::Billing::Response:0x38ee3bc @test=true, @params=
{"timestamp"=>"2009-10-30T17:21:12Z",
"correlation_id"=>"70e05f0c6785", "authorization_id"=>nil,
"build"=>"1093451", "error_codes"=>"10609", "version"=>"52.0",
"ack"=>"Failure", "message"=>"Transaction id is invalid."},
@authorization=nil, @message="Transaction id is invalid.",
@success=false, @cvv_result={"code"=>nil, "message"=>nil},
@fraud_review=false, @avs_result={"code"=>nil, "postal_match"=>nil,
"street_match"=>nil, "message"=>nil}>

I tried doing Authorize and Capture, then passing in the response from
Authroize, but that still didn't work. The only thing that works for
me is Credit(), which doesn't refund the paypal fees.

Is there something that I'm overlooking?

Alex Chee

unread,
Oct 30, 2009, 7:26:19 PM10/30/09
to Active Merchant
So can anyone tell if I'm on the right path?

I've taken a look at the PayAPI and found out that their doRefund
method can take a 'Full' type but the AM code has it hardcoded to
'Partial'. I've modified the paypal_common_api to change type to be
'Full' and remove 'Amount' from the xml if the money passed in was
nil. Here's my patch:
==============================
--- a/vendor/plugins/active_merchant/lib/active_merchant/billing/
gateways/paypal/paypal_common_api.rb
+++ b/vendor/plugins/active_merchant/lib/active_merchant/billing/
gateways/paypal/paypal_common_api.rb
@@ -147,8 +147,12 @@ module ActiveMerchant #:nodoc:
xml.tag! 'RefundTransactionRequest', 'xmlns:n2' =>
EBAY_NAMESPACE do
xml.tag! 'n2:Version', API_VERSION
xml.tag! 'TransactionID', identification
- xml.tag! 'Amount', amount(money), 'currencyID' => options
[:currency] || currency(money)
- xml.tag! 'RefundType', 'Partial'
+ if money.nil?
+ xml.tag! 'RefundType', 'Full'
+ else
+ xml.tag! 'Amount', amount(money), 'currencyID' =>
options[:currency] || currency(money)
+ xml.tag! 'RefundType', 'Partial'
+ end
xml.tag! 'Memo', options[:note] unless options
[:note].blank?
end
end
==============================

PayPal seems to be able to accept the request and returns a response
to me.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages