Class: Paynow::Payment

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

Overview

Value object with information about the payment

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Payment

Returns a new instance of Payment.



19
20
21
22
23
24
25
26
27
28
# File 'lib/paynow/payment.rb', line 19

def initialize(attributes)
  @response = attributes[:response]
  @amount = attributes[:amount]
  @description = attributes[:description]
  @buyer = attributes[:buyer]
  @payment_id = attributes[:payment_id]
  @status = attributes[:status]
  @redirect_url = attributes[:redirect_url]
  @external_id = attributes[:external_id]
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



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

def amount
  @amount
end

#buyerObject (readonly)

Returns the value of attribute buyer.



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

def buyer
  @buyer
end

#descriptionObject (readonly)

Returns the value of attribute description.



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

def description
  @description
end

#external_idObject (readonly)

Returns the value of attribute external_id.



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

def external_id
  @external_id
end

#payment_idObject (readonly)

Returns the value of attribute payment_id.



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

def payment_id
  @payment_id
end

#redirect_urlObject (readonly)

Returns the value of attribute redirect_url.



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

def redirect_url
  @redirect_url
end

#responseObject (readonly)

Returns the value of attribute response.



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

def response
  @response
end

#statusObject (readonly)

Returns the value of attribute status.



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

def status
  @status
end

Class Method Details

.create(*args) ⇒ Object



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

def self.create(*args)
  Paynow::Configuration.gateway.create_payment(*args)
end

Instance Method Details

#created?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/paynow/payment.rb', line 30

def created?
  response.code == '201' && status == 'NEW'
end