Skip to content

Commit

Permalink
Remove @response instance variable in PsigateGateway. Don't use billi…
Browse files Browse the repository at this point in the history
…ng address for shipping

git-svn-id: https://activemerchant.googlecode.com/svn/trunk/active_merchant@622 6513ea26-6c20-0410-8a68-89cd7235086d
  • Loading branch information
codyfauser committed Jan 28, 2008
1 parent 7ce2b61 commit 8119ebd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 33 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
@@ -1,5 +1,6 @@
= ActiveMerchant CHANGELOG

* Remove @response instance variable in PsigateGateway. Don't use billing address for shipping [cody]
* Remove @response instance variable in PaypalGateway. Don't use billing address for shipping. [cody]
* Remove @response instance variable in PayflowGateway [cody]
* Remove @response instance variable in MonerisGateway [cody]
Expand Down
28 changes: 13 additions & 15 deletions lib/active_merchant/billing/gateways/psigate.rb
Expand Up @@ -86,21 +86,19 @@ def credit(money, authorization, options = {})
private

def commit(money, creditcard, options = {})
parameters = parameters(money, creditcard, options)

url = test? ? TEST_URL : LIVE_URL
data = ssl_post(url, post_data(parameters))

@response = parse(data)
success = (@response[:approved] == "APPROVED")

Response.new(success, message_from(@response), @response,
response = parse(ssl_post(test? ? TEST_URL : LIVE_URL, post_data(money, creditcard, options)))

Response.new(successful?(response), message_from(response), response,
:test => test?,
:authorization => @response[:orderid],
:avs_result => { :code => @response[:avsresult] },
:cvv_result => @response[:cardidresult]
:authorization => response[:orderid],
:avs_result => { :code => response[:avsresult] },
:cvv_result => response[:cardidresult]
)
end

def successful?(response)
response[:approved] == "APPROVED"
end

def parse(xml)
response = {:message => "Global Error Receipt", :complete => false}
Expand All @@ -115,12 +113,12 @@ def parse(xml)
response
end

def post_data(parameters = {})
def post_data(money, creditcard, options)
xml = REXML::Document.new
xml << REXML::XMLDecl.new
root = xml.add_element("Order")

for key, value in parameters
for key, value in parameters(money, creditcard, options)
root.add_element(key.to_s).text = value if value
end

Expand Down Expand Up @@ -178,7 +176,7 @@ def parameters(money, creditcard, options = {})
params[:Bcompany] = address[:company] unless address[:company].blank?
end

if address = options[:shipping_address] || options[:address]
if address = options[:shipping_address]
params[:Sname] = address[:name] || creditcard.name
params[:Saddress1] = address[:address1] unless address[:address1].blank?
params[:Saddress2] = address[:address2] unless address[:address2].blank?
Expand Down
18 changes: 0 additions & 18 deletions test/unit/gateways/psigate_test.rb
Expand Up @@ -45,24 +45,6 @@ def test_amount_style
end
end

def test_purchase_is_valid_xml
parameters = @gateway.send(:parameters, 2000, @credit_card, {:order_id => 1004,
:billing_address => address,
:email => 'jack@yahoo.com',
:CardAction => 0 } )
assert data = @gateway.send(:post_data, parameters)
assert_nothing_raised{ REXML::Document.new(data) }
end

def test_capture_is_valid_xml
parameters = @gateway.send(:parameters, 2000, CreditCard.new({}), {:order_id => 1004,
:CardAction => 2 } )

assert data = @gateway.send(:post_data, parameters)
assert REXML::Document.new(data)
assert_equal xml_capture_fixture.size, data.size
end

def test_supported_countries
assert_equal ['CA'], PsigateGateway.supported_countries
end
Expand Down

0 comments on commit 8119ebd

Please sign in to comment.