lib/pxpay/request.rb in pxpay-0.1.1 vs lib/pxpay/request.rb in pxpay-0.1.2

- old
+ new

@@ -1,6 +1,7 @@ module Pxpay + # The request object to send to Payment Express class Request attr_accessor :post # Create a new instance of Pxpay::Request @@ -15,29 +16,30 @@ end # Get the redirect URL from Payment Express def url require 'rest_client' + require 'nokogiri' response = ::RestClient.post("https://sec2.paymentexpress.com/pxpay/pxaccess.aspx", post ) - url = Hash.from_xml(response)['Request']['URI'] + url = ::Nokogiri::XML(response).at_css("URI").inner_html return URI::extract(url).first.gsub("&", "&") end private # Internal method to build the xml to send to Payment Express def build_xml( id, price, options ) - xml = Builder::XmlMarkup.new + xml = ::Builder::XmlMarkup.new xml.GenerateRequest do - xml.PxPayUserId PXPAY_CONFIG[:pxpay][:pxpay_user_id] - xml.PxPayKey PXPAY_CONFIG[:pxpay][:pxpay_key] + xml.PxPayUserId ::PXPAY_CONFIG[:pxpay][:pxpay_user_id] + xml.PxPayKey ::PXPAY_CONFIG[:pxpay][:pxpay_key] xml.AmountInput sprintf("%.2f", price) xml.CurrencyInput options[:currency] || "NZD" xml.MerchantReference options[:reference] || id.to_s xml.EmailAddress options[:email] xml.TxnType "Purchase" xml.TxnId id - xml.UrlSuccess PXPAY_CONFIG[:pxpay][:success_url] - xml.UrlFail PXPAY_CONFIG[:pxpay][:failure_url] + xml.UrlSuccess ::PXPAY_CONFIG[:pxpay][:success_url] + xml.UrlFail ::PXPAY_CONFIG[:pxpay][:failure_url] end end end end \ No newline at end of file