Sha256: 3fa62607c3893a8eb66a8a8031cdb7402d3a698fd5a3c1b6d53e2821f50ebb1c
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
module Pxpay class Request attr_accessor :post def initialize( id , price, options = {} ) @post = build_xml( id, price, options ) end 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 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] 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] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pxpay-0.1.0 | lib/pxpay/request.rb |