Permalink
Browse files

Allow voiding of transactions on gateways supporting profiles

Closes #1546
  • Loading branch information...
1 parent 215dec3 commit 8939921c9c1fb82ee8cb3a032cbd585c28146984 @tneems tneems committed with radar May 16, 2012
Showing with 22 additions and 4 deletions.
  1. +8 −1 core/app/models/spree/payment/processing.rb
  2. +14 −3 core/spec/models/payment_spec.rb
@@ -50,7 +50,14 @@ def void_transaction!
protect_from_connection_error do
check_environment
- response = payment_method.void(self.response_code, gateway_options)
+ if payment_method.payment_profiles_supported?
+ # Gateways supporting payment profiles will need access to creditcard object because this stores the payment profile information
+ # so supply the authorization itself as well as the creditcard, rather than just the authorization code
+ response = payment_method.void(self.response_code, source, gateway_options)
+ else
+ # Standard ActiveMerchant void usage
+ response = payment_method.void(self.response_code, gateway_options)
+ end
record_response(response)
if response.success?
@@ -221,9 +221,20 @@
payment.state = 'pending'
end
- it "should call payment_gateway.void with the payment's response_code" do
- gateway.should_receive(:void).with('123', anything).and_return(success_response)
- payment.void_transaction!
+ context "when profiles are supported" do
+ it "should call payment_gateway.void with the payment's response_code" do
+ gateway.stub :payment_profiles_supported? => true
+ gateway.should_receive(:void).with('123', card, anything).and_return(success_response)
+ payment.void_transaction!
+ end
+ end
+
+ context "when profiles are not supported" do
+ it "should call payment_gateway.void with the payment's response_code" do
+ gateway.stub :payment_profiles_supported? => false
+ gateway.should_receive(:void).with('123', anything).and_return(success_response)
+ payment.void_transaction!
+ end
end
it "should log the response" do

0 comments on commit 8939921

Please sign in to comment.