Class: PaycorpRails

Inherits:
Object
  • Object
show all
Defined in:
lib/paycorp_rails.rb,
lib/paycorp_rails/version.rb

Overview

Paycorp internet payment gateway

Constant Summary collapse

VERSION =
"1.0.0"

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ PaycorpRails

Get the credentials and store them in the memory



6
7
8
# File 'lib/paycorp_rails.rb', line 6

def initialize(options)
    @options = options
end

Instance Method Details

#complete_payment(payment_options) ⇒ Object

Send the payment confirmation to Paycorp to complete the transaction



19
20
21
22
23
24
# File 'lib/paycorp_rails.rb', line 19

def complete_payment(payment_options)
    json = (create_complete_params(payment_options)).to_json
    hash = gen_hash(json, @options[:hmac])
    response = set_request_url(@options[:auth_token], hash, json)
    JSON.parse(response.read_body)
end

#initiate_payment(payment_options) ⇒ Object

Talk to Paycorp and initiate the payment



11
12
13
14
15
16
# File 'lib/paycorp_rails.rb', line 11

def initiate_payment(payment_options)
    json = (create_init_params(payment_options)).to_json
    hash = gen_hash(json, @options[:hmac])
    response = set_request_url(@options[:auth_token], hash, json)
    JSON.parse(response.read_body)
end