Class: Powerpay21
- Inherits:
-
Object
- Object
- Powerpay21
- Defined in:
- lib/powerpay21.rb
Overview
Main class for Powerpay21 API
Constant Summary collapse
- URL_HASH =
Constants - URLs
{ :demo => { :init => "https://pay4.powercash21.com/powercash21-3-2/payment/init", :pre_auth => "https://pay4.powercash21.com/powercash21-3-2/backoffice/payment_preauthorize", :auth => "https://pay4.powercash21.com/powercash21-3-2/backoffice/payment_authorize", :refund => "https://pay4.powercash21.com/powercash21-3-2/backoffice/payment_refund", :reveral => "https://pay4.powercash21.com/powercash21-3-2/backoffice/payment_reversal", :capture => "https://pay4.powercash21.com/powercash21-3-2/backoffice/payment_capture" }, :live => { :init => "https://pay4.powercash21.com/powercash21-3-2/payment/init", :pre_auth => "https://pay4.powercash21.com/powercash21-3-2/backoffice/payment_preauthorize", :auth => "https://pay4.powercash21.com/powercash21-3-2/backoffice/payment_authorize", :refund => "https://pay4.powercash21.com/powercash21-3-2/backoffice/payment_refund", :reveral => "https://pay4.powercash21.com/powercash21-3-2/backoffice/payment_reversal", :capture => "https://pay4.powercash21.com/powercash21-3-2/backoffice/payment_capture" } }
Class Method Summary collapse
Instance Method Summary collapse
- #authorize(params) ⇒ Object
-
#calculate_signature(params) ⇒ Object
Calculates the SHA1Sum signature for give param hash by sorting the keys in ascending order.
- #cancel ⇒ Object
- #capture ⇒ Object
- #cft ⇒ Object
-
#initialize(merchantid, secret, live = false) ⇒ Powerpay21
constructor
A new instance of Powerpay21.
- #pre_authorize ⇒ Object
- #refund ⇒ Object
- #status ⇒ Object
Constructor Details
#initialize(merchantid, secret, live = false) ⇒ Powerpay21
Returns a new instance of Powerpay21.
32 33 34 35 36 37 38 39 40 |
# 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 |
Class Method Details
.help ⇒ Object
43 44 45 |
# File 'lib/powerpay21.rb', line 43 def self.help puts "This is a Powerpay21 API. Check our website for Guide" end |
Instance Method Details
#authorize(params) ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/powerpay21.rb', line 47 def (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) ⇒ Object
Calculates the SHA1Sum signature for give param hash by sorting the keys in ascending order
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# 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 ⇒ Object
85 86 |
# File 'lib/powerpay21.rb', line 85 def cancel end |
#capture ⇒ Object
76 77 |
# File 'lib/powerpay21.rb', line 76 def capture end |
#cft ⇒ Object
82 83 |
# File 'lib/powerpay21.rb', line 82 def cft end |
#pre_authorize ⇒ Object
73 74 |
# File 'lib/powerpay21.rb', line 73 def end |
#refund ⇒ Object
79 80 |
# File 'lib/powerpay21.rb', line 79 def refund end |
#status ⇒ Object
88 89 |
# File 'lib/powerpay21.rb', line 88 def status end |