public
Fork of Shopify/active_merchant
Description: Active Merchant is a simple payment abstraction library used in and sponsored by Shopify. It is written by Tobias Luetke, Cody Fauser, and contributors. The aim of the project is to feel natural to Ruby users and to abstract as many parts as possible away from the user to offer a consistent interface across all supported gateways.
Homepage: http://activemerchant.org
Clone URL: git://github.com/econsultancy/active_merchant.git
Added support to datacash gateway for refunds on transactions which were 
taken via continuous authority
mocoso (author)
Thu Sep 04 07:01:22 -0700 2008
tomstuart (committer)
Fri Sep 05 08:14:03 -0700 2008
commit  7762697191a7c9803f7aa151589e00b00cddf1b9
tree    41ba3f120d0c11b3a7439deeaff5d20cc883a04d
parent  759e0bc1d39c3de0069a60febe80c93f260d67ec
...
138
139
140
141
 
 
142
143
144
 
145
146
147
...
369
370
371
 
372
373
374
375
376
 
377
378
379
...
386
387
388
 
 
 
389
390
391
...
138
139
140
 
141
142
143
144
 
145
146
147
148
...
370
371
372
373
374
375
376
377
 
378
379
380
381
...
388
389
390
391
392
393
394
395
396
0
@@ -138,10 +138,11 @@ module ActiveMerchant
0
       # * <tt>reference_or_credit_card</tt> The credit card you want to refund OR the datacash_reference for the existing transaction you are refunding
0
       # * <tt>options</tt> Are ignored when refunding via reference to an existing transaction, otherwise
0
       # * <tt>:order_id</tt> A unique reference for this order (corresponds to merchantreference in datacash documentation)
0
- # * <tt>:address</tt>:: billing address for card
0
+ # * <tt>:address</tt> Billing address for card
0
+ # * <tt>:capturemethod</tt> If transaction was originally made with a continuous authority then this MUST be set to 'ecomm' or 'cnp'
0
       def credit(money, reference_or_credit_card, options = {})
0
         if reference_or_credit_card.is_a?(String)
0
- request = build_transaction_refund_request(money, reference_or_credit_card)
0
+ request = build_transaction_refund_request(money, reference_or_credit_card, options)
0
         else
0
           request = build_refund_request(money, reference_or_credit_card, options)
0
         end
0
@@ -369,11 +370,12 @@ module ActiveMerchant
0
       # </HistoricTxn>
0
       # <TxnDetails>
0
       # <amount>10.00</amount>
0
+ # <capturemethod>ecomm</capturemethod>
0
       # </TxnDetails>
0
       # </Transaction>
0
       # </Request>
0
       #
0
- def build_transaction_refund_request(money, reference)
0
+ def build_transaction_refund_request(money, reference, options)
0
         xml = Builder::XmlMarkup.new :indent => 2
0
         xml.instruct!
0
         xml.tag! :Request do
0
@@ -386,6 +388,9 @@ module ActiveMerchant
0
             unless money.nil?
0
               xml.tag! :TxnDetails do
0
                 xml.tag! :amount, amount(money)
0
+ unless options[:capture_method].nil?
0
+ xml.tag! :capturemethod, options[:capture_method]
0
+ end
0
               end
0
             end
0
           end
...
267
268
269
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
270
271
272
...
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
0
@@ -267,6 +267,27 @@ class RemoteDataCashTest < Test::Unit::TestCase
0
     assert refund.test?
0
   end
0
 
0
+ def test_successful_transaction_refund_for_purchase_made_with_continuous_authority
0
+ #Authorize first payment
0
+ @params[:set_up_continuous_authority] = true
0
+ collect_ca_authorization = @gateway.authorize(@amount, @mastercard, @params)
0
+ assert_success collect_ca_authorization
0
+ assert !collect_ca_authorization.authorization.to_s.split(';')[2].blank?
0
+ assert collect_ca_authorization.test?
0
+
0
+ purchase_params = { :order_id => generate_unique_id }
0
+ purchase = @gateway.purchase(201, collect_ca_authorization.authorization, purchase_params)
0
+ assert_success purchase
0
+ assert purchase.test?
0
+
0
+ refund = @gateway.credit(@amount, purchase.params['datacash_reference'], { :capture_method => 'ecomm' })
0
+ assert_success refund
0
+ assert !refund.params['datacash_reference'].blank?
0
+ assert !refund.params['merchantreference'].blank?
0
+
0
+ assert refund.test?
0
+ end
0
+
0
   def test_successful_transaction_refund_with_money_set_to_nil
0
     purchase = @gateway.purchase(@amount, @mastercard, @params)
0
     assert_success purchase

Comments

    No one has commented yet.