Class: BreadMachine::SecureTrading::St3dCardQueryRequest

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

Overview

A 3-D Secure query to figure out whether a given card is enrolled in 3-D Secure. Although XPay doesn’t absolutely require all of the order information etc., BreadMachine does as it’s better for history tracking and is strongly recommended by XPay.

Instance Method Summary collapse

Constructor Details

#initialize(amount, card, customer_info, order_info, options = {}) ⇒ St3dCardQueryRequest

Returns a new instance of St3dCardQueryRequest.

Raises:

  • (ArgumentError)


11
12
13
14
15
16
17
18
19
# File 'lib/breadmachine/secure_trading/st_3d_card_query_request.rb', line 11

def initialize(amount, card, customer_info, order_info, options = {})
  raise ArgumentError, 'Currency mismatch' unless amount.currency == BreadMachine::SecureTrading::configuration.currency

  @amount = amount
  @customer_info = BreadMachine::SecureTrading::CustomerInfoEnrolmentXml.new(customer_info)
  @order_info = BreadMachine::SecureTrading::OrderInfoXml.new(order_info)
  @card = BreadMachine::SecureTrading::CardXml.new(card)
  @options = options
end

Instance Method Details

#response(xml) ⇒ Object



21
22
23
# File 'lib/breadmachine/secure_trading/st_3d_card_query_request.rb', line 21

def response(xml)
  St3dCardQueryResponse.new(xml)
end

#to_xmlObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/breadmachine/secure_trading/st_3d_card_query_request.rb', line 25

def to_xml
  xml = Builder::XmlMarkup.new(:indent => 2)
  xml.Request("Type" => "ST3DCARDQUERY") {
    xml.Operation {
      xml.Amount @amount.cents
      xml.Currency BreadMachine::SecureTrading::configuration.currency
      xml.SiteReference BreadMachine::SecureTrading::configuration.site_reference
      xml.TermUrl self.term_url
      xml.MerchantName BreadMachine::SecureTrading::configuration.merchant_name
    }
    xml << @customer_info.to_xml
    xml.PaymentMethod {
      xml << @card.to_xml
    }
    xml << @order_info.to_xml
  }
end