Class: BreadMachine::SecureTrading::XPay

Inherits:
Object
  • Object
show all
Defined in:
lib/breadmachine/secure_trading/xpay.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exchange(request) ⇒ Object

A class method which wraps the individual request block with the necessary xml for the XPay gateway. Once the request is wrapped, this method writes it to the Xpay client and returns the response.



10
11
12
13
# File 'lib/breadmachine/secure_trading/xpay.rb', line 10

def self.exchange(request)
  xpay = self.new
  xpay.exchange(request)
end

Instance Method Details

#exchange(request, retries = 3) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/breadmachine/secure_trading/xpay.rb', line 15

def exchange(request, retries = 3)
  request_xml = generate_xml(request)
  begin
    response_xml = exchange_with_xpay_client(request_xml)
    response = request.response(response_xml)
    handle_errors(response)
    return response
  rescue BreadMachine::GatewayConnectionError
    retry unless (retries -= 1) == 0
    raise
  end
end