Class: Payfast::Payment

Inherits:
Object
  • Object
show all
Defined in:
lib/payfast/payment.rb

Constant Summary collapse

ATTRIBUTES =
Payfast::Attributes.all_fields.map(&:to_sym)

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Payment

Returns a new instance of Payment.



7
8
9
10
11
12
13
# File 'lib/payfast/payment.rb', line 7

def initialize(args = {})
  args.each do |k,v|
    run_validations(args)
    variable_name = "@#{k}"
    instance_variable_set(variable_name,v) unless v.nil?
  end
end

Class Method Details

.create(args = {}) ⇒ Object



15
16
17
# File 'lib/payfast/payment.rb', line 15

def self.create(args = {})
  Payfast::Config.client.create_payment(args)
end

Instance Method Details

#failed?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/payfast/payment.rb', line 23

def failed?
  !success?
end

#success?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/payfast/payment.rb', line 19

def success?
  status == '200' && message == 'OK'
end