class Powerpay21

Main class for Powerpay21 API

Constants

URL_HASH

Constants - URLs

Public Class Methods

help() click to toggle source
# File lib/powerpay21.rb, line 43
def self.help
        puts "This is a Powerpay21 API. Check our website for Guide"
end
new(merchantid, secret, live=false) click to toggle source
# File lib/powerpay21.rb, line 32
def initialize(merchantid, secret, live=false)
        @merchantid=merchantid
        @secret=secret
        if live
                @live_demo=:live
        else
                @live_demo=:demo
        end
end

Public Instance Methods

authorize(params) click to toggle source
# File lib/powerpay21.rb, line 47
def authorize(params)
        uri = URI(URL_HASH[@live_demo][:auth])

        signature = calculate_signature(params)

        params['signature'] = signature

        res = Net::HTTP.post_form(uri, params)
end
calculate_signature(params) click to toggle source

Calculates the SHA1Sum signature for give param hash by sorting the keys in ascending order

# File lib/powerpay21.rb, line 59
def calculate_signature(params)
        raw_string = ""
        params.sort.each do |key,value|
                raw_string += value
        end

        sha1 = Digest::SHA1.new

        sha1 << raw_string

        return sha1.hexdigest || ""

end
cancel() click to toggle source
# File lib/powerpay21.rb, line 85
def cancel
end
capture() click to toggle source
# File lib/powerpay21.rb, line 76
def capture
end
cft() click to toggle source
# File lib/powerpay21.rb, line 82
def cft
end
pre_authorize() click to toggle source
# File lib/powerpay21.rb, line 73
def pre_authorize
end
refund() click to toggle source
# File lib/powerpay21.rb, line 79
def refund
end
status() click to toggle source
# File lib/powerpay21.rb, line 88
def status
end