Class: Moyasar::Payment

Inherits:
Resource show all
Includes:
Actions::Capture, Actions::Refund, Actions::Void
Defined in:
lib/moyasar/payment.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Actions::Void

included

Methods included from Actions::Capture

included

Methods included from Actions::Refund

included

Methods inherited from Resource

class_name, resource_name, resource_url

Methods included from Actions::Cancel

included

Methods included from Actions::Update

included

Methods included from Actions::Fetch

included

Methods included from Actions::List

included

Methods included from Actions::Construct

included

Methods included from Actions::Request

included, #request

Constructor Details

#initialize(attrs = {}) ⇒ Payment

Returns a new instance of Payment.



12
13
14
15
16
17
18
# File 'lib/moyasar/payment.rb', line 12

def initialize(attrs = {})
  source  = attrs.delete('source')
  type    = source.delete('type')
  @source = Moyasar::Source.build(type, source)

  super
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



7
8
9
# File 'lib/moyasar/payment.rb', line 7

def amount
  @amount
end

#amount_formatObject (readonly)

Returns the value of attribute amount_format.



7
8
9
# File 'lib/moyasar/payment.rb', line 7

def amount_format
  @amount_format
end

#callback_urlObject (readonly)

Returns the value of attribute callback_url.



7
8
9
# File 'lib/moyasar/payment.rb', line 7

def callback_url
  @callback_url
end

#capturedObject (readonly)

Returns the value of attribute captured.



7
8
9
# File 'lib/moyasar/payment.rb', line 7

def captured
  @captured
end

#captured_atObject (readonly)

Returns the value of attribute captured_at.



7
8
9
# File 'lib/moyasar/payment.rb', line 7

def captured_at
  @captured_at
end

#created_atObject (readonly)

Returns the value of attribute created_at.



7
8
9
# File 'lib/moyasar/payment.rb', line 7

def created_at
  @created_at
end

#currencyObject (readonly)

Returns the value of attribute currency.



7
8
9
# File 'lib/moyasar/payment.rb', line 7

def currency
  @currency
end

#descriptionObject

Returns the value of attribute description.



10
11
12
# File 'lib/moyasar/payment.rb', line 10

def description
  @description
end

#feeObject (readonly)

Returns the value of attribute fee.



7
8
9
# File 'lib/moyasar/payment.rb', line 7

def fee
  @fee
end

#fee_formatObject (readonly)

Returns the value of attribute fee_format.



7
8
9
# File 'lib/moyasar/payment.rb', line 7

def fee_format
  @fee_format
end

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/moyasar/payment.rb', line 7

def id
  @id
end

#invoice_idObject (readonly)

Returns the value of attribute invoice_id.



7
8
9
# File 'lib/moyasar/payment.rb', line 7

def invoice_id
  @invoice_id
end

#ipObject (readonly)

Returns the value of attribute ip.



7
8
9
# File 'lib/moyasar/payment.rb', line 7

def ip
  @ip
end

#metadataObject (readonly)

Returns the value of attribute metadata.



7
8
9
# File 'lib/moyasar/payment.rb', line 7

def 
  @metadata
end

#refundedObject (readonly)

Returns the value of attribute refunded.



7
8
9
# File 'lib/moyasar/payment.rb', line 7

def refunded
  @refunded
end

#refunded_atObject (readonly)

Returns the value of attribute refunded_at.



7
8
9
# File 'lib/moyasar/payment.rb', line 7

def refunded_at
  @refunded_at
end

#sourceObject (readonly)

Returns the value of attribute source.



7
8
9
# File 'lib/moyasar/payment.rb', line 7

def source
  @source
end

#statusObject (readonly)

Returns the value of attribute status.



7
8
9
# File 'lib/moyasar/payment.rb', line 7

def status
  @status
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



7
8
9
# File 'lib/moyasar/payment.rb', line 7

def updated_at
  @updated_at
end

#voided_atObject (readonly)

Returns the value of attribute voided_at.



7
8
9
# File 'lib/moyasar/payment.rb', line 7

def voided_at
  @voided_at
end

Class Method Details

.create(source:, amount:, currency: 'SAR', description: nil, invoice_id: nil, callback_url: nil) ⇒ Object



32
33
34
35
# File 'lib/moyasar/payment.rb', line 32

def create(source:, amount:, currency: 'SAR', description: nil, invoice_id: nil, callback_url: nil)
  params = {amount: amount, currency: currency, description: description, source: source, invoice_id: invoice_id, callback_url: callback_url}
  super(params)
end

Instance Method Details

#==(other) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/moyasar/payment.rb', line 20

def ==(other)
  return false unless other.is_a? Payment

  [:id, :status, :amount, :fee, :currency, :invoice_id, :source, :refunded, :refunded_at, :captured, :captured_at, :voided_at, :ip, :created_at, :updated_at].all? do |attr|
    self.send(attr) == other.send(attr)
  end
end