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

- old
+ new

@@ -1,22 +1,30 @@ module Pxpay class Request attr_accessor :post + # Create a new instance of Pxpay::Request + # Pxpay::Request.new( id, amount, options = {} ) + # Current available options are: + # :currency, currency for transaction, default is NZD, can be any of Pxpay::Base.currency_types + # :reference, a reference field, default is the id + # :email, email address of user, default is nil + def initialize( id , price, options = {} ) @post = build_xml( id, price, options ) end + # Get the redirect URL from Payment Express def url require 'rest_client' response = ::RestClient.post("https://sec2.paymentexpress.com/pxpay/pxaccess.aspx", post ) url = Hash.from_xml(response)['Request']['URI'] 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.GenerateRequest do xml.PxPayUserId PXPAY_CONFIG[:pxpay][:pxpay_user_id] xml.PxPayKey PXPAY_CONFIG[:pxpay][:pxpay_key] \ No newline at end of file