module PX::Request

Constants

URL

Endpoint for Request / Response related posts

XML

Public Class Methods

build(data) click to toggle source
# File lib/px.rb, line 80
def self.build(data)
  params = {
    uid: UID,
    key: KEY,

    # = Required parameters with smart defaults:
    currency: data.fetch(:currency, "USD"),

    # == Optimized for Token Billing defaults
    #    (AUTH and Amount = 1 only)
    type: data.fetch(:type, TYPE_AUTH),
    amount: data.fetch(:amount, "1"),

    # = Optional parameters, but we make it mandatory
    # in this library
    email: data.fetch(:email),

    # == Really optional (both in API and in lib)
    ref: data.fetch(:ref, ""),
    data1: data.fetch(:data1, ""),
    data2: data.fetch(:data2, ""),
    data3: data.fetch(:data3, ""),
    txn_id: data.fetch(:txn_id, ""),

    # == Given that we optimize for Token billing, we
    #    default to `true`.
    add_bill_card: data.fetch(:add_bill_card, true),

    success_url: data.fetch(:success_url, SUCCESS_URL),
    fail_url: data.fetch(:fail_url, FAIL_URL),

    this: Hache,
  }

  mote(XML, params)
end
parse(xml) click to toggle source

<Request valid=“1”>

<URI>https://sec.paymentexpress.com/pxmi3/XXXX</URI>

</Request>

# File lib/px.rb, line 70
def self.parse(xml)
  dict = XmlSimple.xml_in(xml, forcearray: false)

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

  if dict["valid"] == "1" && dict["URI"]
    dict["URI"]
  end
end