Module: PX::Response

Extended by:
Mote::Helpers
Defined in:
lib/px.rb

Constant Summary collapse

XML =
File.expand_path("../xml/response.xml", __FILE__)
URL =

Endpoint for Request / Response related posts

"https://sec.paymentexpress.com/pxaccess/pxpay.aspx"

Class Method Summary collapse

Class Method Details

.build(data) ⇒ Object



140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/px.rb', line 140

def self.build(data)
  params = {
    uid: UID,
    key: KEY,

    # The only key we require for PX::Response
    # is `response` which is obtained after
    # a successful redirect with the `result`
    # query string parameter.
    #
    response: data.fetch(:response),

    this: Hache,
  }

  mote(XML, params)
end

.parse(xml) ⇒ Object



126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/px.rb', line 126

def self.parse(xml)
  dict = XmlSimple.xml_in(xml, forcearray: false)

  PX::Util.log(:info, self.name, dict.inspect)

  if dict["valid"] == "1" && dict["Success"] == "1"
    # Provide a more agnostic term so outside code
    # fetching it won't look too tied to PX.
    dict[:token] = dict["DpsBillingId"]

    return dict
  end
end