Sha256: 3daf0d3568770a24fb2167d3ecd0facefd0bc7fc76a30011ffe8fb90e438804d

Contents?: true

Size: 826 Bytes

Versions: 1

Compression:

Stored size: 826 Bytes

Contents

module Pxpay
  class Response
    attr_accessor :result
    def initialize(params)
      @result = params[:result]
      @user_id = params[:userid]
    end
    
    # Retrieving the transaction details from Payment Express as an instance of Pxpay::Notification
    def response
      require 'rest_client'
      response = ::RestClient.post( 'https://www.paymentexpress.com/pxpay/pxaccess.aspx', build_xml( result ) )
      return ::Pxpay::Notification.new( response )
    end
  
    private
    # Internal method to build the xml to send to Payment Express
    def build_xml( result )
      xml = Builder::XmlMarkup.new
    
      xml.ProcessResponse do 
        xml.PxPayUserId PXPAY_CONFIG[:pxpay][:pxpay_user_id]
        xml.PxPayKey PXPAY_CONFIG[:pxpay][:pxpay_key]
        xml.Response result
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pxpay-0.1.1 lib/pxpay/response.rb