Skip to content

Commit

Permalink
Added support for repeat transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Tenner committed Apr 19, 2009
1 parent 665227e commit 8eb7b17
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
9 changes: 9 additions & 0 deletions lib/active_merchant/billing/gateways/xpay.rb
Expand Up @@ -94,6 +94,15 @@ def credit(money, identification, options = {})

commit(TRANSACTIONS[:credit], nil, post)
end

def repeat(money, identification, options={})
post = {}
add_parent_transaction_data(post, identification)
add_invoice(post, options)
add_amount(post, money, options, 1)

commit(TRANSACTIONS[:purchase], money, post)
end

private

Expand Down
26 changes: 22 additions & 4 deletions test/remote/gateways/remote_xpay_test.rb
Expand Up @@ -41,6 +41,8 @@ def setup
:description => 'Store Purchase',
:currency => 'GBP'
}

@responses = {}
end

def test_successful_purchase
Expand Down Expand Up @@ -85,7 +87,6 @@ def test_unsuccessful_capture
end

def test_authorize_and_void
@responses = {}
@credit_cards.each do |type, credit_card|
assert response = @gateway.authorize(@amount, credit_card, @options)
assert_success response
Expand All @@ -105,7 +106,6 @@ def test_authorize_and_void
end

def test_authorize_and_capture_and_refund
@responses = {}
@credit_cards.each do |type, credit_card|
assert response = @gateway.authorize(@amount, credit_card, @options)
assert_success response
Expand All @@ -132,5 +132,23 @@ def test_authorize_and_capture_and_refund
assert_equal "The transaction was processed successfully.", response.message
end
end

end

def test_purchase_and_repeat
@credit_cards.each do |type, credit_card|
assert response = @gateway.purchase(@amount, credit_card, @options)
assert_success response
assert_equal "The transaction was processed successfully.", response.message
@responses[type] = response
end
@credit_cards.each do |type, credit_card|
identification = {
:transaction_reference => @responses[type].transaction_reference,
:transaction_verifier => @responses[type].transaction_verifier
}
assert response = @gateway.repeat(@amount, identification, @options)
assert_success response
assert_equal "The transaction was processed successfully.", response.message
end
end

end

0 comments on commit 8eb7b17

Please sign in to comment.