Created
May 9, 2011 15:51
-
-
Save kernow/962764 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create a worldpay response object that acts like a string but has the each_header method | |
# so that we can access the headers that worldpay returns | |
class WorldPayResponse < String | |
def initialize(resp) | |
@resp = resp | |
super(resp.body) | |
end | |
def each_header(&block) | |
@resp.each_header &block | |
end | |
end | |
# overwrite the handle_response method so that it returns a WorldPayResponse object rather | |
# than the response.body string, this acts the same as a string but includes the each_header | |
# method for accessing the returned headers | |
module ActiveMerchant | |
class Connection | |
private | |
def handle_response(response) | |
case response.code.to_i | |
when 200...300 | |
WorldPayResponse.new(response) | |
else | |
raise ResponseError.new(response) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment