Module: PX::Request

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

Constant Summary collapse

XML =
File.expand_path("../xml/request.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



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# 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) ⇒ Object

<Request valid=“1”>

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

</Request>



70
71
72
73
74
75
76
77
78
# 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